Instructions to use MrWoRmMrLabs/prompt-surgeon-lfm2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use MrWoRmMrLabs/prompt-surgeon-lfm2.5 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("LiquidAI/LFM2.5-2.6B") model = PeftModel.from_pretrained(base_model, "MrWoRmMrLabs/prompt-surgeon-lfm2.5") - Notebooks
- Google Colab
- Kaggle
Prompt Surgeon β LFM2.5-2.6B (LoRA)
A tiny, fully local prompt surgeon for AI agents. Given an agent's current prompt and evidence of a failure (a hallucination case plus a groundedness auditor's verdict), it proposes a single surgical fix β one rule to ADD to the prompt that prevents that whole class of failure β or says no change needed when the response was actually fine.
It is the companion to the groundedness-judge: the judge detects the hallucination, this model prescribes the cure. Together they close a measure β fix β re-measure loop that a local agent stack can run on itself, offline.
Built as a LoRA adapter on LiquidAI/LFM2.5-2.6B β small enough to run on a phone at Q4, trained on a single Tesla P100.
Trained by MrWoRmMr.
Task & output schema
Input: the agent's current prompt (excerpt) + the failure evidence (bad response + auditor verdict). Output: a JSON object with
| field | type | meaning |
|---|---|---|
diagnosis |
str | the failure pattern, in one line |
proposed_rule |
str | the exact instruction to add (or "" if none) |
target |
str | append_to_system | prepend_to_system | none |
rationale |
str | why this rule fixes the pattern |
It is surgical, not a rewrite: it adds one targeted rule instead of rewriting the whole prompt β
safer (won't break the persona), composable, and learnable. It also learns restraint: on
grounded responses (or anti-artifact cases like naming the operator), it returns target: "none"
and adds nothing.
Training
- Base: LiquidAI/LFM2.5-2.6B Β· Method: LoRA (rank 16, Ξ± 32, dropout 0.05, all linear modules)
- Data: a small synthetic dataset of (prompt + failure β surgical fix) cases, balanced between "fix" and "no-change" so the model learns when not to prescribe. Synthetic on purpose β reproducible and privacy-preserving; it never sees real user data.
- Hyperparams: 6 epochs, lr 1.5e-4 (cosine), fp16, cutoff 1024, single Tesla P100 (Pascal).
- Held-out check: correctly diagnoses failures and abstains on grounded cases.
Reproduction gotchas (Pascal / LFM2.5)
- LFM2.5's tokenizer needs transformers 5.x; but transformers 5.x needs torch β₯ 2.5. On a CUDA-12.2 driver, torch 2.5.1+cu121 is the sweet spot.
- Pascal (sm_60) has no bf16 and no FlashAttention β
bf16: false,fp16: true,flash_attn: disabled.
Known limitation (read this)
Like its judge sibling, the model reliably reaches the correct fix, but on out-of-distribution
inputs it tends to reason in prose before emitting JSON. Force structured output at inference
(llama.cpp / Ollama JSON grammar or format: json; transformers constrained decoding). The fine-tune
supplies the judgment, the grammar supplies the format.
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
tok = AutoTokenizer.from_pretrained("MrWoRmMrLabs/prompt-surgeon-lfm2.5")
base = AutoModelForCausalLM.from_pretrained("LiquidAI/LFM2.5-2.6B")
model = PeftModel.from_pretrained(base, "MrWoRmMrLabs/prompt-surgeon-lfm2.5")
# feed: system rubric + (agent prompt + failure evidence). Prefer constrained JSON decoding.
License
LoRA weights under the LFM Open License v1.0 (inherited from the base model): free for organizations under $10M annual revenue; commercial licensing above that threshold.
- Downloads last month
- 7