[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6XFNFN2546XP43M65QD1M5F":3,"skill-same:01M6XFNFN2546XP43M65QD1M5F":128},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":66,"commitSha":67,"skillDirectory":68,"forksCount":14,"repositoryHtmlUrl":69,"repositoryHomepageUrl":6,"ownerHtmlUrl":70,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":71,"install":72,"resources":85},"01M6XFNFN2546XP43M65QD1M5F","tinker-fine-tuning",null,"Provides guidance for fine-tuning LLMs using the Tinker cloud training API from Thinking Machines Lab. Use when running supervised fine-tuning, reinforcement learning (GRPO\u002FPPO), or LoRA training on cloud GPUs via Tinker's managed infrastructure instead of local compute.","fadrienne\u002FMyGitHub","fadrienne","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F197874571?v=4","01M6X64V8VWCRSMFZ4EPS2BWXG","Francesca Adrienne","01M6X64VD5MW4F9PHDWQKS7ZAF",0,"MIT","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"tinker fine tuning","tuning","fine tuning","synthetic","Cloud Training","Supervised Learning","Tinker","running","when","supervised","managed","cookbook","llms","local","thinking","vision","api","Transformers","training","infrastructure","2026-11-10 10:12:30",false,"---\nname: tinker-fine-tuning\ndescription: Provides guidance for fine-tuning LLMs using the Tinker cloud training API from Thinking Machines Lab. Use when running supervised fine-tuning, reinforcement learning (GRPO\u002FPPO), or LoRA training on cloud GPUs via Tinker's managed infrastructure instead of local compute.\ncategory: cloud-compute\nversion: 1.0.0\nauthor: Synthetic Sciences\nlicense: MIT\ntags: [Fine-Tuning, Tinker, LoRA, Reinforcement Learning, Supervised Learning, DPO, RLHF, Cloud Training, Vision-Language Models]\ndependencies: [tinker, tinker-cookbook, chz, transformers>=4.40.0, datasets, numpy]\n---\n\n# Tinker API - Cloud LLM Fine-Tuning\n\nExpert guidance for fine-tuning large language models using Tinker's managed cloud training API. Tinker handles GPU allocation, model hosting, and distributed training — you write the training logic, Tinker runs it on cloud infrastructure.\n\n## When to Use This Skill\n\n**Use Tinker when you need to:**\n- Fine-tune models up to 235B parameters without managing GPU infrastructure\n- Run LoRA training on Qwen, Llama, DeepSeek, or GPT-OSS models\n- Train vision-language models (Qwen3-VL)\n- Implement custom RL loops (GRPO, PPO, importance sampling) on cloud GPUs\n- Iterate quickly with a training API that handles hardware provisioning\n\n**Do NOT use Tinker when:**\n- You need full fine-tuning (not LoRA) — Tinker only supports LoRA\n- You need to train custom architectures — Tinker supports specific model families\n- You want to use your own GPUs — use Axolotl, Unsloth, or LLaMA-Factory instead\n- You need offline\u002Fair-gapped training\n\n**Tinker vs Alternatives:**\n\n| Need | Use |\n|------|-----|\n| Managed cloud LoRA training | **Tinker** |\n| Local GPU fine-tuning | Axolotl, Unsloth, LLaMA-Factory |\n| Full parameter fine-tuning | DeepSpeed + Transformers |\n| RLHF with TRL locally | TRL + GRPO skill |\n| Quantized training | Unsloth, bitsandbytes |\n\n## Quick Reference\n\n| Topic | Reference |\n|-------|-----------|\n| Setup & Core Concepts | [Getting Started](references\u002Fgetting-started.md) |\n| API Classes & Types | [API Reference](references\u002Fapi-reference.md) |\n| Supervised Learning | [Supervised Learning](references\u002Fsupervised-learning.md) |\n| RL Training & Environments | [Reinforcement Learning](references\u002Freinforcement-learning.md) |\n| DPO, RLHF & Distillation | [DPO & Preference Learning](references\u002Fdpo-and-preference.md) |\n| Loss Functions | [Loss Functions](references\u002Floss-functions.md) |\n| Chat Templates | [Rendering](references\u002Frendering.md) |\n| Models & LoRA | [Models & LoRA](references\u002Fmodels-and-lora.md) |\n| Evaluations | [Evaluations](references\u002Fevaluations.md) |\n| Example Scripts | [Recipes](references\u002Frecipes.md) |\n\n## Installation\n\n```bash\npip install tinker tinker-cookbook\n# TINKER_API_KEY must be set — connect Tinker in the OpenScience dashboard to sync your API key.\n# Verify: [ -n \"$TINKER_API_KEY\" ] && echo \"set\" || echo \"not set\"\n```\n\n---\n\n## Workflow 1: Supervised Fine-Tuning (Cookbook)\n\nUse this for standard SFT with JSONL or HuggingFace datasets.\n\n### Checklist\n- [ ] Prepare data in JSONL chat format (`{\"messages\": [...]}`)\n- [ ] Choose base model (see model table below)\n- [ ] Set hyperparameters (LR, batch size, epochs)\n- [ ] Run training via Cookbook\n- [ ] Monitor metrics (`train_mean_nll`, `test\u002Fnll`)\n- [ ] Save and deploy weights\n\n### Implementation\n\n```python\nimport json\nimport chz\nimport asyncio\nfrom tinker_cookbook.supervised import train\nfrom tinker_cookbook.supervised.types import ChatDatasetBuilderCommonConfig\nfrom tinker_cookbook.supervised.data import FromConversationFileBuilder\nfrom tinker_cookbook.renderers import TrainOnWhat\nfrom tinker_cookbook.model_info import get_recommended_renderer_name\nfrom tinker_cookbook.hyperparam_utils import get_lr\nfrom tinker_cookbook.tokenizer_utils import get_tokenizer\n\nmodel_name = \"Qwen\u002FQwen3-30B-A3B\"\nrenderer_name = get_recommended_renderer_name(model_name)\nnum_epochs = 3\ndata_file = \"training_data.jsonl\"\n\ncommon_config = ChatDatasetBuilderCommonConfig(\n    model_name_for_tokenizer=model_name,\n    renderer_name=renderer_name,\n    max_length=2048,\n    batch_size=128,\n    train_on_what=TrainOnWhat.ALL_ASSISTANT_MESSAGES,\n)\n\ndataset_builder = FromConversationFileBuilder(\n    common_config=common_config,\n    file_path=data_file,\n)\n\nblueprint = chz.Blueprint(train.Config).apply({\n    \"log_path\": \"\u002Ftmp\u002Fsft-run\",\n    \"model_name\": model_name,\n    \"dataset_builder\": dataset_builder,\n    \"learning_rate\": get_lr(model_name),\n    \"lr_schedule\": \"linear\",\n    \"num_epochs\": num_epochs,\n    \"lora_rank\": 32,\n})\n\nconfig = blueprint.make()\nasyncio.run(train.main(config))\n\n# --- Exact usage reporting (auto-captured by CLI) ---\ntokenizer = get_tokenizer(model_name)\ntotal_tokens = 0\nwith open(data_file) as f:\n    for line in f:\n        row = json.loads(line)\n        text = \" \".join(m.get(\"content\", \"\") for m in row.get(\"messages\", []))\n        total_tokens += len(tokenizer.encode(text))\ntotal_tokens *= num_epochs\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\n### Data Format\n\nJSONL with chat messages (one per line):\n```json\n{\"messages\": [{\"role\": \"user\", \"content\": \"Translate to French: hello\"}, {\"role\": \"assistant\", \"content\": \"bonjour\"}]}\n```\n\n### TrainOnWhat Options\n\n| Option | When to Use |\n|--------|-------------|\n| `ALL_ASSISTANT_MESSAGES` | Standard SFT, multi-turn conversations |\n| `LAST_ASSISTANT_MESSAGE` | Classification, chain-of-thought where only final answer matters |\n\n---\n\n## Workflow 2: Reinforcement Learning (GRPO-style)\n\nUse this for training with reward functions — math reasoning, format compliance, verifiable tasks.\n\n### Checklist\n- [ ] Define reward function(s) that return float scores\n- [ ] Choose group size (16 recommended)\n- [ ] Set up sampling → reward → training loop\n- [ ] Monitor `correct`, `format`, `reward\u002Ftotal`, KL divergence\n- [ ] Keep KL below 0.01 for stable training\n\n### Implementation (Cookbook)\n\n```python\nimport json\nimport asyncio\nimport chz\nfrom tinker_cookbook.rl import train\nfrom tinker_cookbook.recipes.math_rl.math_env import Gsm8kDatasetBuilder\nfrom tinker_cookbook import model_info\n\nmodel_name = \"meta-llama\u002FLlama-3.1-8B\"\nrenderer_name = model_info.get_recommended_renderer_name(model_name)\nbatch_size = 128\ngroup_size = 16\nmax_tokens = 256\n\nbuilder = Gsm8kDatasetBuilder(\n    batch_size=batch_size,\n    group_size=group_size,\n    renderer_name=renderer_name,\n    model_name_for_tokenizer=model_name,\n)\n\nblueprint = chz.Blueprint(train.Config).apply({\n    \"model_name\": model_name,\n    \"log_path\": \"\u002Ftmp\u002Frl-run\",\n    \"dataset_builder\": builder,\n    \"learning_rate\": 4e-5,\n    \"max_tokens\": max_tokens,\n})\n\nconfig = blueprint.make()\nasyncio.run(train.main(config))\n\n# --- Exact usage reporting (auto-captured by CLI) ---\n# For RL: estimate from batch_size × group_size × max_tokens × num_batches\n# The exact count comes from the training loop — check \u002Ftmp\u002Frl-run for logs\nimport glob, os\nlog_files = sorted(glob.glob(\"\u002Ftmp\u002Frl-run\u002Fmetrics*.json\"))\ntotal_tokens = 0\nfor lf in log_files:\n    with open(lf) as f:\n        for line in f:\n            m = json.loads(line)\n            total_tokens += m.get(\"num_tokens\", 0)\nif total_tokens == 0:\n    # Fallback estimate: batch_size × group_size × max_tokens × num_batches\n    total_tokens = batch_size * group_size * max_tokens * 100\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\n### Custom RL with Low-Level API\n\nFor full control over sampling, reward computation, and advantage centering:\n\n```python\nimport json\nimport tinker\nfrom tinker import types\nfrom tinker.types.tensor_data import TensorData\nimport torch\n\nmodel_name = \"meta-llama\u002FLlama-3.1-8B\"\nservice_client = tinker.ServiceClient()\ntraining_client = service_client.create_lora_training_client(\n    base_model=model_name, rank=32\n)\n\ntotal_tokens = 0  # Track exact tokens for billing\n\nfor batch_idx, batch_rows in enumerate(dataset):\n    path = training_client.save_weights_for_sampler(name=f\"{batch_idx:06d}\").result().path\n    sampling_client = service_client.create_sampling_client(model_path=path)\n\n    datums = []\n    for question, answer in batch_rows:\n        prompt = renderer.build_generation_prompt([{\"role\": \"user\", \"content\": question}])\n        prompt_tokens = prompt.to_ints()\n        result = sampling_client.sample(\n            prompt=prompt, num_samples=16,\n            sampling_params=types.SamplingParams(max_tokens=256, stop=renderer.get_stop_sequences()),\n        ).result()\n\n        rewards = [compute_reward(seq, answer) for seq in result.sequences]\n        mean_reward = sum(rewards) \u002F len(rewards)\n        advantages = [r - mean_reward for r in rewards]\n        if all(a == 0 for a in advantages):\n            continue\n\n        for seq, advantage in zip(result.sequences, advantages):\n            tokens = prompt_tokens + seq.tokens\n            ob_len = len(prompt_tokens) - 1\n            datum = types.Datum(\n                model_input=types.ModelInput.from_ints(tokens=tokens[:-1]),\n                loss_fn_inputs={\n                    \"target_tokens\": TensorData.from_torch(torch.tensor(tokens[1:])),\n                    \"logprobs\": TensorData.from_torch(torch.tensor([0.0]*ob_len + list(seq.logprobs))),\n                    \"advantages\": TensorData.from_torch(torch.tensor([0.0]*ob_len + [advantage]*(len(tokens)-1-ob_len))),\n                },\n            )\n            datums.append(datum)\n\n    # Track exact token count from datums\n    total_tokens += sum(d.model_input.length() for d in datums)\n\n    fwd_bwd = training_client.forward_backward(datums, loss_fn=\"importance_sampling\")\n    optim = training_client.optim_step(types.AdamParams(learning_rate=4e-5))\n    fwd_bwd.result(); optim.result()\n\n# --- Exact usage reporting (auto-captured by CLI) ---\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\n### Available RL Loss Functions\n\n| Loss | Use Case |\n|------|----------|\n| `importance_sampling` | Standard policy gradient with off-policy correction |\n| `ppo` | Clipped surrogate objective (PPO) |\n| `cispo` | Clipped importance sampling PO |\n| `dro` | Direct reward optimization with quadratic penalty |\n\n---\n\n## Available Models\n\n| Model | Type | Architecture | Train $\u002FM tokens |\n|-------|------|-------------|------------------|\n| Qwen3-4B-Instruct-2507 | Instruction | Dense Compact | $0.22 |\n| Qwen3-8B | Hybrid | Dense Small | $0.40 |\n| Qwen3-30B-A3B | Hybrid | MoE Medium | $0.36 |\n| Qwen3-32B | Hybrid | Dense Medium | $1.47 |\n| Qwen3-VL-30B-A3B-Instruct | Vision | MoE Medium | $0.53 |\n| Llama-3.2-1B | Base | Dense Compact | $0.09 |\n| Llama-3.1-8B | Base | Dense Small | $0.40 |\n| Llama-3.1-70B | Base | Dense Large | $3.16 |\n| DeepSeek-V3.1 | Hybrid | MoE Large | $3.38 |\n| GPT-OSS-120B | Reasoning | MoE Medium | $0.52 |\n\n**Model Selection Tips:**\n- **Cost efficiency**: MoE models (Qwen3-30B-A3B at $0.36\u002FM)\n- **Experimentation**: Start with 8B models\n- **Vision tasks**: Qwen3-VL-30B-A3B-Instruct\n- **Reasoning**: Hybrid or Reasoning models with chain-of-thought\n\n## LoRA Configuration\n\nTinker exclusively uses LoRA. Default rank: 32.\n\n```python\ntraining_client = service_client.create_lora_training_client(\n    base_model=\"Qwen\u002FQwen3-30B-A3B\",\n    rank=32,\n    train_attn=True,\n    train_mlp=True,\n    seed=42,\n)\n```\n\n**Critical**: LoRA needs 20-100x higher LR than full fine-tuning. Use `tinker_cookbook.hyperparam_utils.get_lr()` for recommended values.\n\n## Hyperparameter Guide\n\n| Parameter | SFT Default | RL Default | Notes |\n|-----------|-------------|------------|-------|\n| `learning_rate` | `get_lr(model)` | 4e-5 | Model-dependent; ~5e-4 for Qwen3-30B, ~2.8e-4 for Llama-8B |\n| `batch_size` | 128 | 128 | Smaller generally better for fine-tuning |\n| `lora_rank` | 32 | 32 | Higher rank = more capacity |\n| `group_size` | N\u002FA | 16 | Rollouts per problem for RL |\n| `max_length` | 2048-32768 | N\u002FA | Sequence length for SFT |\n| `max_tokens` | N\u002FA | 256 | Max generation length for RL |\n| `num_epochs` | 1-3 | N\u002FA | Training passes |\n| `lr_schedule` | linear | N\u002FA | Only `linear` and `constant` supported |\n\n## Workflow 3: DPO (Preference Learning)\n\nUse this for aligning models with human preferences without a separate reward model.\n\n### Quick Start\n\n```bash\npython -m tinker_cookbook.recipes.preference.train \\\n    log_path=\u002Ftmp\u002Fdpo-experiment \\\n    model_name=meta-llama\u002FLlama-3.2-1B \\\n    dataset=hhh \\\n    renderer_name=role_colon \\\n    learning_rate=1e-5 \\\n    dpo_beta=0.1\n```\n\n**Key differences from SFT**: Use lower LR (1e-5 to 1e-6), base model should be in-distribution with preference data.\n\n**Available datasets**: `hhh` (Anthropic), `helpsteer3` (NVIDIA), `ultrafeedback`\n\n**Full RLHF pipeline**: See [DPO & Preference Learning](references\u002Fdpo-and-preference.md) for the three-step SL → preference model → RL pipeline.\n\n---\n\n## Evaluations\n\n### Inline (During Training)\n\nAdd `evaluator_builders` to config for periodic evaluation:\n\n```python\nblueprint = chz.Blueprint(train.Config).apply({\n    ...\n    \"evaluator_builders\": [my_evaluator],\n    \"eval_every\": 8,\n})\n```\n\n### Offline (After Training)\n\n```bash\nMODEL_PATH=tinker:\u002F\u002FYOUR_MODEL_PATH_HERE\npython -m tinker_cookbook.eval.run_inspect_evals \\\n    model_path=$MODEL_PATH \\\n    model_name=MODEL_NAME \\\n    tasks=inspect_evals\u002Fifeval,inspect_evals\u002Fmmlu_0_shot\n```\n\nSee [Evaluations](references\u002Fevaluations.md) for custom evaluators and LLM-as-judge.\n\n---\n\n## Cost Estimation & Usage Tracking\n\n### Pre-Training Cost Estimation\n\n**ALWAYS estimate cost before starting Tinker training.** Load the `tinker-training-cost` skill and use its pricing tables or calculate manually:\n\n```\nTraining Cost = (total_tokens × epochs × train_price_per_million) \u002F 1,000,000\n```\n\nPresent the cost estimate to the user for approval before starting training.\n\n### Automatic Usage Reporting (Ground Truth)\n\n**CRITICAL**: All training scripts MUST print a `[OPENSCIENCE_USAGE]` line at the end. The CLI automatically captures this and reports exact billing to the dashboard.\n\n```python\n# Add this at the END of every training script:\nimport json\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\nHow token counting works per workflow:\n- **Cookbook SFT**: Tokenize dataset with `get_tokenizer(model_name)`, multiply by `num_epochs`\n- **Cookbook RL**: Parse training logs for `num_tokens`, or estimate from `batch_size × group_size × max_tokens × batches`\n- **Low-level API**: Sum `datum.model_input.length()` across all `forward_backward()` calls\n\nThe CLI bash tool scans output for `[OPENSCIENCE_USAGE]` markers and auto-reports to the dashboard — no manual reporting needed.\n\n## Common Issues\n\n| Problem | Solution |\n|---------|----------|\n| `TINKER_API_KEY` not set | `export TINKER_API_KEY=your_key` or check OpenScience credential sync |\n| KL divergence > 0.01 | Reduce learning rate, check group size |\n| OOM on dataset loading | Use `StreamingSupervisedDatasetFromHFDataset` for large datasets |\n| Reward stuck at 0 | Debug reward function independently, check answer extraction |\n| All advantages = 0 | Increase group size, ensure reward variance across completions |\n| Wrong tokenizer | Use model-specific tokenizer (see Models & LoRA reference) |\n| `Unknown learning rate schedule` | Only `\"linear\"` and `\"constant\"` are supported; `\"cosine\"` does NOT work |\n| Python 3.14 pydantic errors | Tinker requires Python 3.10-3.13; pydantic v1 is incompatible with 3.14+ |\n| Only 1 step per epoch | `batch_size` too large for dataset size; aim for 100+ steps per epoch |\n\n## Saving and Resuming\n\n```python\nsampling_path = training_client.save_weights_for_sampler(name=\"final\").result().path\nsampling_client = service_client.create_sampling_client(model_path=sampling_path)\n\nresume_path = training_client.save_state(name=\"checkpoint\").result().path\ntraining_client.load_state(resume_path)\n```\n\n## Common Imports\n\n```python\nimport tinker\nfrom tinker import types\nfrom tinker.types import Datum, ModelInput, TensorData, AdamParams, SamplingParams\n\nimport chz\nimport asyncio\nfrom tinker_cookbook.supervised import train\nfrom tinker_cookbook.supervised.types import ChatDatasetBuilder, ChatDatasetBuilderCommonConfig\nfrom tinker_cookbook.supervised.data import (\n    SupervisedDatasetFromHFDataset,\n    StreamingSupervisedDatasetFromHFDataset,\n    FromConversationFileBuilder,\n    conversation_to_datum,\n)\nfrom tinker_cookbook.renderers import get_renderer, TrainOnWhat\nfrom tinker_cookbook.model_info import get_recommended_renderer_name\nfrom tinker_cookbook.tokenizer_utils import get_tokenizer\n```\n\n## External Resources\n\n- Documentation: https:\u002F\u002Ftinker-docs.thinkingmachines.ai\u002F\n- Cookbook Repo: https:\u002F\u002Fgithub.com\u002Fthinking-machines-lab\u002Ftinker-cookbook\n- Console: https:\u002F\u002Ftinker-console.thinkingmachines.ai\n","# Tinker API - Cloud LLM Fine-Tuning\n\nExpert guidance for fine-tuning large language models using Tinker's managed cloud training API. Tinker handles GPU allocation, model hosting, and distributed training — you write the training logic, Tinker runs it on cloud infrastructure.\n\n## When to Use This Skill\n\n**Use Tinker when you need to:**\n- Fine-tune models up to 235B parameters without managing GPU infrastructure\n- Run LoRA training on Qwen, Llama, DeepSeek, or GPT-OSS models\n- Train vision-language models (Qwen3-VL)\n- Implement custom RL loops (GRPO, PPO, importance sampling) on cloud GPUs\n- Iterate quickly with a training API that handles hardware provisioning\n\n**Do NOT use Tinker when:**\n- You need full fine-tuning (not LoRA) — Tinker only supports LoRA\n- You need to train custom architectures — Tinker supports specific model families\n- You want to use your own GPUs — use Axolotl, Unsloth, or LLaMA-Factory instead\n- You need offline\u002Fair-gapped training\n\n**Tinker vs Alternatives:**\n\n| Need | Use |\n|------|-----|\n| Managed cloud LoRA training | **Tinker** |\n| Local GPU fine-tuning | Axolotl, Unsloth, LLaMA-Factory |\n| Full parameter fine-tuning | DeepSpeed + Transformers |\n| RLHF with TRL locally | TRL + GRPO skill |\n| Quantized training | Unsloth, bitsandbytes |\n\n## Quick Reference\n\n| Topic | Reference |\n|-------|-----------|\n| Setup & Core Concepts | [Getting Started](references\u002Fgetting-started.md) |\n| API Classes & Types | [API Reference](references\u002Fapi-reference.md) |\n| Supervised Learning | [Supervised Learning](references\u002Fsupervised-learning.md) |\n| RL Training & Environments | [Reinforcement Learning](references\u002Freinforcement-learning.md) |\n| DPO, RLHF & Distillation | [DPO & Preference Learning](references\u002Fdpo-and-preference.md) |\n| Loss Functions | [Loss Functions](references\u002Floss-functions.md) |\n| Chat Templates | [Rendering](references\u002Frendering.md) |\n| Models & LoRA | [Models & LoRA](references\u002Fmodels-and-lora.md) |\n| Evaluations | [Evaluations](references\u002Fevaluations.md) |\n| Example Scripts | [Recipes](references\u002Frecipes.md) |\n\n## Installation\n\n```bash\npip install tinker tinker-cookbook\n# TINKER_API_KEY must be set — connect Tinker in the OpenScience dashboard to sync your API key.\n# Verify: [ -n \"$TINKER_API_KEY\" ] && echo \"set\" || echo \"not set\"\n```\n\n---\n\n## Workflow 1: Supervised Fine-Tuning (Cookbook)\n\nUse this for standard SFT with JSONL or HuggingFace datasets.\n\n### Checklist\n- [ ] Prepare data in JSONL chat format (`{\"messages\": [...]}`)\n- [ ] Choose base model (see model table below)\n- [ ] Set hyperparameters (LR, batch size, epochs)\n- [ ] Run training via Cookbook\n- [ ] Monitor metrics (`train_mean_nll`, `test\u002Fnll`)\n- [ ] Save and deploy weights\n\n### Implementation\n\n```python\nimport json\nimport chz\nimport asyncio\nfrom tinker_cookbook.supervised import train\nfrom tinker_cookbook.supervised.types import ChatDatasetBuilderCommonConfig\nfrom tinker_cookbook.supervised.data import FromConversationFileBuilder\nfrom tinker_cookbook.renderers import TrainOnWhat\nfrom tinker_cookbook.model_info import get_recommended_renderer_name\nfrom tinker_cookbook.hyperparam_utils import get_lr\nfrom tinker_cookbook.tokenizer_utils import get_tokenizer\n\nmodel_name = \"Qwen\u002FQwen3-30B-A3B\"\nrenderer_name = get_recommended_renderer_name(model_name)\nnum_epochs = 3\ndata_file = \"training_data.jsonl\"\n\ncommon_config = ChatDatasetBuilderCommonConfig(\n    model_name_for_tokenizer=model_name,\n    renderer_name=renderer_name,\n    max_length=2048,\n    batch_size=128,\n    train_on_what=TrainOnWhat.ALL_ASSISTANT_MESSAGES,\n)\n\ndataset_builder = FromConversationFileBuilder(\n    common_config=common_config,\n    file_path=data_file,\n)\n\nblueprint = chz.Blueprint(train.Config).apply({\n    \"log_path\": \"\u002Ftmp\u002Fsft-run\",\n    \"model_name\": model_name,\n    \"dataset_builder\": dataset_builder,\n    \"learning_rate\": get_lr(model_name),\n    \"lr_schedule\": \"linear\",\n    \"num_epochs\": num_epochs,\n    \"lora_rank\": 32,\n})\n\nconfig = blueprint.make()\nasyncio.run(train.main(config))\n\n# --- Exact usage reporting (auto-captured by CLI) ---\ntokenizer = get_tokenizer(model_name)\ntotal_tokens = 0\nwith open(data_file) as f:\n    for line in f:\n        row = json.loads(line)\n        text = \" \".join(m.get(\"content\", \"\") for m in row.get(\"messages\", []))\n        total_tokens += len(tokenizer.encode(text))\ntotal_tokens *= num_epochs\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\n### Data Format\n\nJSONL with chat messages (one per line):\n```json\n{\"messages\": [{\"role\": \"user\", \"content\": \"Translate to French: hello\"}, {\"role\": \"assistant\", \"content\": \"bonjour\"}]}\n```\n\n### TrainOnWhat Options\n\n| Option | When to Use |\n|--------|-------------|\n| `ALL_ASSISTANT_MESSAGES` | Standard SFT, multi-turn conversations |\n| `LAST_ASSISTANT_MESSAGE` | Classification, chain-of-thought where only final answer matters |\n\n---\n\n## Workflow 2: Reinforcement Learning (GRPO-style)\n\nUse this for training with reward functions — math reasoning, format compliance, verifiable tasks.\n\n### Checklist\n- [ ] Define reward function(s) that return float scores\n- [ ] Choose group size (16 recommended)\n- [ ] Set up sampling → reward → training loop\n- [ ] Monitor `correct`, `format`, `reward\u002Ftotal`, KL divergence\n- [ ] Keep KL below 0.01 for stable training\n\n### Implementation (Cookbook)\n\n```python\nimport json\nimport asyncio\nimport chz\nfrom tinker_cookbook.rl import train\nfrom tinker_cookbook.recipes.math_rl.math_env import Gsm8kDatasetBuilder\nfrom tinker_cookbook import model_info\n\nmodel_name = \"meta-llama\u002FLlama-3.1-8B\"\nrenderer_name = model_info.get_recommended_renderer_name(model_name)\nbatch_size = 128\ngroup_size = 16\nmax_tokens = 256\n\nbuilder = Gsm8kDatasetBuilder(\n    batch_size=batch_size,\n    group_size=group_size,\n    renderer_name=renderer_name,\n    model_name_for_tokenizer=model_name,\n)\n\nblueprint = chz.Blueprint(train.Config).apply({\n    \"model_name\": model_name,\n    \"log_path\": \"\u002Ftmp\u002Frl-run\",\n    \"dataset_builder\": builder,\n    \"learning_rate\": 4e-5,\n    \"max_tokens\": max_tokens,\n})\n\nconfig = blueprint.make()\nasyncio.run(train.main(config))\n\n# --- Exact usage reporting (auto-captured by CLI) ---\n# For RL: estimate from batch_size × group_size × max_tokens × num_batches\n# The exact count comes from the training loop — check \u002Ftmp\u002Frl-run for logs\nimport glob, os\nlog_files = sorted(glob.glob(\"\u002Ftmp\u002Frl-run\u002Fmetrics*.json\"))\ntotal_tokens = 0\nfor lf in log_files:\n    with open(lf) as f:\n        for line in f:\n            m = json.loads(line)\n            total_tokens += m.get(\"num_tokens\", 0)\nif total_tokens == 0:\n    # Fallback estimate: batch_size × group_size × max_tokens × num_batches\n    total_tokens = batch_size * group_size * max_tokens * 100\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\n### Custom RL with Low-Level API\n\nFor full control over sampling, reward computation, and advantage centering:\n\n```python\nimport json\nimport tinker\nfrom tinker import types\nfrom tinker.types.tensor_data import TensorData\nimport torch\n\nmodel_name = \"meta-llama\u002FLlama-3.1-8B\"\nservice_client = tinker.ServiceClient()\ntraining_client = service_client.create_lora_training_client(\n    base_model=model_name, rank=32\n)\n\ntotal_tokens = 0  # Track exact tokens for billing\n\nfor batch_idx, batch_rows in enumerate(dataset):\n    path = training_client.save_weights_for_sampler(name=f\"{batch_idx:06d}\").result().path\n    sampling_client = service_client.create_sampling_client(model_path=path)\n\n    datums = []\n    for question, answer in batch_rows:\n        prompt = renderer.build_generation_prompt([{\"role\": \"user\", \"content\": question}])\n        prompt_tokens = prompt.to_ints()\n        result = sampling_client.sample(\n            prompt=prompt, num_samples=16,\n            sampling_params=types.SamplingParams(max_tokens=256, stop=renderer.get_stop_sequences()),\n        ).result()\n\n        rewards = [compute_reward(seq, answer) for seq in result.sequences]\n        mean_reward = sum(rewards) \u002F len(rewards)\n        advantages = [r - mean_reward for r in rewards]\n        if all(a == 0 for a in advantages):\n            continue\n\n        for seq, advantage in zip(result.sequences, advantages):\n            tokens = prompt_tokens + seq.tokens\n            ob_len = len(prompt_tokens) - 1\n            datum = types.Datum(\n                model_input=types.ModelInput.from_ints(tokens=tokens[:-1]),\n                loss_fn_inputs={\n                    \"target_tokens\": TensorData.from_torch(torch.tensor(tokens[1:])),\n                    \"logprobs\": TensorData.from_torch(torch.tensor([0.0]*ob_len + list(seq.logprobs))),\n                    \"advantages\": TensorData.from_torch(torch.tensor([0.0]*ob_len + [advantage]*(len(tokens)-1-ob_len))),\n                },\n            )\n            datums.append(datum)\n\n    # Track exact token count from datums\n    total_tokens += sum(d.model_input.length() for d in datums)\n\n    fwd_bwd = training_client.forward_backward(datums, loss_fn=\"importance_sampling\")\n    optim = training_client.optim_step(types.AdamParams(learning_rate=4e-5))\n    fwd_bwd.result(); optim.result()\n\n# --- Exact usage reporting (auto-captured by CLI) ---\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\n### Available RL Loss Functions\n\n| Loss | Use Case |\n|------|----------|\n| `importance_sampling` | Standard policy gradient with off-policy correction |\n| `ppo` | Clipped surrogate objective (PPO) |\n| `cispo` | Clipped importance sampling PO |\n| `dro` | Direct reward optimization with quadratic penalty |\n\n---\n\n## Available Models\n\n| Model | Type | Architecture | Train $\u002FM tokens |\n|-------|------|-------------|------------------|\n| Qwen3-4B-Instruct-2507 | Instruction | Dense Compact | $0.22 |\n| Qwen3-8B | Hybrid | Dense Small | $0.40 |\n| Qwen3-30B-A3B | Hybrid | MoE Medium | $0.36 |\n| Qwen3-32B | Hybrid | Dense Medium | $1.47 |\n| Qwen3-VL-30B-A3B-Instruct | Vision | MoE Medium | $0.53 |\n| Llama-3.2-1B | Base | Dense Compact | $0.09 |\n| Llama-3.1-8B | Base | Dense Small | $0.40 |\n| Llama-3.1-70B | Base | Dense Large | $3.16 |\n| DeepSeek-V3.1 | Hybrid | MoE Large | $3.38 |\n| GPT-OSS-120B | Reasoning | MoE Medium | $0.52 |\n\n**Model Selection Tips:**\n- **Cost efficiency**: MoE models (Qwen3-30B-A3B at $0.36\u002FM)\n- **Experimentation**: Start with 8B models\n- **Vision tasks**: Qwen3-VL-30B-A3B-Instruct\n- **Reasoning**: Hybrid or Reasoning models with chain-of-thought\n\n## LoRA Configuration\n\nTinker exclusively uses LoRA. Default rank: 32.\n\n```python\ntraining_client = service_client.create_lora_training_client(\n    base_model=\"Qwen\u002FQwen3-30B-A3B\",\n    rank=32,\n    train_attn=True,\n    train_mlp=True,\n    seed=42,\n)\n```\n\n**Critical**: LoRA needs 20-100x higher LR than full fine-tuning. Use `tinker_cookbook.hyperparam_utils.get_lr()` for recommended values.\n\n## Hyperparameter Guide\n\n| Parameter | SFT Default | RL Default | Notes |\n|-----------|-------------|------------|-------|\n| `learning_rate` | `get_lr(model)` | 4e-5 | Model-dependent; ~5e-4 for Qwen3-30B, ~2.8e-4 for Llama-8B |\n| `batch_size` | 128 | 128 | Smaller generally better for fine-tuning |\n| `lora_rank` | 32 | 32 | Higher rank = more capacity |\n| `group_size` | N\u002FA | 16 | Rollouts per problem for RL |\n| `max_length` | 2048-32768 | N\u002FA | Sequence length for SFT |\n| `max_tokens` | N\u002FA | 256 | Max generation length for RL |\n| `num_epochs` | 1-3 | N\u002FA | Training passes |\n| `lr_schedule` | linear | N\u002FA | Only `linear` and `constant` supported |\n\n## Workflow 3: DPO (Preference Learning)\n\nUse this for aligning models with human preferences without a separate reward model.\n\n### Quick Start\n\n```bash\npython -m tinker_cookbook.recipes.preference.train \\\n    log_path=\u002Ftmp\u002Fdpo-experiment \\\n    model_name=meta-llama\u002FLlama-3.2-1B \\\n    dataset=hhh \\\n    renderer_name=role_colon \\\n    learning_rate=1e-5 \\\n    dpo_beta=0.1\n```\n\n**Key differences from SFT**: Use lower LR (1e-5 to 1e-6), base model should be in-distribution with preference data.\n\n**Available datasets**: `hhh` (Anthropic), `helpsteer3` (NVIDIA), `ultrafeedback`\n\n**Full RLHF pipeline**: See [DPO & Preference Learning](references\u002Fdpo-and-preference.md) for the three-step SL → preference model → RL pipeline.\n\n---\n\n## Evaluations\n\n### Inline (During Training)\n\nAdd `evaluator_builders` to config for periodic evaluation:\n\n```python\nblueprint = chz.Blueprint(train.Config).apply({\n    ...\n    \"evaluator_builders\": [my_evaluator],\n    \"eval_every\": 8,\n})\n```\n\n### Offline (After Training)\n\n```bash\nMODEL_PATH=tinker:\u002F\u002FYOUR_MODEL_PATH_HERE\npython -m tinker_cookbook.eval.run_inspect_evals \\\n    model_path=$MODEL_PATH \\\n    model_name=MODEL_NAME \\\n    tasks=inspect_evals\u002Fifeval,inspect_evals\u002Fmmlu_0_shot\n```\n\nSee [Evaluations](references\u002Fevaluations.md) for custom evaluators and LLM-as-judge.\n\n---\n\n## Cost Estimation & Usage Tracking\n\n### Pre-Training Cost Estimation\n\n**ALWAYS estimate cost before starting Tinker training.** Load the `tinker-training-cost` skill and use its pricing tables or calculate manually:\n\n```\nTraining Cost = (total_tokens × epochs × train_price_per_million) \u002F 1,000,000\n```\n\nPresent the cost estimate to the user for approval before starting training.\n\n### Automatic Usage Reporting (Ground Truth)\n\n**CRITICAL**: All training scripts MUST print a `[OPENSCIENCE_USAGE]` line at the end. The CLI automatically captures this and reports exact billing to the dashboard.\n\n```python\n# Add this at the END of every training script:\nimport json\nprint(f'\\n[OPENSCIENCE_USAGE] {json.dumps({\"service\": \"tinker\", \"event_type\": \"training\", \"model\": model_name, \"tokens_used\": total_tokens})}')\n```\n\nHow token counting works per workflow:\n- **Cookbook SFT**: Tokenize dataset with `get_tokenizer(model_name)`, multiply by `num_epochs`\n- **Cookbook RL**: Parse training logs for `num_tokens`, or estimate from `batch_size × group_size × max_tokens × batches`\n- **Low-level API**: Sum `datum.model_input.length()` across all `forward_backward()` calls\n\nThe CLI bash tool scans output for `[OPENSCIENCE_USAGE]` markers and auto-reports to the dashboard — no manual reporting needed.\n\n## Common Issues\n\n| Problem | Solution |\n|---------|----------|\n| `TINKER_API_KEY` not set | `export TINKER_API_KEY=your_key` or check OpenScience credential sync |\n| KL divergence > 0.01 | Reduce learning rate, check group size |\n| OOM on dataset loading | Use `StreamingSupervisedDatasetFromHFDataset` for large datasets |\n| Reward stuck at 0 | Debug reward function independently, check answer extraction |\n| All advantages = 0 | Increase group size, ensure reward variance across completions |\n| Wrong tokenizer | Use model-specific tokenizer (see Models & LoRA reference) |\n| `Unknown learning rate schedule` | Only `\"linear\"` and `\"constant\"` are supported; `\"cosine\"` does NOT work |\n| Python 3.14 pydantic errors | Tinker requires Python 3.10-3.13; pydantic v1 is incompatible with 3.14+ |\n| Only 1 step per epoch | `batch_size` too large for dataset size; aim for 100+ steps per epoch |\n\n## Saving and Resuming\n\n```python\nsampling_path = training_client.save_weights_for_sampler(name=\"final\").result().path\nsampling_client = service_client.create_sampling_client(model_path=sampling_path)\n\nresume_path = training_client.save_state(name=\"checkpoint\").result().path\ntraining_client.load_state(resume_path)\n```\n\n## Common Imports\n\n```python\nimport tinker\nfrom tinker import types\nfrom tinker.types import Datum, ModelInput, TensorData, AdamParams, SamplingParams\n\nimport chz\nimport asyncio\nfrom tinker_cookbook.supervised import train\nfrom tinker_cookbook.supervised.types import ChatDatasetBuilder, ChatDatasetBuilderCommonConfig\nfrom tinker_cookbook.supervised.data import (\n    SupervisedDatasetFromHFDataset,\n    StreamingSupervisedDatasetFromHFDataset,\n    FromConversationFileBuilder,\n    conversation_to_datum,\n)\nfrom tinker_cookbook.renderers import get_renderer, TrainOnWhat\nfrom tinker_cookbook.model_info import get_recommended_renderer_name\nfrom tinker_cookbook.tokenizer_utils import get_tokenizer\n```\n\n## External Resources\n\n- Documentation: https:\u002F\u002Ftinker-docs.thinkingmachines.ai\u002F\n- Cookbook Repo: https:\u002F\u002Fgithub.com\u002Fthinking-machines-lab\u002Ftinker-cookbook\n- Console: https:\u002F\u002Ftinker-console.thinkingmachines.ai\n",{"name":5,"tags":49,"author":56,"license":15,"version":57,"category":58,"description":7,"dependencies":59},[50,30,51,52,29,53,54,28,55],"Fine-Tuning","LoRA","Reinforcement Learning","DPO","RLHF","Vision-Language Models","Synthetic Sciences","1.0.0","cloud-compute",[60,61,62,63,64,65],"tinker","tinker-cookbook","chz","transformers>=4.40.0","datasets","numpy","main","4aa39efd1cdab0b4657ecee16c92a92011a5b10f","openscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub","https:\u002F\u002Fgithub.com\u002Ffadrienne","2026-10-28 00:43:09",{"source":8,"skillName":5,"commands":73,"prompt":83,"zipAvailable":84},[74,77,80],{"tool":75,"command":76},"npx","npx skills add fadrienne\u002FMyGitHub --skill tinker-fine-tuning",{"tool":78,"command":79},"bunx","bunx skills add fadrienne\u002FMyGitHub --skill tinker-fine-tuning",{"tool":81,"command":82},"pnpm","pnpm dlx skills add fadrienne\u002FMyGitHub --skill tinker-fine-tuning","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002FSKILL.md",true,[86,92,96,100,104,108,112,116,120,124],{"path":87,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fapi-reference.md","REFERENCE","参考文档",4012,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Fapi-reference.md",{"path":93,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":94,"sourceHtmlUrl":95},"references\u002Fdpo-and-preference.md",6141,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Fdpo-and-preference.md",{"path":97,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":98,"sourceHtmlUrl":99},"references\u002Fevaluations.md",5449,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Fevaluations.md",{"path":101,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":102,"sourceHtmlUrl":103},"references\u002Fgetting-started.md",4793,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Fgetting-started.md",{"path":105,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":106,"sourceHtmlUrl":107},"references\u002Floss-functions.md",4640,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Floss-functions.md",{"path":109,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":110,"sourceHtmlUrl":111},"references\u002Fmodels-and-lora.md",4976,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Fmodels-and-lora.md",{"path":113,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":114,"sourceHtmlUrl":115},"references\u002Frecipes.md",10574,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Frecipes.md",{"path":117,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":118,"sourceHtmlUrl":119},"references\u002Freinforcement-learning.md",10771,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Freinforcement-learning.md",{"path":121,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":122,"sourceHtmlUrl":123},"references\u002Frendering.md",6297,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Frendering.md",{"path":125,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":126,"sourceHtmlUrl":127},"references\u002Fsupervised-learning.md",8103,"https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fopenscience\u002Fbackend\u002Fcli\u002Fskills\u002Fcloud-compute\u002Ftinker\u002Freferences\u002Fsupervised-learning.md",[129,158,185,218,245,272],{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":138,"publishedAt":44},"01M7167B28PK20HP7R7ZED2DY0","statistical-power","Sample size calculation, power analysis, and effect size conversion for scientific studies. Use BEFORE data collection (a priori) to determine required N, or after (post-hoc) to compute achieved power. Covers parametric tests (t-test, ANOVA, chi-square, proportions, correlation, regression), simulation-based power for complex\u002Fclustered\u002Fnested designs, and power curves. Use this skill when someone asks 'how many samples do I need', 'what is my power', 'what effect size can I detect', or any variant. Pairs with \u002Fexperimental-design (choose design first, then compute power) and \u002Fstatistical-analysis (analyze data after collection).","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fstatistical-power\u002FSKILL.md",[135],{"categoryNo":136,"categoryName":137,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[139,140,141,142,143,144,145,146,32,147,148,149,150,151,152,153,154,155,156,157],"power","statistical power","effect","scipy","regression","choose","design","uv","Bash","collection","analysis","calculation","ANOVA","conversion","analyze","t-test","chi-square","simulation","sample",{"skillNo":159,"name":160,"nameZh":6,"description":161,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":162,"categories":163,"keywords":167,"publishedAt":44},"01M71677EBCM8EPCE9BZCK8505","statistical-analysis","Guided statistical analysis with test selection and reporting. Use when you need help choosing appropriate tests for your data, assumption checking, power analysis, and APA-formatted results. Best for academic research reporting, test selection guidance. For implementing specific models programmatically use statsmodels.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fstatistical-analysis\u002FSKILL.md",[164],{"categoryNo":165,"categoryName":166,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[149,168,139,169,170,171,32,172,173,174,175,176,177,178,179,180,181,182,183,184],"statistical analysis","academic research","implementing","selection","you","reporting","data","for","tests","use","with","test","research","results","statsmodels","models","help",{"skillNo":186,"name":187,"nameZh":6,"description":188,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":189,"categories":190,"keywords":200,"publishedAt":44},"01M71673R93XAHFH81DBNVNG7H","scientific-writing","Core skill for the deep research and writing tool. Write scientific manuscripts in full paragraphs (never bullet points). Use two-stage process with (1) section outlines with key points using research-lookup then (2) convert to flowing prose. IMRAD structure, citations (APA\u002FAMA\u002FVancouver), figures\u002Ftables, reporting guidelines (CONSORT\u002FSTROBE\u002FPRISMA), for research papers and journal submissions.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fscientific-writing\u002FSKILL.md",[191,194,195],{"categoryNo":192,"categoryName":193,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":136,"categoryName":137,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":196,"categoryName":197,"taxonomyType":198,"taxonomyTypeDesc":199},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[201,202,203,204,205,206,207,208,209,210,147,40,211,212,213,214,215,216,173,217],"writing","scientific","scientific writing","Citations","deep","deep research","never","papers","journal","false","prisma","structure","openrouter","Outlines","core skill","read","features",{"skillNo":219,"name":220,"nameZh":6,"description":221,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":222,"categories":223,"keywords":228,"publishedAt":44},"01M7166ZPKXBF4EBPHVTJPQBB1","scientific-visualization","Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib\u002Fseaborn\u002Fplotly with publication styles. For quick exploration use seaborn or plotly directly.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fscientific-visualization\u002FSKILL.md",[224,227],{"categoryNo":225,"categoryName":226,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000013","分析与可视化",{"categoryNo":136,"categoryName":137,"taxonomyType":21,"taxonomyTypeDesc":22},[229,202,230,231,232,233,234,235,236,209,32,237,238,239,240,241,242,243,175,244],"visualization","scientific visualization","error","ready","quick","exploration","meta-skill","Meta","safe","plotly","annotations","formatting","Publication","figures","panel","submission",{"skillNo":246,"name":247,"nameZh":6,"description":248,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":249,"categories":250,"keywords":257,"publishedAt":44},"01M7166VXJWQSSC3RQZP60WBGR","research-code","Debug, profile, review, and restructure Python research and analysis code. Use when analysis scripts crash, produce wrong results, run too slowly, or need a correctness review. Covers: reading tracebacks and diagnosing root causes, hypothesis-driven debugging, reviewing code for common statistical\u002Fnumerical errors, profiling data pipelines, improving reproducibility (seeds, environments, determinism), and structuring analysis scripts for sharing. Distinct from \u002Fexploratory-data-analysis (which understands data) and \u002Fstatistical-analysis (which chooses and runs tests) — this skill focuses on the code itself.","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fresearch-code\u002FSKILL.md",[251,254],{"categoryNo":252,"categoryName":253,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":255,"categoryName":256,"taxonomyType":198,"taxonomyTypeDesc":199},"01JBSEEDCAT000000000000030","开发工程师",[258,259,180,260,261,262,263,146,264,32,147,149,265,266,267,268,269,270,216,271],"code","research code","which","memory","data-analysis","errors","debugging","common","review","data pipelines","run","scripts","line","write",{"skillNo":273,"name":274,"nameZh":6,"description":275,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":276,"licenseFileUrl":6,"sourceHtmlUrl":277,"categories":278,"keywords":285,"publishedAt":44},"01M7166CF5HSR7SVZYZFWTDX55","markdown-mermaid-writing","Comprehensive markdown and Mermaid diagram writing skill. Use when creating any scientific document, report, analysis, or visualization. Establishes text-based diagrams as the default documentation standard with full style guides (markdown + mermaid), 24 diagram type references, and 9 document templates.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Ffadrienne\u002FMyGitHub\u002Fblob\u002Fmain\u002Fscientific-agent-skills\u002Fskills\u002Fmarkdown-mermaid-writing\u002FSKILL.md",[279,282,283,284],{"categoryNo":280,"categoryName":281,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":192,"categoryName":193,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":136,"categoryName":137,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":196,"categoryName":197,"taxonomyType":198,"taxonomyTypeDesc":199},[201,286,287,288,289,290,229,291,292,32,147,149,293,294,295,296,297,298,202,216],"markdown mermaid writing","mermaid","markdown","community","diagrams","project","default","team","guides","text","documentation","references","diagram"]