Instructions to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM5-1B") model = PeftModel.from_pretrained(base_model, "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2") - Transformers
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2
- SGLang
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 with Docker Model Runner:
docker model run hf.co/ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2
- MiniCPM5-1B Agentic Tooluse QLoRA v2
- Base model architecture
- Thinking mode
- Citation
- ModelScope
- Related repos
- Adapter Configuration
- Tool-Calling Behavior
- Load with PEFT
- Recommended Serving
- External Evaluation
- Understanding Natural Termination
- Training Lineage
- Runtime Responsibilities
- Measured Improvements and Scope
- Deployment Notes
- Version History
- Limitations
- Base model architecture
MiniCPM5-1B Agentic Tooluse QLoRA v2
Current PEFT/LoRA adapter for
openbmb/MiniCPM5-1B,
specialized for MiniCPM5 XML tool calling and repaired with targeted Nemotron SFT followed by DPO.
This is an adapter-only repository. Load it on top of the exact base model named in adapter_config.json, or use the standalone merged repository.
Base model architecture
MiniCPM5-1B uses a standard LlamaForCausalLM architecture:
| Property | Value |
|---|---|
| Parameters (total) | 1,080,632,832 |
| Parameters (non-embedding) | 679,552,512 |
| Architecture | LlamaForCausalLM |
| Layers | 24 |
| Attention heads (GQA) | 16 Q / 2 KV |
| Context length | 131,072 tokens |
| Training | SFT → RL (GRPO) fine-tune on openbmb/MiniCPM5-1B |
Thinking mode
MiniCPM5-1B has a built-in <think>...</think> chat template. The same checkpoint can act as a fast assistant or a deliberate chain-of-thought reasoner — controlled by a single flag:
# Fast mode — recommended for tool calling (thinking OFF)
prompt = tokenizer.apply_chat_template(
messages, tools=tools, add_generation_prompt=True,
enable_thinking=False,
tokenize=False,
)
# Reasoning mode (thinking ON — NOT recommended for tool calling)
prompt = tokenizer.apply_chat_template(
messages, tools=tools, add_generation_prompt=True,
enable_thinking=True,
tokenize=False,
)
Important: always use
enable_thinking=Falsefor tool/function calling. With thinking ON the model spends its token budget inside<think>...</think>and may not reach a completed function call. All benchmark numbers in this card use thinking OFF.
Citation
If you use this model, please cite the base model paper:
@article{minicpm4,
title = {MiniCPM4: Ultra-Efficient LLMs on End Devices},
author = {MiniCPM Team},
journal = {arXiv preprint arXiv:2506.07900},
year = {2025}
}
And the ToolACE dataset used for fine-tuning:
@article{toolace,
title = {ToolACE: Winning the Points of LLM Function Calling},
author = {Liu, Ying and others},
journal = {arXiv preprint arXiv:2409.00920},
year = {2024}
}
ModelScope
The base model is also available on ModelScope (for users in China and East Asia):
(The fine-tuned adapter/GGUF builds are currently HuggingFace-only.)
Related repos
Latest v3 release
| Format | Repository |
|---|---|
| LoRA adapter (PEFT, smallest download, fine-tune further) | MiniCPM5-1B-Agentic-Tooluse-QLoRA-v3 |
| Merged full-weight FP16 (transformers / vLLM / SGLang serving) | MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16 |
| GGUF quantizations (llama.cpp / Ollama / LM Studio, CPU-friendly) | MiniCPM5-1B-Agentic-Tooluse-v3-GGUF |
v2 family (this release)
| Format | Repository |
|---|---|
| v2 LoRA adapter | MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2 |
| v2 Merged FP16 | MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 |
| v2 GGUF | MiniCPM5-1B-Agentic-Tooluse-GGUF |
Adapter Configuration
- Base:
openbmb/MiniCPM5-1B - PEFT type: LoRA for causal language modeling
- Rank: 32
- Alpha: 64
- Dropout: 0.05
- Bias: none
- Target modules:
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj - Adapter parameters: approximately 22.4 million
Current primary artifacts:
adapter_model.safetensorsadapter_config.json- matching tokenizer and
chat_template.jinja inference_example.pyEVAL_RESULTS.mdexternal_toolace_base_vs_nemotron_dpo_eval.json
Tool-Calling Behavior
MiniCPM5-1B already has native XML-style tool calling:
<function name="tool_name"><param name="parameter">value</param></function>
This adapter specializes first-call tool selection, valid function names, argument selection, schema-copy avoidance and repeated-call suppression. It does not create tool calling from scratch.
Load with PEFT
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_id = "openbmb/MiniCPM5-1B"
adapter_id = "ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2"
# The adapter repository carries the matching final tokenizer/template.
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base = AutoModelForCausalLM.from_pretrained(
base_id,
dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(base, adapter_id)
model.eval()
Use tokenizer.apply_chat_template(messages, tools=tools, add_generation_prompt=True) rather than constructing a raw prompt. For deterministic tool selection, use do_sample=False.
See inference_example.py for a complete first-call example with bounded generation.
Recommended Serving
PEFT adapters are most convenient in Transformers. For a standalone server, use the merged FP16 repository.
OpenBMB recommends SGLang and its MiniCPM5 parser for tool calling:
python -m sglang.launch_server \
--model-path ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 \
--tool-call-parser minicpm5
The parser converts a completed <function ...>...</function> block into an OpenAI-compatible tool_calls response.
External Evaluation
Evaluation used 300 examples derived from the external
Team-ACE/ToolACE
dataset, deterministic decoding, and identical cases for the base and adapter. This is a custom first-call evaluation, not an official ToolACE or BFCL leaderboard submission.
| Metric | Base MiniCPM5-1B | Final adapter | Delta |
|---|---|---|---|
| Parseable tool call | 0.0133 | 0.9933 | +0.9800 |
| Valid available-tool name | 0.0133 | 0.9700 | +0.9567 |
| Expected tool name | 0.0133 | 0.9267 | +0.9133 |
| Exact arguments | 0.1500 | 0.6533 | +0.5033 |
| Argument-key overlap | 0.0033 | 0.7517 | +0.7484 |
| No schema copying | 1.0000 | 1.0000 | +0.0000 |
| No repetition | 0.9967 | 1.0000 | +0.0033 |
| Natural clean termination | 0.0000 | 0.1500 | +0.1500 |
Full metrics and bad-row records are published in EVAL_RESULTS.md and external_toolace_base_vs_nemotron_dpo_eval.json.
Understanding Natural Termination
stopped_cleanly_rate=0.15 measures whether generation naturally ended immediately after the completed function call without runtime intervention. It is not the usable-call rate.
The same run achieved 99.33% parseability, 97% available-tool names and 92.67% expected-tool selection. Production should use the official minicpm5 parser where supported and treat the first completed </function> as the action boundary.
Training Lineage
The current release continues from the earlier xLAM/Glaive adapter and preference-repair stages, then applies:
- A targeted SFT continuation using cleaned Nemotron agentic tool data.
- DPO preference optimization using valid calls versus corrupted or wrong-tool calls.
Nemotron sources:
nvidia/Nemotron-SFT-Agentic-v2nvidia/Nemotron-RL-Agentic-Function-Calling-Pivot-v1nvidia/Nemotron-RL-Agentic-Conversational-Tool-Use-Pivot-v1
The final pipeline inspected physical data files, skipped one malformed SFT JSONL row, removed oversized policy text where needed, preserved tool schemas and recent context, and rejected unknown arguments, schema-copy placeholders and invalid expected tools.
Runtime Responsibilities
The application must:
- Render only the available tools.
- Extract the first complete function block.
- Validate the exact function name and argument schema.
- Enforce permissions and request confirmation for sensitive actions.
- Execute the tool outside the model.
- Return the tool result in a new turn.
Measured Improvements and Scope
This adapter improved every task-quality metric reported against the base model:
- Parseable calls: 1.33% -> 99.33%
- Valid available-tool names: 1.33% -> 97.00%
- Expected-tool selection: 1.33% -> 92.67%
- Exact arguments: 15.00% -> 65.33%
- Argument-key overlap: 0.33% -> 75.17%
- No repetition: 99.67% -> 100.00%
- Natural clean termination: 0.00% -> 15.00%
The remaining gap to 100% is residual error after a large improvement, not a regression caused by fine-tuning.
Deployment Notes
- This is intentionally an adapter package; load it with
openbmb/MiniCPM5-1B, or use the merged repository for standalone inference. - Schema validation, permission checks and confirmation for sensitive actions are standard requirements for every tool-calling model, including the base model.
- Exact-argument accuracy improved by 50.33 percentage points. Applications should still validate required fields, types and ranges before execution.
- Valid-name accuracy improved by 95.67 percentage points. Rare near misses can still occur on unseen or unusually named tools.
- Natural termination improved from 0% to 15%; MiniCPM5's official parser-based serving path extracts the completed call rather than relying solely on natural EOS.
- The external evaluation is custom rather than an official ToolACE/BFCL leaderboard submission.
Version History
The current branch contains the July 2026 Nemotron SFT+DPO adapter and current external evaluation artifacts. Older adapter and evaluation states remain recoverable from Hugging Face commit history.
Limitations
- Downloads last month
- 23
Model tree for ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2
Base model
openbmb/MiniCPM5-1BDataset used to train ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2
Papers for ewin-reg/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2
MiniCPM4: Ultra-Efficient LLMs on End Devices
ToolACE: Winning the Points of LLM Function Calling
Evaluation results
- Parseable tool-call rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported0.993
- Valid available-tool name rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported0.970
- Expected tool-name rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported0.927
- Exact-arguments rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported0.653
- Argument-key overlap on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported0.752
- No-schema-copy rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported1.000
- No-repetition rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported1.000
- Stopped-cleanly rate on External ToolACE-derived first-call evaluation (held-out 300 examples)self-reported0.150