vllm.v1.engine.detokenizer
¶
Classes:
Functions:
-
check_stop_strings–Check if any stop strings are matched and truncate sequence
-
get_decode_stream_seed–Return a prompt tail that primes a
DecodeStreamlike the full prompt. -
uses_fast_detokenizer–Whether the engine detokenizes with
FastIncrementalDetokenizer.
BaseIncrementalDetokenizer
¶
Bases: IncrementalDetokenizer, ABC
Methods:
-
get_next_output_text–If delta is True, only new text since the last call to
-
update–Update RequestState for the request_id by:
Source code in vllm/v1/engine/detokenizer.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
get_next_output_text(finished, delta)
¶
If delta is True, only new text since the last call to this method is returned
Source code in vllm/v1/engine/detokenizer.py
update(new_token_ids, stop_terminated)
¶
Update RequestState for the request_id by
1) Detokenize the new token ids incrementally. 2) Evaluate stop criteria.
Return matched stop string or None.
Source code in vllm/v1/engine/detokenizer.py
check_stop_strings(output_text, new_char_count, stop, include_in_output)
¶
Check if any stop strings are matched and truncate sequence output text accordingly.
Returns tuple (stop_string, offset) if matched or else None.
Where stop_string is the matched stop string and offset is the length to which output_text should be truncated, or -1 for no truncation.
When several stop strings match within the newly generated text (for example when speculative decoding appends multiple tokens in a single step), the stop string that completes earliest in the text is selected, so the result matches appending one token at a time. Ties are broken by stop-list order.
Source code in vllm/v1/engine/detokenizer.py
get_decode_stream_seed(tokenizer, prompt_token_ids, skip_special_tokens)
¶
Return a prompt tail that primes a DecodeStream like the full prompt.
The seed only shapes the first delta, so a short tail avoids an O(prompt)
decode. The tail holds INITIAL_INCREMENTAL_DETOKENIZATION_OFFSET tokens
that decode to text on their own (decoders like Metaspace treat the start
of the text specially), extended if its text ends in U+FFFD. Falls back to
the full prompt if the prompt's own text ends in U+FFFD.