SGLang:结构化语言模型程序的高效执行

SGLang: Efficient Execution of Structured Language Model Programs

郑怜悯 Lianmin Zheng · UC Berkeley · 2023-12-12 · arXiv:2312.07104 ↗ · 被引 1014

打开互动全文版(逐段中英对照 + 图/公式 + 论文问答)→

摘要 · Abstract

大型语言模型(LLM)越来越多地用于需要多次生成调用、高级提示技术、控制流和结构化输入/输出的复杂任务。然而,目前缺乏高效的编程和执行系统来支持这些应用。我们提出了 SGLang,一个用于高效执行复杂语言模型程序的系统。SGLang 包含一个前端语言和一个运行时。前端通过提供生成和并行控制的原语简化了编程。运行时通过新颖的优化加速执行,例如用于 KV 缓存重用的 RadixAttention 和用于更快结构化输出解码的压缩有限状态机。实验表明,在包括智能体控制、逻辑推理、少样本学习基准、JSON 解码、检索增强生成管道和多轮对话等任务上,SGLang 在各种大型语言和多模态模型上实现了高达 6.4 倍的吞吐量提升,相比最先进的推理系统。代码已在 https://github.com/sgl-project/sglang 公开。

Large language models (LLMs) are increasingly used for complex tasks that require multiple generation calls, advanced prompting techniques, control flow, and structured inputs/outputs. However, efficient systems are lacking for programming and executing these applications. We introduce SGLang, a system for efficient execution of complex language model programs. SGLang consists of a frontend language and a runtime. The frontend simplifies programming with primitives for generation and parallelism control. The runtime accelerates execution with novel optimizations like RadixAttention for KV cache reuse and compressed finite state machines for faster structured output decoding. Experiments show that SGLang achieves up to 6.4x higher throughput compared to state-of-the-art inference systems on various large language and multi-modal models on tasks including agent control, logical reasoning, few-shot learning benchmarks, JSON decoding, retrieval-augmented generation pipelines, and multi-turn chat. The code is publicly available at https://github.com/sgl-project/sglang

核心贡献 · Key contributions

局限 · Limitations

论文章节 · Sections(共 22)

阅读逐段中英对照全文 →