CoolFace
Modelpublic

krzysztofwos/LFM25-1.2B-CodeAgent-sonnet-default

sourceHugging Faceapache-2.0updated 8mo agoView on Hugging Face
0likes10downloads
Model Card

LFM25-1.2B-CodeAgent-sonnet-default

A LoRA fine-tuned adapter for LiquidAI/LFM2.5-1.2B-Instruct trained to follow the smolagents CodeAgent format.

Model Description

This adapter teaches LFM2.5-1.2B to respond in the structured Thought + Code format required by smolagents CodeAgent:

`
Thought: I need to calculate this.

result = 2 + 2 final_answer(result)

Key Features

  • Base Model: LiquidAI/LFM2.5-1.2B-Instruct (1.17B parameters)
  • Token Accuracy: 90.6% on training data
  • Single-Turn Rate: 64.6% of tasks solved in one turn
  • Adapter Size: ~42MB (LoRA rank=16, alpha=32)

Training Details

Training Data

  • 127 successful CodeAgent trajectories generated using Claude 3.5 Sonnet
  • Tasks include mathematical reasoning, string manipulation, file operations, and general problem-solving
  • Each trajectory demonstrates the Thought → Code → Observation → final_answer pattern
  • Average trajectory length: 3054 tokens

Training Configuration

ParameterValue
LoRA Rank16
LoRA Alpha32
Target Modulesw1, w2, w3, qproj, kproj, vproj, outproj, in_proj
Trainable Parameters11.1M (0.94% of base model)
Epochs3
Learning Rate1e-4
Batch Size2 (effective 8 with gradient accumulation)
Max Sequence Length8192
HardwareNVIDIA RTX 3090 (24GB)
Training Time260s

Training Framework

Ablation Study Results

This model is part of a teacher ablation study comparing different Claude models and prompting strategies:

Teacher ConfigToken AccuracyTraining TimeAvg Trajectory Tokens
haiku-default73.8%461s2,957
sonnet-default90.6%260s3,054
opus4-default90.2%260s2,971
sonnet4-terse94.9%93s632
opus4-terse95.0%76s613

Key Finding: Terse, focused trajectories from capable teachers transfer significantly better to small models.

Usage

With PEFT

python
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
    "LiquidAI/LFM2.5-1.2B-Instruct",
    device_map="auto",
    torch_dtype="bfloat16",
)
tokenizer = AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-1.2B-Instruct")

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "krzysztofwos/LFM25-1.2B-CodeAgent-sonnet-default")

# 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.1,
    top_p=0.1,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

With smolagents

python
from smolagents import CodeAgent, FinalAnswerTool, TransformersModel

model = TransformersModel(
    model_id="LiquidAI/LFM2.5-1.2B-Instruct",
    peft_model="krzysztofwos/LFM25-1.2B-CodeAgent-sonnet-default",
)

agent = CodeAgent(
    tools=[FinalAnswerTool()],
    model=model,
)

result = agent.run("What is 15 * 23?")
print(result)

Intended Use

  • Code-assisted problem solving with small, efficient models
  • Mathematical reasoning tasks
  • Automated code generation following structured formats
  • Research into prompt distillation and teacher model selection

Limitations

  • 1.2B model constraints: Limited reasoning depth compared to larger models
  • English only: Trained on English-language tasks
  • CodeAgent format specific: Optimized for smolagents Thought/Code/final_answer pattern

Citation

If you use this model, please cite:

bibtex
@misc{lfm25-codeagent-sonnet_default-2025,
  author = {krzysztofwos},
  title = {LFM25-1.2B-CodeAgent-sonnet-default},
  year = {2025},
  publisher = {Hugging Face},
  url = {https://huggingface.co/krzysztofwos/LFM25-1.2B-CodeAgent-sonnet-default}
}

Acknowledgments