tinker_cookbook 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tinker_cookbook-0.1.0/.github/workflows/claude-review.yml +82 -0
- tinker_cookbook-0.1.0/.github/workflows/pre-commit.yaml +17 -0
- tinker_cookbook-0.1.0/.github/workflows/pyright.yaml +25 -0
- tinker_cookbook-0.1.0/.gitignore +1 -0
- tinker_cookbook-0.1.0/.pre-commit-config.yaml +23 -0
- tinker_cookbook-0.1.0/.sync_state +4 -0
- tinker_cookbook-0.1.0/AGENTS.md +134 -0
- tinker_cookbook-0.1.0/CLAUDE.md +1 -0
- tinker_cookbook-0.1.0/CONTRIBUTING.md +77 -0
- tinker_cookbook-0.1.0/LICENSE +202 -0
- tinker_cookbook-0.1.0/PKG-INFO +146 -0
- tinker_cookbook-0.1.0/README.md +90 -0
- tinker_cookbook-0.1.0/assets/tinker-cover.png +0 -0
- tinker_cookbook-0.1.0/llms-full.txt +2599 -0
- tinker_cookbook-0.1.0/llms.txt +174 -0
- tinker_cookbook-0.1.0/pyproject.toml +79 -0
- tinker_cookbook-0.1.0/scripts/publish-pypi +7 -0
- tinker_cookbook-0.1.0/tinker_cookbook/__init__.py +0 -0
- tinker_cookbook-0.1.0/tinker_cookbook/chat_app/README.md +46 -0
- tinker_cookbook-0.1.0/tinker_cookbook/chat_app/tinker_chat_cli.py +179 -0
- tinker_cookbook-0.1.0/tinker_cookbook/checkpoint_utils.py +109 -0
- tinker_cookbook-0.1.0/tinker_cookbook/cli_utils.py +60 -0
- tinker_cookbook-0.1.0/tinker_cookbook/completers.py +118 -0
- tinker_cookbook-0.1.0/tinker_cookbook/display.py +46 -0
- tinker_cookbook-0.1.0/tinker_cookbook/distillation/datasets.py +278 -0
- tinker_cookbook-0.1.0/tinker_cookbook/distillation/train_on_policy.py +461 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/README.md +1 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/custom_evaluators.py +101 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/custom_inspect_task.py +69 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/evaluators.py +30 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/inspect_evaluators.py +120 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/inspect_utils.py +154 -0
- tinker_cookbook-0.1.0/tinker_cookbook/eval/run_inspect_evals.py +57 -0
- tinker_cookbook-0.1.0/tinker_cookbook/example_data/conversations.jsonl +128 -0
- tinker_cookbook-0.1.0/tinker_cookbook/example_data/multilingual.txt +2100 -0
- tinker_cookbook-0.1.0/tinker_cookbook/hyperparam_utils.py +182 -0
- tinker_cookbook-0.1.0/tinker_cookbook/model_info.py +114 -0
- tinker_cookbook-0.1.0/tinker_cookbook/preference/comparison_policy_evaluator.py +67 -0
- tinker_cookbook-0.1.0/tinker_cookbook/preference/dpo_datasets.py +77 -0
- tinker_cookbook-0.1.0/tinker_cookbook/preference/preference_datasets.py +170 -0
- tinker_cookbook-0.1.0/tinker_cookbook/preference/train_dpo.py +396 -0
- tinker_cookbook-0.1.0/tinker_cookbook/preference/types.py +146 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/README.md +40 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/chat_sl/README.md +41 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/chat_sl/chat_datasets.py +77 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/chat_sl/train.py +164 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/code_rl/README.md +45 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/code_rl/code_env.py +283 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/code_rl/code_grading.py +159 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/code_rl/lcb_utils.py +821 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/code_rl/sandbox_config/local.yaml +122 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/code_rl/train.py +112 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/distillation/README.md +94 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/distillation/off_policy_reasoning.py +193 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/distillation/on_policy_distillation.py +168 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/distillation/on_policy_multi_teacher.py +178 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/math_rl/README.md +85 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/math_rl/arithmetic_env.py +105 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/math_rl/math_env.py +449 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/math_rl/math_grading.py +548 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/math_rl/train.py +156 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/README.md +14 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/guess_number/README.md +82 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/guess_number/env.py +163 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/guess_number/train.py +72 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/text_arena/README.md +65 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/text_arena/env.py +298 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/text_arena/train.py +74 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/twenty_questions/README.md +73 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/twenty_questions/common_english_nouns.txt +171 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/twenty_questions/env.py +271 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/multiplayer_rl/twenty_questions/train.py +74 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/README.md +12 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/datasets.py +315 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/dpo/README.md +34 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/dpo/train.py +125 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/rlhf/README.md +28 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/rlhf/rlhf_pipeline.py +285 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/shorter/README.md +29 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/shorter/env.py +61 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/preference/shorter/train.py +46 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/prompt_distillation/README.md +76 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/prompt_distillation/create_data.py +177 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/prompt_distillation/train.py +111 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/rl_basic.py +41 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/rl_loop.py +248 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/sl_basic.py +51 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/sl_loop.py +155 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/tool_use/search/README.md +63 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/tool_use/search/embedding.py +133 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/tool_use/search/offline_eval.py +210 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/tool_use/search/search_env.py +379 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/tool_use/search/tools.py +190 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/tool_use/search/train.py +143 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/verifiers_rl/README.md +35 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/verifiers_rl/evaluate.py +155 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/verifiers_rl/tinker_openai.py +243 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/verifiers_rl/train.py +149 -0
- tinker_cookbook-0.1.0/tinker_cookbook/recipes/verifiers_rl/verifiers_env.py +173 -0
- tinker_cookbook-0.1.0/tinker_cookbook/renderers.py +889 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/data_processing.py +209 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/metric_util.py +136 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/metrics.py +169 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/play_w_env.py +87 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/preference_envs.py +282 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/problem_env.py +102 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/rollouts.py +81 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/train.py +1126 -0
- tinker_cookbook-0.1.0/tinker_cookbook/rl/types.py +159 -0
- tinker_cookbook-0.1.0/tinker_cookbook/supervised/common.py +56 -0
- tinker_cookbook-0.1.0/tinker_cookbook/supervised/data.py +170 -0
- tinker_cookbook-0.1.0/tinker_cookbook/supervised/nll_evaluator.py +26 -0
- tinker_cookbook-0.1.0/tinker_cookbook/supervised/train.py +373 -0
- tinker_cookbook-0.1.0/tinker_cookbook/supervised/types.py +83 -0
- tinker_cookbook-0.1.0/tinker_cookbook/supervised/viz_sft_dataset.py +53 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/compare_sampling_training_logprobs.py +154 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/smoke_tests.py +138 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/test_logtree.py +506 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/test_renderers.py +179 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/test_resume.py +131 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/test_rl_datasets.py +32 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/test_trace.py +127 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/test_utils.py +47 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tests/validate_temperature_logprobs.py +368 -0
- tinker_cookbook-0.1.0/tinker_cookbook/tokenizer_utils.py +31 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/code_state.py +130 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/file_utils.py +6 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/format_colorized.py +50 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/logtree.py +1017 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/logtree_formatters.py +108 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/lr_scheduling.py +15 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/misc_utils.py +94 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/ml_log.py +517 -0
- tinker_cookbook-0.1.0/tinker_cookbook/utils/trace.py +443 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/README.md +93 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/__init__.py +6 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/control.py +509 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/core.py +658 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/examples/async_rl_sweep.py +93 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/examples/fake_train.py +75 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/examples/ml_sweep.py +278 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/run_job.py +50 -0
- tinker_cookbook-0.1.0/tinker_cookbook/xmux/utils.py +253 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
name: Claude Code
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write # allow Claude to edit files & push commits
|
|
5
|
+
pull-requests: write # allow PR comments/reviews & PR creation
|
|
6
|
+
issues: write # allow issue comments & labels
|
|
7
|
+
|
|
8
|
+
id-token: write # Necessary because otherwise we get:
|
|
9
|
+
# Error: Failed to setup GitHub token: Error: Could not fetch an OIDC token. Did you remember to add `id-token: write` to your workflow permissions?
|
|
10
|
+
# If you instead wish to use this action with a custom GitHub token or custom GitHub app, provide a `github_token` in the `uses` section of the app in your workflow yml file.
|
|
11
|
+
actions: read
|
|
12
|
+
# ^^^ Not sure if this is necessary, but my previous working configuration had it.
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
# 1) Automatic PR review (non‑excessive)
|
|
16
|
+
pull_request:
|
|
17
|
+
types: [opened, reopened, ready_for_review]
|
|
18
|
+
|
|
19
|
+
# 2) Talk to @claude in PRs & issues
|
|
20
|
+
issue_comment:
|
|
21
|
+
types: [created]
|
|
22
|
+
pull_request_review_comment:
|
|
23
|
+
types: [created]
|
|
24
|
+
issues:
|
|
25
|
+
types: [opened]
|
|
26
|
+
|
|
27
|
+
env:
|
|
28
|
+
# Shared Claude CLI configuration for all jobs
|
|
29
|
+
CLAUDE_ARGS_COMMON: >
|
|
30
|
+
--max-turns 50
|
|
31
|
+
--allowedTools "Read" "Write" "Edit" "MultiEdit"
|
|
32
|
+
"Glob" "Grep" "LS"
|
|
33
|
+
"Bash(git:*)" "Bash(gh:*)"
|
|
34
|
+
"mcp__github_inline_comment__create_inline_comment"
|
|
35
|
+
|
|
36
|
+
jobs:
|
|
37
|
+
pr_review:
|
|
38
|
+
name: Automatic PR review
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
# Only run this job for pull_request events
|
|
41
|
+
if: github.event_name == 'pull_request'
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout repository
|
|
44
|
+
uses: actions/checkout@v5
|
|
45
|
+
with:
|
|
46
|
+
fetch-depth: 1
|
|
47
|
+
|
|
48
|
+
- name: Claude PR review
|
|
49
|
+
uses: anthropics/claude-code-action@v1
|
|
50
|
+
with:
|
|
51
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
52
|
+
# Official slash command for PR review (context comes from the PR event)
|
|
53
|
+
# https://code.claude.com/docs/en/github-actions#using-slash-commands
|
|
54
|
+
prompt: "/review"
|
|
55
|
+
claude_args: ${{ env.CLAUDE_ARGS_COMMON }}
|
|
56
|
+
track_progress: true
|
|
57
|
+
show_full_output: true
|
|
58
|
+
|
|
59
|
+
claude_mention:
|
|
60
|
+
name: Respond to @claude in issues & PRs
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
# Only run when @claude actually appears
|
|
63
|
+
if: >
|
|
64
|
+
(github.event_name == 'issue_comment' &&
|
|
65
|
+
contains(github.event.comment.body, '@claude')) ||
|
|
66
|
+
(github.event_name == 'pull_request_review_comment' &&
|
|
67
|
+
contains(github.event.comment.body, '@claude')) ||
|
|
68
|
+
(github.event_name == 'issues' &&
|
|
69
|
+
contains(github.event.issue.body, '@claude'))
|
|
70
|
+
steps:
|
|
71
|
+
- name: Checkout repository
|
|
72
|
+
uses: actions/checkout@v5
|
|
73
|
+
with:
|
|
74
|
+
fetch-depth: 1
|
|
75
|
+
|
|
76
|
+
- name: Claude on @mention
|
|
77
|
+
uses: anthropics/claude-code-action@v1
|
|
78
|
+
with:
|
|
79
|
+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
80
|
+
# No prompt → action switches to "tag" mode and responds to @claude
|
|
81
|
+
# https://code.claude.com/docs/en/github-actions#configuration-examples
|
|
82
|
+
claude_args: ${{ env.CLAUDE_ARGS_COMMON }}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: pyright
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
type-check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: checkout
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: install-uv
|
|
17
|
+
uses: astral-sh/setup-uv@v6
|
|
18
|
+
with:
|
|
19
|
+
enable-cache: true
|
|
20
|
+
|
|
21
|
+
- name: venv
|
|
22
|
+
run: uv venv && uv sync --all-extras
|
|
23
|
+
|
|
24
|
+
- name: pyright
|
|
25
|
+
run: uv run pyright
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
**/__pycache__
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
default_install_hook_types: [pre-commit, pre-push]
|
|
2
|
+
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
+
rev: v5.0.0
|
|
6
|
+
hooks:
|
|
7
|
+
- id: check-added-large-files
|
|
8
|
+
args: ["--maxkb=500"]
|
|
9
|
+
- id: end-of-file-fixer
|
|
10
|
+
exclude: |
|
|
11
|
+
(?x)
|
|
12
|
+
^(
|
|
13
|
+
\.sync_state
|
|
14
|
+
)$
|
|
15
|
+
- id: trailing-whitespace
|
|
16
|
+
|
|
17
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
18
|
+
rev: v0.13.2
|
|
19
|
+
hooks:
|
|
20
|
+
# Run the linter.
|
|
21
|
+
- id: ruff-check
|
|
22
|
+
# Run the formatter.
|
|
23
|
+
- id: ruff-format
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Tinker Cookbook Agent Guide
|
|
2
|
+
|
|
3
|
+
Working notes for future agents hacking on `tinker-cookbook`. Additional docs can be found in the `llms.txt` (condensed) / `llms-full.txt` (complete), `CONTRIBUTING`, and the bundled documentation.
|
|
4
|
+
|
|
5
|
+
## Mission & Scope
|
|
6
|
+
- `tinker-cookbook` is the client-side layer for the hosted **Tinker** service. You author training/eval loops that run on a CPU machine; Tinker executes the heavy GPU work (LoRA fine-tuning, sampling, checkpointing) on synchronized worker pools (a.k.a. clock cycles).
|
|
7
|
+
- The cookbook must mirror the public docs. Both `llms.txt` and `llms-full.txt` are autogenerated outside this repo—treat them as read-only and coordinate with maintainers when they need a refresh.
|
|
8
|
+
- Primary users: (1) researchers cloning recipes and swapping in their data/envs; (2) SDK developers extending abstractions like renderers, datasets, evaluators, completers.
|
|
9
|
+
|
|
10
|
+
## Tooling & Setup
|
|
11
|
+
- Python ≥3.11. Follow the onboarding instructions: join the waitlist, create a `TINKER_API_KEY` in the console, `pip install tinker`, then `pip install -e .[dev]` (or `uv pip install -e .[dev]`). Most contributors already have the env variable set; if requests fail with auth errors, re-export it.
|
|
12
|
+
- Optional extras (`vector-search`, `wandb`, `verifiers`, etc.) are defined in `pyproject.toml`.
|
|
13
|
+
- CLI utilities expect datasets, logs, and checkpoints to live under user-controlled paths (default `/tmp/tinker-examples/...`). Clean up disk usage between runs.
|
|
14
|
+
- Heavy examples (smoke tests, RL recipes) download Hugging Face datasets and call the hosted API; run them only when you have network+API access.
|
|
15
|
+
|
|
16
|
+
## Architecture & Patterns
|
|
17
|
+
- **Builder pattern (per CONTRIBUTING):**
|
|
18
|
+
- Config objects are lightweight `chz` dataclasses (e.g., `SupervisedDatasetBuilder`, `RLDatasetBuilder`, `EnvGroupBuilder`, `EvaluatorBuilder`). They capture parameters, stay serializable, and usually expose a `.build()`/`__call__()` that returns heavyweight runtime objects.
|
|
19
|
+
- Launch scripts define a CLI-facing `CLIConfig` (parsed by `chz`) that instantiates the richer training `Config`. This gives every recipe a consistent `python -m ... key=value` interface.
|
|
20
|
+
- Env builders compose like `RLDatasetBuilder → EnvGroupBuilder → Env`. Groups let us share metadata (tags, pairwise comparisons) and center rewards across related rollouts.
|
|
21
|
+
- **Completers:** algorithms interact with the `TokenCompleter` interface. `TinkerTokenCompleter` (wrapping a `SamplingClient`) is the default implementation, but evaluators may accept any `TokenCompleter` or `MessageCompleter`.
|
|
22
|
+
- **Renderers & tokenizer utils:** pick the renderer that matches your tokenizer/model pair (e.g., `role_colon`, `llama3`, `qwen3`). `TrainOnWhat` controls which tokens get weight=1 in SFT. Tokenizers are cached via `tokenizer_utils.get_tokenizer`, with Llama-3 names remapped to `thinkingmachineslabinc/meta-llama-3-tokenizer` to bypass HF gating.
|
|
23
|
+
- **Loss plumbing:** every `tinker.Datum` bundles a `model_input` plus `loss_fn_inputs` (`TensorData`). Use helpers such as `conversation_to_datum`, `datum_from_tokens_weights`, and `_remove_mask` instead of constructing dicts manually. Built-in losses: `cross_entropy`, `importance_sampling`, `ppo`; `forward_backward_custom` covers bespoke differentiable objectives.
|
|
24
|
+
|
|
25
|
+
## Conventions & Notation (from CONTRIBUTING)
|
|
26
|
+
- **Subscripts:** `_P` (problems/prompts), `_G` (groups of rollouts sharing metadata), `_T` (tokens/time), `_D` (datums), with flattened forms like `_PG`. Example: `tokens_P_G_T[p][g][t]` indexes tokens for problem `p`, group member `g`, token `t`. Keep these suffixes when naming tensors/metrics so downstream tooling can interpret shapes.
|
|
27
|
+
- **Env lifecycle:** `Env` objects are single-use (no `reset`); create them via `EnvGroupBuilder`, which returns correlated envs (for GRPO-style centering or multi-agent comparisons). Datasets return groups, not individual envs.
|
|
28
|
+
- **Typing:** prefer explicit typing, avoid `Any` / `type: ignore`. Keep generics readable. Converters like `TensorData.from_numpy` and helper casting utilities already exist; use them.
|
|
29
|
+
- **`chz` usage:** configuration objects (`Config`, dataset builders, CLI configs) are `@chz.chz` classes so they can be serialized, logged, and hydrated from CLI key-value pairs.
|
|
30
|
+
- **Logging style:** training scripts rely on `ml_log` for metrics (`metrics.jsonl`, optional W&B) and `logtree` for HTML transcripts. When adding new metrics, follow the `ml_log.log_metrics` shape conventions (`str → float/int/str`).
|
|
31
|
+
- **Safe iteration:** functions like `safezip`, `timed`, and `scope` (tracing) are widely used; follow those patterns instead of hand-writing logging/zip logic.
|
|
32
|
+
|
|
33
|
+
## Data & Rendering
|
|
34
|
+
- Rendering is the bridge between chat-style data and token sequences. `renderers.py` defines `Renderer.build_supervised_example`, `build_generation_prompt`, `get_stop_sequences`, and `parse_response`. Use `TrainOnWhat` to switch between “last assistant only” vs “all assistant messages” vs “prompt distillation” setups.
|
|
35
|
+
- For supervised chat datasets, reuse `SupervisedDatasetFromHFDataset`, `StreamingSupervisedDatasetFromHFDataset`, or `FromConversationFileBuilder`. They expect HF rows with `messages` arrays; map them through a renderer and optional max length.
|
|
36
|
+
- RL data is organized by dimensions `_P` (problems), `_G` (group members / rollouts per problem), `_T` (tokens), `_D` (datums). Keep arrays ragged-aware, and document shape suffixes when introducing new tensors.
|
|
37
|
+
|
|
38
|
+
## Training Playbooks
|
|
39
|
+
### Supervised Learning
|
|
40
|
+
- **Main loop:** `tinker_cookbook/supervised/train.py`. It pipelines batches by submitting `forward_backward_async` and `optim_step_async` immediately, storing futures inside `SubmittedBatch`. Metrics/logging run through `ml_log`, stdout previews via `display.colorize_example`.
|
|
41
|
+
- **Configs:** include LR schedule (`linear` multiplier via `compute_schedule_lr_multiplier`), LoRA rank, checkpoint cadence (`save_every`), eval cadence (`eval_every`, `infrequent_eval_every`), and dataset builders.
|
|
42
|
+
- **Hyperparameters:** Call `hyperparam_utils.get_lr(model_name)`; LR is independent of LoRA rank.
|
|
43
|
+
- **Prompt distillation:** see `tinker_cookbook/recipes/prompt_distillation`. Renderers assign weight=0 to context instructions and weight=1 to distilled responses.
|
|
44
|
+
- **Sweeps:** `tinker_cookbook/recipes/sl_loop.py` doubles as a sweep harness (log-scale grid, aggregate from `metrics.jsonl`). Keep these scripts runnable; they double as docs tests.
|
|
45
|
+
|
|
46
|
+
### Reinforcement Learning
|
|
47
|
+
- **Main loop:** `tinker_cookbook/rl/train.py`. Steps: build dataset (`RLDatasetBuilder`), get groups of envs (`EnvGroupBuilder`), collect rollouts (`do_group_rollout`), compute advantages (`compute_advantages`), assemble datums (`assemble_training_data`), run `forward_backward_async(..., loss_fn="importance_sampling" | "ppo")`, apply `optim_step_async`.
|
|
48
|
+
- **Policies:** implement the `TokenCompleter` interface. Training loops usually instantiate `TinkerTokenCompleter`, but tests may stub a completer.
|
|
49
|
+
- **Hyperparameters:** key knobs are `batch_size` vs `group_size`, `num_substeps` (similar to PPO epochs but still single-pass), and advanced configs:
|
|
50
|
+
- `StreamMinibatchConfig` overlaps sampling with training (still on-policy).
|
|
51
|
+
- `AsyncConfig` enables bounded off-policy lag (“off-by-K”). Monitor KL metrics (`compute_kl_sample_train`, `compute_post_kl`) plus reward trends to make sure drift stays manageable.
|
|
52
|
+
- **Environments:** `Env`, `EnvGroupBuilder`, and `RLDataset` live in `tinker_cookbook/rl/types.py`. Groups make it easy to compute pairwise rewards (preference models) or multi-agent games. Example: `recipes/multiplayer_rl/twenty_questions`.
|
|
53
|
+
- **Recipes:** `rl_basic.py` demonstrates default metrics: reward, entropy, `ac_tokens_per_turn`, format rate, KL approximations, and progress/time tokens.
|
|
54
|
+
|
|
55
|
+
### Preferences & Distillation
|
|
56
|
+
- **DPO:** `tinker_cookbook/preference/train_dpo.py` (CLI in `recipes/preference/train.py`). Important knobs: dataset builder (choose whichever comparison corpus you need), `renderer_name`, `dpo_beta`, LR (often 1e-5 to 1e-6). Metrics like `dpo_loss`, `accuracy`, `margin`, `chosen/rejected_reward` come from the implicit reward model.
|
|
57
|
+
- **RLHF pipeline:** `recipes/preference/rlhf/rlhf_pipeline.py` walks through the standard three stages (supervised warm-start, preference model, RL self-play using pairwise comparisons).
|
|
58
|
+
- **Distillation:** `distillation/train_on_policy.py` handles on-policy or SFT-style distillation; combine with `renderers`, `hyperparam_utils`, and `sampling_client` utilities.
|
|
59
|
+
|
|
60
|
+
### Evaluations & Sampling
|
|
61
|
+
- Inline evaluators implement either `TrainingClientEvaluator` or `SamplingClientEvaluator`. Training loops accept builder lists (`evaluator_builders`, `infrequent_evaluator_builders`). Inspect AI integration is in `eval/inspect_evaluators.py` and `eval/run_inspect_evals.py`.
|
|
62
|
+
- Sampling clients come from `training_client.save_weights_and_get_sampling_client(name=...)`. To export weights, use `RestClient.get_checkpoint_archive_url_from_tinker_path`.
|
|
63
|
+
|
|
64
|
+
## Async & Performance
|
|
65
|
+
- Worker pools advance in ~10s clock cycles. Submit `forward_backward_async` and `optim_step_async` back-to-back, then await both futures to keep them on the same cycle.
|
|
66
|
+
- Pipeline batches: enqueue the next `forward_backward_async` before awaiting the previous batch’s results so there’s always work when a clock cycle begins.
|
|
67
|
+
- Use async everywhere performance matters (RL loops, production SFT). The synchronous helpers exist only for pedagogy (e.g., `recipes/sl_loop.py`) and small tests.
|
|
68
|
+
|
|
69
|
+
- Training CLIs (`recipes/*/*.py`) call `cli_utils.check_log_dir` at startup to decide whether to delete, resume, or prompt about an existing `log_path`. This convention is specific to training/eval entry points and is wired through `chz` CLI configs so users can choose behaviors (`delete`, `resume`, `ask`, `raise`).
|
|
70
|
+
- `ml_log` handles structured logging: metrics stream to stdout, `metrics.jsonl`, and optionally Weights & Biases (`wandb_project`, `wandb_name`). Use `logtree` scopes for HTML transcripts when you need qualitative review of rollouts.
|
|
71
|
+
- `checkpoint_utils.save_checkpoint_async` writes `{log_path}/checkpoints.jsonl` entries for state and/or sampler checkpoints. `get_last_checkpoint` filters by key (`state_path`, `sampler_path`) before resuming.
|
|
72
|
+
- After each optimizer step sequence, call `save_weights_for_sampler[_async]` (or `save_weights_and_get_sampling_client`) and then create a **new** sampling client. Existing `SamplingClient`s do not automatically pick up fresh weights, so evaluators must use the newly returned client handle.
|
|
73
|
+
|
|
74
|
+
## Testing & Troubleshooting
|
|
75
|
+
- Lightweight checks: `pytest tinker_cookbook/tests/test_renderers.py`, `pytest tinker_cookbook/tests/test_utils.py`. `tests/smoke_tests.py` spins up real training runs (needs HF + API access).
|
|
76
|
+
- Example data lives in `tinker_cookbook/example_data/` (e.g., `conversations.jsonl`, `multilingual.txt`) and mirrors the formats documented in `training-sampling`.
|
|
77
|
+
- If you hit auth/network issues, double-check `TINKER_API_KEY`, ensure your environment can reach the Tinker service, and verify dependencies (`pip show tinker`).
|
|
78
|
+
- Resize datasets/batch sizes in recipes when debugging; `dataset_builder` objects usually accept `n_batches`, `batch_size`, and `group_size` fields so you can shrink workloads.
|
|
79
|
+
|
|
80
|
+
## Common Pitfalls
|
|
81
|
+
- **LoRA LR mismatch:** LoRA typically needs learning rates tens of times higher than full fine-tuning. Use `hyperparam_utils.get_lr` or the LR formula above. Rank does not change the optimal LR.
|
|
82
|
+
- **Renderer/tokenizer mismatch:** The renderer determines BOS/EOS tokens and stop sequences. Pair `renderer_name` with the tokenizer family your model expects (`llama3`, `qwen3`, `role_colon`, etc.). Otherwise loss weights and sampling stops will be wrong.
|
|
83
|
+
- **Loss inputs wrong shape:** Stick to helper functions so `loss_fn_inputs["weights"]`, `["target_tokens"]`, `["advantages"]`, etc., end up as `TensorData` with the right dtype. Custom DPO/RL objectives often fail here.
|
|
84
|
+
- **Async gaps:** Awaiting `forward_backward` before submitting `optim_step` wastes two extra clock cycles. Submit both first, then await results.
|
|
85
|
+
- **Sampler desync:** Saving weights isn’t enough; always request a new sampling client (e.g., via `save_weights_and_get_sampling_client`) before running evals so the client reflects the latest checkpoint.
|
|
86
|
+
- **Group semantics:** RL advantages are centered within each group.
|
|
87
|
+
- **DPO beta / LR:** Too large a beta or LR makes the policy collapse; start with `dpo_beta=0.1`, LR≈1e-5, and watch `accuracy` + `margin` trends.
|
|
88
|
+
|
|
89
|
+
## Quick Reference Commands
|
|
90
|
+
1. **Environment setup:**
|
|
91
|
+
```bash
|
|
92
|
+
python -m venv .venv
|
|
93
|
+
source .venv/bin/activate
|
|
94
|
+
pip install tinker
|
|
95
|
+
pip install -e .[dev]
|
|
96
|
+
# Set once per shell if needed
|
|
97
|
+
export TINKER_API_KEY=sk-...
|
|
98
|
+
```
|
|
99
|
+
2. **Basic SFT run (default recipe):**
|
|
100
|
+
```bash
|
|
101
|
+
python -m tinker_cookbook.recipes.sl_basic \
|
|
102
|
+
model_name=meta-llama/Llama-3.2-1B \
|
|
103
|
+
log_path=/tmp/tinker-examples/sl_basic
|
|
104
|
+
```
|
|
105
|
+
3. **Custom JSONL SFT (bring your own conversations file):**
|
|
106
|
+
```bash
|
|
107
|
+
python -m tinker_cookbook.recipes.sl_basic \
|
|
108
|
+
dataset_path=/path/to/conversations.jsonl \
|
|
109
|
+
renderer_name=role_colon \
|
|
110
|
+
train_on_what=all_assistant_messages \
|
|
111
|
+
log_path=/tmp/tinker-examples/sl_jsonl
|
|
112
|
+
```
|
|
113
|
+
4. **RL basic run (default reward):**
|
|
114
|
+
```bash
|
|
115
|
+
python -m tinker_cookbook.recipes.rl_basic \
|
|
116
|
+
model_name=meta-llama/Llama-3.1-8B \
|
|
117
|
+
log_path=/tmp/tinker-examples/rl_basic
|
|
118
|
+
```
|
|
119
|
+
5. **DPO training (generic preference dataset):**
|
|
120
|
+
```bash
|
|
121
|
+
python -m tinker_cookbook.recipes.preference.train \
|
|
122
|
+
log_path=/tmp/dpo-run \
|
|
123
|
+
model_name=meta-llama/Llama-3.2-1B \
|
|
124
|
+
dataset=<preference_dataset> renderer_name=role_colon \
|
|
125
|
+
learning_rate=1e-5 dpo_beta=0.1
|
|
126
|
+
```
|
|
127
|
+
6. **Inspect eval after training:**
|
|
128
|
+
```bash
|
|
129
|
+
python -m tinker_cookbook.eval.run_inspect_evals \
|
|
130
|
+
model_path=tinker://YOUR_MODEL \
|
|
131
|
+
model_name=meta-llama/Llama-3.2-1B \
|
|
132
|
+
tasks=<inspect_task_id> \
|
|
133
|
+
renderer_name=role_colon
|
|
134
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
This 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.
|
|
4
|
+
|
|
5
|
+
We welcome PR contributions after our private beta is over. If you have any feedback, please email us at tinker@thinkingmachines.ai.
|
|
6
|
+
|
|
7
|
+
## Organization of training scripts
|
|
8
|
+
|
|
9
|
+
We're designing the codebase with the following goals:
|
|
10
|
+
|
|
11
|
+
1. Low barrier to entry: it should be dead simple to run something and see numbers go up.
|
|
12
|
+
2. Extensible: it should be possible to pass in custom datasets and evals and control all the hyperparameters.
|
|
13
|
+
3. Science-friendly: it should be easy to run sweeps, and analyze the results.
|
|
14
|
+
|
|
15
|
+
To achieve this, we'll use the following structure around training scripts:
|
|
16
|
+
|
|
17
|
+
- There's a main training function, such as [rl/train.py](tinker_cookbook/rl/train.py) or [supervised/train.py](tinker_cookbook/supervised/train.py), which contains the main loop.
|
|
18
|
+
- This function contains a detailed config object (`Config`), which isn't constructable from the command line.
|
|
19
|
+
- The config contains members that specify things like datasets and evals. However, these should be chz configs (with a `.build` method that constructs the actual object) or callables (we recommend using functools.partial). This way, the config is serializable, which is useful for sweeps.
|
|
20
|
+
- There are launch scripts that assemble training configs (e.g., [recipes/math_rl/train.py](tinker_cookbook/recipes/math_rl/train.py)), which construct a smaller config object (`CLIConfig`) from the command line.
|
|
21
|
+
|
|
22
|
+
## Async
|
|
23
|
+
|
|
24
|
+
Async is very useful for RL, where it allows us to make many queries in parallel (e.g., sampling calls). For all of the interfaces used in RL (such as the `Env` class), all the methods that take nontrivial amounts of time should be async. For some of the other code, such as [recipes/sl_loop.py](tinker_cookbook/recipes/sl_loop.py), we've chosen not to use async methods, just to make it more beginner-friendly, as many python programmers are not familiar with async.
|
|
25
|
+
|
|
26
|
+
## Typing
|
|
27
|
+
|
|
28
|
+
Please use typing wherever possible; avoid `Any` and `type: ignore`; prefer casting. However, avoid using convoluted generics or writing code that's much more verbose just to satisfy the type checker. Prefer using single types over union types.
|
|
29
|
+
|
|
30
|
+
## Classes
|
|
31
|
+
|
|
32
|
+
There are a lot of different classes, which might make the code feel less approachable. However, they follow *the builder pattern*, and the code should be less confusing when you know the pattern.
|
|
33
|
+
|
|
34
|
+
We can illustrate the pattern with the two main examples:
|
|
35
|
+
|
|
36
|
+
- A `SupervisedDatasetBuilder` is a configuration object which builds a `SupervisedDataset`.
|
|
37
|
+
- An `RLDatasetBuilder` is a configuration object which builds an `RLDataset`, which generates batches of `EnvGroupBuilder` objects, which each generate a group of `Env` objects.
|
|
38
|
+
|
|
39
|
+
Here, the `SupervisedDatasetBuilder`, `RLDatasetBuilder`, and `EnvGroupBuilder` are all configuration objects, which have a `__call__` method that builds another object. You can see these objects in [supervised/types.py](tinker_cookbook/supervised/types.py) and [rl/types.py](tinker_cookbook/rl/types.py).
|
|
40
|
+
|
|
41
|
+
In general, we use a lot of configuration objects, with a `__call__` method that returns a heavyweight object (like a dataset). We use `chz` for the configuration objects -- it's similar to a dataclass but with some extra features that are nice for configs. We use either dataclasses or regular python classes for the heavyweight objects.
|
|
42
|
+
|
|
43
|
+
## Envs
|
|
44
|
+
|
|
45
|
+
An `Env` is an RL environment. For those with an RL background, it roughly corresponds to an MDP or a POMDP, however we use in more general cases (such as multi-agent settings) that don't strictly correspond to the MDP/POMDP formalism. It's roughly analogous the concept of an Env in OpenAI Gym, but unlike OpenAI Gym, we don't have a `reset` method; rather, the env should be discarded after a rollout. Any shared resources should be maintained by whatever object is creating the envs.
|
|
46
|
+
|
|
47
|
+
The `Env`s are created by `EnvGroupBuilder`s. The group of envs returned by `EnvGroupBuilder` have something in common; either they correspond to the same task (in which case we can use this information for variance reduction, as in GRPO, which centers per group); or, we can use the group to define a multi-agent environment.
|
|
48
|
+
|
|
49
|
+
- One common multi-agent environment is where we use a pairwise preference model to compare pairs of completions.
|
|
50
|
+
- We can also use the group to define a two-player game. Some two player games such as tic-tac-toe are currently supported through the [text_arena](tinker_cookbook/recipes/multiplayer_rl/text_arena/env.py) environments.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Notation
|
|
54
|
+
|
|
55
|
+
We'll use subscripts to indicate the shapes of objects. For example, `tokens_P_G_T` indicates a three-dimensional array of tokens, with `P` problems, `G` groups, and `T` tokens per groups, so `tokens_P_G_T[p][g][t]` should refer to a single token. In many cases, the arrays will be ragged. E.g., the `T` axis will have different lengths for different `(p,g)`. Sometimes, a given dimension will be flattened from two dimensions. If we write `tokens_PG_T`, that means that we have a two dimensional array, where the 0th dimension is flattened from the `P` and `G` dimensions.
|
|
56
|
+
|
|
57
|
+
### Common Dimension Names
|
|
58
|
+
|
|
59
|
+
Here are the standard dimension subscripts used throughout the codebase:
|
|
60
|
+
|
|
61
|
+
- `_D`: Data/Datum dimension (for training data items)
|
|
62
|
+
- `_G`: Group dimension (for multiple attempts/rollouts of the same problem)
|
|
63
|
+
- `_P`: Problem dimension (for different problems/prompts)
|
|
64
|
+
- `_T`: Token/Time dimension (for sequences)
|
|
65
|
+
|
|
66
|
+
The relationship between dimensions in RL:
|
|
67
|
+
- A batch contains multiple problems (`_P`)
|
|
68
|
+
- Each problem spawns multiple attempts/environments (`_G`), forming a group
|
|
69
|
+
- Each attempt produces one trajectory
|
|
70
|
+
- Advantages are normalized within each group (across the `_G` dimension)
|
|
71
|
+
|
|
72
|
+
Examples:
|
|
73
|
+
- `env_group_builders_P`: A list of environment builders, one per problem
|
|
74
|
+
- `trajectories_G`: Multiple trajectories from attempts at the same problem
|
|
75
|
+
- `rewards_G`: Rewards for each attempt within a group
|
|
76
|
+
- `tokens_P_G_T`: Tokens with problem, group, and time dimensions
|
|
77
|
+
- `data_D`: A list of training data items
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Thinking Machines Lab
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|