A LoRA adapter that makes Qwen2.5-0.5B-Instruct answer in a fixed format: Summary / Key points (3 bullets) / Next step.
Newer version (v2): https://huggingface.co/Meow07/qwen2.5-0.5b-format-lora-v2
Live demo (base vs v1 vs v2): https://huggingface.co/spaces/Meow07/format-lora-demo
Code, datasets and experiments: https://github.com/Aryan-1947/qwen-format-lora
| Base | Base + format prompt | v1 | v2 | |
|---|---|---|---|---|
| Strict format, 40 questions | 0/40 | 0/40 | 37/40 | 40/40 |
| Strict format, 111 questions | n/a | n/a | 89.2% | 97.3% |
Answer quality did not measurably change (LLM judge 3.48 vs 3.50 for the base model; the judge was unreliable, so treat this as rough).
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
model = PeftModel.from_pretrained(base, "Meow07/qwen2.5-0.5b-format-lora")
Qwen/Qwen2.5-0.5B-Instruct