From e906c66fcfdc11f4ddcfe32ddc0a476943015b1f Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 17 Jul 2026 09:08:11 +0300 Subject: [PATCH] fix: clean tokenization spaces in huggingface_api decode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Matches inference.py so Vicuna/SentencePiece outputs drop ▁ artifacts (#3795). Co-authored-by: Cursor --- fastchat/serve/huggingface_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fastchat/serve/huggingface_api.py b/fastchat/serve/huggingface_api.py index 8022fbc93..b15b8c998 100644 --- a/fastchat/serve/huggingface_api.py +++ b/fastchat/serve/huggingface_api.py @@ -48,7 +48,10 @@ def main(args): else: output_ids = output_ids[0][len(inputs["input_ids"][0]) :] outputs = tokenizer.decode( - output_ids, skip_special_tokens=True, spaces_between_special_tokens=False + output_ids, + skip_special_tokens=True, + spaces_between_special_tokens=False, + clean_up_tokenization_spaces=True, ) # Print results