Skip to content

Commit 595fb4b

Browse files
authored
bump to transformer v5 (#689)
1 parent 79a0721 commit 595fb4b

2 files changed

Lines changed: 3 additions & 14 deletions

File tree

mlx_lm/tokenizer_utils.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ def finalize(self):
8989
def text(self):
9090
if self._current_tokens:
9191
self._current_text = self._tokenizer.decode(self._current_tokens)
92-
if self._current_text.endswith("\ufffd") or (
93-
self._tokenizer.clean_up_tokenization_spaces
94-
and len(self._current_text) > 0
95-
and self._current_text[-1] == " "
96-
):
92+
if self._current_text.endswith("\ufffd"):
9793
self._current_text = self._current_text[:-1]
9894
if self._current_text and self._current_text[-1] == "\n":
9995
self._text += self._current_text
@@ -161,8 +157,6 @@ class BPEStreamingDetokenizer(StreamingDetokenizer):
161157
_space_matches = (".", "?", "!", ",", "n't", "'m", "'s", "'ve", "'re")
162158

163159
def __init__(self, tokenizer):
164-
self.clean_spaces = tokenizer.clean_up_tokenization_spaces
165-
166160
# Extract the tokens in a list from id to text
167161
self.tokenmap = [None] * len(tokenizer.vocab)
168162
for value, tokenid in tokenizer.vocab.items():
@@ -197,8 +191,6 @@ def _maybe_trim_space(self, current_text):
197191
return current_text
198192
elif not self.text:
199193
return current_text[1:]
200-
elif self.clean_spaces and current_text[1:].startswith(self._space_matches):
201-
return current_text[1:]
202194
return current_text
203195

204196
def add_token(self, token):
@@ -208,10 +200,7 @@ def add_token(self, token):
208200
text = self._decode_bytes(self._unflushed)
209201

210202
# For multi-byte utf-8 wait until they are complete
211-
# For single spaces wait until the next token to clean it if needed
212-
if not text.endswith("\ufffd") and not (
213-
len(v) == 1 and self._byte_decoder.get(v[0]) == 32
214-
):
203+
if not text.endswith("\ufffd"):
215204
self.text += self._maybe_trim_space(text)
216205
self._unflushed = ""
217206

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
install_requires=[
2727
f"mlx>={MIN_MLX_VERSION}; platform_system == 'Darwin'",
2828
"numpy",
29-
"transformers>=4.39.3",
29+
"transformers==5.0.0rc1",
3030
"sentencepiece",
3131
"protobuf",
3232
"pyyaml",

0 commit comments

Comments
 (0)