Skip to content

vllm.entrypoints.pooling.classify.protocol

ClassificationRequest module-attribute

ClassificationChatRequest

Bases: PoolingBasicRequestMixin

Source code in vllm/entrypoints/pooling/classify/protocol.py
class ClassificationChatRequest(PoolingBasicRequestMixin):
    messages: list[ChatCompletionMessageParam]

    # --8<-- [start:chat-classification-extra-params]
    add_generation_prompt: bool = Field(
        default=False,
        description=(
            "If true, the generation prompt will be added to the chat template. "
            "This is a parameter used by chat template in tokenizer config of the "
            "model."
        ),
    )

    add_special_tokens: bool = Field(
        default=False,
        description=(
            "If true, special tokens (e.g. BOS) will be added to the prompt "
            "on top of what is added by the chat template. "
            "For most models, the chat template takes care of adding the "
            "special tokens so this should be set to false (as is the "
            "default)."
        ),
    )

    chat_template: str | None = Field(
        default=None,
        description=(
            "A Jinja template to use for this conversion. "
            "As of transformers v4.44, default chat template is no longer "
            "allowed, so you must provide a chat template if the tokenizer "
            "does not define one."
        ),
    )

    chat_template_kwargs: dict[str, Any] | None = Field(
        default=None,
        description=(
            "Additional keyword args to pass to the template renderer. "
            "Will be accessible by the chat template."
        ),
    )

    mm_processor_kwargs: dict[str, Any] | None = Field(
        default=None,
        description=("Additional kwargs to pass to the HF processor."),
    )

    softmax: bool | None = Field(
        default=None,
        description="softmax will be deprecated, please use use_activation instead.",
    )

    activation: bool | None = Field(
        default=None,
        description="activation will be deprecated, please use use_activation instead.",
    )

    use_activation: bool | None = Field(
        default=None,
        description="Whether to use activation for classification outputs. "
        "Default is True.",
    )
    # --8<-- [end:chat-classification-extra-params]

    def to_pooling_params(self):
        return PoolingParams(
            truncate_prompt_tokens=self.truncate_prompt_tokens,
            use_activation=get_use_activation(self),
        )

activation class-attribute instance-attribute

activation: bool | None = Field(
    default=None,
    description="activation will be deprecated, please use use_activation instead.",
)

add_generation_prompt class-attribute instance-attribute

add_generation_prompt: bool = Field(
    default=False,
    description="If true, the generation prompt will be added to the chat template. This is a parameter used by chat template in tokenizer config of the model.",
)

add_special_tokens class-attribute instance-attribute

add_special_tokens: bool = Field(
    default=False,
    description="If true, special tokens (e.g. BOS) will be added to the prompt on top of what is added by the chat template. For most models, the chat template takes care of adding the special tokens so this should be set to false (as is the default).",
)

chat_template class-attribute instance-attribute

chat_template: str | None = Field(
    default=None,
    description="A Jinja template to use for this conversion. As of transformers v4.44, default chat template is no longer allowed, so you must provide a chat template if the tokenizer does not define one.",
)

chat_template_kwargs class-attribute instance-attribute

chat_template_kwargs: dict[str, Any] | None = Field(
    default=None,
    description="Additional keyword args to pass to the template renderer. Will be accessible by the chat template.",
)

messages instance-attribute

mm_processor_kwargs class-attribute instance-attribute

mm_processor_kwargs: dict[str, Any] | None = Field(
    default=None,
    description="Additional kwargs to pass to the HF processor.",
)

softmax class-attribute instance-attribute

softmax: bool | None = Field(
    default=None,
    description="softmax will be deprecated, please use use_activation instead.",
)

use_activation class-attribute instance-attribute

use_activation: bool | None = Field(
    default=None,
    description="Whether to use activation for classification outputs. Default is True.",
)

to_pooling_params

to_pooling_params()
Source code in vllm/entrypoints/pooling/classify/protocol.py
def to_pooling_params(self):
    return PoolingParams(
        truncate_prompt_tokens=self.truncate_prompt_tokens,
        use_activation=get_use_activation(self),
    )

ClassificationCompletionRequest

Bases: PoolingBasicRequestMixin, CompletionRequestMixin

Source code in vllm/entrypoints/pooling/classify/protocol.py
class ClassificationCompletionRequest(PoolingBasicRequestMixin, CompletionRequestMixin):
    # --8<-- [start:classification-extra-params]
    softmax: bool | None = Field(
        default=None,
        description="softmax will be deprecated, please use use_activation instead.",
    )

    activation: bool | None = Field(
        default=None,
        description="activation will be deprecated, please use use_activation instead.",
    )

    use_activation: bool | None = Field(
        default=None,
        description="Whether to use activation for classification outputs. "
        "Default is True.",
    )
    # --8<-- [end:classification-extra-params]

    def to_pooling_params(self):
        return PoolingParams(
            truncate_prompt_tokens=self.truncate_prompt_tokens,
            use_activation=get_use_activation(self),
        )

activation class-attribute instance-attribute

activation: bool | None = Field(
    default=None,
    description="activation will be deprecated, please use use_activation instead.",
)

softmax class-attribute instance-attribute

softmax: bool | None = Field(
    default=None,
    description="softmax will be deprecated, please use use_activation instead.",
)

use_activation class-attribute instance-attribute

use_activation: bool | None = Field(
    default=None,
    description="Whether to use activation for classification outputs. Default is True.",
)

to_pooling_params

to_pooling_params()
Source code in vllm/entrypoints/pooling/classify/protocol.py
def to_pooling_params(self):
    return PoolingParams(
        truncate_prompt_tokens=self.truncate_prompt_tokens,
        use_activation=get_use_activation(self),
    )

ClassificationData

Bases: OpenAIBaseModel

Source code in vllm/entrypoints/pooling/classify/protocol.py
class ClassificationData(OpenAIBaseModel):
    index: int
    label: str | None
    probs: list[float]
    num_classes: int

index instance-attribute

index: int

label instance-attribute

label: str | None

num_classes instance-attribute

num_classes: int

probs instance-attribute

probs: list[float]

ClassificationResponse

Bases: OpenAIBaseModel

Source code in vllm/entrypoints/pooling/classify/protocol.py
class ClassificationResponse(OpenAIBaseModel):
    id: str = Field(default_factory=lambda: f"classify-{random_uuid()}")
    object: str = "list"
    created: int = Field(default_factory=lambda: int(time.time()))
    model: str
    data: list[ClassificationData]
    usage: UsageInfo

created class-attribute instance-attribute

created: int = Field(default_factory=lambda: int(time()))

data instance-attribute

id class-attribute instance-attribute

id: str = Field(
    default_factory=lambda: f"classify-{random_uuid()}"
)

model instance-attribute

model: str

object class-attribute instance-attribute

object: str = 'list'

usage instance-attribute

usage: UsageInfo