
如何创建用于微调的工具调用训练数据集
微调指南中最大的空白:没人讲如何实际构建数据集。以下是从模式文档到合成扩展到 JSONL 格式化的逐步过程——含 5 工具客服代理的真实示例。
每个微调工具调用模型的指南都假设你已经有了数据。"只需准备 JSONL 格式的训练数据集",然后直接跳到训练命令。
这跳过了最难的部分。构建高质量工具调用数据集是 80% 的工作。
目标:5 工具客服代理
lookup_order— 按订单 ID 或邮箱查找订单check_status— 获取订单当前状态initiate_refund— 启动退款流程update_address— 更改配送地址escalate_to_human— 转接人工
步骤 1:记录工具模式
每个工具需要精确的 JSON 模式。描述比名称更重要——模型从描述学习何时调用工具。
步骤 2:生成种子示例
每个工具手写 10-20 条用户消息。手写这些。 不要为种子示例使用 LLM。
步骤 3:合成扩展
使用前沿模型将种子集扩展到每工具 50-100+ 变体。
步骤 4:添加负面示例
大多数人跳过这一步——这是大多数微调工具调用模型过度触发的原因。目标 20% 数据集为负面示例。包含近似消息(接近某工具但不完全触发)。
步骤 5:格式化为 JSONL
每行一个 JSON 对象。参数是 JSON 字符串而非嵌套对象。系统消息在所有示例中相同。
训练前质量检查
- 模式合规性
- 参数验证
- 平衡检查(每工具约 100 示例 + 125 负面)
- 边缘案例覆盖
多轮序列
包含 20-30 个多轮对话序列——客户查找订单、检查状态、然后请求退款——全在一个对话中。
总时间:5 工具代理 4-8 小时。总示例:500-750。7B 模型 LoRA 训练时间:20-40 分钟。
数据集就是模型。构建好它。
Ship AI that runs on your users' devices.
Ertas early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.
延伸阅读
Ship AI that runs on your users' devices.
Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.
Keep reading

Replacing OpenAI in OpenAI Agents SDK With Your Fine-Tuned Local Model
The OpenAI Agents SDK is intentionally model-agnostic. Swap the OpenAI client for an Ertas-trained model running on Ollama and you keep the developer experience while killing per-token costs. A drop-in tutorial.

Pydantic AI On-Device: Fine-Tune Qwen3-4B for Type-Safe Mobile Agents
Pydantic AI brings type safety and FastAPI ergonomics to LLM agents. Combine it with a fine-tuned 4B model running on-device via llama.cpp and you get production-grade agents in mobile apps with zero API costs and validated outputs by construction.

Pydantic AI vs LangGraph: Which Agent Framework for Fine-Tuned Models
Pydantic AI and LangGraph are the two production agent frameworks of 2026. Choose between them on type safety vs graph orchestration, then layer fine-tuning on top. Here's how to decide.