Support single integer or empty list as input to decode

#7
by peakji - opened
Files changed (1) hide show
  1. tokenization_chatglm.py +4 -0
tokenization_chatglm.py CHANGED
@@ -264,6 +264,10 @@ class ChatGLMTokenizer(PreTrainedTokenizer):
264
  spaces_between_special_tokens: bool = True,
265
  **kwargs
266
  ) -> str:
 
 
 
 
267
  if isinstance(token_ids[0], list):
268
  tokens = []
269
  for single_token_ids in token_ids:
 
264
  spaces_between_special_tokens: bool = True,
265
  **kwargs
266
  ) -> str:
267
+ if not isinstance(token_ids, list):
268
+ token_ids = [token_ids]
269
+ if len(token_ids) == 0:
270
+ return ""
271
  if isinstance(token_ids[0], list):
272
  tokens = []
273
  for single_token_ids in token_ids: