MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / LogprobsLists

Class LogprobsLists

fastdeploy/worker/output.py:39–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39class LogprobsLists(NamedTuple):
40 """ """
41
42 # [num_reqs, max_num_logprobs + 1]
43 logprob_token_ids: list[list[int]]
44 # [num_reqs, max_num_logprobs + 1]
45 logprobs: list[list[float]]
46 # [num_reqs]
47 sampled_token_ranks: list[int]
48
49 def slice_columns(self, start: int, end: int):
50 """
51 Slice columns (per-row top-k logprobs and token IDs).
52 Keeps the number of requests unchanged.
53 """
54 return LogprobsLists(
55 [row[start:end] for row in self.logprob_token_ids],
56 [row[start:end] for row in self.logprobs],
57 self.sampled_token_ranks, # unchanged
58 )
59
60 def slice_rows(self, start: int, end: int):
61 """
62 Slice rows.
63 Keeps the number of max_num_logprobs unchanged.
64 """
65 return LogprobsLists(
66 self.logprob_token_ids[start:end],
67 self.logprobs[start:end],
68 self.sampled_token_ranks[start:end],
69 )
70
71
72class LogprobsTensors(NamedTuple):

Calls

no outgoing calls