convert : import bytes_to_unicode from convert_slow_tokenizer (#26217)
bytes_to_unicode was removed from transformers.models.gpt2.tokenization_gpt2 in huggingface/transformers#40936, but it had already been copied into transformers.convert_slow_tokenizer in huggingface/transformers#30334 (transformers 4.54.1), so import it directly from there. Applies the same fix to chatglm.py.
This commit is contained in:
@@ -81,7 +81,7 @@ class ChatGLMModel(TextModel):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def token_bytes_to_string(b):
|
def token_bytes_to_string(b):
|
||||||
from transformers.models.gpt2.tokenization_gpt2 import bytes_to_unicode # ty: ignore[unresolved-import]
|
from transformers.convert_slow_tokenizer import bytes_to_unicode
|
||||||
byte_encoder = bytes_to_unicode()
|
byte_encoder = bytes_to_unicode()
|
||||||
return ''.join([byte_encoder[ord(char)] for char in b.decode('latin-1')])
|
return ''.join([byte_encoder[ord(char)] for char in b.decode('latin-1')])
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ class QwenModel(TextModel):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def token_bytes_to_string(b):
|
def token_bytes_to_string(b):
|
||||||
from transformers.models.gpt2.tokenization_gpt2 import bytes_to_unicode # ty: ignore[unresolved-import]
|
from transformers.convert_slow_tokenizer import bytes_to_unicode
|
||||||
byte_encoder = bytes_to_unicode()
|
byte_encoder = bytes_to_unicode()
|
||||||
return ''.join([byte_encoder[ord(char)] for char in b.decode('latin-1')])
|
return ''.join([byte_encoder[ord(char)] for char in b.decode('latin-1')])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user