Conversation
This was referenced Jul 27, 2026
Ubospica
marked this pull request as ready for review
July 30, 2026 15:38
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动摘要
词元是模型词表中的基本单位,词元允许集合是某个语法状态允许生成的词元表。LLGuidance 是另一个语法约束生成实现,本请求将它作为外部参考。
原因
慢输入会重复执行三类工作:
新路径共享只由语法决定的结果,复用结构相同的任务,并在局部证明或缓存接纳条件不成立时保留精确的原有路径。
性能
XGrammar 是本仓库的语法约束生成库。使用两个实现都能完成的 15 个大型 JSON Schema(用于描述 JSON 数据结构的规格),每个输入运行三次并取中位数:
XGrammar 的生成阶段在这组输入上快 2.3%。全流程耗时是参考实现的 1.67 倍,相比优化前的 2299.331 毫秒降低 11.8%。
慢输入的附加工作量统计:
正确性