{"slug": "tinker-cookbook", "title": "Tinker Cookbook", "summary": "Thinking Machines Lab released two open-source libraries, `tinker` and `tinker-cookbook`, to help developers and researchers fine-tune large language models. The `tinker` SDK handles distributed training complexities via API requests, while `tinker-cookbook` provides realistic fine-tuning examples, tutorials, and abstractions for supervised learning, reinforcement learning, and advanced techniques like DPO and RLHF.", "body_md": "We provide two libraries for the broader community to customize their language models: `tinker`\n\nand `tinker-cookbook`\n\n.\n\n`tinker`\n\nis 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`\n\nincludes realistic examples of fine-tuning language models. It builds on the Tinker API and provides common abstractions to fine-tune language models.\n\n- Sign up for Tinker\n[here](https://auth.thinkingmachines.ai/sign-up). - Once you have access, create an API key from the\n[console](https://tinker-console.thinkingmachines.ai)and export it as environment variable`TINKER_API_KEY`\n\n. - Install\n`tinker-cookbook`\n\n(includes the`tinker`\n\nSDK as a dependency):\n\n```\n# Latest stable release from PyPI\nuv pip install tinker-cookbook\n\n# Or install the nightly build\nuv pip install 'tinker-cookbook @ git+https://github.com/thinking-machines-lab/tinker-cookbook.git@nightly'\n```\n\nHere we introduce a few Tinker primitives — the basic components to fine-tune LLMs (see the [quickstart guide](https://tinker-docs.thinkingmachines.ai/tinker/quickstart/) for more details):\n\n``` python\nimport tinker\nservice_client = tinker.ServiceClient()\ntraining_client = service_client.create_lora_training_client(\n  base_model=\"meta-llama/Llama-3.2-1B\", rank=32,\n)\ntraining_client.forward_backward(...)\ntraining_client.optim_step(...)\ntraining_client.save_state(...)\ntraining_client.load_state(...)\n\nsampling_client = training_client.save_weights_and_get_sampling_client()\nsampling_client.sample(...)\n```\n\nSee [tinker_cookbook/recipes/sl_loop.py](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/sl_loop.py) and [tinker_cookbook/recipes/rl_loop.py](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/rl_loop.py) for minimal examples of using these primitives to fine-tune LLMs.\n\nNew to Tinker? The [ tutorials/](/thinking-machines-lab/tinker-cookbook/blob/main/tutorials) directory contains 20+ progressive\n\n[marimo](https://marimo.io/)notebooks that walk through core concepts — rendering, loss functions, completers, weight management — and advanced topics such as custom RL environments, DPO, RLHF, and weight export. Run any tutorial with\n\n`marimo edit tutorials/101_hello_tinker.py`\n\n. See the [tutorials README](/thinking-machines-lab/tinker-cookbook/blob/main/tutorials/README.md)for the full list, or browse rendered versions on the\n\n[Tinker docs site](https://tinker-docs.thinkingmachines.ai/tutorials).\n\nTo download the weights of any model:\n\n```\nrest_client = service_client.create_rest_client()\nfuture = rest_client.get_checkpoint_archive_url_from_tinker_path(sampling_client.model_path)\nwith open(f\"model-checkpoint.tar.gz\", \"wb\") as f:\n    f.write(future.result())\n```\n\nBesides 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.\n[ tinker_cookbook/recipes/sl_basic.py](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/sl_basic.py) and\n\n[contain minimal examples to configure supervised learning and reinforcement learning.](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/rl_basic.py)\n\n`tinker_cookbook/recipes/rl_basic.py`\n\nWe also include more complete examples in the [ tinker_cookbook/recipes/](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes) folder:\n\n: supervised fine-tuning on conversational datasets (e.g., Tulu3).[Chat SFT](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/chat_sl): reinforcement learning for mathematical reasoning with verifiable rewards.[Math RL](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/math_rl): RL on competitive programming with sandboxed code execution (DeepCoder replication).[Code RL](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/code_rl): DPO and a three-stage RLHF pipeline (SFT, reward model, RL).[Preference learning](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/preference): on-policy and off-policy knowledge distillation with single- and multi-teacher configurations.[Distillation](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/distillation): RL for retrieval-augmented generation (Search-R1 replication).[Tool use](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/search_tool): multi-agent RL with self-play and cross-play.[Multi-agent](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/multiplayer_rl)\n\nThe [recipes README](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/recipes/README.md) covers all available recipes, including Harbor RL, rubric-based grading, VLM classification, and SDFT. Each recipe includes a `README.md`\n\nwith implementation details, launch commands, and expected results.\n\nTinker Cookbook includes a [benchmark framework](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/eval) for evaluating trained models:\n\n``` python\nfrom tinker_cookbook.eval.benchmarks import run_benchmarks, BenchmarkConfig\n\nresults = await run_benchmarks(\n    [\"gsm8k\", \"mmlu_pro\", \"ifeval\"],\n    sampling_client, renderer,\n    BenchmarkConfig(save_dir=\"evals/step500\"),\n)\n```\n\nThe framework currently supports 12 benchmarks (GSM8K, MATH-500, MMLU-Pro, MMLU-Redux, GPQA, IFEval, MBPP, C-Eval, SuperGPQA, IFBench, AIME 2025, AIME 2026) with verified scores against published results, plus experimental benchmarks such as LiveCodeBench, Terminal Bench, and SWE-bench. Benchmarks can also serve as inline training evaluators via `BenchmarkEvaluator`\n\n.\n\n**Note:** Benchmark scores are sensitive to evaluation configuration — system prompts, `max_tokens`\n\n, temperature, and timeout settings can shift results significantly. We document our exact settings alongside all reported scores. This framework is under active development; feedback and contributions are welcome. See the [eval README](/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/eval/README.md) for verified scores, configuration details, and instructions for adding new benchmarks.\n\nFor the full Tinker documentation, visit [tinker-docs.thinkingmachines.ai](https://tinker-docs.thinkingmachines.ai).\n\nTinker Cookbook also provides reusable building blocks:\n\n— bidirectional conversion between token sequences and structured chat messages`renderers`\n\n— learning rate and hyperparameter scaling for LoRA training`hyperparam_utils`\n\n— benchmark framework and inline training evaluators (see`eval`\n\n[Evaluation](#evaluation-experimental)above)\n\nTinker Cookbook ships with [Claude Code skills](https://docs.anthropic.com/en/docs/claude-code/skills) that teach Claude how to use the Tinker API. Install them so Claude can help you write training code in any project:\n\n```\n/plugin marketplace add thinking-machines-lab/tinker-cookbook\n```\n\nThen install the **tinker** plugin from the Discover tab (`/plugin`\n\n→ Discover). Once installed, two skills are available:\n\n| Command | What it does |\n|---|---|\n`/tinker:research` |\nPlan and run post-training experiments — SFT, RL, DPO, distillation, evaluation, hyperparameters, model selection, and more |\n`/tinker:debug` |\nDiagnose slow training, hangs, output mismatches, renderer issues, and errors |\n\nSkills also trigger automatically based on context — ask Claude to \"set up SFT training\" and it will load the right skill without a slash command. Skills update automatically when the repo is updated.\n\n```\nuv sync --extra dev\npre-commit install\n```\n\nThis installs dev dependencies and registers pre-commit hooks that run `ruff`\n\nformatting and linting on every commit. CI enforces these checks on all pull requests.\n\nThis project is built in the spirit of open science and collaborative development. We believe that the best tools emerge through community involvement and shared learning.\n\nWe welcome PR contributions after our private beta is over. If you have any feedback, please email us at [tinker@thinkingmachines.ai](mailto:tinker@thinkingmachines.ai).\n\nIf you use Tinker for your research, please cite it as:\n\n```\nThinking Machines Lab, 2026. Tinker. https://thinkingmachines.ai/tinker/.\n```\n\nOr use this BibTeX citation:\n\n```\n@misc{tml2026tinker,\n  author = {Thinking Machines Lab},\n  title = {Tinker},\n  year = {2026},\n  url = {https://thinkingmachines.ai/tinker/},\n}\n```\n\n", "url": "https://wpnews.pro/news/tinker-cookbook", "canonical_source": "https://github.com/thinking-machines-lab/tinker-cookbook", "published_at": "2026-06-06 01:48:47+00:00", "updated_at": "2026-06-06 02:17:38.467429+00:00", "lang": "en", "topics": ["large-language-models", "machine-learning", "artificial-intelligence", "ai-tools", "ai-infrastructure"], "entities": ["Tinker", "tinker-cookbook", "Thinking Machines Lab", "Meta", "Llama-3.2-1B", "PyPI", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/tinker-cookbook", "markdown": "https://wpnews.pro/news/tinker-cookbook.md", "text": "https://wpnews.pro/news/tinker-cookbook.txt", "jsonld": "https://wpnews.pro/news/tinker-cookbook.jsonld"}}