mcpField
T
tinker-training-cost

tinker-training-cost

github.com/sundial-org数据与数据库15361 次安装15 周前更新
代码仓库

关于 tinker-training-cost

tinker-training-cost 是用于估算 Tinker 微调费用的命令行计算器。它使用所选模型的分词器处理 JSONL 中的聊天、文本或指令数据,再按训练价格和轮数计算费用。

主要功能

  1. 01对 JSONL 数据集分词
  2. 02支持聊天、文本和指令格式
  3. 03使用模型专属分词器
  4. 04按轮数和训练价格估算费用
  5. 05列出可用模型及价格

适用场景

  1. 01在 Tinker 微调前估算费用
  2. 02比较不同支持模型的数据集成本
  3. 03统计训练数据的令牌数

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/sundial-org/skills --skill tinker-training-cost

安装后在 Claude Code 中输入/tinker-training-cost确认已加载。

附带文件scripts/calculate_cost.py

详细介绍

Tinker 训练成本计算器

通过使用正确的模型分词器对数据集进行分词,并应用当前定价,计算 Tinker 微调任务的训练成本。

快速开始

使用附带的脚本计算训练成本:

# List available models and pricing
python scripts/calculate_cost.py --list-models

# Calculate cost for a JSONL dataset (model matches on unambiguous fragment)
python scripts/calculate_cost.py training_data.jsonl --model Qwen3-8B --epochs 3

# Output as JSON
python scripts/calculate_cost.py training_data.jsonl --model Inkling --json

该脚本:

  1. 为所选模型加载正确的分词器(如果已安装 tinker-cookbook,则通过它加载;否则使用 transformers)
  2. 统计 JSONL 文件中的 token 数量(支持聊天、文本和指令格式)
  3. 计算预估训练成本

成本公式

Training Cost = (total_tokens × epochs × train_price_per_million) / 1_000_000

Tinker 定价

价格自 2026 年 7 月 17 日起生效(当天预填充/采样价格上涨约 50%,训练价格上涨约 10%) 来源:https://tinker-docs.thinkingmachines.ai/tinker/models/

所有价格均以 每百万 token 的美元金额计。预填充 = 输入上下文(推理),采样 = 输出 token(推理),训练 = 训练 token。缓存的预填充 token 可享受 八折优惠。:peft:<context> = 扩展上下文版本。

模型预填充采样训练
thinkingmachines/Inkling*$1.87$4.68$5.61
thinkingmachines/Inkling:peft:262144*$3.74$9.36$11.23
nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16*$2.49$6.225$5.478
nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-BF16:peft:262144*$3.32$8.30$9.96
nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16*$0.57$1.44$1.276
nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16:peft:262144*$0.76$1.92$2.32
nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16*$0.195$0.495$0.44
moonshotai/Kimi-K2.6$2.205$5.49$4.84
moonshotai/Kimi-K2.6:peft:131072$5.15$12.81$15.40
Qwen/Qwen3.6-35B-A3B$0.54$1.335$1.177
Qwen/Qwen3.6-27B$1.86$5.595$4.103
Qwen/Qwen3.5-397B-A17B$3.00$7.50$6.60
Qwen/Qwen3.5-397B-A17B:peft:262144$4.00$10.00$12.00
Qwen/Qwen3.5-35B-A3B-Base$0.54$1.335$1.177
Qwen/Qwen3.5-9B (+ -Base)$0.66$1.995$1.463
Qwen/Qwen3.5-4B$0.33$1.005$0.737
Qwen/Qwen3-8B$0.195$0.60$0.44
openai/gpt-oss-120b$0.33$0.84$0.737
openai/gpt-oss-120b:peft:131072$0.78$1.94$2.33
openai/gpt-oss-20b$0.18$0.45$0.396
deepseek-ai/DeepSeek-V3.1$1.695$4.215$3.718
  • Inkling 和 Nemotron 的价格反映限时五折优惠。

检查点存储:每 GB 每月 $0.10。


分词

每个模型的分词器都可通过其 Tinker 模型 ID 解析(已验证上方列出的所有模型):

from tinker_cookbook.tokenizer_utils import get_tokenizer  # preferred
tokenizer = get_tokenizer("Qwen/Qwen3-8B")

# Or with plain transformers (same IDs, minus any :peft: suffix)
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B", trust_remote_code=True)

token_count = len(tokenizer.encode("Your training text here"))
支持的 JSONL 格式

聊天格式(推荐):

{"messages": [{"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}

文本格式:

{"text": "Your training text here"}

指令格式(Alpaca 风格):

{"instruction": "...", "input": "...", "output": "..."}

快速成本示例

示例 1:Qwen3-8B,1M token,3 个训练轮次
Training tokens: 1,000,000 × 3 = 3,000,000
Cost: 3.0M × $0.44/M = $1.32
示例 2:Qwen3.6-35B-A3B,5M token,2 个训练轮次
Training tokens: 5,000,000 × 2 = 10,000,000
Cost: 10.0M × $1.177/M = $11.77
示例 3:Inkling,2M token,4 个训练轮次
Training tokens: 2,000,000 × 4 = 8,000,000
Cost: 8.0M × $5.61/M = $44.88

重要说明

  1. LoRA 微调:Tinker 使用低秩适配(LoRA),而非全量微调
  2. Token 计数:始终使用模型的原生分词器——不同的分词器对同一文本会产生不同的计数
  3. RL 的成本高于单独的训练费率:除了训练 token 费用外,rollout 还按采样/预填充费率计费
  4. 多模态输入(Inkling 图像/音频)会在文本分词之外增加 token

评论

支持 Markdown