typedecide.training.config¶
TrainConfig and the fixed policy constants that are written into every manifest. Field-by-field guide: Configure training.
typedecide.training.config
¶
The full description of a fine-tuning run, in one frozen object.
Everything that changes the weights lives here, so TrainConfig.to_manifest() plus the
base model id and the dataset fingerprint is enough to re-run a job. Values that are
really fixed policy rather than knobs (the LoRA target modules, the schedule) are module
constants, and they are still written into the manifest -- a manifest that only records
the fields someone happened to expose is a manifest you cannot reproduce from.
LORA_TARGET_MODULES
module-attribute
¶
LORA_TARGET_MODULES: tuple[str, ...] = (
"q_proj",
"k_proj",
"v_proj",
"o_proj",
"gate_proj",
"up_proj",
"down_proj",
)
TrainConfig
dataclass
¶
TrainConfig(
base_model: str,
output_dir: Path,
epochs: float = 2.0,
batch_size: int = 4,
grad_accum: int = 4,
learning_rate: float = 0.0001,
lora_rank: int = 16,
lora_alpha: int | None = None,
lora_dropout: float = 0.05,
max_length: int = 1024,
seed: int = 0,
randomise_option_order: bool = True,
)
One fine-tuning job.
output_dir receives the LoRA adapter, the tokenizer and manifest.json.
lora_alpha defaults to twice the rank when left unset; read the resolved value
from effective_lora_alpha, never from the field.
effective_lora_alpha
property
¶
The alpha actually handed to peft: twice the rank unless one was given.
effective_batch_size
property
¶
Decisions per optimiser step, which is the number that shapes the run.
from_file
classmethod
¶
from_file(path: str | Path) -> TrainConfig
Read a config from YAML or JSON.
The format is taken from the suffix; anything else is tried as JSON and then as
YAML. A relative output_dir is resolved against the config file's own
directory, so a config can be moved with its run without being rewritten.
Source code in src/typedecide/training/config.py
from_mapping
classmethod
¶
from_mapping(
payload: Mapping[str, Any],
*,
base_dir: Path | None = None
) -> TrainConfig
Build a config from an already-parsed mapping, naming every unusable key.
Source code in src/typedecide/training/config.py
to_manifest
¶
A JSON-safe, fully resolved record of this config.
Resolved means no None standing for "work it out later": lora_alpha is the
number peft receives, and the fixed policy constants are included so a manifest
written by one release still describes the run if a later one changes them.