Text Generation
Transformers
Safetensors
llama
minicpm
minicpm5
minicpm5-1b
tool-calling
function-calling
tool-use
agentic
xml-tool-calling
sglang
vllm
merged-model
nemotron
dpo
openbmb
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 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-Merged-FP16") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16") model = AutoModelForCausalLM.from_pretrained("ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 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-Merged-FP16" # 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-Merged-FP16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16
- SGLang
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 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-Merged-FP16" \ --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-Merged-FP16", "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-Merged-FP16" \ --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-Merged-FP16", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 with Docker Model Runner:
docker model run hf.co/ewin-reg/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16
yyy
Add model-index eval YAML, arch spec, thinking docs, limitations, citation, ModelScope; remove column meanings note
1304414 verified | license: apache-2.0 | |
| base_model: openbmb/MiniCPM5-1B | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - minicpm | |
| - minicpm5 | |
| - minicpm5-1b | |
| - tool-calling | |
| - function-calling | |
| - tool-use | |
| - agentic | |
| - xml-tool-calling | |
| - transformers | |
| - sglang | |
| - vllm | |
| - safetensors | |
| - merged-model | |
| - nemotron | |
| - dpo | |
| - openbmb | |
| widget: | |
| - text: "Use the available tool to create a note titled Team Meeting Agenda." | |
| - text: "Run tests for the calculator bug using the available tool." | |
| datasets: | |
| - Team-ACE/ToolACE | |
| model-index: | |
| - name: MiniCPM5-1B-Agentic-Tooluse-v2 | |
| results: | |
| - task: | |
| type: text-generation | |
| name: Tool calling | |
| dataset: | |
| name: External ToolACE-derived first-call evaluation (held-out 300 examples) | |
| type: Team-ACE/ToolACE | |
| metrics: | |
| - type: parseable_rate | |
| value: 0.9933 | |
| name: Parseable tool-call rate | |
| - type: valid_name_rate | |
| value: 0.9700 | |
| name: Valid available-tool name rate | |
| - type: expected_name_rate | |
| value: 0.9267 | |
| name: Expected tool-name rate | |
| - type: args_exact_rate | |
| value: 0.6533 | |
| name: Exact-arguments rate | |
| - type: arg_key_overlap | |
| value: 0.7517 | |
| name: Argument-key overlap | |
| - type: no_schema_copy_rate | |
| value: 1.0000 | |
| name: No-schema-copy rate | |
| - type: no_repetition_rate | |
| value: 1.0000 | |
| name: No-repetition rate | |
| - type: stopped_cleanly_rate | |
| value: 0.1500 | |
| name: Stopped-cleanly rate | |
| # MiniCPM5-1B Agentic Tooluse Merged FP16 | |
| Standalone merged FP16 checkpoint of | |
| [`openbmb/MiniCPM5-1B`](https://huggingface.co/openbmb/MiniCPM5-1B) | |
| and the latest | |
| [`MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2`](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2) | |
| adapter after the July 2026 Nemotron SFT+DPO repair. | |
| This repository contains the complete model. It is **not** an adapter and does not require PEFT at inference time. | |
| ## 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](https://huggingface.co/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: | |
| ```python | |
| # 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=False` for 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: | |
| ```bibtex | |
| @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: | |
| ```bibtex | |
| @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): | |
| - [OpenBMB/MiniCPM5-1B on ModelScope](https://www.modelscope.cn/models/OpenBMB/MiniCPM5-1B) | |
| *(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](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v3) | | |
| | Merged full-weight FP16 (transformers / vLLM / SGLang serving) | [MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16) | | |
| | GGUF quantizations (llama.cpp / Ollama / LM Studio, CPU-friendly) | [MiniCPM5-1B-Agentic-Tooluse-v3-GGUF](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-v3-GGUF) | | |
| ### v2 family (this release) | |
| | Format | Repository | | |
| |--------|-----------| | |
| | v2 LoRA adapter | [MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-QLoRA-v2) | | |
| | v2 Merged FP16 | [MiniCPM5-1B-Agentic-Tooluse-Merged-FP16](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16) | | |
| | v2 GGUF | [MiniCPM5-1B-Agentic-Tooluse-GGUF](https://huggingface.co/ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-GGUF) | | |
| ## Current Files | |
| The current model weights are one indexed checkpoint: | |
| - `model-00001-of-00002.safetensors` | |
| - `model-00002-of-00002.safetensors` | |
| - `model.safetensors.index.json` | |
| The repository also includes the matching tokenizer, `chat_template.jinja`, model configuration, generation configuration and external evaluation artifacts. The previous single-file model remains recoverable from Hub history but is not part of the current branch. | |
| ## Tool-Calling Behavior | |
| MiniCPM5-1B natively emits XML-style calls: | |
| ```xml | |
| <function name="tool_name"><param name="parameter">value</param></function> | |
| ``` | |
| The fine-tuning specializes first-call tool selection, function-name accuracy, argument selection, schema-copy avoidance and repeated-call suppression. | |
| An application remains responsible for parsing and validating calls, executing tools externally, and returning tool results in a new turn. | |
| ## Recommended Tool-Calling Deployment | |
| OpenBMB recommends SGLang with its built-in MiniCPM5 parser: | |
| ```bash | |
| pip install "sglang[srt]>=0.5.12" | |
| python -m sglang.launch_server \ | |
| --model-path ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 \ | |
| --port 30000 \ | |
| --tool-call-parser minicpm5 | |
| ``` | |
| The parser converts a completed `<function ...>...</function>` block into an OpenAI-compatible `tool_calls` response. | |
| ## Transformers | |
| ```python | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_id = "ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_id, | |
| dtype=torch.float16, | |
| device_map="auto", | |
| ) | |
| model.eval() | |
| ``` | |
| Use `tokenizer.apply_chat_template(...)` and the repository's matching chat template. For deterministic tool selection, override the sampling defaults: | |
| ```python | |
| outputs = model.generate( | |
| **inputs, | |
| do_sample=False, | |
| max_new_tokens=128, | |
| pad_token_id=tokenizer.pad_token_id, | |
| eos_token_id=tokenizer.eos_token_id, | |
| ) | |
| ``` | |
| Remove `token_type_ids` from `inputs` if the installed Transformers/tokenizer combination returns them, because this Llama model does not consume that argument. | |
| ## vLLM | |
| The merged safetensors checkpoint is the preferred format for vLLM: | |
| ```bash | |
| vllm serve ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-Merged-FP16 | |
| ``` | |
| Parser availability depends on the installed vLLM release. Use SGLang's official `minicpm5` parser path when OpenAI-compatible tool-call extraction is required and the vLLM build does not provide an equivalent parser. | |
| ## External Evaluation | |
| The final adapter and this merged checkpoint have identical weights for evaluation purposes. Evaluation used 300 examples derived from the external | |
| [`Team-ACE/ToolACE`](https://huggingface.co/datasets/Team-ACE/ToolACE) | |
| dataset, deterministic decoding, and the same cases for both models. This is not an official ToolACE or BFCL leaderboard submission. | |
| | Metric | Base MiniCPM5-1B | Repaired model | 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 | | |
| The full rows and metrics are published in: | |
| - `external_toolace_base_vs_nemotron_dpo_eval.json` | |
| - `EVAL_RESULTS.md` | |
| ## Understanding the 15% Termination Metric | |
| `stopped_cleanly_rate=0.15` is a strict natural-termination metric. It measures whether the model naturally ended immediately after a completed function call without runtime intervention. | |
| It does **not** mean that only 15% of cases produced usable calls. In the same evaluation, 99.33% were parseable, 97% used an available tool name, and 92.67% selected the expected tool. | |
| MiniCPM5's deployment contract uses a parser to extract the completed XML function block. Production should treat the first completed `</function>` as the action boundary and prevent generated synthetic tool responses or later dialogue from being interpreted as additional actions. | |
| ## Training Lineage | |
| The current adapter was produced by: | |
| 1. Earlier xLAM/Glaive SFT and preference-repair stages. | |
| 2. Targeted Nemotron SFT continuation from the previous DPO adapter. | |
| 3. DPO preference optimization over valid versus corrupted tool calls. | |
| 4. Merge into `openbmb/MiniCPM5-1B`. | |
| Nemotron sources used in the repair: | |
| - `nvidia/Nemotron-SFT-Agentic-v2` | |
| - `nvidia/Nemotron-RL-Agentic-Function-Calling-Pivot-v1` | |
| - `nvidia/Nemotron-RL-Agentic-Conversational-Tool-Use-Pivot-v1` | |
| The data pipeline inspected physical dataset files, skipped one malformed JSONL row in the SFT tool-calling file, removed oversized policy text where needed, preserved tool schemas and recent context, and rejected unknown arguments, schema-copy placeholders and invalid expected tools. | |
| ## Measured Improvements and Scope | |
| This merged checkpoint contains the same repaired adapter behavior and improved every reported task-quality metric over base MiniCPM5-1B: | |
| - 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 evidence that merging or fine-tuning degraded the base model. | |
| ## Deployment Notes | |
| - Schema validation, permission checks and confirmation for sensitive actions are standard requirements for every tool-calling model. | |
| - Exact-argument accuracy improved by **50.33 percentage points**; applications should still validate generated values before execution. | |
| - Valid-name accuracy improved by **95.67 percentage points**; rare near misses can remain on unseen tool libraries. | |
| - Natural termination improved from 0% to 15%. MiniCPM5's parser-based serving contract extracts the completed call, so this metric is separate from the 99.33% parseable-call rate. | |
| - The external evaluation is custom rather than an official ToolACE/BFCL leaderboard submission. | |
| - GGUF quantizations may differ slightly from FP16 and are published separately. | |
| ## Limitations | |