nemo_automodel.components.loss.utils#
Module Contents#
Functions#
Return the model’s LM-head module, if one can be found. |
|
Return the model’s LM-head weight, materializing DTensor weights when needed. |
|
Return the final hidden-states tensor from an HF-like model output. |
|
Calculate the loss. |
API#
- nemo_automodel.components.loss.utils._get_lm_head_module(
- model: torch.nn.Module,
Return the model’s LM-head module, if one can be found.
Local copy of
components.utils.model_utils.get_lm_head_moduleto keepcomponents/loss/import-independent fromcomponents/utils/(see theComponents must not import each otherimport-linter contract).
- nemo_automodel.components.loss.utils._get_lm_head_weight(model: torch.nn.Module) torch.Tensor#
Return the model’s LM-head weight, materializing DTensor weights when needed.
- model_output: Any,
Return the final hidden-states tensor from an HF-like model output.
Local copy of
components.training.model_output_utils.get_final_hidden_statesto keepcomponents/loss/import-independent fromcomponents/training/.
- nemo_automodel.components.loss.utils.calculate_loss(loss_fn, **kwargs) torch.Tensor#
Calculate the loss.
- Parameters:
loss_fn – Loss function.
**kwargs – Keyword arguments for the loss function.
- Returns:
The loss.