Answers for LLM inference engineers

data did not match any variant of untagged enum ModelWrapper (PyPreTokenizerTypeWrapper, PyDecoderWrapper, PyNormalizerTypeWrapper): which tokenizers release reads your tokenizer.json

Exception: data did not match any variant of untagged enum ModelWrapper at line N column 3 means the installed tokenizers could not read the model section of tokenizer.json; PyPreTokenizerTypeWrapper, PyNormalizerTypeWrapper, PyDecoderWrapper and PostProcessorWrapper are the same failure in the pre_tokenizer, normalizer, decoder and post_processor sections. The usual cause in files written since August 2024: tokenizers 0.20.0 and later save BPE merges as pairs (["a", "b"]), and 0.19.1 and earlier read only strings ("a b"). Install tokenizers 0.20.0 or later, which transformers requires from 4.45.0 (4.18.0 to 4.44.2 cap it below 0.20), or rewrite the merges as strings. The line number is where the section ends, not where the problem is.

Published 2026-12-04 · Data as of 2026-12-04 · tokenizers 0.8.0 to 0.23.3 (46 releases from PyPI, each installed and run), 411 tokenizer.json forms, 18,906 loads · transformers 4.0.0 to 5.26.0 (217 releases, requirements read from PyPI)

Which tokenizers release can read my tokenizer.json?

Load the file: the checker lists every component, the releases that read it, the message the others print, and the transformers releases whose requirement allows a release that works. Without the file, paste the error and pick your version.

Examples (trained on nine sentences):

Your version: pip show tokenizers (do not trust tokenizers.__version__ on 0.11.1 to 0.11.5: those five releases report 0.11.0). The checker matches each component against the 342 distinct forms we ran; a combination of fields outside them is reported as not tested instead of guessed.

What does "untagged enum ModelWrapper" mean?

The name after untagged enum tells you which top-level section of tokenizer.json failed to parse, and nothing more. tokenizers tries every type it knows for that section and reports only that none fitted.

section of tokenizer.jsonname in the message (releases that print it)
modelModelWrapper (0.9.0 to 0.19.1); ModelUntagged (0.20.0 and later); MergeType (0.20.0 and later)
pre_tokenizerPyPreTokenizerTypeWrapper (0.9.0 to 0.21.1); PreTokenizerUntagged (0.21.2 and later)
normalizerPyNormalizerTypeWrapper (0.9.0 to 0.21.1); NormalizerUntagged (0.21.2 and later)
decoderPyDecoderWrapper (0.9.0 and later)
post_processorPostProcessorWrapper (0.9.0 and later)

The position in the message is the end of that section. In the 18,084 loads on 0.9.0 to 0.23.3, 2,960 errors pointed at the last character of the failing section and 494 at the last character of the file; none pointed at the field that caused it. Model errors are reported at the end of the file from 0.20.0 on, at the end of model before. Since model is the last section tokenizers writes, a file saved with the default pretty layout gives line (last line - 1) column 3 on 0.19.1 and earlier and line (last line) column 1 on 0.20.0 and later.

From 0.20.0 the model section also reports what is wrong instead of this message when the type is known (see the broken-file table); the pre-tokenizer does so from 0.21.2 for a regex that does not compile and for the Metaspace mismatch below.

Which tokenizers version does each tokenizer.json feature need?

These are the first releases that read each form and kept reading it through 0.23.3. "transformers from" is the first transformers release from which every release allows such a tokenizers.

sectionform in the filetokenizers fromreleasedtransformers fromthe release before it says
modelBPE with merges as pairs: "merges": [["a", "b"], ...]0.20.02024-08-084.45.0data did not match any variant of untagged enum ModelWrapper
modelBPE with "ignore_merges" honoured0.19.12024-04-174.40.0loads, field ignored
modelBPE with "byte_fallback" honoured0.13.32023-04-054.23.0loads, field ignored
modelUnigram with "byte_fallback" honoured0.14.02023-09-074.34.0loads, field ignored
normalizerPrepend0.13.32023-04-054.23.0data did not match any variant of untagged enum PyNormalizerTypeWrapper
normalizerByteLevel as a normalizer0.20.02024-08-084.45.0data did not match any variant of untagged enum PyNormalizerTypeWrapper
normalizerReplace, Nmt, Precompiled, StripAccents0.9.02020-10-094.0.0–
pre_tokenizerSplit0.10.02021-01-124.3.0data did not match any variant of untagged enum PyPreTokenizerTypeWrapper
pre_tokenizerPunctuation with "behavior"0.11.02021-12-234.16.0data did not match any variant of untagged enum PyPreTokenizerTypeWrapper
pre_tokenizerByteLevel with "use_regex" honoured0.12.02022-03-314.16.0loads, field ignored
pre_tokenizerMetaspace with "prepend_scheme" honoured (file also has "add_prefix_space")0.15.02023-11-144.35.2loads, field ignored
pre_tokenizerMetaspace with "prepend_scheme" and "split", no "add_prefix_space"0.19.02024-04-174.40.0data did not match any variant of untagged enum PyPreTokenizerTypeWrapper
pre_tokenizerFixedLength0.21.22025-06-244.47.0data did not match any variant of untagged enum PyPreTokenizerTypeWrapper
decoderCTC0.10.32021-05-244.3.0data did not match any variant of untagged enum PyDecoderWrapper
decoderSequence of decoders0.13.02022-09-214.23.0data did not match any variant of untagged enum PyDecoderWrapper
decoderReplace, Fuse, ByteFallback, Strip0.13.32023-04-054.23.0data did not match any variant of untagged enum PyDecoderWrapper
decoderMetaspace with "prepend_scheme" and "split", no "add_prefix_space"0.19.02024-04-174.40.0data did not match any variant of untagged enum PyDecoderWrapper
post_processorSequence of post-processors0.13.02022-09-214.23.0data did not match any variant of untagged enum PostProcessorWrapper
truncation"direction" honoured0.11.12021-12-284.16.0loads, field ignored

"Honoured" rows: older releases from 0.9.0 load the file and skip the field, see below. A component inside a Sequence needs both the row for the Sequence and its own row: in 11 Sequences we ran, the Sequence failed exactly where its container or one of its members failed. The last column is what the newest release before it does.

Which transformers versions allow which tokenizers?

transformers declares a tokenizers range and pip keeps tokenizers inside it, so the fix is usually a transformers upgrade: merges written as pairs need transformers 4.45.0 or later.

transformersfirst releasedrequires tokenizersreleases we ran in that rangereads merges as pairs
4.0.0 to 4.2.22020-11-30==0.9.40.9.4no
4.3.0 to 4.15.02021-02-08<0.11,>=0.10.10.10.1, 0.10.2, 0.10.3no
4.16.0 to 4.16.22022-01-27!=0.11.3,>=0.10.10.10.1 to 0.23.3 (35 releases)only 0.20.0 and later
4.17.02022-03-03!=0.11.3,>=0.11.10.11.1 to 0.23.3 (31 releases)only 0.20.0 and later
4.18.0 to 4.22.22022-04-06!=0.11.3,<0.13,>=0.11.10.11.1, 0.11.2, 0.11.4, 0.11.5, 0.11.6, 0.12.1no
4.23.0 to 4.33.32022-10-10!=0.11.3,<0.14,>=0.11.10.11.1 to 0.13.3 (10 releases)no
4.34.0 to 4.35.12023-10-03<0.15,>=0.140.14.0, 0.14.1no
4.35.2 to 4.39.32023-11-15<0.19,>=0.140.14.0, 0.14.1, 0.15.0, 0.15.1, 0.15.2no
4.40.0 to 4.44.22024-04-18<0.20,>=0.190.19.0, 0.19.1no
4.45.0 to 4.46.32024-09-25<0.21,>=0.200.20.0, 0.20.1, 0.20.2, 0.20.3yes
4.47.0 to 4.55.42024-12-05<0.22,>=0.210.21.0, 0.21.1, 0.21.2, 0.21.4yes
4.56.0 to 5.15.12025-08-29<=0.23.0,>=0.22.00.22.0, 0.22.1, 0.22.2yes
5.16.0 to 5.26.02026-08-26<0.24.0,>=0.23.10.23.1, 0.23.2, 0.23.3yes

From the Requires-Dist of each final transformers release on PyPI (2026-12-04). The fourth column lists the releases we ran that the range admits (yanked 0.12.0 and 0.20.4 left out). 4.16.0 to 4.17.0 declare no upper bound, so pip gives them the newest tokenizers that has a wheel for your Python; we did not run transformers itself. transformers before 4.0.0 pinned one exact tokenizers build, some of them release candidates we did not run.

Can a newer tokenizers fail on a file an older one reads?

Yes, in two cases. Of the 181 forms the releases themselves wrote, 0.23.3 rejects only these.

Does an older tokenizers that loads the file give the same tokens?

Not when the file sets a field the release does not know: from 0.9.0, unknown fields are skipped without a warning. One small tokenizer per field, run in every release:

the file setsinputhonoured fromtokens beforetokens from then on
BPE "ignore_merges": trueabc0.19.1a bcabc
BPE "byte_fallback": trueaé0.13.3a <unk>a <0xC3> <0xA9>
Unigram "byte_fallback": trueaé0.14.0a éa <0xC3> <0xA9>
ByteLevel pre-tokenizer "use_regex": falsea b0.12.0a Ġ baĠ b
Metaspace "add_prefix_space": true, "prepend_scheme": "never"a b0.15.0▁a ▁ba ▁b
truncation "direction": "Left", max_length 2a b c0.11.1a bb c

The checker reports such a release as "reads it, ignores a field" only when the file's value differs from what the old release does anyway (for example ignore_merges: false is harmless).

What if the file itself is broken?

Then no upgrade fixes it, but 0.20.0 or later tells you what is wrong where older releases only say ModelWrapper. Hand-edited or generated files we ran:

sectionwhat is wrong0.19.1 says0.23.3 says0.23.3 behaviour since
modelBPE, merges as strings: a merge names a token that is not in vocabdata did not match any variant of untagged enum ModelWrapperToken `ab` out of vocabulary0.20.0
modelBPE, merges as strings: no vocab keydata did not match any variant of untagged enum ModelWrapperMissing vocab/merges0.20.0
modelBPE, merges as strings: two tokens share an idloadsloads0.9.0
modelBPE, merges as pairs: a merge names a token that is not in vocabdata did not match any variant of untagged enum ModelWrapperToken `ab` out of vocabulary0.20.0
modelBPE, merges as pairs: no vocab keydata did not match any variant of untagged enum ModelWrapperMissing vocab/merges0.20.0
modelBPE, merges as pairs: two tokens share an iddata did not match any variant of untagged enum ModelWrapperloads0.20.0
modelBPE, merges as strings: a line with three partsdata did not match any variant of untagged enum ModelWrapperMerges text file invalid at line 10.20.0
modelBPE, merges as strings: a line with one partdata did not match any variant of untagged enum ModelWrapperMerges text file invalid at line 10.20.0
modelBPE, merges as pairs: an entry with three partsdata did not match any variant of untagged enum ModelWrapperdata did not match any variant of untagged enum MergeType0.20.0
modelempty objectdata did not match any variant of untagged enum ModelWrapperdata did not match any variant of untagged enum ModelUntagged0.20.0
modelunknown type namedata did not match any variant of untagged enum ModelWrapperdata did not match any variant of untagged enum ModelUntagged0.20.0
modelUnigram: unk_id past the end of vocabdata did not match any variant of untagged enum ModelWrapperUnable to load vocab UnkIdNotInVocabulary0.20.0
modelUnigram: a score is null (what NaN becomes in JSON)data did not match any variant of untagged enum ModelWrapperinvalid type: null, expected f640.20.0
modelUnigram: empty vocab with unk_id 0data did not match any variant of untagged enum ModelWrapperUnable to load vocab EmptyVocabulary0.20.0
modelWordPiece: unk_token is not in vocabloadsloads0.9.0
modelWordLevel: unk_token is not in vocabloadsloads0.9.0
post_processorTemplateProcessing: a template names a special token that special_tokens lacksloadsloads0.9.0
pre_tokenizerSplit: the regex does not compiledata did not match any variant of untagged enum PyPreTokenizerTypeWrapperOniguruma error: end pattern with unmatched parenthesis0.21.2
normalizerPrecompiled: charsmap is not a valid blobdata did not match any variant of untagged enum PyNormalizerTypeWrapperPanicException: Precompiled: Error("Cannot parse precompiled_charsmap", line: 0, column: 0)0.20.0

The checker finds the vocab, merge and Unigram problems of this table in your file; it does not compile regexes or decode a Precompiled charsmap. Two BPE tokens with the same id load in every release that reads the merges, and the loaded tokenizer keeps one of them (which one differed between two runs of the same release). A WordPiece or WordLevel whose unk_token is not in the vocab loads from 0.9.0; 0.8.0 and 0.8.1 abort the Python process.

Can I convert the file instead of upgrading?

Yes for merges written as pairs, if no token contains a space. The checker does it in the browser; the same in Python:

import json

d = json.load(open("tokenizer.json", encoding="utf-8"))
merges = d["model"]["merges"]
assert all(" " not in a and " " not in b for a, b in merges), "a token contains a space: needs tokenizers>=0.20.0"
d["model"]["merges"] = [a + " " + b for a, b in merges]
json.dump(d, open("tokenizer.old.json", "w", encoding="utf-8"), ensure_ascii=False, indent=2)

We converted three trained files this way (two with the checker's code, one with this script). The byte-level BPE then loaded in 0.9.0 and later, the one with a Prepend normalizer and byte fallback in 0.13.3 and later, and the one with ignore_merges in 0.19.1 and later (0.13.0 to 0.19.0 load it and ignore that field). Every load the checker calls full gave the ids of the original in 0.23.3.

Which releases behave differently from their neighbours?

Four patch releases of 0.11 do; transformers excludes one of them.

How was this measured?

Every final tokenizers release on PyPI from 0.8.0 (2020-06-26) to 0.23.3 (2026-10-09) was installed from its wheel (CPython 3.8 up to 0.20.3, 3.12 after) and run on Linux x86_64.

Questions

How do I fix "data did not match any variant of untagged enum ModelWrapper"?

The installed tokenizers could not read the model section of tokenizer.json. In files written since August 2024 the usual reason is that tokenizers 0.20.0 or later saved the BPE merges as pairs, and tokenizers 0.19.1 or earlier reads only strings. Install tokenizers 0.20.0 or later; transformers requires that from 4.45.0, and 4.18.0 to 4.44.2 do not allow it. If the merges are already strings, or the model is not BPE, the file content is wrong: tokenizers 0.20.0 or later names the real problem instead of this message.

What does the line number in an untagged enum error mean?

It is the line where the failing section ends, not the line of the problem. In the 18,084 loads we ran on tokenizers 0.9.0 to 0.23.3, every error that carried a position pointed at the last character of the failing top-level section, or at the last character of the file for model errors on 0.20.0 and later. That is why the message says column 3 for a pretty-printed file read by an older release, and why the line is close to the end of the file.

Which tokenizers version does transformers install?

Each transformers release declares a range. 4.40.0 to 4.44.2 require tokenizers>=0.19,<0.20 and cannot read merges written as pairs; 4.45.0 to 4.46.3 require >=0.20,<0.21; 4.47.0 to 4.55.4 require >=0.21,<0.22. Upgrading tokenizers alone past the range makes pip report a conflict, so upgrade transformers.

Why does a newer tokenizers reject a tokenizer.json that an older one reads?

Two cases in our runs. A Metaspace pre-tokenizer or decoder with add_prefix_space false and no prepend_scheme "never" (written by 0.14.1 and earlier, and by 0.15.x) is rejected by 0.19.0 and later; 0.21.2 and later say "add_prefix_space does not match declared prepend_scheme" for the pre-tokenizer. And a BPE whose tokens contain spaces, saved by 0.19.1 or earlier, is rejected by every release from 0.10.1. Adding "prepend_scheme": "never" repairs the first; the second needs the merges rebuilt as pairs, which is not always possible from the file alone.

Can I make a tokenizer.json from tokenizers 0.20 or later load in an older tokenizers?

Yes when the only obstacle is the merges: rewrite each pair ["a", "b"] as the string "a b". It works only if no token contains a space. The file then loads in 0.19.1 and, where the other components allow, in older releases; in our runs the converted files gave the same ids as the originals. Releases before 0.19.1 load the file but ignore ignore_merges, which changes the tokens when it is true.

An old tokenizers loads the file without an error. Are the tokens the same?

Not always. Releases from 0.9.0 skip fields they do not know. Before 0.19.1 ignore_merges is ignored, before 0.13.3 byte_fallback of BPE, before 0.14.0 byte_fallback of Unigram, before 0.12.0 use_regex of ByteLevel, before 0.15.0 prepend_scheme of Metaspace, and before 0.11.1 the truncation direction. We ran one small tokenizer for each and the tokens changed at exactly those releases.

Sources

The same data as JSON: data.json, licensed CC BY 4.0.

Related: "cannot import name 'X' from 'transformers'" · "cannot import name 'cached_download' from 'huggingface_hub'" · GGUF token ids that differ from Transformers · which Python each ML package installs on.