vllm.model_executor.layers.pooler
AllPool
¶
Bases: SimplePooler
Source code in vllm/model_executor/layers/pooler.py
extract_states
¶
extract_states(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Union[list[Tensor], Tensor]
Source code in vllm/model_executor/layers/pooler.py
CLSPool
¶
Bases: SimplePooler
Source code in vllm/model_executor/layers/pooler.py
extract_states
¶
extract_states(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Union[list[Tensor], Tensor]
Source code in vllm/model_executor/layers/pooler.py
CrossEncodingPooler
¶
Bases: Module
A layer that pools specific information from hidden states.
This layer does the following:
1. Extracts specific tokens or aggregates data based on pooling method.
2. Normalizes output if specified.
3. Returns structured results as PoolerOutput.
Attributes:
| Name | Type | Description |
|---|---|---|
pooling_type |
The type of pooling to use. |
|
normalize |
Whether to normalize the pooled data. |
Source code in vllm/model_executor/layers/pooler.py
default_activation_function
instance-attribute
¶
default_activation_function = (
get_cross_encoder_activation_function(config)
)
__init__
¶
Source code in vllm/model_executor/layers/pooler.py
forward
¶
forward(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> PoolerOutput
Pools sentence pair scores from the hidden_states.
Source code in vllm/model_executor/layers/pooler.py
LastPool
¶
Bases: SimplePooler
Source code in vllm/model_executor/layers/pooler.py
extract_states
¶
extract_states(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Union[list[Tensor], Tensor]
Source code in vllm/model_executor/layers/pooler.py
MeanPool
¶
Bases: SimplePooler
Source code in vllm/model_executor/layers/pooler.py
extract_states
¶
extract_states(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Union[list[Tensor], Tensor]
Source code in vllm/model_executor/layers/pooler.py
Pooler
¶
Bases: Module
Source code in vllm/model_executor/layers/pooler.py
from_config_with_defaults
classmethod
¶
from_config_with_defaults(
pooler_config: PoolerConfig,
pooling_type: PoolingType,
normalize: bool,
softmax: bool,
step_tag_id: Optional[int] = None,
returned_token_ids: Optional[list[int]] = None,
) -> SimplePooler
Source code in vllm/model_executor/layers/pooler.py
PoolerHead
¶
Bases: Module
Source code in vllm/model_executor/layers/pooler.py
__init__
¶
forward
¶
forward(
pooled_data: Union[list[Tensor], Tensor],
pooling_metadata: PoolingMetadata,
)
Source code in vllm/model_executor/layers/pooler.py
PoolingType
¶
Bases: IntEnum
Enumeration for different types of pooling methods.
Source code in vllm/model_executor/layers/pooler.py
SimplePooler
¶
Bases: Module
A layer that pools specific information from hidden states.
This layer does the following:
1. Extracts specific tokens or aggregates data based on pooling method.
2. Normalizes output if specified.
3. Returns structured results as PoolerOutput.
Attributes:
| Name | Type | Description |
|---|---|---|
pooling_type |
The type of pooling to use. |
|
normalize |
Whether to normalize the pooled data. |
Source code in vllm/model_executor/layers/pooler.py
__init__
¶
build_output
¶
build_output(data: Tensor) -> PoolingSequenceGroupOutput
extract_states
¶
forward
¶
forward(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> PoolerOutput
Source code in vllm/model_executor/layers/pooler.py
from_pooling_type
staticmethod
¶
from_pooling_type(
pooling_type: PoolingType,
*,
normalize: bool,
softmax: bool,
step_tag_id: Optional[int] = None,
returned_token_ids: Optional[list[int]] = None,
) -> SimplePooler
Source code in vllm/model_executor/layers/pooler.py
get_prompt_lens
¶
get_prompt_lens(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Tensor
StepPool
¶
Bases: SimplePooler
Source code in vllm/model_executor/layers/pooler.py
__init__
¶
__init__(
*,
normalize: bool,
softmax: bool,
step_tag_id: Optional[int] = None,
returned_token_ids: Optional[list[int]] = None,
)
Source code in vllm/model_executor/layers/pooler.py
extract_states
¶
extract_states(
hidden_states: Tensor, pooling_metadata: PoolingMetadata
) -> Union[list[Tensor], Tensor]