mlx_lm.convert tokenizer regex mismatch

#2
by heykb - opened
mlx_lm.generate \
  --model /Users/a1-6/models/Qwopus3.6-35B-A3B-v1-mlx \
  --prompt "写个 Python 快排" \
  --max-tokens 2560 --temp 0.6
[transformers] The tokenizer you are loading from '/Users/a1-6/models/Qwopus3.6-35B-A3B-v1-mlx' with an incorrect regex pattern: https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503/discussions/84#69121093e8b480e709447d5e. This will lead to incorrect tokenization. You should set the `fix_mistral_regex=True` flag when loading this tokenizer to fix this issue.
==========
1.  **理解用户需求**:用户想要一个 Python 实现的快速排序(Quick Sort)算法。

2.  **快速排序的核心思想**:
    *   **分治法**:选出一个基准值(pivot)。
    *   **分区**:将数组分成两部分,一部分小于基准值,一部分大于基准值。
    *   **递归**:对这两个部分分别进行快速排序。
    *   **合并**:将 sorted 的两部分和基准值组合起来。

Note: I also converted the official Qwen/Qwen3.6-35B-A3B with the same mlx_lm.convert command, and that one works fine without any warning.

Questions:
What does this regex mismatch actually affect?
Which tokenizer version was used during training — HF broken or Mistral official?
Should I manually patch tokenizer.json, or leave it as-is?

Owner

Hi, thank you for your feedback. This warning mainly comes from the tokenizer check in transformers, and it affects how text is split into tokens. In the related official Mistral discussion, there is an example showing that the same string, "'The'", can be tokenized into different token ID sequences by the official Mistral tokenizer and the older HF tokenizer.

This model is a version that I fine-tuned from the base model using Unsloth. In principle, inference should use the tokenizer and chat template saved during fine-tuning, to avoid any mismatch between the tokenizer used during training and the one used during inference.

Therefore, my recommendation is not to manually modify the original tokenizer.json directly for now. If it is only a warning and the model output looks normal, it can be safely ignored for the time being.

Thank you for your support!

Sign up or log in to comment