mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 21:15:28 +08:00
29 lines
932 B
Python
29 lines
932 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
|
|
# We use dataclass for now because it is used for
|
|
# openai server output, and msgspec is not serializable.
|
|
# TODO(sang): Fix it.
|
|
@dataclass
|
|
class Logprob:
|
|
"""Infos for supporting OpenAI compatible logprobs and token ranks.
|
|
|
|
Attributes:
|
|
logprob: The logprob of chosen token
|
|
rank: The vocab rank of chosen token (>=1)
|
|
decoded_token: The decoded chosen token index
|
|
"""
|
|
logprob: float
|
|
rank: Optional[int] = None
|
|
decoded_token: Optional[str] = None
|
|
|
|
|
|
# {token_id -> logprob} per each sequence group. None if the corresponding
|
|
# sequence group doesn't require prompt logprob.
|
|
PromptLogprobs = list[Optional[dict[int, Logprob]]]
|
|
# {token_id -> logprob} for each sequence group.
|
|
SampleLogprobs = list[dict[int, Logprob]]
|