[Bugfix]: Fix messy code when using logprobs (#20910)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey 2025-07-14 19:06:45 +08:00 committed by GitHub
parent 9887e8ec50
commit a4851cfe68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,7 +78,6 @@ def convert_prompt_ids_to_tokens(
def convert_ids_list_to_tokens( def convert_ids_list_to_tokens(
tokenizer: AnyTokenizer, tokenizer: AnyTokenizer,
token_ids: list[int], token_ids: list[int],
skip_special_tokens: bool = False,
) -> list[str]: ) -> list[str]:
"""Detokenize the input ids individually. """Detokenize the input ids individually.
@ -92,10 +91,8 @@ def convert_ids_list_to_tokens(
""" """
token_str_lst = [] token_str_lst = []
for token_id in token_ids: for token_id in token_ids:
token_str = tokenizer.decode( # use default skip_special_tokens.
[token_id], token_str = tokenizer.decode([token_id])
skip_special_tokens=skip_special_tokens,
)
if token_str is None: if token_str is None:
token_str = "" token_str = ""
token_str_lst.append(token_str) token_str_lst.append(token_str)