arXiv:2409.13551cs.SEcs.CL2024-09被引 13

用多模态上下文提升代码生成准确率,解决数据清洗自动化难题

Contextualized Data-Wrangling Code Generation in Computational Notebooks

  • 通过数据流分析挖掘带上下文依赖的清洗代码样本
  • 构建包含58,221个样本的CoCoNote数据集,明确标注上下文关系
  • 提出DataCoder模型,分别编码数据与代码/文本上下文,效果更优

数据清洗是计算笔记本中准备原始数据的关键步骤,但耗时且复杂。代码生成有望通过将用户意图转化为可执行代码来降低分析师负担。精准生成清洗代码需综合考虑笔记本中的文本、代码和数据上下文。然而,笔记本常将非线性的分析任务线性排列,上下文依赖关系不清晰,直接训练模型难以充分利用上下文。为此,本文提出自动化方法CoCoMine,通过数据流分析识别清洗代码块,并追踪与重放笔记本以提取具有明确多模态上下文依赖的代码生成样本。基于此,构建了包含58,221个样本的CoCoNote数据集。实验表明,该数据集能有效提升预训练代码模型与大语言模型在清洗代码生成任务上的表现。此外,本文还提出DataCoder模型,分别编码数据上下文与代码/文本上下文,显著提升生成质量。

原文摘要 · Abstract (English)

Data wrangling, the process of preparing raw data for further analysis in computational notebooks, is a crucial yet time-consuming step in data science. Code generation has the potential to automate the data wrangling process to reduce analysts' overhead by translating user intents into executable code. Precisely generating data wrangling code necessitates a comprehensive consideration of the rich context present in notebooks, including textual context, code context and data context. However, notebooks often interleave multiple non-linear analysis tasks into linear sequence of code blocks, where the contextual dependencies are not clearly reflected. Directly training models with source code blocks fails to fully exploit the contexts for accurate wrangling code generation. To bridge the gap, we aim to construct a high quality datasets with clear and rich contexts to help training models for data wrangling code generation tasks. In this work, we first propose an automated approach, CoCoMine to mine data-wrangling code generation examples with clear multi-modal contextual dependency. It first adopts data flow analysis to identify the code blocks containing data wrangling codes. Then, CoCoMine extracts the contextualized datawrangling code examples through tracing and replaying notebooks. With CoCoMine, we construct CoCoNote, a dataset containing 58,221 examples for Contextualized Data-wrangling Code generation in Notebooks. To demonstrate the effectiveness of our dataset, we finetune a range of pretrained code models and prompt various large language models on our task. Furthermore, we also propose DataCoder, which encodes data context and code&textual contexts separately to enhance code generation. Experiment results demonstrate the significance of incorporating data context in data-wrangling code generation and the effectiveness of our model. We release code and data at url...

代码生成数据清洗上下文建模笔记本

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。