[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

View File

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