初始化项目,由ModelHub XC社区提供模型

Model: GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-10 20:31:54 +08:00
commit 8df2fcab45
10 changed files with 654447 additions and 0 deletions

35
.gitattributes vendored Normal file
View 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

103
README-cn.md Normal file
View File

@@ -0,0 +1,103 @@
---
library_name: transformers
license: apache-2.0
language:
- en
- zh
base_model: openbmb/MiniCPM5-1B
base_model_relation: finetune
pipeline_tag: text-generation
tags:
- minicpm
- minicpm5
- thinking
- fable5
- coding
- instruction-following
---
<p align="center">
<img src="assets/banner.png" alt="MiniCPM5-1B-Claude-Opus-Fable5-Thinking" width="100%"/>
</p>
# MiniCPM5-1B-Claude-Opus-Fable5-Thinking
GGUF 量化版:**[MiniCPM5-1B-Claude-Opus-Fable5-Thinking-GGUF](https://huggingface.co/GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking-GGUF)**
[English README](./README.md)
**MiniCPM5-1B-Claude-Opus-Fable5-Thinking** 是基于 [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) 的 1B **Thinking** 语言模型。该模型使用 **Fable 5** 数据进一步微调,增强了 **Coding编程****指令遵循Instruction Following** 能力,同时保留 MiniCPM5 原生的 Thinking 对话模板与工具调用格式。
llama.cpp / Ollama / LM Studio 部署请参阅 **[GGUF 仓库](https://huggingface.co/GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking-GGUF)**。
---
## 模型概述
| 项目 | 说明 |
|---|---|
| **基座模型** | [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)1B 稠密 Llama 架构) |
| **后训练数据** | Fable 5 traces |
| **主要提升** | 相较基座Coding 与指令遵循能力更强 |
| **对话格式** | MiniCPM5 原生 Thinking 模板,支持可选的思维链推理块 |
| **上下文长度** | **128K**`max_position_embeddings = 131072` |
| **部署特点** | 单卡友好,适合边缘 / 本地场景 |
---
## 能力
- **Coding** — 代码生成、调试及软件工程类任务
- **Instruction Following** — 更稳定地遵循用户提示与结构化任务约束
- **Thinking 模式** — 通过 MiniCPM5 对话模板进行思维链推理
- **工具调用** — 继承 MiniCPM5 的 XML 工具调用格式
- **长上下文** — 最高 **128K tokens**`config.json` 中为 131,072
---
## 快速开始
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True,
torch_dtype=torch.bfloat16, device_map="auto",
)
messages = [{"role": "user", "content": "写一个 Python 函数,合并两个有序链表。"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
---
## 采样建议
生成参数继承自 **[MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)**
| 模式 | 参数 |
|---|---|
| **Think**(默认) | `temperature=0.9, top_p=0.95` |
| **No Think** | `temperature=0.7, top_p=0.95``enable_thinking=False` |
---
## 局限性
- **Thinking 输出** — 模型可能在最终回答前输出推理块;下游应用可在展示前将其剥离
- **1B 体量** — 面向轻量本地部署,非前沿规模通用推理模型
---
## 许可与致谢
- 许可证:**Apache-2.0**(继承自 MiniCPM5-1B
- 基座:[OpenBMB / MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)
- GGUF[llama.cpp](https://github.com/ggml-org/llama.cpp)

110
README.md Normal file
View File

@@ -0,0 +1,110 @@
---
library_name: transformers
license: apache-2.0
language:
- en
- zh
base_model: openbmb/MiniCPM5-1B
base_model_relation: finetune
pipeline_tag: text-generation
tags:
- minicpm
- minicpm5
- llama
- text-generation
- thinking
- fable5
- coding
- instruction-following
---
<p align="center">
<img src="assets/banner.png" alt="MiniCPM5-1B-Claude-Opus-Fable5-Thinking" width="100%"/>
</p>
# MiniCPM5-1B-Claude-Opus-Fable5-Thinking
GGUF quantizations for local deployment: **[MiniCPM5-1B-Claude-Opus-Fable5-Thinking-GGUF](https://huggingface.co/GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking-GGUF)**
[中文说明](./README-cn.md)
**MiniCPM5-1B-Claude-Opus-Fable5-Thinking** is a compact 1B **Thinking** language model built on [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B). It is further fine-tuned on **Fable 5** data to improve **coding** and **instruction-following** while keeping MiniCPM5's native Thinking chat template and tool-call format.
For llama.cpp / Ollama / LM Studio deployment, see the **[GGUF repository](https://huggingface.co/GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking-GGUF)**.
---
## Overview
| Item | Detail |
|---|---|
| **Base model** | [openbmb/MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B) (1B dense Llama architecture) |
| **Post-training** | Fable 5 traces |
| **Key gains** | Stronger coding and instruction following vs. the base checkpoint |
| **Chat format** | MiniCPM5 native Thinking template with optional chain-of-thought blocks |
| **Context length** | **128K** (`max_position_embeddings = 131072`) |
| **Deployment** | Single-GPU friendly; suitable for edge / local use |
---
## Capabilities
- **Coding** — code generation, debugging, and software-engineering-style tasks
- **Instruction following** — more reliable adherence to user prompts and structured constraints
- **Thinking mode** — chain-of-thought reasoning via the MiniCPM5 chat template
- **Tool calling** — inherits MiniCPM5's XML tool-call format
- **Long context** — up to **128K tokens** (131,072 tokens per `config.json`)
---
## Quick start
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "GnLOLot/MiniCPM5-1B-Claude-Opus-Fable5-Thinking"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [{"role": "user", "content": "Write a Python function to merge two sorted lists."}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```
---
## Sampling recommendations
Generation defaults are inherited from **[MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)**:
| Mode | Params |
|---|---|
| **Think** (default) | `temperature=0.9, top_p=0.95` |
| **No Think** | `temperature=0.7, top_p=0.95`, `enable_thinking=False` |
---
## Limitations
- **Thinking outputs** — the model may emit reasoning blocks before the final answer; downstream apps can strip them before display
- **1B scale** — optimized for lightweight local deployment, not frontier-scale general reasoning
---
## Provenance & licensing
Released under **Apache-2.0**, inherited from [MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B).
## Acknowledgements
- Base model: [OpenBMB / MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B)
- GGUF conversion: [llama.cpp](https://github.com/ggml-org/llama.cpp)

BIN
assets/banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

179
chat_template.jinja Normal file
View 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 %}

35
config.json Normal file
View File

@@ -0,0 +1,35 @@
{
"architectures": [
"LlamaForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": 0,
"dtype": "bfloat16",
"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_parameters": {
"rope_theta": 5000000,
"rope_type": "default"
},
"tie_word_embeddings": false,
"transformers_version": "5.6.0",
"use_cache": true,
"vocab_size": 130560
}

13
generation_config.json Normal file
View 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": "5.6.0"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:689e9f7eb54a22c91b02e57bb2af884693184db963845cffcae373df47f9b178
size 2161290944

653947
tokenizer.json Normal file

File diff suppressed because it is too large Load Diff

22
tokenizer_config.json Normal file
View File

@@ -0,0 +1,22 @@
{
"add_prefix_space": null,
"backend": "tokenizers",
"bos_token": "<s>",
"clean_up_tokenization_spaces": false,
"eos_token": "</s>",
"extra_special_tokens": [
"<|im_end|>"
],
"is_local": true,
"legacy": true,
"local_files_only": false,
"model_max_length": 1000000000000000019884624838656,
"pad_token": "</s>",
"padding_side": "left",
"sp_model_kwargs": {},
"spaces_between_special_tokens": false,
"split_special_tokens": false,
"tokenizer_class": "TokenizersBackend",
"unk_token": "<unk>",
"use_default_system_prompt": false
}