Instructions to use LiquidAI/LFM2-350M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiquidAI/LFM2-350M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="LiquidAI/LFM2-350M") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("LiquidAI/LFM2-350M") model = AutoModelForCausalLM.from_pretrained("LiquidAI/LFM2-350M", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use LiquidAI/LFM2-350M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "LiquidAI/LFM2-350M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiquidAI/LFM2-350M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/LiquidAI/LFM2-350M
- SGLang
How to use LiquidAI/LFM2-350M with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "LiquidAI/LFM2-350M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiquidAI/LFM2-350M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "LiquidAI/LFM2-350M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "LiquidAI/LFM2-350M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use LiquidAI/LFM2-350M with Docker Model Runner:
docker model run hf.co/LiquidAI/LFM2-350M
Commit History
-
Fix chat template: render assistant tool_calls
Verified signatureAssistant messages carrying `tool_calls` render to nothing under the current template: the message loop ends in a single `{{- content + "<|im_end|>\n" -}}` with no branch for tool calls. Two consequences, both reproduced on llama.cpp `server-rocm-b10088`: 1. llama.cpp probes the template at startup, sees that a tool call renders to nothing, and reports `supports_tool_calls: false` / `supports_parallel_tool_calls: false` in `/props`. It then constrains generation to at most one call, so the second call of a parallel request is never sampled. 2. Replaying a conversation that already contains an assistant tool call produces an empty assistant turn, while the following `tool` result is still rendered -- the model sees an answer to a question it has no record of asking. **This PR** adds the `format_arg_value` / `render_tool_calls` macros (taken verbatim from the latest LFM2.5 template) and one branch that emits them, so a tool call renders as `<|tool_call_start|>[name(ar…f4c593a
-
Update README.md
Verified signature45f6d3d
-
Update README.md
Verified signatureb3afba2
-
Fix link bar, add Discord and br tag, update Contact section
b29be27
-
Fix typo in README, there's no LLM with "2.6" parameters! (#18)
- Fix typo in README, there's no LLM with "2.6" parameters! (f70d22bde5a09942036d545417b1dd0aca6e23be) Co-authored-by: Mihai Popa <MihaiPopa-1@users.noreply.huggingface.co>349e939
-
Update README.md
Verified signature28a2c07 -
Update README.md
Verified signatureed0d3e2
-
Update README.md
Verified signatureb9c8626
-
Update README.md
Verified signatureb1df251 -
Update README.md
Verified signature78f35ec
-
Update README.md
Verified signaturea98a38b
-
Update README.md
Verified signature0b6ea93
-
Update README.md
Verified signature8707ee0
-
Update README.md
Verified signature8198e60 -
Update README.md
Verified signature7b6b053
-
Update Unsloth notebook
Verified signatureb17ebff -
Update README.md
Verified signature6a8f6ca
-
Fix expected model inputs (#13)
Verified signature- Fix expected model inputs (6b247b7eacd42b3bee634f127293ff808b90814b) Co-authored-by: Pedro Cuenca <pcuenq@users.noreply.huggingface.co>0fa3ebc
-
Update chat_template.jinja (#11)
Yuri Khrustalev +1: Xenova Verified signature- Update chat_template.jinja (16d3c9b08df3621b720407b9a85b4d4f2e1a2ebd) - Update chat template (7212ba35e776fbd3375be66b8f51fcfe80d7a569) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>b9e9a59
-
Add tool calling support to chat template (#10)
Verified signature- Add tool calling support to chat template (ecc69cf5dcf60511986e8b2f5005cd90dfe803cf) Co-authored-by: Joshua <Xenova@users.noreply.huggingface.co>68a2413
-
Update README.md
Verified signature3976fb7
-
Update README.md
Verified signature80dfd9b -
Update README.md
Verified signaturefe6939e
-
Update README.md
Verified signature0ddaf20
-
Update README.md
Verified signature1ea4043
-
Bump transformers v4.54.0.dev0
Verified signature73e3c25 -
Bump transformers source v4.54.0.dev0
Verified signaturee9eb554
-
Update README.md
Verified signaturecb34594 -
Bump transformers source v4.54.0.dev0
Verified signature2ccebab -
Upload via hf_clone.py
Verified signature45aebb2 -
Update README.md
Verified signature09e6f9a -
Update README.md
Verified signature1a74448 -
Upload all model files
Verified signature3dbef32 -
initial commit
Verified signaturea12f3c6