Skip to content

Commit a8e10a6

Browse files
committed
fix logprobs bug
1 parent ca7a64d commit a8e10a6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fastdeploy/entrypoints/openai/serving_completion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,13 +788,13 @@ def _build_logprobs_response(
788788
[tid], clean_up_tokenization_spaces=False
789789
)
790790
if "\ufffd" in token_str:
791-
token_bytes = token_str.encode("utf-8", errors="replace")
791+
raw_token = self.engine_client.data_processor.tokenizer.convert_ids_to_tokens(tid)
792+
token_bytes = raw_token.encode("utf-8", errors="replace")
792793
token_str = "bytes:" + "".join(f"\\x{byte:02x}" for byte in token_bytes)
793794
if idx == 0:
794795
tokens.append(token_str)
795796
token_logprobs.append(lp)
796-
else:
797-
top_logprobs[token_str] = lp
797+
top_logprobs[token_str] = lp
798798
idx += 1
799799

800800
# Construct the sampled token object (avoid sharing references with top_logprob_entries)

0 commit comments

Comments
 (0)