Skip to content

dew.objectives

NameSummary
AuxEverything a loss returns besides its statistics. Documented in dew.objectives.base.
DistillationObjectiveMix the student’s own loss with a frozen teacher’s soft targets.
EMASpecSay which leaves the EMA copy tracks, and how fast it follows them. Documented in dew.objectives.base.
MeanCarry a scalar sum together with the mass it is averaged over. Documented in dew.objectives.base.
ObjectiveDefine what is being learned: the parameters, the loss, what evaluation produces. Documented in dew.objectives.base.
PredictionHold what a token objective scored a batch with, for a teacher to compare. Documented in dew.objectives.base.
StepWhat the trainer tells an objective about the current step. Documented in dew.objectives.base.
mean_lossReduce a shared-denominator estimator, including empty support. Documented in dew.objectives.base.
scalar_lossEvaluate and reduce canonical statistics for direct JAX differentiation. Documented in dew.objectives.base.

class source

class DistillationObjective(
student: Objective[Loss, Effects],
teacher: Objective[Loss, Effects],
*,
alpha: Weight = 0.5,
temperature: Weight = 1.0,
features: Sequence[tuple[int, int]] = (),
beta: Weight = 0.0,
feature_loss: FeatureLoss = 'cosine',
)

Mix the student’s own loss with a frozen teacher’s soft targets.

def held_variables() -> Variables | None

Return the student’s held tree, if any, with the teacher’s under teacher.

def init(key: jax.Array, variables: Variables | None = None) -> Variables
def student_variables(params: Variables) -> Variables

Cut the student’s own tree out of the whole.

That is what the student’s methods read, and what a distilled checkpoint hands on to a plain student run.

def loss(params: Variables, batch: Batch, step: Step) -> tuple[Mean, Aux[Effects]]
def apply_effects(variables: Variables, effects: Effects) -> Variables
def evaluate(params: Variables, batch: Batch, step: Step) -> Artifacts | None
def preview(
params: Variables,
batch: Batch,
step: Step,
*,
scored: Artifacts | None = None,
) -> Artifacts | None
def pipeline(state: TrainState, *, ema: bool = True)

The student as its inference task; the teacher stays behind.