Downloads · 30 days
9
13% of all-time downloads
krzysztofwos/LFM2-2.6B-CodeAgent-LoRA
LFM2-2.6B-CodeAgent-LoRA is a text generation model from krzysztofwos. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A LoRA fine-tuned adapter for LiquidAI/LFM2-2.6B-Exp trained to follow the smolagents CodeAgent format.
Downloads · 30 days
9
13% of all-time downloads
All-time downloads
69
Public
Repo size
49 MB
Likes
0
Public
Click a slice to open those files.
.safetensors49 MB · 91%
From the Hugging Face model README
A LoRA fine-tuned adapter for LiquidAI/LFM2-2.6B-Exp trained to follow the smolagents CodeAgent format.
This adapter teaches LFM2-2.6B-Exp to respond in the structured Thought + Code format required by smolagents CodeAgent:
Thought: I need to calculate this.
```python
result = 2 + 2
final_answer(result)
```
| Parameter | Value |
|---|---|
| LoRA Rank | 8 |
| LoRA Alpha | 16 |
| Target Modules | q_proj, v_proj |
| Trainable Parameters | 12.2M (0.47% of base) |
| Training Steps | 30 |
| Learning Rate | 2e-4 |
| Batch Size | 4 |
| Max Sequence Length | 2048 |
| Hardware | NVIDIA RTX 3090 (24GB) |
| Training Time | ~5.5 hours |
| Prompt Mode | Format Compliance | Answer Accuracy |
|---|---|---|
| Minimal | 100% | 80% |
| Default | 80% | 80% |
| None | 0% | 0% |
The model performs best with the minimal prompt (~95 tokens), demonstrating successful prompt distillation.
You are a CodeAgent that solves tasks by writing and executing Python code.
Always respond with Thought + Python code block. Example:
Thought: I need to calculate this.
```python
result = 2 + 2
final_answer(result)
```
Call final_answer(result) when done. Now Begin!
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"LiquidAI/LFM2-2.6B-Exp",
device_map="auto",
torch_dtype="bfloat16",
)
tokenizer = AutoTokenizer.from_pretrained("LiquidAI/LFM2-2.6B-Exp")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "krzysztofwos/LFM2-2.6B-CodeAgent-LoRA")
# Generate
messages = [{"role": "user", "content": "What is 15 * 23?"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.3,
min_p=0.15,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
from smolagents import CodeAgent, FinalAnswerTool, TransformersModel
model = TransformersModel(
model_id="LiquidAI/LFM2-2.6B-Exp",
peft_model="krzysztofwos/LFM2-2.6B-CodeAgent-LoRA",
)
agent = CodeAgent(
tools=[FinalAnswerTool()],
model=model,
)
result = agent.run("What is 15 * 23?")
print(result)
If you use this model, please cite:
@misc{lfm2_2.6b_codeagent_lora,
author = {krzysztofwos},
title = {LFM2-2.6B-CodeAgent-LoRA},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/krzysztofwos/LFM2-2.6B-CodeAgent-LoRA}
}