Instructions to use pmrccs/minicpm5-2b-python-tool-calling-v3-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use pmrccs/minicpm5-2b-python-tool-calling-v3-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, "pmrccs/minicpm5-2b-python-tool-calling-v3-lora") - Transformers
How to use pmrccs/minicpm5-2b-python-tool-calling-v3-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pmrccs/minicpm5-2b-python-tool-calling-v3-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("pmrccs/minicpm5-2b-python-tool-calling-v3-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pmrccs/minicpm5-2b-python-tool-calling-v3-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pmrccs/minicpm5-2b-python-tool-calling-v3-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pmrccs/minicpm5-2b-python-tool-calling-v3-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pmrccs/minicpm5-2b-python-tool-calling-v3-lora
- SGLang
How to use pmrccs/minicpm5-2b-python-tool-calling-v3-lora 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 "pmrccs/minicpm5-2b-python-tool-calling-v3-lora" \ --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": "pmrccs/minicpm5-2b-python-tool-calling-v3-lora", "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 "pmrccs/minicpm5-2b-python-tool-calling-v3-lora" \ --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": "pmrccs/minicpm5-2b-python-tool-calling-v3-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use pmrccs/minicpm5-2b-python-tool-calling-v3-lora with Docker Model Runner:
docker model run hf.co/pmrccs/minicpm5-2b-python-tool-calling-v3-lora
MiniCPM5-2B Python Tool-Calling v3 (LoRA)
A Python-oriented tool/function-calling LoRA adapter fine-tuned from openbmb/MiniCPM5-2B. This repository contains the adapter weights, which must be loaded with the base model. The model was trained using SFT via the TRL library. The BFCL v4 results below are from local evaluation runs; they were not submitted to an official public leaderboard.
- Base model:
openbmb/MiniCPM5-2B - Project repository: GitHub
- License: CC-BY-NC-4.0 for this repository; review the base model and upstream dataset terms separately.
Model Summary & Architecture
- Fine-tuned by: pmrccs
- Model type: Causal language model with a PEFT/LoRA adapter for structured tool/function-call generation
- Base model:
openbmb/MiniCPM5-2B - Adapter format: PEFT LoRA; not a standalone full-model checkpoint
- LoRA configuration: rank 16, alpha 32, dropout 0.0
- Target modules:
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj - Maximum formatted training sequence length: 1,024 tokens
- License:
cc-by-nc-4.0for this repository - Training Method: Supervised Fine-Tuning (SFT)
Training
For raw output files check Github
Uses
Intended for research and development involving structured tool/function-call generation with MiniCPM5-2B. Evaluation covered selected BFCL v4 categories involving Python, Java, and JavaScript schemas, as well as single, multiple, parallel, and irrelevance scenarios.
The adapter does not execute tools. A host application must parse and validate model outputs, determine whether a tool call is permitted, execute approved calls, and handle tool results. Treat generated calls as untrusted input and validate arguments against the actual tool schema before execution.
Bias, Risks & Limitations
| Limitation | Details / recommended handling |
|---|---|
| Tool-call correctness | The model may omit a needed call, produce an unnecessary call, emit malformed output, or generate arguments that do not match a schema. Validate before execution. |
| Language differences | In the recorded BFCL simple categories, results for Java and JavaScript were lower than those for Python. Do not assume equal performance across languages. |
| Post-processing | The post-processed evaluation results include deterministic schema-guided transformations after generation. They are not raw model-only results. |
| Evaluation coverage | The reported evaluation covers 13 selected BFCL v4 categories, not the full BFCL v4 suite. Format-sensitivity, memory, web-search, and multi-turn categories were not included in these runs. |
| Execution safety | Do not directly execute generated calls against sensitive systems. Use allowlists, schema/type validation, authorization checks, rate limits, timeouts, and sandboxing appropriate to the application. |
| Dataset and base-model terms | This card does not establish that all upstream dataset items have compatible redistribution or commercial-use terms. Review the base model and each upstream dataset's license and terms. |
Quick Start
Basic Loading (PEFT Model)
Install compatible versions of transformers and peft, then load the base model and adapter together. The recorded generation environment used transformers==4.57.6, peft==0.21.0, accelerate==1.10.1, and huggingface_hub==0.36.2. The base model and tokenizer were loaded with trust_remote_code=True in that environment.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
base_id = "openbmb/MiniCPM5-2B"
adapter_id = "pmrccs/minicpm5-2b-python-tool-calling-v3-lora"
tokenizer = AutoTokenizer.from_pretrained(
base_id,
trust_remote_code=True,
use_fast=True,
)
base_model = AutoModelForCausalLM.from_pretrained(
base_id,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
# Prepare prompts/messages using the base model's expected chat template.
# Parse and validate any generated tool call before executing it.
Alternative Pipeline Inference
You can also run text generation using the Hugging Face pipeline structure:
from transformers import pipeline
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
generator = pipeline("text-generation", model="None", device="cuda")
output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
print(output["generated_text"])
Training Details
Data Mix
The recorded data-preparation run combined ToolBench, ToolACE, Hermes, and When2Call sources. The processing log reports the following source row counts before filtering:
| Source | Rows recorded before filtering |
|---|---|
| ToolBench | 187,542 |
| ToolACE | 11,300 |
| Hermes | 1,893 |
| When2Call | 15,000 |
The pipeline log then records filtering, tool/schema unification, conversion to tool-call examples, addition of negative/no-tool examples, XML/tool-call validation, and deduplication. The final recorded dataset contained 61,497 examples, split into 58,423 training rows and 3,074 evaluation rows. The formatted-chat length limit was 1,024 tokens. The pipeline included a 20% negative/no-tool mix.
These figures describe the recorded dataset-preparation run and are not an independent audit of the source datasets or their licensing. The Hugging Face dataset configured for training is pmrccs/minicpm5-2b-python-tool-calling-v2.
Hyperparameters
| Setting | Value |
|---|---|
| Base model | openbmb/MiniCPM5-2B |
| Training duration | 1 epoch |
LoRA rank (r) |
16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.0 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Maximum sequence length | 1,024 tokens |
| Learning rate | 5e-5 |
| Scheduler | Cosine |
| Warmup ratio | 0.03 |
| Optimizer | adamw_8bit |
| Weight decay | 0.01 |
| Maximum gradient norm | 1.0 |
| Per-device batch size | 1 |
| Effective batch size | 16 across the configured visible GPUs and gradient accumulation |
| Seed | 42 |
| Evaluation/save interval | Every 200 steps |
| Evaluation rows per evaluation pass | Up to 200 |
| Gradient checkpointing | Unsloth |
| Hardware recorded for training | 2 ร NVIDIA Tesla T4 GPUs |
The training run completed at step 3,652, with a final logged eval_loss of 0.40880. This is a training/evaluation loss metric, not a downstream tool-calling accuracy score. Each evaluation pass was configured to use at most 200 rows; it should not be interpreted as evaluating all 3,074 evaluation rows at every checkpoint.
Evaluation
The BFCL v4 evaluation used bfcl-eval==2026.3.23 and the Gorilla repository pinned to commit f7cf7359b7ac615a0b294831c5ba2bc95ee4a000. The generation runs selected 3,641 examples across 13 categories.
For BFCL evaluation, the recorded generation setup used the base tokenizer's chat-template/prompt preparation, left padding, deterministic generation (do_sample=False), and separate model copies on two Tesla T4 GPUs. Generation used staged maximum-new-token caps of 512, 1,024, and 2,048; only generations that hit a cap were retried at the next stage. The two runs used different enable_thinking settings. Exact prompt preparation, decoding, and post-processing affect the reported scores.
Evaluation Scope
| Category | Examples |
|---|---|
simple_python |
400 |
simple_java |
100 |
simple_javascript |
50 |
multiple |
200 |
parallel |
200 |
parallel_multiple |
200 |
irrelevance |
240 |
live_simple |
258 |
live_multiple |
1,053 |
live_parallel |
16 |
live_parallel_multiple |
24 |
live_relevance |
16 |
live_irrelevance |
884 |
| Total | 3,641 |
Overall Results
- Raw: output after transport conversion, without repair rules.
- Postprocessed: raw conversion plus deterministic, schema-guided, language-specific transformations. These transformations are applied after generation.
- Postprocessed cascade: available for the thinking-enabled run; combines postprocessed outputs with a fallback for certain cut-off-reasoning records using the thinking-disabled run. This is an evaluation cascade, not an independent generation condition.
| Run / output condition | Weighted overall |
|---|---|
| Thinking disabled โ raw | 72.18% |
| Thinking disabled โ postprocessed | 73.08% |
| Thinking enabled โ raw | 75.47% |
| Thinking enabled โ postprocessed | 76.05% |
| Thinking enabled โ postprocessed cascade | 76.11% |
These results apply to the selected 13-category evaluation scope and the recorded prompt, conversion, and scoring setup. Postprocessed results should not be described as raw adapter-only performance.
Per-Category Accuracy
| Category | Thinking disabled raw | Thinking disabled postprocessed | Thinking enabled raw | Thinking enabled postprocessed | Thinking enabled cascade |
|---|---|---|---|---|---|
irrelevance |
74.17% | 73.75% | 80.00% | 80.00% | 75.00% |
live_irrelevance |
75.68% | 75.45% | 78.85% | 78.85% | 75.00% |
live_multiple |
64.01% | 64.48% | 66.76% | 67.14% | 69.80% |
live_parallel |
50.00% | 50.00% | 56.25% | 56.25% | 56.25% |
live_parallel_multiple |
66.67% | 70.83% | 54.17% | 58.33% | 58.33% |
live_relevance |
75.00% | 75.00% | 75.00% | 75.00% | 81.25% |
live_simple |
68.99% | 70.16% | 76.74% | 77.52% | 79.07% |
multiple |
90.00% | 90.00% | 91.00% | 91.00% | 91.00% |
parallel |
69.00% | 69.50% | 78.00% | 78.00% | 78.50% |
parallel_multiple |
73.00% | 78.50% | 79.00% | 80.00% | 84.00% |
simple_java |
47.00% | 60.00% | 47.00% | 57.00% | 58.00% |
simple_javascript |
54.00% | 56.00% | 52.00% | 54.00% | 60.00% |
simple_python |
88.75% | 89.00% | 88.75% | 89.00% | 89.50% |
| Weighted overall | 72.18% | 73.08% | 75.47% | 76.05% | 76.11% |
The cascade is not reported as a separate condition for the thinking-disabled run because the fallback setup applies to the thinking-enabled run.
Output Conversion and Post-processing
The thinking-disabled run recorded 3,641 examples with these conversion statuses:
NO_FUNCTION_BLOCK: 906VALID_CONVERSION: 2,671SCHEMA_TYPE_MISMATCH: 58MALFORMED_FUNCTION_BLOCK: 6
The thinking-enabled run recorded these conversion statuses:
NO_FUNCTION_BLOCK: 1,015VALID_CONVERSION: 2,561SCHEMA_TYPE_MISMATCH: 65
The evaluation pipeline used separate post-processing rules for Python, Java, and JavaScript. Rule types included unwrapping quoted strings, converting boolean literals, normalizing numeric values, handling container literals, and removing unknown parameters. These transformations can change evaluation outcomes and are not part of the model weights.
Technical Specifications & Framework Versions
The logged inference and training environment utilized the following software stack components:
- PEFT: 0.21.0 / 0.21.2
- TRL: 0.24.0
- Transformers: 4.57.6 / 5.5.0
- Accelerate: 1.10.1
- Huggingface Hub: 0.36.2
- Datasets: 4.3.0
- Tokenizers: 0.22.2
- BFCL Eval: 2026.3.23
- PyTorch & CUDA:
2.11.0+cu128along with CUDA12.8 - Hardware: 2 ร NVIDIA Tesla T4 GPUs for training and BFCL generation runs
For reproducibility, match the BFCL dataset revision, prompt preparation, generation settings, conversion logic, and post-processing behavior. The listed versions describe the recorded environment; dependency conflicts were reported during setup, so a clean, isolated environment is recommended.
Acknowledgements
- MiniCPM5-2B for the base model.
- Gorilla / Berkeley Function Calling Leaderboard for BFCL and its evaluation framework.
- The upstream training data sources used by the dataset-preparation pipeline: ToolBench, ToolACE, Hermes, and When2Call.
Citation
No paper citation for this adapter was identified in the project materials. If you use this adapter, cite the base model and the BFCL/Gorilla project as appropriate, and reference this model repository:
https://huggingface.co
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished \(= {\url{https://github.com}} \)}
- Downloads last month
- 250
Model tree for pmrccs/minicpm5-2b-python-tool-calling-v3-lora
Base model
openbmb/MiniCPM5-2B