文章背景与核心概要
大语言模型(LLM)在解决复杂任务时,经常依赖外部工具和代码执行(通常使用 Python 编写)来利用循环和条件判断等高级控制流。然而,直接在 Python 中实现专门的编程特性往往具有挑战性。本文介绍了 Quasar,这是一种专门为增强 LLM 代码操作而设计的新型编程语言。
Quasar 将内部程序逻辑与外部工具交互严格分离,通过对外部调用进行标注并调整内部执行,能够干净利落地集成先进的语言特性。作者通过三项关键改进展示了 Quasar 的实用性:利用批处理用户查询来实现访问控制以提高安全性;通过外部调用的自动并行化来降低执行延迟;以及利用保形预测(Conformal Prediction)提供不确定性量化,从而帮助缓解模型的幻觉问题。
Quasar: A Programming Language Specialized for LLM Code Actions
Summary
大语言模型(LLM)经常依赖外部工具和代码执行(通常是用 Python 编写的)来利用循环和条件等高级控制流解决复杂任务。然而,直接在 Python 中实现支持更有效代码操作的许多编程语言特性是困难的。本文提出了 Quasar,这是一种专门设计用于增强 LLM 代码操作的新型编程语言。Quasar 将捕获程序逻辑的内部代码与同与世界交互的外部工具的调用分离开来。然后,可以通过以下方式轻松实现新特性:(1) 用与该特性相关的副作用注释外部调用,以及 (2) 修改内部代码的执行以跟踪此信息。我们开发了一种实现这一创新理念的新型编程语言 Quasar。为了说明其实用性,我们在 Quasar 之上实现了几个有用的特性来增强代码操作:使用批量用户查询进行访问控制以提高安全性、外部调用的自动并行化以减少延迟、以及用于不确定性量化以减轻幻觉的保形预测。
Large language models (LLMs) frequently rely on external tools and code execution—typically written in Python—to solve complex tasks using advanced control flows like loops and conditionals. However, implementing specialized programming features directly in Python can be challenging.
This paper introduces Quasar, a novel programming language designed specifically to enhance LLM code actions. Quasar separates internal program logic from external tool interactions, allowing advanced language features to be integrated cleanly by annotating external calls and adapting internal execution. The authors demonstrate Quasar's utility through three key enhancements: * Access Control: Utilizing batched user queries to improve security. * Autoparallelization: Optimizing external calls to reduce execution latency. * Conformal Prediction: Providing uncertainty quantification to help mitigate model hallucinations.
Paper Metadata
- arXiv ID: arXiv:2506.12202 [cs.PL]
- Subjects: 编程语言 (
cs.PL); 人工智能 (cs.AI); 密码学与安全 (cs.CR); 机器学习 (cs.LG) - Journal Reference: 第三届语言建模会议 (COLM 2026)
- Submission Date: 2025年6月13日 (最后修订:2026年8月25日)
Authors
- Stephen Mell
- Botong Zhang
- David Mell
- Shuo Li
- Ramya Ramalingam
- Nathan Yu
- Stephan Zdancewic
- Osbert Bastani
Abstract
大语言模型(LLM)经常调用外部工具来解决任务。一种有效的策略是让 LLM 编写代码,使其能够使用条件判断和循环等复杂的控制流。此类代码操作通常表示为 Python 代码,因为 LLM 非常擅长编写 Python。然而,许多能够支持更有效代码操作的编程语言特性在 Python 中很难实现。我们建议将捕获程序逻辑的内部代码与对与世界交互的工具的外部调用分离开来。然后,可以通过以下方式轻松实现新特性:(1) 用与该特性相关的副作用注释外部调用,以及 (2) 修改内部代码的执行以跟踪此信息。我们开发了一种实现这一想法的新型编程语言 Quasar。为了说明其实用性,我们在 Quasar 之上实现了几个有用的特性来增强代码操作:通过批量用户查询进行访问控制以提高安全性,自动并行化外部调用以减少延迟,以及用于减轻幻觉的不确定性量化的保形预测。
Large language models (LLMs) often call external tools to solve tasks. One effective strategy is for LLMs to write code, enabling them to use complex control flow such as conditionals and loops. Such code actions are typically represented as Python code, since LLMs are proficient at writing it. However, many programming language features that would support more effective code actions are difficult to implement for Python. We propose separating internal code that captures program logic from external calls to tools that interact with the world. New features can then easily be implemented by (1) annotating external calls with the effects relevant to that feature, and (2) modifying the execution of the internal code to track this information. We develop a novel programming language, Quasar, that implements this idea. To illustrate its utility, we implement several useful features on top of Quasar to enhance code actions: access control with batched user queries to improve security, autoparallelization of external calls to reduce latency, and conformal prediction for uncertainty quantification to mitigate hallucinations.