[Bugfix][Frontend] Truncate prompt_is_token_ids with the prompt (#54509)
Signed-off-by: hotragn <hotragn.pettugani_2024@woxsen.edu.in>
This commit is contained in:
@@ -420,8 +420,8 @@ class TokenizeParams:
|
||||
"""The slice truncation applies to a sequence of `length` tokens.
|
||||
|
||||
`None` means no truncation. Anything parallel to the prompt tokens
|
||||
(see `prompt_token_offsets`) must be reduced with this same slice to
|
||||
stay aligned with them.
|
||||
(see `prompt_token_offsets` and `prompt_is_token_ids`) must be reduced
|
||||
with this same slice to stay aligned with them.
|
||||
"""
|
||||
max_length = self.truncate_prompt_tokens
|
||||
if max_length is not None and max_length < 0:
|
||||
@@ -516,5 +516,10 @@ class TokenizeParams:
|
||||
truncation = self._truncation_slice(tokenizer, len(offsets))
|
||||
if truncation is not None:
|
||||
prompt["prompt_token_offsets"] = offsets[truncation] # type: ignore[typeddict-unknown-key]
|
||||
is_token_ids = cast(EmbedsPrompt, prompt).get("prompt_is_token_ids")
|
||||
if is_token_ids is not None:
|
||||
truncation = self._truncation_slice(tokenizer, len(is_token_ids))
|
||||
if truncation is not None:
|
||||
prompt["prompt_is_token_ids"] = is_token_ids[truncation] # type: ignore[typeddict-unknown-key]
|
||||
|
||||
return prompt
|
||||
|
||||
Reference in New Issue
Block a user