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)# 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=40) 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
Update README.md
Browse files
README.md
CHANGED
|
@@ -74,15 +74,15 @@ Due to their small size, **we recommend fine-tuning LFM2 models on narrow use ca
|
|
| 74 |
They are particularly suited for agentic tasks, data extraction, RAG, creative writing, and multi-turn conversations.
|
| 75 |
However, we do not recommend using them for tasks that are knowledge-intensive or require programming skills.
|
| 76 |
|
| 77 |
-
| Property |
|
| 78 |
-
| ------------------- | ----------------------------- |
|
| 79 |
-
| **Parameters** | 354,483,968 |
|
| 80 |
-
| **Layers** | 16 (10 conv + 6 attn) |
|
| 81 |
-
| **Context length** | 32,768 tokens |
|
| 82 |
-
| **Vocabulary size** | 65,536 |
|
| 83 |
-
| **Precision** | bfloat16 |
|
| 84 |
-
| **Training budget** | 10 trillion tokens |
|
| 85 |
-
| **License** | LFM Open License v1.0 |
|
| 86 |
|
| 87 |
**Supported languages**: English, Arabic, Chinese, French, German, Japanese, Korean, and Spanish.
|
| 88 |
|
|
@@ -102,7 +102,7 @@ What is C. elegans?<|im_end|>
|
|
| 102 |
It's a tiny nematode that lives in temperate soil environments.<|im_end|>
|
| 103 |
```
|
| 104 |
|
| 105 |
-
You can apply it using the dedicated [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) function from Hugging Face transformers.
|
| 106 |
|
| 107 |
**Tool use**: It consists of four main steps:
|
| 108 |
1. **Function definition**: LFM2 takes JSON function definitions as input (JSON objects between `<|tool_list_start|>` and `<|tool_list_end|>` special tokens), usually in the system prompt
|
|
|
|
| 74 |
They are particularly suited for agentic tasks, data extraction, RAG, creative writing, and multi-turn conversations.
|
| 75 |
However, we do not recommend using them for tasks that are knowledge-intensive or require programming skills.
|
| 76 |
|
| 77 |
+
| Property | [**LFM2-350M**](https://huggingface.co/LiquidAI/LFM2-350M) | [**LFM2-700M**](https://huggingface.co/LiquidAI/LFM2-700M) | [**LFM2-1.2B**](https://huggingface.co/LiquidAI/LFM2-1.2B) |
|
| 78 |
+
| ------------------- | ----------------------------- | ----------------------------- | ----------------------------- |
|
| 79 |
+
| **Parameters** | 354,483,968 | 742,489,344 | 1,170,340,608 |
|
| 80 |
+
| **Layers** | 16 (10 conv + 6 attn) | 16 (10 conv + 6 attn) | 16 (10 conv + 6 attn) |
|
| 81 |
+
| **Context length** | 32,768 tokens | 32,768 tokens | 32,768 tokens |
|
| 82 |
+
| **Vocabulary size** | 65,536 | 65,536 | 65,536 |
|
| 83 |
+
| **Precision** | bfloat16 | bfloat16 | bfloat16 |
|
| 84 |
+
| **Training budget** | 10 trillion tokens | 10 trillion tokens | 10 trillion tokens |
|
| 85 |
+
| **License** | LFM Open License v1.0 | LFM Open License v1.0 | LFM Open License v1.0 |
|
| 86 |
|
| 87 |
**Supported languages**: English, Arabic, Chinese, French, German, Japanese, Korean, and Spanish.
|
| 88 |
|
|
|
|
| 102 |
It's a tiny nematode that lives in temperate soil environments.<|im_end|>
|
| 103 |
```
|
| 104 |
|
| 105 |
+
You can automatically apply it using the dedicated [`.apply_chat_template()`](https://huggingface.co/docs/transformers/en/chat_templating#applychattemplate) function from Hugging Face transformers.
|
| 106 |
|
| 107 |
**Tool use**: It consists of four main steps:
|
| 108 |
1. **Function definition**: LFM2 takes JSON function definitions as input (JSON objects between `<|tool_list_start|>` and `<|tool_list_end|>` special tokens), usually in the system prompt
|