初始化项目,由ModelHub XC社区提供模型
Model: ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16 Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
285
README.md
Normal file
285
README.md
Normal file
@@ -0,0 +1,285 @@
|
||||
---
|
||||
license: apache-2.0
|
||||
base_model: openbmb/MiniCPM5-1B
|
||||
tags:
|
||||
- minicpm
|
||||
- minicpm5
|
||||
- minicpm5-1b
|
||||
- tool-calling
|
||||
- function-calling
|
||||
- tool-use
|
||||
- agentic
|
||||
- agentic-ai
|
||||
- ai-agent
|
||||
- xml-tool-calling
|
||||
- json-function-calling
|
||||
- merged-model
|
||||
- full-finetune
|
||||
- unsloth
|
||||
- openbmb
|
||||
- llama
|
||||
- text-generation
|
||||
- conversational
|
||||
- small-language-model
|
||||
- slm
|
||||
- edge-ai
|
||||
- on-device
|
||||
- local-llm
|
||||
- vllm
|
||||
- sglang
|
||||
- transformers
|
||||
language:
|
||||
- en
|
||||
pipeline_tag: text-generation
|
||||
datasets:
|
||||
- Team-ACE/ToolACE
|
||||
model-index:
|
||||
- name: MiniCPM5-1B-Agentic-Tooluse-v3
|
||||
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: 1.0000
|
||||
name: Parseable tool-call rate
|
||||
- type: valid_name_rate
|
||||
value: 0.9867
|
||||
name: Valid available-tool name rate
|
||||
- type: expected_name_rate
|
||||
value: 0.9533
|
||||
name: Expected tool-name rate
|
||||
- type: args_exact_rate
|
||||
value: 0.7467
|
||||
name: Exact-arguments rate
|
||||
- type: arg_key_overlap
|
||||
value: 0.9388
|
||||
name: Argument-key overlap
|
||||
- type: no_schema_copy_rate
|
||||
value: 0.9967
|
||||
name: No-schema-copy rate
|
||||
- type: no_repetition_rate
|
||||
value: 0.3400
|
||||
name: No-repetition rate
|
||||
- type: stopped_cleanly_rate
|
||||
value: 0.0000
|
||||
name: Stopped-cleanly rate
|
||||
---
|
||||
|
||||
# MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16 — Small Function-Calling LLM for vLLM / SGLang / Transformers
|
||||
|
||||
**MiniCPM5-1B-Agentic-Tooluse-v3** is a **1-billion-parameter open-weight function-calling model** merged into a single full-precision FP16 checkpoint — no adapter loading, no PEFT setup, no extra dependencies. Load it directly with `transformers`, serve it with **vLLM** or **SGLang**, and start calling tools immediately.
|
||||
|
||||
If you are looking for a **small function-calling LLM for production serving**, a **1B tool-use model for vLLM or SGLang**, a **compact open-weight alternative to GPT-4o / Claude function calling**, or a **locally deployable structured-output model for agent pipelines**, this is the single-file, deploy-anywhere version.
|
||||
|
||||
> **74.67% exact-argument accuracy** on a held-out 300-example benchmark — trained with QLoRA supervised fine-tuning followed by GRPO reinforcement learning, rewarding exact function-name and argument-value correctness.
|
||||
|
||||
## Why this model
|
||||
|
||||
MiniCPM5-1B-Agentic-Tooluse-v3 is fine-tuned specifically to parse a tool schema and a natural-language user request, then emit a structured, correctly-named, correctly-valued function call — the exact skill that powers LangChain agents, LlamaIndex pipelines, AutoGen, CrewAI, MCP tool servers, ReAct loops, and home-automation assistants.
|
||||
|
||||
Unlike most small open tool-calling models that stop at supervised fine-tuning, this model goes further with **GRPO reinforcement learning** on top of the SFT checkpoint, specifically rewarding the two hardest parts of tool calling: choosing the right function name and getting every argument value exactly right.
|
||||
|
||||
**Compared to GPT-4o / Claude for function calling:** this model is 100% free, runs locally, keeps all data private, has zero per-call cost, and is fine-tunable — it trades some absolute accuracy for massive gains in cost, latency, and privacy. The merged FP16 format means you can load it with a single `AutoModelForCausalLM.from_pretrained()` call, just like any base model.
|
||||
## Why this model
|
||||
|
||||
MiniCPM5-1B-Agentic-Tooluse-v3 is fine-tuned specifically for **agentic tool/function calling**: given a tool schema and a natural-language request, it reliably produces a correctly-named, correctly-structured, correctly-valued function call — the exact capability that powers LangChain/LlamaIndex/AutoGen/CrewAI agents, MCP tool servers, ReAct-style loops, and home-automation assistants.
|
||||
|
||||
This release combines **QLoRA supervised fine-tuning** with a **GRPO reinforcement-learning refinement stage**, specifically optimized to improve exact function-name selection and exact argument-value correctness — historically the two hardest failure modes for small (~1B) tool-calling models.
|
||||
|
||||
## Results
|
||||
|
||||
Evaluated on a held-out 300-example test slice drawn from a **seeded shuffle** of ToolACE (see *Split integrity*).
|
||||
The base-model column is the same model with the same prompt and no adapter.
|
||||
|
||||
The **published weights are SFT + GRPO** (see *GRPO / RLVR*). The SFT column is kept because every
|
||||
negative result below is measured against it.
|
||||
|
||||
| metric | v2 (previous release) | SFT retrain (pre-GRPO) | **v3 = SFT + GRPO (published)** |
|
||||
|---|---|---|---|
|
||||
| `parseable` — output is a well-formed call | 0.9933 | 1.0000 | **1.0000** |
|
||||
| `valid_name` — name exists among the offered tools | 0.9700 | 0.9867 | **0.9867** |
|
||||
| `expected_name` — name matches gold | 0.9067 | 0.9567 | **0.9533** |
|
||||
| `args_exact` — *every* argument value matches gold | 0.6133 | 0.7367 | **0.7467** |
|
||||
| `arg_key_overlap` — F1 over argument keys | 0.8757 | 0.9422 | **0.9388** |
|
||||
| **mean of 5** | 0.8718 | 0.9245 | **0.9251** |
|
||||
|
||||
GRPO buys +0.0100 on `args_exact`, the metric that matters here, and gives back 0.0034 (one test example
|
||||
each) on `expected_name` and `arg_key_overlap`. That trade is reported rather than hidden: the mean moves
|
||||
only +0.0006, so this is a targeted gain on the hardest metric, not a broad improvement.
|
||||
|
||||
## Full 8-metric benchmark (held-out test set, n=300)
|
||||
|
||||
This table mirrors the evaluation format from v2 and shows Base, v2, and v3 side-by-side
|
||||
across all 8 metrics using a single consistent harness and held-out test slice:
|
||||
|
||||
| Metric | Base MiniCPM5-1B | v2 (previous release) | v3 (this model) | Delta (v2 → v3) |
|
||||
|---|---:|---:|---:|---:|
|
||||
| parseable_rate | 0.0133 | 0.9933 | 1.0000 | +0.0067 |
|
||||
| valid_name_rate | 0.0133 | 0.9700 | 0.9867 | +0.0167 |
|
||||
| expected_name_rate | 0.0133 | 0.9267 | 0.9533 | +0.0267 |
|
||||
| args_exact_rate | 0.1500 | 0.6533 | 0.7467 | +0.0934 |
|
||||
| arg_key_overlap | 0.0033 | 0.7517 | 0.9388 | +0.1871 |
|
||||
| no_schema_copy_rate | 1.0000 | 1.0000 | 0.9967 | -0.0033 |
|
||||
| no_repetition_rate | 0.9967 | 1.0000 | 0.3400 | -0.6600 |
|
||||
| stopped_cleanly_rate | 0.0000 | 0.1500 | 0.0000 | -0.1500 |
|
||||
|
||||
**What the additional metrics mean:**
|
||||
- `no_schema_copy_rate` — the model did **not** copy the tool schema's own field description
|
||||
verbatim into an argument value.
|
||||
- `no_repetition_rate` — the completion did not contain a duplicated function-call block or
|
||||
degenerate repeated-phrase loop. This model has a known weakness here: it often continues
|
||||
generating filler content after the tool call completes. Use a parser that extracts the first
|
||||
completed `<function>...</function>` block.
|
||||
- `stopped_cleanly_rate` — the model naturally stopped immediately after the completed
|
||||
`</function>` tag with no trailing tokens. Use a parser that treats the first completed
|
||||
`<function>...</function>` block as the action boundary — do not rely on natural end-of-generation.
|
||||
|
||||
## Model details
|
||||
|
||||
- **Base model:** [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)
|
||||
|
||||
- **Architecture:** Llama-style causal language model, ~1.08B parameters
|
||||
|
||||
- **Format:** merged full weights, safetensors, FP16 — no adapter/PEFT loading required
|
||||
|
||||
- **Training pipeline:** QLoRA SFT on tool-calling trajectories → GRPO reinforcement learning targeting exact argument correctness
|
||||
|
||||
- **Compatible with:** `transformers`, vLLM, SGLang, TGI, and any standard Hugging Face causal-LM serving pipeline
|
||||
|
||||
## Quickstart
|
||||
|
||||
```python
|
||||
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
tok = AutoTokenizer.from_pretrained("ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16")
|
||||
|
||||
model = AutoModelForCausalLM.from_pretrained("ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16")
|
||||
|
||||
# Use tok.apply_chat_template(messages, tools=[...]) with your function/tool schema,
|
||||
|
||||
# then generate as usual — the model emits a structured function call.
|
||||
|
||||
```
|
||||
|
||||
**vLLM:**
|
||||
|
||||
```bash
|
||||
|
||||
vllm serve ewinregirgojr/MiniCPM5-1B-Agentic-Tooluse-v3-Merged-FP16
|
||||
|
||||
```
|
||||
|
||||
## Ideal use cases
|
||||
|
||||
- Production agent backends that need a fast, cheap, self-hosted function-calling model
|
||||
|
||||
- LangChain / LlamaIndex / AutoGen / CrewAI / MCP-based agents needing a small, reliable tool-calling backbone
|
||||
|
||||
- On-device and edge deployments where a 7B+ model isn't an option
|
||||
|
||||
- High-throughput services where per-request cost and latency matter more than squeezing out the last few points of accuracy from a much larger model
|
||||
|
||||
- Teams that want a fully open-weight, fine-tunable starting point instead of depending on a closed API for structured tool calls
|
||||
|
||||
## 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
|
||||
|
||||
### v3 model family (this 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) |
|
||||
|
||||
### Previous releases
|
||||
|
||||
| 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) |
|
||||
## FAQ
|
||||
|
||||
**Do I need the adapter repo too?** No — this repo already contains the fully merged weights. Use the adapter repo only if you want to load it on top of base MiniCPM5-1B yourself or continue fine-tuning.
|
||||
|
||||
**What's the difference between this and the GGUF repo?** This is full-precision FP16 safetensors for GPU-backed serving frameworks (`transformers`, vLLM, SGLang). The GGUF repo is quantized for CPU-friendly local inference via llama.cpp/Ollama/LM Studio.
|
||||
|
||||
**How was v3 trained differently from v2?** v3 continues from the v2-era recipe with an additional QLoRA SFT pass plus a GRPO reinforcement-learning stage explicitly rewarding exact argument-value correctness, which is what drives the args_exact improvement shown above.
|
||||
|
||||
## Base model
|
||||
|
||||
Built on [MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) by OpenBMB.
|
||||
|
||||
## Limitations
|
||||
179
chat_template.jinja
Normal file
179
chat_template.jinja
Normal file
@@ -0,0 +1,179 @@
|
||||
{{- bos_token }}{%- if tools %}
|
||||
{%- set tool_definitions %}
|
||||
{{- "# Tools\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
||||
{%- for tool in tools %}
|
||||
{{- "\n" }}
|
||||
{{- tool | tojson(ensure_ascii=False) }}
|
||||
{%- endfor %}
|
||||
{{- '\n</tools>\n\nTool usage guidelines:\n- You may call zero or more functions. If no function calls are needed, just answer normally and do not include any <function ... </function>.\n- When calling a function, return an XML object within <function ... </function> using:\n<function name="function-name"><param name="param-name">param-value</param></function>\n- param-value may be multi-line. If it contains <, & or newline characters, wrap it in a CDATA block: <param name="param-name"><![CDATA[...multi-line value...]]></param>' }}
|
||||
{%- endset %}
|
||||
|
||||
{{- '<|im_start|>system\n' }}
|
||||
{%- if messages[0].role == 'system' %}
|
||||
{%- if '<tool_def_sep>' in messages[0].content %}
|
||||
{{- messages[0].content.replace('<tool_def_sep>', tool_definitions) }}
|
||||
{%- else %}
|
||||
{{- messages[0].content + '\n\n' + tool_definitions }}
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
{{- tool_definitions.lstrip() }}
|
||||
{%- endif %}
|
||||
{{- '<|im_end|>\n' }}
|
||||
{%- else %}
|
||||
{%- if messages[0].role == 'system' %}
|
||||
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
||||
{%- for message in messages[::-1] %}
|
||||
{%- set index = (messages|length - 1) - loop.index0 %}
|
||||
{%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
|
||||
{%- set ns.multi_step_tool = false %}
|
||||
{%- set ns.last_query_index = index %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- for message in messages %}
|
||||
{%- if message.content is string %}
|
||||
{%- set content = message.content %}
|
||||
{%- else %}
|
||||
{%- set content = '' %}
|
||||
{%- endif %}
|
||||
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
||||
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
||||
{%- elif message.role == "assistant" %}
|
||||
{%- set reasoning_content = '' %}
|
||||
{%- if message.reasoning_content is string %}
|
||||
{%- set reasoning_content = message.reasoning_content %}
|
||||
{%- else %}
|
||||
{%- if '</think>' in content %}
|
||||
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
|
||||
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
||||
{%- if message.tool_calls %}
|
||||
{%- set content_parts = content.split('<tool_sep>') %}
|
||||
{%- set processed_content = content_parts[0] %}
|
||||
{%- set tool_calls_count = message.tool_calls|length %}
|
||||
{%- set tool_sep_count = content_parts|length - 1 %}
|
||||
{%- set min_count = [tool_calls_count, tool_sep_count]|min %}
|
||||
|
||||
{%- for i in range(1, content_parts|length) %}
|
||||
{%- set tool_index = i - 1 %}
|
||||
{%- if tool_index < tool_calls_count %}
|
||||
{%- set tool_call = message.tool_calls[tool_index] %}
|
||||
{%- if tool_call.function %}
|
||||
{%- set tool_call = tool_call.function %}
|
||||
{%- endif %}
|
||||
{%- set single_tool_xml %}
|
||||
{{- '<function name="' ~ tool_call.name ~ '">' }}
|
||||
{%- if tool_call.arguments %}
|
||||
{%- set args_dict = tool_call.arguments %}
|
||||
{%- for param_name, param_value in args_dict.items() %}
|
||||
{{- '<param name="' ~ param_name ~ '">' }}
|
||||
{%- if param_value is string and ('<' in param_value or '&' in param_value or '\n' in param_value) %}
|
||||
{{- '<![CDATA[' + param_value + ']]>' }}
|
||||
{%- else %}
|
||||
{{- param_value }}
|
||||
{%- endif %}
|
||||
{{- '</param>' }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{{- '</function>' }}
|
||||
{%- endset %}
|
||||
{%- set processed_content = processed_content + single_tool_xml + content_parts[i] %}
|
||||
{%- else %}
|
||||
{%- set processed_content = processed_content + content_parts[i] %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{%- if tool_calls_count > tool_sep_count %}
|
||||
{%- for remaining_index in range(tool_sep_count, tool_calls_count) %}
|
||||
{%- set tool_call = message.tool_calls[remaining_index] %}
|
||||
{%- if tool_call.function %}
|
||||
{%- set tool_call = tool_call.function %}
|
||||
{%- endif %}
|
||||
{%- set remaining_tool_xml %}
|
||||
{{- '<function name="' ~ tool_call.name ~ '">' }}
|
||||
{%- if tool_call.arguments %}
|
||||
{%- set args_dict = tool_call.arguments %}
|
||||
{%- for param_name, param_value in args_dict.items() %}
|
||||
{{- '<param name="' ~ param_name ~ '">' }}
|
||||
{%- if param_value is string and ('<' in param_value or '&' in param_value or '\n' in param_value) %}
|
||||
{{- '<![CDATA[' + param_value + ']]>' }}
|
||||
{%- else %}
|
||||
{{- param_value }}
|
||||
{%- endif %}
|
||||
{{- '</param>' }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{{- '</function>' }}
|
||||
{%- endset %}
|
||||
{%- set processed_content = processed_content + remaining_tool_xml %}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
|
||||
{%- set content = processed_content %}
|
||||
{%- endif %}
|
||||
|
||||
{%- if loop.index0 > ns.last_query_index %}
|
||||
{%- if reasoning_content %}
|
||||
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
|
||||
{%- else %}
|
||||
{{- '<|im_start|>' + message.role + '\n' + content }}
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
{{- '<|im_start|>' + message.role + '\n' + content }}
|
||||
{%- endif %}
|
||||
|
||||
{%- if message.tool_calls and not has_tool_sep %}
|
||||
{%- for tool_call in message.tool_calls %}
|
||||
{%- if (loop.first and content) or (not loop.first) %}
|
||||
{{- '\n' }}
|
||||
{%- endif %}
|
||||
{%- if tool_call.function %}
|
||||
{%- set tool_call = tool_call.function %}
|
||||
{%- endif %}
|
||||
{{- '<function name="' ~ tool_call.name ~ '">' }}
|
||||
{%- if tool_call.arguments %}
|
||||
{%- set args_dict = tool_call.arguments %}
|
||||
{%- for param_name, param_value in args_dict.items() %}
|
||||
{{- '<param name="' ~ param_name ~ '">' }}
|
||||
{%- if param_value is string and ('<' in param_value or '&' in param_value or '\n' in param_value) %}
|
||||
{{- '<![CDATA[' + param_value + ']]>' }}
|
||||
{%- else %}
|
||||
{{- param_value }}
|
||||
{%- endif %}
|
||||
{{- '</param>' }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{{- '</function>' }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{{- '<|im_end|>\n' }}
|
||||
{%- elif message.role == "tool" %}
|
||||
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
||||
{{- '<|im_start|>user' }}
|
||||
{%- endif %}
|
||||
{{- '\n<tool_response>\n' }}
|
||||
{%- if message.content is string %}
|
||||
{{- content }}
|
||||
{%- else %}
|
||||
{{- message.content | tojson(ensure_ascii=False) }}
|
||||
{%- endif %}
|
||||
{{- '\n</tool_response>' }}
|
||||
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
||||
{{- '<|im_end|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- if add_generation_prompt %}
|
||||
{{- '<|im_start|>assistant\n' }}
|
||||
{%- if enable_thinking is defined %}
|
||||
{%- if enable_thinking is false %}
|
||||
{{- '<think>\n\n</think>\n\n' }}
|
||||
{%- elif enable_thinking is true %}
|
||||
{{- '<think>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
33
config.json
Normal file
33
config.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
"attention_bias": false,
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 0,
|
||||
"dtype": "float16",
|
||||
"eos_token_id": [
|
||||
1,
|
||||
130073
|
||||
],
|
||||
"head_dim": 128,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 1536,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 4608,
|
||||
"max_position_embeddings": 131072,
|
||||
"mlp_bias": false,
|
||||
"model_type": "llama",
|
||||
"num_attention_heads": 16,
|
||||
"num_hidden_layers": 24,
|
||||
"num_key_value_heads": 2,
|
||||
"pad_token_id": 1,
|
||||
"pretraining_tp": 1,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 5000000,
|
||||
"tie_word_embeddings": false,
|
||||
"transformers_version": "4.57.3",
|
||||
"use_cache": true,
|
||||
"vocab_size": 130560
|
||||
}
|
||||
13
generation_config.json
Normal file
13
generation_config.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"_from_model_config": true,
|
||||
"bos_token_id": 0,
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
1,
|
||||
130073
|
||||
],
|
||||
"pad_token_id": 1,
|
||||
"temperature": 0.9,
|
||||
"top_p": 0.95,
|
||||
"transformers_version": "4.57.3"
|
||||
}
|
||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:30d777ad58a6c4875b3fd08e80a6147257c340a3df593d41995c69e3a84ccfd4
|
||||
size 2161290720
|
||||
30
special_tokens_map.json
Normal file
30
special_tokens_map.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"bos_token": {
|
||||
"content": "<s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"eos_token": {
|
||||
"content": "</s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "</s>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"unk_token": {
|
||||
"content": "<unk>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
653947
tokenizer.json
Normal file
653947
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
4099
tokenizer_config.json
Normal file
4099
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user