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.
日本語の概要は準備中です。原文の説明を表示しています。
Reference for Tinker SDK types — Datum, ModelInput, TensorData, SamplingParams, response types, error types, and helper functions. Use when the user needs to build training data, construct model inputs, understand response objects, or handle errors.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Quick reference for the core types used throughout the Tinker SDK and cookbook.
Read docs/api-reference/types.md for the complete type reference.
Datum
├── model_input: ModelInput (list of chunks)
│ ├── EncodedTextChunk (token IDs)
│ └── ImageChunk (vision inputs)
└── loss_fn_inputs: dict[str, TensorData]
└── TensorData (numpy/torch wrapper)
from tinker import ModelInput
mi = ModelInput.from_ints([1, 2, 3, 4, 5]) # From token list
tokens = mi.to_ints() # Back to list
length = mi.length # Token count (property)
mi2 = mi.append(chunk) # Append a chunk
mi3 = mi.append_int(42) # Append a single token
mi_empty = ModelInput.empty() # Empty input
from tinker import TensorData
td = TensorData.from_numpy(np.array([1.0, 0.0, 1.0])) # From numpy
td = TensorData.from_torch(torch.tensor([1.0, 0.0])) # From torch
arr = td.to_numpy() # Back to numpy
tensor = td.to_torch() # Back to torch
lst = td.tolist() # Back to list
# Fields: data (flat list), dtype ("int64"|"float32"), shape (optional)
from tinker import Datum, ModelInput, TensorData
datum = Datum(
model_input=ModelInput.from_ints(tokens),
loss_fn_inputs={"weights": TensorData.from_numpy(weights_array)},
)
from tinker import SamplingParams
params = SamplingParams(
max_tokens=256, # Max generation length
temperature=1.0, # Sampling temperature
top_k=50, # Top-K sampling (-1 = no limit)
top_p=0.95, # Nucleus sampling
stop=["<|eot_id|>"], # Stop sequences (strings or token IDs)
seed=42, # Reproducible seed
)
from tinker import AdamParams
adam = AdamParams(
learning_rate=2e-4,
beta1=0.9, # Gradient moving average
beta2=0.95, # Gradient squared moving average
eps=1e-12, # Numerical stability
weight_decay=0.0, # Decoupled weight decay
grad_clip_norm=1.0, # Global gradient norm clipping (0.0 = disabled)
)
from tinker import LoraConfig
config = LoraConfig(
rank=32, # LoRA rank
seed=None, # Initialization seed
train_mlp=True, # Train MLP layers
train_attn=True, # Train attention layers
train_unembed=True, # Train unembedding layer
)
Returned by forward_backward() and forward():
result = tc.forward_backward(data=batch, loss_fn="cross_entropy")
result.metrics # dict[str, float] — training metrics (includes loss)
result.loss_fn_outputs # list[LossFnOutput] — per-sample outputs
result.loss_fn_output_type # str — loss output class name
Returned by sample():
response = sc.sample(prompt=mi, num_samples=4, sampling_params=params)
response.sequences # list[SampledSequence]
response.prompt_logprobs # Optional[list[Optional[float]]] — per-prompt-token logprobs
response.topk_prompt_logprobs # Optional[list[Optional[list[tuple[int, float]]]]] — top-K
for seq in response.sequences:
seq.tokens # list[int] — generated token IDs
seq.logprobs # Optional[list[float]] — per-token logprobs
seq.stop_reason # StopReason: "length" | "stop"
OptimStepResponse — confirms parameter updateSaveWeightsResponse — path: str (tinker:// path to saved weights)LoadWeightsResponse — confirms loaded weightsGetInfoResponse — model_data: ModelData (model_name, lora_rank, tokenizer_id)GetServerCapabilitiesResponse — supported_models: list[SupportedModel]WeightsInfoResponse — base_model, lora_rank, is_lora, train_mlp, train_attn, train_unembedfrom tinker import TrainingRun, Checkpoint, CheckpointType, ParsedCheckpointTinkerPath
# TrainingRun — metadata about a training run
run.training_run_id # str
run.base_model # str
run.is_lora # bool
run.lora_rank # Optional[int]
run.last_checkpoint # Optional[Checkpoint]
run.user_metadata # Optional[dict[str, str]]
# Checkpoint — metadata about a saved checkpoint
ckpt.checkpoint_id # str
ckpt.checkpoint_type # CheckpointType: "training" | "sampler"
ckpt.tinker_path # str (tinker:// path)
ckpt.size_bytes # Optional[int]
ckpt.public # bool
ckpt.expires_at # Optional[datetime]
# Parse a tinker:// path
parsed = ParsedCheckpointTinkerPath.from_tinker_path("tinker://run-id/weights/ckpt-id")
parsed.training_run_id # str
parsed.checkpoint_type # CheckpointType
parsed.checkpoint_id # str
All exceptions inherit from tinker.TinkerError:
APIError → APIStatusError: BadRequestError (400), AuthenticationError (401), PermissionDeniedError (403), NotFoundError (404), ConflictError (409), UnprocessableEntityError (422), RateLimitError (429), InternalServerError (500+)APIConnectionError, APITimeoutError, APIResponseValidationErrorRequestFailedError — async request failure with error categoryUse these instead of manual Datum construction:
tinker_cookbook.supervised.data.conversation_to_datum(messages, renderer, max_length, train_on_what) — full SL pipelinetinker_cookbook.supervised.common.datum_from_model_input_weights(model_input, weights, max_length) — from ModelInput + weightsrenderer.build_supervised_example(messages) — returns (ModelInput, weights)TensorData wraps arrays — don't pass raw numpy/torch directly to loss_fn_inputsModelInput.from_ints() expects a flat list of integers, not nested listsModelInput.length is a property, not a methodtinker.RateLimitError in production code with exponential backoffまだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
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.
日本語の概要は準備中です。原文の説明を表示しています。