[论文解读] InterCode: Standardizing and Benchmarking Interactive Coding with Execution Feedback
InterCode 提供一个轻量级、基于 Docker 的交互式代码生成框架,带执行反馈,并展示 Bash、SQL、Python 环境以在不同提示策略下对最先进的大型语言模型进行基准测试。
Humans write code in a fundamentally interactive manner and rely on constant execution feedback to correct errors, resolve ambiguities, and decompose tasks. While LLMs have recently exhibited promising coding capabilities, current coding benchmarks mostly consider a static instruction-to-code sequence transduction process, which has the potential for error propagation and a disconnect between the generated code and its final execution environment. To address this gap, we introduce InterCode, a lightweight, flexible, and easy-to-use framework of interactive coding as a standard reinforcement learning (RL) environment, with code as actions and execution feedback as observations. Our framework is language and platform agnostic, uses self-contained Docker environments to provide safe and reproducible execution, and is compatible out-of-the-box with traditional seq2seq coding methods, while enabling the development of new methods for interactive code generation. We use InterCode to create three interactive code environments with Bash, SQL, and Python as action spaces, leveraging data from the static NL2Bash, Spider, and MBPP datasets. We demonstrate InterCode's viability as a testbed by evaluating multiple state-of-the-art LLMs configured with different prompting strategies such as ReAct and Plan & Solve. Our results showcase the benefits of interactive code generation and demonstrate that InterCode can serve as a challenging benchmark for advancing code understanding and generation capabilities. InterCode is designed to be easily extensible and can even be used to create new tasks such as Capture the Flag, a popular coding puzzle that is inherently multi-step and involves multiple programming languages. Project site with code and data: https://intercode-benchmark.github.io
研究动机与目标
- 模仿人类的写-执行-测试调试流程,以执行反馈提升代码生成质量。
- 提供一个通用、对环境无关、可扩展且通过 Docker 容器实现安全的交互式编码框架。
- 将现有静态数据集置于交互式任务的情境中,以实现迭代改进与评估。
- 评估多种模型与提示策略,以量化交互在编码任务中的收益。
- 提出一个可扩展的任务构建流水线,用以创建新的交互式编码基准和数据集。
提出的方法
- 将 InterCode 定义为一个部分可观测马尔可夫决策过程(POMDP),包含指令空间、状态、行动、观测和奖励信号。
- 实现基于 Docker 的执行沙盒,将 Bash、SQL、Python 环境作为行动空间。
- 将静态 NL-to-code 数据集(NL2Bash、Spider、MBPP)通过将指令和黄金响应映射到可执行环境来落地到交互式任务。
- 使用基于执行的奖励(包含精确匹配和 IoU/Kendall 等变体),并提供自定义信号的奖励函数端点。
- 在多种提示策略(单轮、再试、ReAct、Plan & Solve)下评估一系列模型(OpenAI、PaLM-2、开源)。
- 提供一个模块化的数据收集与环境构建流水线,将现有数据集转换为 InterCode 任务,并通过单元测试检验安全性。
实验结果
研究问题
- RQ1交互式编码是否在具有执行反馈的情况下相较静态序列到序列基准提升代码生成?
- RQ2不同的提示策略在 Bash、SQL、Python 任务中对交互式编码的有效性有何影响?
- RQ3当前大型语言模型在长时程交互式编码中的挑战与局限性为何,InterCode 如何促进改进?
- RQ4如何将现有 NL-to-code 数据集转化为具有安全执行环境的灵活交互式任务?
- RQ5InterCode 是否具备足够的可扩展性,以支持如 Capture the Flag(CTF)等新任务?
主要发现
- 在多轮交互下,交互式编码在各任务和模型上均提升了性能。
- GPT-4 在 InterCode-SQL 使用 Try Again 提示时成功率高达 73.7%,显示了交互带来的显著收益。
- 鼓励显式推理的提示策略(ReAct、Plan & Solve)通常在更少的回合数和更好的可达性下实现更高的成功率。
- 模型展现出规划与模块化问题求解的能力,利用观测来组合更高阶的行动,并利用早前解决的子问题来应对多步任务。
- InterCode 作为一个安全、可扩展的基准,用于评估交互式代码生成,并可通过其基于 Docker 的环境为新数据集和任务提供落地支撑。
- 该框架支持多样化的任务设置(Bash、SQL、Python),并可扩展到其他语言及更复杂的任务,如 CTF 风格挑战。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。