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 ¶
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
__init__ ¶
__init__(*, vllm_config: VllmConfig, prefix: str = '')
_build_model ¶
_build_model(
vllm_config: VllmConfig, prefix: str = ""
) -> Union[BertModel, BertWithRope]
Source code in vllm/model_executor/models/roberta.py
forward ¶
forward(
input_ids: Tensor,
positions: Tensor,
intermediate_tensors: Optional[
IntermediateTensors
] = None,
inputs_embeds: Optional[Tensor] = None,
) -> Tensor
Source code in vllm/model_executor/models/roberta.py
load_weights ¶
Source code in vllm/model_executor/models/roberta.py
RobertaForSequenceClassification ¶
Bases: Module
, SupportsCrossEncoding
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
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
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",
}
)
pooler instance-attribute
¶
pooler = DispatchPooler(
{
"encode": for_encode(pooler_config),
"classify": ClassifierPooler(
pooling=CLSPool(),
classifier=classifier,
act_fn=act_fn_for_seq_cls(model_config),
),
"score": ClassifierPooler(
pooling=CLSPool(),
classifier=classifier,
act_fn=act_fn_for_cross_encoder(model_config),
),
}
)
roberta instance-attribute
¶
roberta = BertModel(
vllm_config=vllm_config,
prefix=maybe_prefix(prefix, "bert"),
embedding_class=RobertaEmbedding,
)
__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