bugfix for npu Grok2 model --detokenizer without all special ids (#29853)
This commit is contained in:
@@ -33,8 +33,10 @@ def decode_without_hf_kwargs(tokenizer, token_ids, skip_special_tokens):
|
|||||||
if skip_special_tokens:
|
if skip_special_tokens:
|
||||||
special_ids = getattr(tokenizer, "all_special_ids_set", None)
|
special_ids = getattr(tokenizer, "all_special_ids_set", None)
|
||||||
if special_ids is None:
|
if special_ids is None:
|
||||||
special_ids = set(tokenizer.all_special_ids)
|
special_ids = getattr(tokenizer, "all_special_ids", None)
|
||||||
token_ids = [tid for tid in token_ids if tid not in special_ids]
|
if special_ids is not None:
|
||||||
|
special_ids_set = set(special_ids)
|
||||||
|
token_ids = [tid for tid in token_ids if tid not in special_ids_set]
|
||||||
return tokenizer.decode(token_ids)
|
return tokenizer.decode(token_ids)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user