xgrammar.CompiledGrammar¶
- class xgrammar.CompiledGrammar[source]¶
Bases:
XGRObject
This is the primary object to store compiled grammar.
A CompiledGrammar can be used to construct GrammarMatcher to generate token masks efficiently.
Note
Do not construct this class directly, instead use
GrammarCompiler
to construct the object.- __init__()¶
Methods
__init__
()Attributes
The original grammar.
The approximate memory usage of the compiled grammar in bytes.
The tokenizer info associated with the compiled grammar.
- property tokenizer_info: TokenizerInfo¶
The tokenizer info associated with the compiled grammar.