要約
LLMエージェントのアプリケーションはますます複雑になり、多様化されており、コード、構造化された関数呼び出し、および具体化されたエージェントコマンドに解析できる構造化された出力の需要が高くなります。
これらの開発は、LLM推論における構造化された世代に大きな要求をもたらします。
コンテキストフリーの文法は、制約されたデコードを介して構造化された生成を可能にする柔軟なアプローチです。
ただし、コンテキストフリーの文法を実行するには、ランタイム中に語彙のすべてのトークンにわたっていくつかのスタック状態を通過する必要があり、構造化された生成のために無視できないオーバーヘッドをもたらします。
この論文では、大規模な言語モデル向けの柔軟で効率的な構造生成エンジンであるXgrammarを提案します。
Xgrammarは、語彙を、実行時に解釈する必要があるコンテキストに依存しないトークンとコンテキスト依存のトークンに分割することにより、コンテキストのない文法実行を加速します。
さらに、文法のコンテキストを拡大し、コンテキストに依存しないトークンの数を減らすために変換を構築します。
さらに、コンテキスト依存のトークンチェックを加速するために、効率的な永続的なスタックを構築します。
最後に、GPU実行と文法計算を重複させるために、文法エンジンをLLM推論エンジンと共同設計します。
評価の結果は、Xgrammarが既存のソリューションよりも最大100倍のスピードアップを達成できることを示しています。
LLM推論エンジンと組み合わせることで、エンドツーエンドの低地サービングでゼロ近くのオーバーヘッド構造生成を生成できます。
要約(オリジナル)
The applications of LLM Agents are becoming increasingly complex and diverse, leading to a high demand for structured outputs that can be parsed into code, structured function calls, and embodied agent commands. These developments bring significant demands for structured generation in LLM inference. Context-free grammar is a flexible approach to enable structured generation via constrained decoding. However, executing context-free grammar requires going through several stack states over all tokens in vocabulary during runtime, bringing non-negligible overhead for structured generation. In this paper, we propose XGrammar, a flexible and efficient structure generation engine for large language models. XGrammar accelerates context-free grammar execution by dividing the vocabulary into context-independent tokens that can be prechecked and context-dependent tokens that need to be interpreted during runtime. We further build transformations to expand the grammar context and reduce the number of context-independent tokens. Additionally, we build an efficient persistent stack to accelerate the context-dependent token checks. Finally, we co-design the grammar engine with LLM inference engine to overlap grammar computation with GPU executions. Evaluation results show that XGrammar can achieve up to 100x speedup over existing solutions. Combined with an LLM inference engine, it can generate near-zero overhead structure generation in end-to-end low-LLM serving.
arxiv情報
著者 | Yixin Dong,Charlie F. Ruan,Yaxing Cai,Ruihang Lai,Ziyi Xu,Yilong Zhao,Tianqi Chen |
発行日 | 2025-05-12 08:20:08+00:00 |
arxivサイト | arxiv_id(pdf) |
提供元, 利用サービス
arxiv.jp, Google