Hugging FaceLeonie Monigatti, ben burtenshaw, Sergio PaniegoTutorial
Fine-tuning a 350M Model for Better Structured Outputs in 100 GRPO Steps
Summary
This guide presents a low-cost recipe for improving structured-output compliance in Liquid AI’s LFM2.5-350M, a task where parseable, schema-adherent responses determine whether an LLM can feed downstream systems. It fine-tunes the model with Group Relative Policy Optimization (GRPO) through TRL, using about 500 samples, 100 steps, three weighted rewards for format, field count, and JSON Schema validation, and a LoRA adapter training roughly 6M parameters. Prompt augmentation covers fenced-code-block instructions and top-level-array tasks, while evaluation uses IFStruct with llama.cpp on an OpenAI-compatible local server. On 2,000 IFStruct samples, the BF16 base model passes 22.6%, rising to 29.7% after tuning. JSON improves from 18.0% to 31.9%, bare-list compliance from 16.6% to 29.7%, while YAML changes little.
Context
Structured-output compliance is a common real-world LLM requirement, but the source states that many benchmarks combine it with broader reasoning or extraction scores. Valid, parseable output in the requested format and shape determines whether a model can be connected to a downstream system.
Approach / What changed
The guide fine-tunes LFM2.5-350M with GRPO using TRL, approximately 500 structured-output samples, LoRA targeting LFM-specific modules, and rewards for format, field count, and JSON Schema validation. It augments prompts for fenced code blocks and top-level arrays, then compares the base and merged models on IFStruct using llama.cpp and an OpenAI-compatible local server.
Takeaways
The three rewards use weights [1.0, 0.5, 2.0]: format correctness, expected top-level field count, and JSON Schema validation, respectively.
Training runs for 100 steps with eight generations per prompt group, a per-device batch size of four, gradient accumulation of eight, and a maximum completion length of 1,024.
Average latency increased from 1,453 ms for the base model to 1,518 ms for the GRPO-tuned model in the reported IFStruct evaluations.
Source and freshness
- Source
- huggingface.co
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.