nemo_automodel.components.models.llama_bidirectional.model
nemo_automodel.components.models.llama_bidirectional.model
Llama Bidirectional model for embedding and retrieval tasks.
This module provides a bidirectional variant of Llama that is auto-discovered by the ModelRegistry via the ModelClass export.
To add support for other backbones (e.g., Qwen2, Mistral), create a similar module in a new directory (e.g., qwen2_bidirectional/) with its own ModelClass export.
Module Contents
Classes
Functions
Data
API
Bases: LlamaConfig
Configuration class for LlamaBidirectionalModel.
Extends LlamaConfig with additional parameters for bidirectional attention and pooling configurations.
Bases: LlamaPreTrainedModel
Llama Bidirectional Model with a sequence classification/regression head.
This model adds a classification head on top of the bidirectional Llama model and includes configurable pooling strategies.
Bases: LlamaModel
Llama Model with bidirectional attention.
This model removes causal masking from all attention layers, allowing tokens to attend to all other tokens in the sequence. This is useful for embedding and retrieval tasks where bidirectional context is beneficial.
The model is auto-discovered by ModelRegistry via the ModelClass export, enabling it to be loaded via NeMoAutoModelBiEncoder.from_pretrained().
Pool hidden states using the specified pooling method.
Register bidirectional models with HuggingFace Auto classes.
This is needed so that AutoModel.from_config(LlamaBidirectionalConfig) works inside LlamaForSequenceClassification.init.