import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-1.2B-Instruct")
# Load model with quantization
base_model = AutoModelForCausalLM.from_pretrained(
"yasserrmd/lfm2.5-1.5b-sdft",
torch_dtype=torch.float16,
device_map="auto"
)
model.eval()
# Generate
prompt = """<|im_start|>userExplain how photosynthesis works.<|im_end|><|im_start|>assistant"""
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
# Use official LiquidAI parameters
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=True,
temperature=0.1,
top_k=50,
top_p=0.1,
repetition_penalty=1.05,
pad_token_id=tokenizer.pad_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
With Demonstration (In-Context Learning)
prompt = """<|im_start|>userExplain how databases work.Here is an example response to guide you:Example: Databases store data in tables. You can query them to get information back.Now provide your own response following a similar approach:<|im_end|><|im_start|>assistant"""
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=True,
temperature=0.1,
top_k=50,
top_p=0.1,
repetition_penalty=1.05
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
<|im_start|>user
{query}
Here is an example response to guide you:
<|im_start|>assistant
{demonstration}
<|im_end|>
<|im_start|>user
Now provide your own response following a similar approach and reasoning:
<|im_end|>
<|im_start|>assistant
Evaluation Results
Tested on Multiple Dimensions:
Category
Description
Performance
ICL Adaptation
Following demonstration style
✅ Good
Task Improvement
Learning from examples
✅ Good
Retention
No catastrophic forgetting
✅ ~80%
Polarity Control
Following demo viewpoint
⚠️ Moderate
Key Findings:
✅
Maintains Knowledge:
No significant forgetting on general tasks
✅
Adapts to Demos:
Successfully follows demonstration styles
✅
Improved Over Training:
Epoch 3 shows stable, coherent outputs
⚠️
Model Size Limitation:
1.2B parameters limits complex reasoning
Comparison to Base Model:
With Demonstrations:
SDFT shows better style matching and task following
Without Demonstrations:
Maintains base model capabilities
Response Quality:
More consistent and focused outputs
Generation Parameters
⚠️ Important:
Use official LiquidAI parameters for best results:
generation_config = {
"max_new_tokens": 256,
"do_sample": True,
"temperature": 0.1, # Official LiquidAI recommendation"top_k": 50, # Official LiquidAI recommendation"top_p": 0.1, # Official LiquidAI recommendation"repetition_penalty": 1.05# Official LiquidAI recommendation
}
These parameters are specifically tuned for LFM2.5 and provide:
Focused, factual responses
Minimal hallucinations
Consistent output quality
Limitations
Model Constraints:
Size:
1.2B parameters (smaller capacity than 7B+ models)
Training Data:
5K samples (vs paper's 20K+)
Hardware:
Single A100 (vs paper's multi-GPU setup)
Complexity:
Limited reasoning on very complex tasks
Known Issues:
May require proper ChatML formatting for best results
Performance degrades on tasks requiring deep technical knowledge
Smaller model size limits polarity control effectiveness
lfm2.5-1.5b-sdft huggingface.co is an AI model on huggingface.co that provides lfm2.5-1.5b-sdft's model effect (), which can be used instantly with this yasserrmd lfm2.5-1.5b-sdft model. huggingface.co supports a free trial of the lfm2.5-1.5b-sdft model, and also provides paid use of the lfm2.5-1.5b-sdft. Support call lfm2.5-1.5b-sdft model through api, including Node.js, Python, http.
lfm2.5-1.5b-sdft huggingface.co is an online trial and call api platform, which integrates lfm2.5-1.5b-sdft's modeling effects, including api services, and provides a free online trial of lfm2.5-1.5b-sdft, you can try lfm2.5-1.5b-sdft online for free by clicking the link below.
yasserrmd lfm2.5-1.5b-sdft online free url in huggingface.co:
lfm2.5-1.5b-sdft is an open source model from GitHub that offers a free installation service, and any user can find lfm2.5-1.5b-sdft on GitHub to install. At the same time, huggingface.co provides the effect of lfm2.5-1.5b-sdft install, users can directly use lfm2.5-1.5b-sdft installed effect in huggingface.co for debugging and trial. It also supports api for free installation.