mixle.task.tune module¶
Search a student recipe with mixle.doe – find a small model that matches the teacher for the least compute.
Distillation has knobs (feature width, hidden size, epochs, learning rate) that trade fidelity against training
cost. Rather than grid-search them, tune_recipe() runs GP Bayesian optimization (mixle.doe.minimize)
over the recipe space, distilling and scoring a handful of candidates and homing in on the best. The objective
is held-out agreement with the teacher, optionally minus a compute penalty (cost_weight) so the search
prefers the cheapest recipe that still matches – the “minimize train time” pillar made concrete. Returns the
re-distilled winner as a callable TaskModel plus the full search history.
The recipe space is a few interpretable axes with sensible defaults; override space to widen or pin them.
- class RecipeSpace(dim_choices=(128, 256, 512, 1024), hidden_range=(16, 128), epochs_range=(50, 400), log10_lr_range=(-3.0, -1.0), n=4)[source]
Bases:
objectThe tunable axes of a distillation recipe and how a unit-cube point decodes into concrete knobs.
- Parameters:
- n: int = 4
- cost(recipe)[source]
Relative training cost of a recipe in [0, 1] (params x steps, normalized by the space’s max).
- class TuneResult(model, recipe, agreement, score, cost, history=None)[source]
Bases:
objectThe outcome of a recipe search: the winning model, its recipe and scores, and the full BO history.
- Parameters:
- model: TaskModel
- agreement: float
- score: float
- cost: float
- history: Any = None
- tune_recipe(teacher, train_texts, val_texts, *, labels=None, space=None, n_init=4, n_iter=8, cost_weight=0.0, seed=0, task='')[source]
Bayesian-optimize the distillation recipe; return the best re-distilled
TaskModel.Maximizes held-out
agreement(student, teacher, val_texts)minuscost_weight * relative_train_cost. Setcost_weight > 0to prefer the cheapest recipe that still matches the teacher.teacheris called once per candidate onval_texts(cached across the search) and once per candidate ontrain_texts.