[Feature][Pooling] Add offline fixed-length late chunking (#60164)
Signed-off-by: Linze-Shi <linzeshi0@gmail.com>
This commit is contained in:
@@ -277,6 +277,20 @@ STREAM_FINISHED = RequestOutput(
|
||||
_O = TypeVar("_O", default=PoolingOutput)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class LateChunk:
|
||||
token_range: tuple[int, int]
|
||||
char_range: tuple[int, int] | None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class LateChunkingMetadata:
|
||||
chunk_size: int
|
||||
input_tokens: int
|
||||
chunks: list[LateChunk]
|
||||
strategy: str = "fixed_tokens"
|
||||
|
||||
|
||||
class PoolingRequestOutput(Generic[_O]):
|
||||
"""The output data of a pooling request to the LLM.
|
||||
|
||||
@@ -287,6 +301,7 @@ class PoolingRequestOutput(Generic[_O]):
|
||||
num_cached_tokens: The number of tokens with prefix cache hit.
|
||||
finished (bool): A flag indicating whether the pooling is completed.
|
||||
error: Structured request-level error information, if the request failed.
|
||||
late_chunking: Token and source ranges for fixed-length late chunking.
|
||||
|
||||
"""
|
||||
|
||||
@@ -299,8 +314,10 @@ class PoolingRequestOutput(Generic[_O]):
|
||||
finished: bool,
|
||||
*,
|
||||
error: RequestError | None = None,
|
||||
late_chunking: LateChunkingMetadata | None = None,
|
||||
):
|
||||
self.request_id = request_id
|
||||
self.late_chunking = late_chunking
|
||||
self.prompt_token_ids = prompt_token_ids
|
||||
self.num_cached_tokens = num_cached_tokens
|
||||
self.finished = finished
|
||||
|
||||
Reference in New Issue
Block a user