Skip to content

Add Mistral tokenizer missing methods#41855

Open
ChrisHughes wants to merge 1 commit intohuggingface:mainfrom
ChrisHughes:mistral_tokenizer_add_missing_functions
Open

Add Mistral tokenizer missing methods#41855
ChrisHughes wants to merge 1 commit intohuggingface:mainfrom
ChrisHughes:mistral_tokenizer_add_missing_functions

Conversation

@ChrisHughes
Copy link
Copy Markdown

Make MistralCommonTokenizer compatible with libraries such as outlines.

Adds a couple of missing methods found in PreTrainedTokenizer, this allows Mistral models to be used with outlines and thus work with Pydantic models.

Builds on this PR #39930.

Fixes issue #39841.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@Rocketknight1
Copy link
Copy Markdown
Member

cc @itazap

Copy link
Copy Markdown
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Ty! Can you rebase ? 🤗

Comment thread src/transformers/tokenization_mistral_common.py Outdated
@ChrisHughes ChrisHughes force-pushed the mistral_tokenizer_add_missing_functions branch from eb5a548 to 0c2ed47 Compare November 25, 2025 17:40
@ChrisHughes
Copy link
Copy Markdown
Author

Rebased. Thanks!

@AA-furkan
Copy link
Copy Markdown

AA-furkan commented Dec 15, 2025

Hi, just pinging - what's the status of the PR? Is there any blocker before the merge?

@ChrisHughes ChrisHughes force-pushed the mistral_tokenizer_add_missing_functions branch from 0c2ed47 to 77ca619 Compare December 15, 2025 18:14
@ChrisHughes
Copy link
Copy Markdown
Author

Hi, just pinging - what's the status of the PR? Is there any blocker before the merge?

Should be good to go. Just rebased again.

@ChrisHughes ChrisHughes force-pushed the mistral_tokenizer_add_missing_functions branch from 77ca619 to 06c12aa Compare December 15, 2025 22:06
Make MistralCommonTokenizer compatible with libraries such as outlines.
@ChrisHughes ChrisHughes force-pushed the mistral_tokenizer_add_missing_functions branch from 06c12aa to cb83ef0 Compare December 16, 2025 00:35
def test_convert_tokens_to_string(self):
tokens = ["Hello", "world", "!"]
string = self.tokenizer.convert_tokens_to_string(tokens)
self.assertIsInstance(string, str)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you do a bit more testing! like what do you expect as string here, tokenizer -> convert tokens to string

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@notrudyyy
Copy link
Copy Markdown

Hey @ChrisHughes any updates on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants