MiniCPM5-2B - OpenCodeReasoning-2 Python LoRA
QLoRA adapter for openbmb/MiniCPM5-2B, trained on a filtered subset of
nvidia/OpenCodeReasoning-2.
Data (important)
This is not trained on the full corpus. OpenCodeReasoning-2 holds ~1.4M Python and ~1.1M C++ rows; this adapter uses 50000 rows (12053 unique questions), selected as:
split="python"only (C++ skipped)judgement == "right"andpass_rate >= 0.8(rows withpass_rate == -1dropped)- unique-question first: the highest-
pass_rater1_generationperquestion_id, then extra high-pass solutions until 50000 rows - prompts reconstructed (OCR-2 stores
questionas"-") by joiningquestion_idtonvidia/OpenCodeReasoningsplit_0id -> input, with adataset/split/indexfallback into BAAI/TACO, codeparrot/apps, deepmind/code_contests and open-r1/codeforces - generations truncated to 12000 characters; very short prompts/generations dropped
OpenCodeReasoning-1 rows were not concatenated as extra training data - OCR-2 supersedes OCR-1 for generations, so mixing them would duplicate.
Training
| Method | 4-bit NF4 QLoRA (double quant, bf16 compute) |
| LoRA | r=16, alpha=32, dropout=0.05 |
| Targets | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Trainer | TRL SFTTrainer, MiniCPM chat template |
| Schedule | 1 epoch, seq 4096, bs 1 x grad-accum 8, lr 1e-4 cosine, warmup 0.03 |
| Optimizer | paged_adamw_8bit, gradient checkpointing |
| Hardware | 1x A100 40GB (Modal) |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM5-2B", trust_remote_code=True, device_map="auto")
tok = AutoTokenizer.from_pretrained("NANI-Nithin/MiniCPM5-2B-OpenCodeReasoning2-LoRA", trust_remote_code=True)
model = PeftModel.from_pretrained(base, "NANI-Nithin/MiniCPM5-2B-OpenCodeReasoning2-LoRA")
msgs = [{"role": "user", "content": "Write a Python function returning the n-th Fibonacci number."}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tok.decode(model.generate(ids, max_new_tokens=512)[0], skip_special_tokens=True))
Licensing and attribution
- Adapter weights: Apache-2.0.
- NVIDIA OpenCodeReasoning-2 reasoning traces: CC BY 4.0.
- Original contest problem statements (TACO, APPS, CodeContests, Codeforces) keep their original licenses and terms; check each source dataset before redistributing.
- Not affiliated with, endorsed by, or produced by OpenBMB or NVIDIA.
Citation
@article{ahmad2025opencodereasoning,
title={OpenCodeReasoning: Advancing Data Distillation for Competitive Coding},
author={Ahmad, Wasi Uddin and Narenthiran, Sean and Majumdar, Somshubra and Ficek, Aleksander and Jain, Siddhartha and Huang, Jocelyn and Noroozi, Vahid and Ginsburg, Boris},
journal={arXiv preprint arXiv:2504.01943},
year={2025}
}
Model discussions
Share what you know. Help others. Build trust.
Loading comments...
Keep it about the model. No spam, scams or personal attacks. Links are not allowed in comments or replies. Comment policy