Text Generation
Transformers
Safetensors
lfm2
full-parameter-fine-tuning
supervised-fine-tuning
assistant-only-loss
tool-use
coding-agent
conversational
Instructions to use AyoubChLin/lfm2.5-2.6b-fable5-coding-agent with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AyoubChLin/lfm2.5-2.6b-fable5-coding-agent with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AyoubChLin/lfm2.5-2.6b-fable5-coding-agent") 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("AyoubChLin/lfm2.5-2.6b-fable5-coding-agent") model = AutoModelForCausalLM.from_pretrained("AyoubChLin/lfm2.5-2.6b-fable5-coding-agent", 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 AyoubChLin/lfm2.5-2.6b-fable5-coding-agent with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AyoubChLin/lfm2.5-2.6b-fable5-coding-agent
- SGLang
How to use AyoubChLin/lfm2.5-2.6b-fable5-coding-agent 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 "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent" \ --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": "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent", "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 "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent" \ --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": "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AyoubChLin/lfm2.5-2.6b-fable5-coding-agent with Docker Model Runner:
docker model run hf.co/AyoubChLin/lfm2.5-2.6b-fable5-coding-agent
Update README.md
Browse files
README.md
CHANGED
|
@@ -126,7 +126,11 @@ This is an illustration, not an evaluation. In deployment:
|
|
| 126 |
Install a recent Transformers release:
|
| 127 |
|
| 128 |
```bash
|
| 129 |
-
pip install -
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
```
|
| 131 |
|
| 132 |
Then apply the checkpoint's native chat template:
|
|
@@ -135,24 +139,41 @@ Then apply the checkpoint's native chat template:
|
|
| 135 |
import torch
|
| 136 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 137 |
|
| 138 |
-
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 141 |
model = AutoModelForCausalLM.from_pretrained(
|
| 142 |
-
|
| 143 |
-
dtype=torch.
|
| 144 |
-
device_map="
|
|
|
|
|
|
|
| 145 |
)
|
|
|
|
| 146 |
model.eval()
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
messages = [
|
| 149 |
{
|
| 150 |
"role": "system",
|
| 151 |
-
"content":
|
|
|
|
|
|
|
|
|
|
| 152 |
},
|
| 153 |
{
|
| 154 |
"role": "user",
|
| 155 |
-
"content":
|
|
|
|
|
|
|
|
|
|
| 156 |
},
|
| 157 |
]
|
| 158 |
|
|
@@ -162,22 +183,34 @@ inputs = tokenizer.apply_chat_template(
|
|
| 162 |
add_generation_prompt=True,
|
| 163 |
return_tensors="pt",
|
| 164 |
return_dict=True,
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
with torch.inference_mode():
|
| 168 |
output = model.generate(
|
| 169 |
**inputs,
|
| 170 |
max_new_tokens=768,
|
| 171 |
do_sample=True,
|
| 172 |
-
temperature=0.
|
| 173 |
top_k=50,
|
| 174 |
repetition_penalty=1.1,
|
|
|
|
| 175 |
pad_token_id=tokenizer.pad_token_id,
|
| 176 |
eos_token_id=tokenizer.eos_token_id,
|
| 177 |
)
|
| 178 |
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
```
|
| 182 |
|
| 183 |
`skip_special_tokens=False` preserves native reasoning and tool-call delimiters for inspection by a compatible parser. Do not send raw reasoning or unvalidated tool syntax directly to end users or executors.
|
|
|
|
| 126 |
Install a recent Transformers release:
|
| 127 |
|
| 128 |
```bash
|
| 129 |
+
%pip install -q --upgrade \
|
| 130 |
+
"transformers==5.15.0" \
|
| 131 |
+
"accelerate>=1.10,<2" \
|
| 132 |
+
"safetensors>=0.6" \
|
| 133 |
+
"huggingface_hub>=0.34"
|
| 134 |
```
|
| 135 |
|
| 136 |
Then apply the checkpoint's native chat template:
|
|
|
|
| 139 |
import torch
|
| 140 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 141 |
|
| 142 |
+
MODEL_ID = "AyoubChLin/lfm2.5-2.6b-fable5-coding-agent"
|
| 143 |
+
|
| 144 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 145 |
|
|
|
|
| 146 |
model = AutoModelForCausalLM.from_pretrained(
|
| 147 |
+
MODEL_ID,
|
| 148 |
+
dtype=torch.float16, # Important: T4 uses FP16, not BF16
|
| 149 |
+
device_map={"": 0}, # Keep the complete model on GPU 0
|
| 150 |
+
low_cpu_mem_usage=True,
|
| 151 |
+
attn_implementation="sdpa", # No external flash-attn installation
|
| 152 |
)
|
| 153 |
+
|
| 154 |
model.eval()
|
| 155 |
|
| 156 |
+
parameter = next(model.parameters())
|
| 157 |
+
print("Model device:", parameter.device)
|
| 158 |
+
print("Model dtype:", parameter.dtype)
|
| 159 |
+
|
| 160 |
+
assert parameter.device.type == "cuda"
|
| 161 |
+
assert parameter.dtype == torch.float16
|
| 162 |
+
|
| 163 |
messages = [
|
| 164 |
{
|
| 165 |
"role": "system",
|
| 166 |
+
"content": (
|
| 167 |
+
"You are a careful coding assistant. Return complete, executable "
|
| 168 |
+
"code and briefly explain how it was verified."
|
| 169 |
+
),
|
| 170 |
},
|
| 171 |
{
|
| 172 |
"role": "user",
|
| 173 |
+
"content": (
|
| 174 |
+
"Write a Python function that merges overlapping integer intervals. "
|
| 175 |
+
"Include pytest tests."
|
| 176 |
+
),
|
| 177 |
},
|
| 178 |
]
|
| 179 |
|
|
|
|
| 183 |
add_generation_prompt=True,
|
| 184 |
return_tensors="pt",
|
| 185 |
return_dict=True,
|
| 186 |
+
truncation=True,
|
| 187 |
+
max_length=8192, # Safe starting point for a T4
|
| 188 |
+
).to("cuda:0")
|
| 189 |
+
|
| 190 |
+
prompt_length = inputs["input_ids"].shape[1]
|
| 191 |
|
| 192 |
with torch.inference_mode():
|
| 193 |
output = model.generate(
|
| 194 |
**inputs,
|
| 195 |
max_new_tokens=768,
|
| 196 |
do_sample=True,
|
| 197 |
+
temperature=0.1,
|
| 198 |
top_k=50,
|
| 199 |
repetition_penalty=1.1,
|
| 200 |
+
use_cache=True,
|
| 201 |
pad_token_id=tokenizer.pad_token_id,
|
| 202 |
eos_token_id=tokenizer.eos_token_id,
|
| 203 |
)
|
| 204 |
|
| 205 |
+
generated_tokens = output[0, prompt_length:]
|
| 206 |
+
|
| 207 |
+
print(
|
| 208 |
+
tokenizer.decode(
|
| 209 |
+
generated_tokens,
|
| 210 |
+
skip_special_tokens=False,
|
| 211 |
+
)
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
```
|
| 215 |
|
| 216 |
`skip_special_tokens=False` preserves native reasoning and tool-call delimiters for inspection by a compatible parser. Do not send raw reasoning or unvalidated tool syntax directly to end users or executors.
|