From fdb7a601d8f8279806124542e11549bdd76f62f6 Mon Sep 17 00:00:00 2001 From: Zhengxiao Du Date: Tue, 4 Apr 2023 09:48:07 +0000 Subject: [PATCH] Support single integer or empty list as input to decode (#7) - Update tokenization_chatglm.py (dffe870a7ef1558ebbc6f3dfdf46491cdb2b3e31) Co-authored-by: Yichao 'Peak' Ji --- tokenization_chatglm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tokenization_chatglm.py b/tokenization_chatglm.py index 3062c7c..caa33d8 100644 --- a/tokenization_chatglm.py +++ b/tokenization_chatglm.py @@ -261,6 +261,10 @@ class ChatGLMTokenizer(PreTrainedTokenizer): spaces_between_special_tokens: bool = True, **kwargs ) -> str: + if not isinstance(token_ids, list): + token_ids = [token_ids] + if len(token_ids) == 0: + return "" if isinstance(token_ids[0], list): tokens = [] for single_token_ids in token_ids: