Claude Code skills for fine-tuning language models with the Tinker API.
npx claudepluginhub thinking-machines-lab/tinker-cookbookSkills for fine-tuning language models with the Tinker API — research, debugging, and more.
Share bugs, ideas, or general feedback.
We provide two libraries for the broader community to customize their language models: tinker and tinker-cookbook.
tinker is a training SDK for researchers and developers to fine-tune language models. You send API requests to us and we handle the complexities of distributed training.tinker-cookbook includes realistic examples of fine-tuning language models. It builds on the Tinker API and provides common abstractions to fine-tune language models.TINKER_API_KEY.tinker-cookbook (includes the tinker SDK as a dependency):
# Latest stable release from PyPI
uv pip install tinker-cookbook
# Or install the nightly build
uv pip install 'tinker-cookbook @ git+https://github.com/thinking-machines-lab/tinker-cookbook.git@nightly'
Refer to the docs to start from basics. Here we introduce a few Tinker primitives - the basic components to fine-tune LLMs:
import tinker
service_client = tinker.ServiceClient()
training_client = service_client.create_lora_training_client(
base_model="meta-llama/Llama-3.2-1B", rank=32,
)
training_client.forward_backward(...)
training_client.optim_step(...)
training_client.save_state(...)
training_client.load_state(...)
sampling_client = training_client.save_weights_and_get_sampling_client()
sampling_client.sample(...)
See tinker_cookbook/recipes/sl_loop.py and tinker_cookbook/recipes/rl_loop.py for minimal examples of using these primitives to fine-tune LLMs.
New to Tinker? The tutorials/ directory has progressive marimo notebooks that guide you from your first API call to building custom RL training pipelines:
| # | Notebook | What you'll learn |
|---|---|---|
| 101 | Hello Tinker | Architecture overview, client hierarchy, sampling |
| 102 | First SFT | Renderers, datum construction, training loop, Kimi K2.5 scaling demo |
| 103 | Efficient Sampling | Concurrent futures, num_samples, batch evaluation throughput |
| 104 | First RL | GRPO on GSM8K: rewards, advantages, degenerate groups |
| 301 | Cookbook RL Abstractions | Env, EnvGroupBuilder, RLDataset, ProblemEnv |
| 302 | Custom RL Environment | Build your own ProblemEnv and RLDataset |
Run any tutorial with marimo edit tutorials/101_hello_tinker.py. Rendered versions are available on the Tinker docs site.
To download the weights of any model:
rest_client = service_client.create_rest_client()
future = rest_client.get_checkpoint_archive_url_from_tinker_path(sampling_client.model_path)
with open(f"model-checkpoint.tar.gz", "wb") as f:
f.write(future.result())
Besides these primitives, we also offer Tinker Cookbook (a.k.a. this repo), a library of a wide range of abstractions to help you customize training environments.
tinker_cookbook/recipes/sl_basic.py and tinker_cookbook/recipes/rl_basic.py contain minimal examples to configure supervised learning and reinforcement learning.