vllm.model_executor.models.roberta ¶
BgeM3EmbeddingModel ¶
Bases: RobertaEmbeddingModel
A model that extends RobertaEmbeddingModel with sparse embeddings.
This class supports loading an additional sparse_linear.pt file to create sparse embeddings as described in https://arxiv.org/abs/2402.03216
Source code in vllm/model_executor/models/roberta.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
BgeM3SparsePooler ¶
Bases: Pooler
BGE-M3 sparse pooling with vocabulary-level aggregation.
Computes lexical weights from the BGE-M3 paper (arXiv:2402.03216): w_t = max_{i: token[i]=t} ReLU(sparse_linear(H[i]))
Unlike the token_classify task which returns raw per-position scores, this pooler aggregates scores by token ID using scatter_reduce with max pooling, producing a vocabulary-sized sparse vector that can be directly used with sparse vector databases (Qdrant, Milvus, Vespa, etc.).
This follows the same pattern as :class:SPLADESparsePooler in bert.py, adapted for BGE-M3's architecture where sparse_linear maps hidden states to a single scalar per position (rather than SPLADE's MLM head which maps to vocab-sized logits).
Source code in vllm/model_executor/models/roberta.py
RobertaClassificationHead ¶
Bases: Module
Head for sentence-level classification tasks.
Source code in vllm/model_executor/models/roberta.py
RobertaEmbeddingModel ¶
Bases: BertEmbeddingModel
A model that uses Roberta to provide embedding functionalities.
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. |