# thinking-machines-lab/tinker-cookbook architecture

> Architecture diagram of the GitHub repository thinking-machines-lab/tinker-cookbook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thinking-machines-lab/tinker-cookbook
- Repository: https://github.com/thinking-machines-lab/tinker-cookbook

## Overview

Tinker Cookbook is a Python library of reusable post-training algorithms and runnable language-model training recipes built on the Tinker API. The typical workflow configures a recipe and dataset or environment, renders model inputs, generates supervised examples or RL rollouts, trains a policy, then evaluates or checkpoints the result. The repository also documents distinct preference-learning, distillation, multimodal, tool-use and multi-agent recipes, plus weight export and capture capabilities. The graph reflects README-described subsystems; sampled source is limited, so uncertain internal wiring is omitted.

Main entry points: [`tinker_cookbook/rl/train.py`](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/train.py) (RL training), [`tinker_cookbook/supervised/train.py`](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/supervised/train.py) (Supervised training), [`tinker_cookbook/capture`](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/capture) (Sampling capture), [`tinker_cookbook/supervised/data.py`](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/supervised/data.py) (Dataset builders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_recipes["Training recipes"]
  node_recipes["Task recipes"]
  node_sft_recipe["Chat SFT"]
  node_rl_recipe["RL recipes"]
  node_code_recipe["Code RL"]
  node_preference["Preference learning"]
  node_rlhf["RLHF pipeline<br/>[rlhf_pipeline.py]"]
  node_distill["Distillation recipes"]
  node_multimodal["Audio and vision"]
  node_tool_multi["Tool and multi-agent"]
end

subgraph group_training["Training abstractions"]
  node_datasets["Dataset builders<br/>[data.py]"]
  node_supervised["Supervised training<br/>[train.py]"]
  node_rl_core["RL training<br/>[train.py]"]
  node_rl_env["RL environments<br/>[problem_env.py]"]
end

subgraph group_model["Model interfaces"]
  node_renderers["Message renderers<br/>[base.py]"]
  node_tinker{{"Tinker API"}}
end

subgraph group_results["Evaluation and artifacts"]
  node_evaluation["Benchmark evaluation"]
  node_stores[("Training and eval stores")]
  node_weights["Weight export"]
end

subgraph group_capture["Capture and observability"]
  node_capture["Sampling capture"]
  node_capture_store[("Capture store")]
end

node_engineer(("Cookbook user"))
node_external(("External agent clients"))

node_engineer -->|"configures"| node_recipes
node_recipes -->|"builds data"| node_datasets
node_sft_recipe -->|"builds data"| node_datasets
node_sft_recipe -->|"starts training"| node_supervised
node_rl_recipe -->|"starts training"| node_rl_core
node_code_recipe -->|"starts training"| node_rl_core
node_preference -->|"uses SFT"| node_supervised
node_preference -->|"uses RL"| node_rl_core
node_rlhf -->|"runs stages"| node_supervised
node_rlhf -->|"runs RL stage"| node_rl_core
node_distill -->|"trains student"| node_supervised
node_distill -->|"scores teacher"| node_tinker
node_multimodal -->|"trains models"| node_supervised
node_multimodal -->|"trains policies"| node_rl_core
node_tool_multi -->|"trains policies"| node_rl_core
node_tool_multi -->|"defines environments"| node_rl_env
node_datasets -->|"formats messages"| node_renderers
node_supervised -->|"trains through"| node_tinker
node_rl_core -->|"runs rollouts"| node_rl_env
node_rl_core -->|"samples and trains"| node_tinker
node_rl_core -->|"logs results"| node_stores
node_supervised -->|"logs results"| node_stores
node_evaluation -->|"evaluates samples"| node_tinker
node_evaluation -->|"persists results"| node_stores
node_tinker -->|"exports weights"| node_weights
node_external -.->|"sends requests"| node_capture
node_capture -->|"samples through"| node_tinker
node_capture -->|"exports records"| node_capture_store

click node_recipes "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes"
click node_sft_recipe "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/chat_sl"
click node_rl_recipe "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/math_rl"
click node_code_recipe "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/code_rl"
click node_preference "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/preference"
click node_rlhf "https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/preference/rlhf/rlhf_pipeline.py"
click node_distill "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/distillation"
click node_multimodal "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/audio"
click node_tool_multi "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/search_tool"
click node_datasets "https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/supervised/data.py"
click node_supervised "https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/supervised/train.py"
click node_rl_core "https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/train.py"
click node_rl_env "https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/problem_env.py"
click node_renderers "https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py"
click node_evaluation "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/eval"
click node_stores "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/stores"
click node_weights "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/weights"
click node_capture "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/capture"
click node_capture_store "https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/capture/store"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_recipes,node_sft_recipe,node_rl_recipe,node_code_recipe,node_preference,node_rlhf,node_distill,node_multimodal,node_tool_multi,node_engineer,node_external toneBlue
class node_datasets,node_supervised,node_rl_core,node_rl_env toneAmber
class node_renderers,node_tinker toneMint
class node_evaluation,node_stores,node_weights toneRose
class node_capture,node_capture_store toneIndigo
```

## Components

### Training recipes

- [Task recipes](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes): `tinker_cookbook/recipes`
- [Chat SFT](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/chat_sl): `tinker_cookbook/recipes/chat_sl`
- [RL recipes](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/math_rl): `tinker_cookbook/recipes/math_rl`
- [Code RL](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/code_rl): `tinker_cookbook/recipes/code_rl`
- [Preference learning](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/preference): `tinker_cookbook/recipes/preference`
- [RLHF pipeline](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/preference/rlhf/rlhf_pipeline.py): `tinker_cookbook/recipes/preference/rlhf/rlhf_pipeline.py`
- [Distillation recipes](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/distillation): `tinker_cookbook/recipes/distillation`
- [Audio and vision](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/audio): `tinker_cookbook/recipes/audio`
- [Tool and multi-agent](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/recipes/search_tool): `tinker_cookbook/recipes/search_tool`

### Training abstractions

- [Dataset builders](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/supervised/data.py): `tinker_cookbook/supervised/data.py`
- [Supervised training](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/supervised/train.py): `tinker_cookbook/supervised/train.py`
- [RL training](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/train.py): `tinker_cookbook/rl/train.py`
- [RL environments](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/problem_env.py): `tinker_cookbook/rl/problem_env.py`

### Model interfaces

- [Message renderers](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py): `tinker_cookbook/renderers/base.py`
- **Tinker API**

### Evaluation and artifacts

- [Benchmark evaluation](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/eval): `tinker_cookbook/eval`
- [Training and eval stores](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/stores): `tinker_cookbook/stores`
- [Weight export](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/weights): `tinker_cookbook/weights`

### Capture and observability

- [Sampling capture](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/capture): `tinker_cookbook/capture`
- [Capture store](https://github.com/thinking-machines-lab/tinker-cookbook/tree/main/tinker_cookbook/capture/store): `tinker_cookbook/capture/store`

### Other components

- **Cookbook user**
- **External agent clients**

## Connections

- Cookbook user → Task recipes: configures
- Task recipes → Dataset builders: builds data
- Chat SFT → Dataset builders: builds data
- Chat SFT → Supervised training: starts training
- RL recipes → RL training: starts training
- Code RL → RL training: starts training
- Preference learning → Supervised training: uses SFT
- Preference learning → RL training: uses RL
- RLHF pipeline → Supervised training: runs stages
- RLHF pipeline → RL training: runs RL stage
- Distillation recipes → Supervised training: trains student
- Distillation recipes → Tinker API: scores teacher
- Audio and vision → Supervised training: trains models
- Audio and vision → RL training: trains policies
- Tool and multi-agent → RL training: trains policies
- Tool and multi-agent → RL environments: defines environments
- Dataset builders → Message renderers: formats messages
- Supervised training → Tinker API: trains through
- RL training → RL environments: runs rollouts
- RL training → Tinker API: samples and trains
- RL training → Training and eval stores: logs results
- Supervised training → Training and eval stores: logs results
- Benchmark evaluation → Tinker API: evaluates samples
- Benchmark evaluation → Training and eval stores: persists results
- Tinker API → Weight export: exports weights
- External agent clients → Sampling capture: sends requests
- Sampling capture → Tinker API: samples through
- Sampling capture → Capture store: exports records
