Instructions to use Mercity/decision-model-minicpm5-2b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Mercity/decision-model-minicpm5-2b-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM5-2B") model = PeftModel.from_pretrained(base_model, "Mercity/decision-model-minicpm5-2b-lora") - Notebooks
- Google Colab
- Kaggle
Decision Model 2B (MiniCPM5-2B LoRA)
- 📖 Blog: How to Train Your Own Decision Model With Minimal Changes to an LLM
- 📊 Training data: Mercity/decision-model-data
- 🤗 Larger sibling (more accurate): Mercity/decision-model-qwen3.5-4b
- 🪣 Code, logs, checkpoints and technical report: Mercity/Desicion-Model-Custom (Hugging Face bucket)
A decision model: give it a piece of evidence, a criterion and a list of options, and it returns a calibrated probability for every option in one forward pass (about 20 ms on an A100). This repo is a LoRA adapter for openbmb/MiniCPM5-2B.
Use it as one model in two states:
- adapter on for fast answers;
- adapter off for thinking.
Fine-tuning damaged MiniCPM5-2B's step-by-step reasoning, so the untouched base model does the thinking. Switching the adapter off costs nothing.
| Base model | openbmb/MiniCPM5-2B (Llama architecture) |
| Adapter | LoRA rank 32, alpha 64, on all attention and MLP projections (201 MB) |
| Training | readout-only: 42K decision questions, no reasoning chains |
| Question types | choice (pick 1 of 2-26 options), yes/no, score (a level on an ordered scale) |
| Language | English |
| License | Apache 2.0 |
Results
Our evaluation set has 5,442 questions from four sources. Thinking-mode and routed numbers use a fixed 1,498-question subset of it.
| MiniCPM5-2B (untrained) | This adapter (fast) + base (thinking) | |
|---|---|---|
| Fast readout accuracy | 50.2% | 66.0% |
| Thinking-mode accuracy (adapter off) | 79.4% | 79.4% |
| Routed: 30% of questions to thinking | 75.6% at 253 thinking tokens/question | |
| Routed: 50% of questions to thinking | 78.0% at 411 thinking tokens/question | |
| S1MB Task Avg, fast readout (137 tasks) | 18.1 | 37.3 |
- Among published ~2B models on S1MB, only two score higher on Task Avg: KnowLine-2B-Gen1 (44.8) and unee-2b (44.4).
- With the adapter left on for thinking, thinking accuracy drops to 70.8%. Training on the 4B's reasoning chains instead drops it to 71.7%.
- On Jevals (suite 0.1.0, Decision Score), the fast readout scores 44.6 on PubMedQA, 53.9 on Banking77 and -0.4 on HelpSteer2.
How it works
- Fast readout (adapter on). The prompt (thinking off) ends where the answer letter goes. The model's next-token
logits for the option letters
A,B, ... are divided by a per-question-type temperature (incalibration.json) and passed through a softmax. Nothing is generated. - Thinking mode (adapter off). The same prompt with thinking on. Base MiniCPM5-2B writes a chain inside
<think>...</think>, and its answer is the letter after the chain. - Routing. Every question gets the fast readout. Questions whose margin is small go to thinking. The margin is the log-probability gap between the top two options.
Usage
Requires transformers, peft, torch and accelerate. The prompt format matters: the model was trained on one
fixed format, and decision.py in this repo builds it.
import json, os, sys
import torch
from huggingface_hub import hf_hub_download
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "Mercity/decision-model-minicpm5-2b-lora"
tok = AutoTokenizer.from_pretrained(repo)
base = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM5-2B", dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, repo).eval()
calib = json.load(open(hf_hub_download(repo, "calibration.json")))
sys.path.insert(0, os.path.dirname(hf_hub_download(repo, "decision.py")))
import decision as D
# Fast readout (adapter on): one forward pass, a probability per option
evidence = "Order #1182: 3 x USB-C dock at $79 each, shipping $12."
criterion = "Does the order fit within a budget of $250?"
options = D.yes_no_options() # A = true, B = false
probs = D.fast_readout(model, tok, evidence, criterion, options, temperature=calib["readout"]["noul"])
print(probs) # [p(true), p(false)]
Options are written as id: description, whichever parts exist. Use the helpers to build them:
choice = [D.option("refund", "Issue a refund."), D.option("replace", "Send a replacement."),
D.option("escalate", "Hand the ticket to a human agent.")] # qtype "choice"
score = D.score_options(["Benign: read-only actions.", "Low: routine writes.",
"Moderate: irreversible actions.", "High: destructive actions."]) # qtype "score"
Routed system (fast with the adapter, thinking without it):
def decide(evidence, criterion, options, qtype, cutoff=calib["routing"]["cutoff_route_30pct"]):
probs = D.fast_readout(model, tok, evidence, criterion, options, temperature=calib["readout"][qtype])
fast = max(range(len(probs)), key=probs.__getitem__)
if D.margin(probs) >= cutoff:
return {"answer": fast, "probs": probs, "mode": "fast"}
with model.disable_adapter(): # thinking runs on the untouched base model
rec = D.think(model, tok, evidence, criterion, options, max_new_tokens=8192,
temperature=1.0, top_p=0.95, top_k=0) # MiniCPM5-2B's sampling settings
if rec["answer"] is None: # chain did not finish: keep the fast answer
return {"answer": fast, "probs": probs, "mode": "fast"}
return {"answer": rec["answer"], "probs": probs, "mode": "thinking", "chain": rec["text"]}
qtypeis"choice","noul"(yes/no) or"score".- The cutoff in
calibration.jsonsent 30% of our evaluation questions to thinking. The share on your traffic will differ, so set the cutoff from a sample of your own questions. - In thinking mode, the returned
probsare still the fast readout's. Base MiniCPM5-2B's readout after a chain was not calibrated.
Our numbers come from vLLM serving a merged copy of this adapter (run3_2b/checkpoints/v2b_ro_merged in the bucket
linked below) for the fast readout, and the base model for thinking.
Training
- Base model choice. MiniCPM5-2B was picked over Qwen3.5-2B by a rule fixed before the probe. The rule combined fast-readout accuracy and first-chain accuracy.
- Readout-only training. Cross-entropy of the option-letter softmax against the target distribution, on 41,994
questions (Mercity/decision-model-data, config
readout):- 18,000 generated procedural decisions (tasksource/procedural-typed-decisions);
- 23,994 converted from 717 tasksource datasets;
- half shown in shuffled option order.
- Run. Learning rate 2e-4, 549 steps, 20.8M tokens, 41 minutes on one A100 80GB. Held-out dev accuracy 76.0%.
- Calibration. Per-type temperatures fitted on 515 held-out questions, never on evaluation data
(
calibration.json).
Limitations
- Built for one prompt format. It is not a chat model. Use
decision.pyor reproduce its format exactly. - Thinking only with the adapter off. Do not use thinking mode with the adapter on.
- Behind the 4B model. It is 4-6 points less accurate at the same routing share, and out-of-distribution gains are smaller than in-distribution ones.
- Limited validation. Results are from a single training run. We scored S1MB and Jevals with our own reimplementations of their published scoring rules, checked against their published numbers.
More
- Write-up: How to Train Your Own Decision Model With Minimal Changes to an LLM
- Training and evaluation data: Mercity/decision-model-data
- Code, data, logs, every checkpoint and the full 23-page technical report (
report/decision_model_report.pdf): Mercity/Desicion-Model-Custom (Hugging Face bucket) - This adapter is
run3_2b/results/adapters/v2b_roin that bucket.
- Downloads last month
- 28
Model tree for Mercity/decision-model-minicpm5-2b-lora
Base model
openbmb/MiniCPM5-2B