Instructions to use PP12546/MiniPolaris-3-Fish-Suiren with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PP12546/MiniPolaris-3-Fish-Suiren with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PP12546/MiniPolaris-3-Fish-Suiren") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("PP12546/MiniPolaris-3-Fish-Suiren") model = AutoModelForCausalLM.from_pretrained("PP12546/MiniPolaris-3-Fish-Suiren", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PP12546/MiniPolaris-3-Fish-Suiren with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PP12546/MiniPolaris-3-Fish-Suiren" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PP12546/MiniPolaris-3-Fish-Suiren", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PP12546/MiniPolaris-3-Fish-Suiren
- SGLang
How to use PP12546/MiniPolaris-3-Fish-Suiren 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 "PP12546/MiniPolaris-3-Fish-Suiren" \ --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": "PP12546/MiniPolaris-3-Fish-Suiren", "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 "PP12546/MiniPolaris-3-Fish-Suiren" \ --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": "PP12546/MiniPolaris-3-Fish-Suiren", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use PP12546/MiniPolaris-3-Fish-Suiren with Docker Model Runner:
docker model run hf.co/PP12546/MiniPolaris-3-Fish-Suiren
MiniMind-3-Fish-Suiren-220M
概述
本模型是基于 MiniMind-3(约 220M 参数)进行全参 SFT 微调后得到的专用 Agent 基座模型。训练目标是尝试 不通过RL 仅通过SFT时进行工具调用训练 赋予小模型在封闭工具集下的函数调用(Function Calling)能力与精确的路由逻辑。模型是通过 1000 条纯合成数据训练的。
模型权重采用 16-bit(Merged Model)格式发布,支持标准的 Transformers 加载。
核心能力
模型内置了针对以下三个工具的路由与参数生成能力:
- **
calculate_math**:处理数学表达式计算(如256 * 37或sqrt(144))。 - **
get_current_time**:查询指定时区(IANA 格式)的当前时间。 - **
search_web**:发起实时信息搜索。
支持的交互模式:
- 直接回答:面对闲聊或常识问题,模型直接输出文本,不触发工具调用。
- 单工具调用:识别意图,输出标准
<tool_call>格式并提取正确参数。 - 短思考(Short Thinking):约 20% 的训练样本包含调用前的单句思考(如“这个需要精确计算”),辅助模型在生成 JSON 前完成路由确认。
- 边界拒答:面对未提供定义的工具请求(如订机票),模型明确回复暂不支持,不产生虚构调用。
训练细节
- 基座模型:MiniMind-3 220M
- 训练框架:Unsloth (Full Fine-tuning)
- 上下文长度:1024 tokens
- 训练数据:约 1000 条 JSONL 格式的合成多轮对话数据,数据包含正负样本(直接回答、单工具调用、缺参澄清、越界拒答、错误恢复)。
- 超参数:
- Epochs:约 2 个(100 步)
- Batch Size:4(梯度累积步数:12)
- Learning Rate:2e-5(Cosine 调度,Warmup 8 步)
- 优化器:Paged AdamW 32-bit
- 掩码策略:仅对 Assistant 回复(包含
<tool_call>部分)计算 Loss
- 硬件环境:Intel Arc B580 (12GB)
- 收敛情况:训练 Loss 最终收敛于 1.62,评估 Loss 约为 1.66,曲线平滑未见过拟合。
数据格式
模型使用 OpenAI 风格的消息结构。系统提示词(System Prompt)中需包含工具定义,模型会以 JSON 格式输出工具调用指令。
快速上手
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "your_username/MiniMind-3-220M-ToolCall-SFT"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
tools = [{
"name": "calculate_math",
"description": "计算数学表达式",
"parameters": {
"type": "object",
"properties": {
"expression": {"type": "string", "description": "如 256*37"}
},
"required": ["expression"]
}
}]
messages = [
{"role": "system", "content": "", "tools": tools},
{"role": "user", "content": "帮我算一下 12345 乘以 6789 是多少?"}
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
outputs = model.generate(inputs, max_new_tokens=128, temperature=0.1)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
局限与风险
泛化边界:模型容量仅为 220M,在面临极度口语化、多重嵌套逻辑或隐喻式提问时,路由准确率会显著下降。
工具封闭性:模型未针对零样本(Zero-shot)新工具(如提示词中临时定义从未见过的工具)进行过泛化训练。更换工具集需重新准备数据微调。
语言能力受损:由于 SFT 阶段使用纯工具调用数据,模型原有的通用知识问答、长文本生成与文学创作能力可能出现一定程度的灾难性遗忘。
参数幻觉:在复杂参数提取时(如极长的数学表达式或罕见时区),可能生成不存在的 IANA 时区或语法错误的表达式。
引用与致谢
训练工具:Unsloth、Minimind 3
数据合成参考见用户名下的:[MiniPolaris-DSWebchat-Synthetic]
- Downloads last month
- 216