Text Generation
Transformers
Safetensors
PyTorch
nemotron_h
nvidia
nemotron-3
latent-moe
mtp
conversational
custom_code
8-bit precision
modelopt

"This will lead to incorrect tokenization" warning

#22
by DanTup - opened

When I try to run this using the instructions from https://github.com/NVIDIA-NeMo/Nemotron/tree/main/usage-cookbook/Nemotron-3-Super/SparkDeploymentGuide#tensorrt-llm, I see this warning in the output:

The tokenizer you are loading from '/root/.cache/huggingface/hub/models--nvidia--NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4/snapshots/3fc50401c152edee0983b3da7a77ddc5feeaa0d7' 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.

Is this something that should be fixed here?

NVIDIA org

Hi @DanTup , the mistral_regex is integrated into the model's tokenizer.json, see

  "pre_tokenizer": {
    "type": "Sequence",
    "pretokenizers": [
      {
        "type": "Split",
        "pattern": {
          "Regex": "[^\\r\\n\\p{L}\\p{N}]?[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}\\p{M}]*[\\p{Ll}\\p{Lm}\\p{Lo}\\p{M}]+|[^\\r\\n\\p{L}\\p{N}]?[\\p{Lu}\\p{Lt}\\p{Lm}\\p{Lo}\\p{M}]+[\\p{Ll}\\p{Lm}\\p{Lo}\\p{M}]*|\\p{N}| ?[^\\s\\p{L}\\p{N}]+[\\r\\n/]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+"
        },
        "behavior": "Isolated",
        "invert": false
      },
...
  },

and the warning is from transformer's previous version, it should work well without code changes.

@WanliJiang

it should work well without code changes

So I don't need to set fix_mistral_regex anywhere? (it's not clear to me from the message where this should be set if I'm just using something like VLLM).

the mistral_regex is integrated into the model's tokenizer.json, see

If the regex is broken and is from this model, could/should it not be fixed to prevent the warning?

Sign up or log in to comment