Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detokenizer space match for quote #1072

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llms/mlx_lm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Copyright © 2023-2024 Apple Inc.

import os

from ._version import __version__

os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"
Copy link
Contributor

@hschaeufler hschaeufler Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment in the code would be nice, why you set the flag.


from .utils import convert, generate, load, stream_generate
2 changes: 1 addition & 1 deletion llms/mlx_lm/tokenizer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class BPEStreamingDetokenizer(StreamingDetokenizer):
"""

_byte_decoder = None
_space_matches = (".", "?", "!", ",", "'", "n't", "'m", "'s", "'ve", "'re")
_space_matches = (".", "?", "!", ",", "n't", "'m", "'s", "'ve", "'re")

def __init__(self, tokenizer):

Expand Down
3 changes: 3 additions & 0 deletions llms/tests/test_tokenizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def check(tokens):
tokens = tokenizer.encode("3 3")
check(tokens)

tokens = tokenizer.encode("import 'package:flutter/material.dart';")
check(tokens)

def test_tokenizers(self):
tokenizer_repos = [
("mlx-community/Qwen1.5-0.5B-Chat-4bit", BPEStreamingDetokenizer),
Expand Down