Repository navigation
Releases
v0.2.9
What's Changed
- feat: support Gemma 4 tool calling with the <|"|> string delimiter by @asanomitakanori in #923
- fix: keep built-in formats within valid JSON strings by @RanaPriyansh in #927
- fix: bound DeepSeek V4.1 auto tool calls by @mashiro01 in #936
- fix: preserve shortest JSON numbers in schema literals by @RanaPriyansh in #926
- perf: cut bounded-string token-mask fills by classifying the repetition body with its parent by @0z5a in #903
- perf: extend the counted-repetition fast path to strings with minLength by @Seven-Streams in #938
- fix: fix the rendering of xgrammar's version on the website. by @Seven-Streams in #941
- ci: remove the nightly Routine Unit Test workflow by @Seven-Streams in #944
- fix: rule-level cache hash collisions between different character ranges and repeat bounds by @Seven-Streams in #943
- build: update dependencies by @Seven-Streams in #950
- fix: resolve JSON Schema references through array indices by @adimalkar in #929
- fix: let a token that starts in a literal finish in a token-level free-text region by @Seven-Streams in #942
- [Python] Add opt-in token_markers to get_model_structural_tag by @JRJRJPRO in #940
- fix: preserve separators in generic JSON rules by @RanaPriyansh in #948
- fix: fix the benchmark script by @Seven-Streams in #962
- fix: compile large regex repetitions with caching enabled by @Seven-Streams in #963
- fix: fix the import of mlxlm. by @Seven-Streams in #976
- Add jump-forward tokens while preserving accepted boundaries by @Ubospica in #980
- fix: match the ECMAScript whitespace class in \s and \S by @jinwukong in #977
- fix: CI Hugging Face rate limiting with shared offline tokenizer assets by @a68lin in #982
- Bugfix: avoid collisions in JSON Schema cache keys by @izhuhaoran in #985
- docs: document any_whitespace interaction with permissive schemas by @davidchung29 in #953
- fix: release erased values in List so cache evictions free memory by @stu-cao in #1003
- feature: Add opt-in JIT grammar compilation by @a68lin in #1017
- fix: accept stop token when it completes the grammar by @n0gu-furiosa in #710
- feat: support Lark syntax in structural tag grammar formats by @BugenZhao in #1015
- fix: keep find_jump_forward_string to whole UTF-8 characters by @Shakhtar-Sankur in #1012
- ci: migrate macOS 14 runners to macOS 15 by @a68lin in #1044
- fix: preserve forbidden bytes across counted repeat lowering by @HengYangDS in #949
New Contributors
- @asanomitakanori made their first contribution in #923
- @RanaPriyansh made their first contribution in #927
- @mashiro01 made their first contribution in #936
- @0z5a made their first contribution in #903
- @adimalkar made their first contribution in #929
- @JRJRJPRO made their first contribution in #940
- @jinwukong made their first contribution in #977
- @a68lin made their first contribution in #982
- @davidchung29 made their first contribution in #953
- @stu-cao made their first contribution in #1003
- @n0gu-furiosa made their first contribution in #710
- @BugenZhao made their first contribution in #1015
- @Shakhtar-Sankur made their first contribution in #1012
- @HengYangDS made their first contribution in #949
Full Changelog: v0.2.8...v0.2.9
v0.2.8
Highlights since v0.2.7:
- Add MiMo-V2.6 Pro and Flash tool-call and reasoning structural tags (
mimo), aligned with the official chat templates and tokenizers. Fix empty root schemas in the shared Qwen XML parameter-list converter (#916). - Add
JSONSchemaFormat.excludesto forbid substrings in string values and property names, including nested JSON strings (#912), and enable control-marker exclusions in Kimi-K3 tool arguments by default (#915). Exclusions apply to strings withoutpatternorformat; theirminLength/maxLengthconstraints are dropped with a warning. - Improve DeepSeek V4.1 token-mask performance and fix root object literals, schema/reference cache isolation, and overlapping text exclusions (#900). Bind DeepSeek V4 XML
string="true|false"attributes to the parameter value type across unions and references (#908). - Reduce token-mask overhead with
max_charsso it no longer grows with the generated prefix length (#913), and mask overridden stop tokens until the grammar can complete (#905). - Fix Unicode character-class ranges, negated classes, and UTF-8 encoding boundaries (#909), plus start-state merging and nested unbounded repetitions (#911). Enforce FSM state limits (#906) and add
GrammarFSMBuilder::FromRegularGrammar(#910). - Warn when JSON Schema string
patternis combined with unsupportedminLength/maxLengthconstraints (#896). - Fix native binding discovery in installed packages (#893), and derive Python package versions from Git tags with
setuptools-scm(#891).
Full changelog: v0.2.7...v0.2.8
v0.2.7
Highlights since v0.2.6:
- Add the DeepSeek V4.1 structural tag (
deepseek_v4_1) and thedeepseek_v4_1_xmlschema style for the spaced DSML tags used by DeepSeek-V4.1-Flash, exposed through Python, C++, and TypeScript and aligned with the official encoder and tokenizer (#885). Correlate each parameter'sstring="true|false"attribute with its value type across unions, mixed enums, references, and dynamic properties, and memoize$refparameter rules so recursive references terminate (#889). - Add the MiniMax M3 tool-call structural tag (
minimax_m3_xml) (#713), and aparallel_tool_callsparameter for the builtin structural tags (#892). - Add canonical recursive Any support for Cohere XML (#872), and memoize Cohere parameter wrappers so unions that refer back to themselves through
$refno longer overflow the stack (#890). - Honor the
additionalPropertiesvalue schema whenpropertyNamesis also present (#836). - Compile
FromLarkunder C++20 (#878). - Document project governance and the release policy (#887).
Full changelog: v0.2.6...v0.2.7
v0.2.6
Highlights since v0.2.5:
- Harden input validation, deserialization, and worker-thread error handling so invalid inputs raise exceptions instead of crashing the process (#869). Preserve tokenizer JSON round trips, including binary vocabulary and token-grammar compilation (#879).
- Extend EBNF and Lark grammars with capture, lazy matching, suffix/stop conditions, token and character budgets, and sampling temperature options. Add Lark regex flags, structured substring expressions, and a cached
GrammarCompiler.compile_larkAPI. - Improve grammar compilation with direct JSON Schema AST construction, shared FSM construction, in-place optimizer passes, and cached parser-state properties.
- Add Cohere XML, Kimi K3, and EXAONE 4.0 structural tags, plus
max_tokens/max_charssupport for AnyTextFormat and AnyTokensFormat. - Fix JSON carriage-return whitespace, positional
prefixItemshandling, NUL regex rejection, repeat-edge metadata, and grammar serialization keys. - Add an NPU token-bitmask backend and Windows ARM64 wheels. Reduce Python wheel size and expand the documentation.
Full changelog: v0.2.5...v0.2.6
Note: this is not the release version of the prior v0.2.6rc1 and v0.2.6rc2. Instead, it covers all the updates in the main branch since v0.2.5. Their official version will be released in the next version.
v0.2.5.post1
Packaging-only follow-up to v0.2.5. This release uses the exact v0.2.5 source code and rebuilds the complete wheel matrix after the original PyPI upload was interrupted by the former project storage limit. Consumers requiring these wheels should pin xgrammar==0.2.5.post1.
v0.2.6rc2 (preview)
Preview release for early testing. This release is cut from the preview/v0.2.6rc2 branch, not from main.
Highlights over v0.2.6rc1:
- Dynamic JSON Schema compilation and token-mask generation optimizations (#846), including reuse of vocabulary common prefixes in token mask generation (#856).
- JSON Schema string length constraints (
minLength/maxLength) no longer cause per-step token-mask slowdowns or latency cliffs (#853, fixing #805 and #852). - Generalized dynamic token-boundary masks beyond JSON strings, with correctness proofs replacing the earlier shape heuristics (#854).
- Correctness fixes: mask cache key, FSM aliasing, and lazy metadata race (#855); JSON string masking issues (#856); repeat-edge auxiliary data preserved in JSON string regex FSMs (#864, fixing #863); local-completion crossing-token bitset preserved on the lazy compilation path and rule-own lookahead assertions enforced in local-completion masks (#867).
- Documentation for the dynamic compilation option (#843) and a multi-version documentation site.
Install with:
pip install xgrammar==0.2.6rc2Note: pip does not pick up pre-releases by default; pin the exact version as above or use pip install --pre xgrammar.
v0.2.6rc1 (preview)
Preview release for early testing. This release is cut from the preview/v0.2.6rc1 branch, not from main.
Highlights:
- Lark grammar compatibility with llguidance v1.8 (hex escapes, terminal set operations, complements, byte/Unicode patterns, text anchors, capture names, grammar options), plus faster Lark compilation. Thanks to the llguidance team for designing these Lark grammar extensions.
- JSON Schema string
pattern/minLength/maxLengthsemantics fixes, using the ECMAScript regex dialect (\d/\ware ASCII) as required by JSON Schema, while Lark keeps Unicode character classes. - Correctness fixes: indirectly nullable repetition ranges, compilation cache size accounting, structurally invalid compiled-grammar cache deserialization now reports an error, raw jump-forward bytes preserved for invalid UTF-8, partial three-byte UTF-8 range handling.
- Performance: dynamic JSON Schema compilation and token-mask generation improvements; token-mask hot path stack usage reduced.
Install with:
pip install xgrammar==0.2.6rc1Note: pip does not pick up pre-releases by default; pin the exact version as above or use pip install --pre xgrammar.
v0.2.5
v0.2.4
What's Changed
- Fix: fix the ci. by @Seven-Streams in #685
- [feat] support whitespace control for structural tag by @izhuhaoran in #660
- fix: fix the ci. by @Seven-Streams in #689
- refactor: remove specialized XML tool calling EBNF converter functions by @Ubospica in #686
- perf: deduplicate identical repetition expansions in RepetitionRangeExpander by @Ubospica in #691
- fix:
\Sregex escape wrongly rejected a literal[by @CaiJohn in #693 - feat: warn when apply_token_bitmask_inplace leaves logits unmasked (undersized bitmask) by @whycoming in #694
- fix: make JSON Schema multipleOf sound for integers, warn for numbers by @palios-taey in #670
- fix: reject unsupported overlapping
oneOfschemas by @palios-taey in #672 - fix(structural_tag): fix several models with
tool_choice="required"to terminate instead of looping. by @Napuh in #695 - Bugfix(fsm): resolve trie back edges via Aho-Corasick failure links by @izhuhaoran in #697
- Bump to v0.2.4. by @Ubospica in #700
New Contributors
- @CaiJohn made their first contribution in #693
- @whycoming made their first contribution in #694
- @palios-taey made their first contribution in #670
- @Napuh made their first contribution in #695
Full Changelog: v0.2.3...v0.2.4
v0.2.3
What's Changed
- fix: fix the returned type of serialzation. by @Seven-Streams in #666
- Update GLM tool-call control tokens by @zRzRzRzRzRzRzR in #663
- feat: support any_order in json_schema format. by @Seven-Streams in #668
- feat: add a new param to control exclude strs for builtin structural tag. by @Seven-Streams in #665
- fix: fix the empty string in regex. by @Seven-Streams in #673
- fix: compile SequenceFormat/OrFormat under C++20 by @tboerstad in #674
- fix: handle negative zero float ranges by @Kevin-Li-2025 in #667
- Fix: fix the number generation. by @Seven-Streams in #669
- Bump to v0.2.3. by @Seven-Streams in #676
New Contributors
- @zRzRzRzRzRzRzR made their first contribution in #663
- @Kevin-Li-2025 made their first contribution in #667
Full Changelog: v0.2.2...v0.2.3