Skip to main content

core.HasMask

core.HasMask()

Which output positions count, e.g. non-padding tokens.

False positions change neither the data fit nor the curvature.

Methods

Name Description
mask The positions that count.

mask

core.HasMask.mask(f, inputs, /)

The positions that count.

Parameters

Name Type Description Default
f Outputs Model outputs for a batch. required
inputs Inputs The batch’s inputs. required

Returns

Name Type Description
Tensor | None A bool tensor shaped like log_prob’s output, [N, *positions], True where a position counts. None when every position counts.