CodeQueries:一个面向代码语义查询的数据集
CodeQueries: A Dataset of Semantic Queries over Code
AI总结:
本文提出 CodeQueries,一个面向 Python 文件级代码语义查询、答案为代码片段的数据集,并通过 GPT3.5-Turbo 与 CuBERT 实验表明其对神经代码理解具有挑战性。
摘要:
开发者经常会对其正在处理的代码的语义方面产生疑问,例如“是否存在一个类,其父类声明了相互冲突的属性?”。回答这些问题需要理解代码语义,例如类的属性和继承关系。对此类问题的回答应当识别构成答案的代码片段(例如子类的声明)以及支持性事实(例如冲突属性的定义)。现有的代码问答研究只考虑了是/否问题或方法级上下文。我们贡献了一个名为 CodeQueries 的标注数据集,涵盖针对 Python 代码的语义查询。与现有数据集相比,在 CodeQueries 中,查询围绕代码语义展开,上下文处于文件级别,而答案是代码片段。我们基于广泛使用的静态分析工具 CodeQL 所支持的查询来构建该数据集,并纳入了正例和负例,以及需要单跳和多跳推理的查询。为评估数据集的价值,我们评测了基线神经方法。我们在 CodeQueries 的一个子集上研究了大语言模型(GPT3.5-Turbo)在零样本和少样本设置下的表现。我们还评测了经过微调的 BERT 风格模型(CuBERT)。我们发现这些模型在 CodeQueries 上取得的成功有限。因此,CodeQueries 是一个具有挑战性的数据集,可用于在抽取式问答设置中测试神经模型理解代码语义的能力。
英文摘要:
Developers often have questions about semantic aspects of code they are working on, e.g., "Is there a class whose parent classes declare a conflicting attribute?". Answering them requires understanding code semantics such as attributes and inheritance relation of classes. An answer to such a question should identify code spans constituting the answer (e.g., the declaration of the subclass) as well as supporting facts (e.g., the definitions of the conflicting attributes). The existing work on question-answering over code has considered yes/no questions or method-level context. We contribute a labeled dataset, called CodeQueries, of semantic queries over Python code. Compared to the existing datasets, in CodeQueries, the queries are about code semantics, the context is file level and the answers are code spans. We curate the dataset based on queries supported by a widely-used static analysis tool, CodeQL, and include both positive and negative examples, and queries requiring single-hop and multi-hop reasoning. To assess the value of our dataset, we evaluate baseline neural approaches. We study a large language model (GPT3.5-Turbo) in zero-shot and few-shot settings on a subset of CodeQueries. We also evaluate a BERT style model (CuBERT) with fine-tuning. We find that these models achieve limited success on CodeQueries. CodeQueries is thus a challenging dataset to test the ability of neural models, to understand code semantics, in the extractive question-answering setting.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。