vllm.model_executor.models.roberta
RobertaClassificationHead
¶
Bases: Module
Head for sentence-level classification tasks.
Source code in vllm/model_executor/models/roberta.py
__init__
¶
RobertaEmbedding
¶
Bases: Module
Source code in vllm/model_executor/models/roberta.py
position_embeddings
instance-attribute
¶
position_embeddings = Embedding(
max_position_embeddings,
hidden_size,
padding_idx=padding_idx,
)
token_type_embeddings
instance-attribute
¶
token_type_embeddings = Embedding(
type_vocab_size, hidden_size
)
word_embeddings
instance-attribute
¶
word_embeddings = VocabParallelEmbedding(
vocab_size, hidden_size
)
__init__
¶
Source code in vllm/model_executor/models/roberta.py
forward
¶
forward(
input_ids: Tensor,
seq_lens: Tensor,
position_ids: Tensor,
token_type_ids: Optional[Tensor] = None,
) -> Tensor
Source code in vllm/model_executor/models/roberta.py
RobertaEmbeddingModel
¶
Bases: BertEmbeddingModel
A model that uses Roberta to provide embedding functionalities.
This class encapsulates the BertModel and provides an interface for embedding operations and customized pooling functions.
Attributes:
Name | Type | Description |
---|---|---|
model |
An instance of BertModel used for forward operations. |
|
_pooler |
An instance of Pooler used for pooling operations. |
Source code in vllm/model_executor/models/roberta.py
_build_model
¶
_build_model(
vllm_config: VllmConfig, prefix: str = ""
) -> Union[BertModel, BertWithRope]
Source code in vllm/model_executor/models/roberta.py
load_weights
¶
Source code in vllm/model_executor/models/roberta.py
RobertaForSequenceClassification
¶
Bases: Module
, SupportsCrossEncoding
, SupportsV0Only
A model that uses Roberta to provide embedding functionalities.
This class encapsulates the BertModel and provides an interface for embedding operations and customized pooling functions.
Attributes:
Name | Type | Description |
---|---|---|
roberta |
An instance of BertModel used for forward operations. |
|
_pooler |
An instance of Pooler used for pooling operations. |
Source code in vllm/model_executor/models/roberta.py
_pooler
instance-attribute
¶
_pooler = ClassifierPooler(
model_config, pooling=CLSPool(), classifier=classifier
)
jina_to_vllm_mapper
class-attribute
instance-attribute
¶
jina_to_vllm_mapper = WeightsMapper(
orig_to_new_substr={
"emb_ln": "embeddings.LayerNorm",
"layers": "layer",
"mixer.Wqkv": "attention.self.qkv_proj",
"mixer.out_proj": "attention.output.dense",
"norm1": "attention.output.LayerNorm",
"mlp.fc1": "intermediate.dense",
"mlp.fc2": "output.dense",
"norm2": "output.LayerNorm",
}
)
roberta
instance-attribute
¶
roberta = BertModel(
vllm_config=vllm_config,
prefix=maybe_prefix(prefix, "bert"),
embedding_class=RobertaEmbedding,
add_pooling_layer=False,
)
__init__
¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
Source code in vllm/model_executor/models/roberta.py
forward
¶
forward(
input_ids: Optional[Tensor],
positions: Tensor,
intermediate_tensors: Optional[
IntermediateTensors
] = None,
inputs_embeds: Optional[Tensor] = None,
token_type_ids: Optional[Tensor] = None,
) -> Tensor
Source code in vllm/model_executor/models/roberta.py
load_weights
¶
pooler
¶
pooler(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Optional[PoolerOutput]
create_position_ids_from_input_ids
¶
Replace non-padding symbols with their position numbers.
Position numbers begin at padding_idx+1. Padding symbols
are ignored. This is modified from fairseq's utils.make_positions
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
torch.Tensor x: |
required |
Returns: torch.Tensor