Guide for checkpointing — saving, loading, and resuming training with CheckpointRecord. Use when the user asks about saving weights, resuming training, checkpoint management, or the checkpoint lifecycle.
日本語の概要は準備中です。原文の説明を表示しています。
Scaffold a new training recipe for the Tinker cookbook following repo conventions. Use when the user wants to create a new recipe, training script, or experiment.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Scaffold a new training recipe in tinker_cookbook/recipes/ following repo conventions.
Ask the user:
recipes/)Before writing any code, read the most relevant existing recipe:
tinker_cookbook/recipes/sl_basic.py and tinker_cookbook/recipes/chat_sl/train.pytinker_cookbook/recipes/rl_basic.py and tinker_cookbook/recipes/math_rl/train.pytinker_cookbook/recipes/preference/dpo/train.pytinker_cookbook/recipes/distillation/on_policy_distillation.pytinker_cookbook/recipes/harbor_rl/train.pyAlso read CLAUDE.md for conventions.
Every recipe MUST follow these patterns:
tinker_cookbook/recipes/<recipe_name>/
├── __init__.py # Empty or minimal
├── train.py # Main entry point with CLIConfig + cli_main
└── <env_or_data>.py # Dataset/environment definitions (if needed)
Or for simple recipes: tinker_cookbook/recipes/<recipe_name>.py
@chz.chz for config)@chz.chz
class CLIConfig:
model_name: str = "meta-llama/Llama-3.1-8B"
learning_rate: float = 1e-4
# ... all configurable parameters with defaults
async def cli_main(cli_config: CLIConfig):
# Build full config from CLI config
# Call training main function
if __name__ == "__main__":
cli_config = chz.entrypoint(CLIConfig)
asyncio.run(cli_main(cli_config))
@chz.chz config class with sensible defaultsmodel_info.get_recommended_renderer_name(model_name) for renderer — never hardcodecli_utils.check_log_dir() before training to avoid clobberingcheckpoint_utils.resolve_renderer_name_from_checkpoint_or_default_async() if loading checkpointsAny or type: ignore_P (problems), _G (groups), _T (tokens), _D (datums)safezip, timed, scope helpers where appropriateml_log.log_metrics for metrics, logtree for transcriptsRecipe must be runnable as:
python -m tinker_cookbook.recipes.<recipe_name>.train [chz overrides]
Write the recipe files following the patterns above. Place them in tinker_cookbook/recipes/$ARGUMENTS/.
The repo has two layers of testing. Both should be added for every new recipe.
Create tests/recipes/test_recipe_<name>.py — a minimal test that runs the recipe for 2 training steps and verifies clean exit. CI auto-discovers these files and runs them daily.
import pytest
from tests.helpers import run_recipe
@pytest.mark.integration
def test_<recipe_name>():
run_recipe(
"tinker_cookbook.recipes.<recipe_name>.train",
[
"behavior_if_log_dir_exists=delete",
# Override params to make it fast:
# "groups_per_batch=4", "group_size=2", "batch_size=16", etc.
],
)
Key conventions:
run_recipe() launches the module as a subprocess and automatically passes max_steps=2 (configurable via the max_steps parameter)behavior_if_log_dir_exists=delete to avoid conflicts in repeated CI runs@pytest.mark.integration — these require TINKER_API_KEYtests/helpers.py for run_recipe() details and tests/conftest.py for fixturesPlace unit tests next to the code they test using the *_test.py naming convention:
tinker_cookbook/recipes/<recipe_name>/<component>_test.py
For example:
tinker_cookbook/recipes/math_rl/math_env_test.py — tests environment logictinker_cookbook/renderers/parsing_test.py — tests parsing helpersUnit tests should:
TINKER_API_KEY (no network calls)# Unit tests only (no API key needed)
uv run pytest tinker_cookbook/
# Integration / smoke tests (requires TINKER_API_KEY)
uv run pytest tests/recipes/test_recipe_<name>.py -v -x -s
pytest tinker_cookbook/) run on every PR via .github/workflows/pytest.yamlpytest tests/) run daily and on manual trigger via .github/workflows/smoke-test-recipes.yamltests/recipes/test_recipe_<name>.py is all that's needed — CI auto-discovers itpython -c "from tinker_cookbook.recipes.<name> import train"python -m tinker_cookbook.recipes.<name>.train --helpuv run pytest tests/recipes/test_recipe_<name>.py -v -x -sまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Guide for checkpointing — saving, loading, and resuming training with CheckpointRecord. Use when the user asks about saving weights, resuming training, checkpoint management, or the checkpoint lifecycle.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for testing conventions and CI pipelines — unit tests, integration smoke tests, pytest markers, and GitHub Actions workflows. Use when the user asks about testing, CI, running tests, or adding tests for a recipe.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for using completers — TokenCompleter and MessageCompleter for text generation during RL rollouts and evaluation. Use when the user asks about generating text, completing messages, or using completers in RL environments.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for contributing to the tinker-cookbook repo — development setup, code style, type checking, PR process, and design conventions. Use when the user asks about how to contribute, set up the dev environment, code style, or project conventions.
日本語の概要は準備中です。原文の説明を表示しています。
Guide for dataset construction — SupervisedDatasetBuilder, RLDatasetBuilder, ChatDatasetBuilder, and custom dataset creation from JSONL, HuggingFace, or conversation data. Use when the user asks about datasets, data loading, data preparation, or custom data formats.
日本語の概要は準備中です。原文の説明を表示しています。
Set up and run knowledge distillation (on-policy, off-policy, or multi-teacher) from a teacher model to a student model using the Tinker API. Use when the user wants to distill knowledge, compress models, or train a student from a teacher.
日本語の概要は準備中です。原文の説明を表示しています。