nemo_automodel.components.loss.utils
nemo_automodel.components.loss.utils
Module Contents
Functions
API
Return the final hidden-states tensor from an HF-like model output.
Local copy of components.training.model_output_utils.get_final_hidden_states
to keep components/loss/ import-independent from components/training/.
Return the model’s LM-head module, if one can be found.
Local copy of components.utils.model_utils.get_lm_head_module to keep
components/loss/ import-independent from components/utils/ (see the
Components must not import each other import-linter contract).
Return the model’s LM-head weight, materializing DTensor weights when needed.
Calculate the loss.
Parameters:
loss_fn
Loss function.
**kwargs
Keyword arguments for the loss function.
Returns: torch.Tensor
The loss.