一句话:提出 CoCoMine 与 CoCoNote,并设计 DataCoder,提升计算笔记本中利用多模态上下文的数据整理代码生成。
在计算笔记本中,数据整理耗时且关键,自动代码生成可将用户意图转为可执行代码。但笔记本把非线性分析任务交织成线性代码块,文本、代码与数据上下文依赖不清,直接用源码块训练难以充分利用上下文。论文提出 CoCoMine:用数据流分析定位数据整理代码块,并通过追踪与重放笔记本挖掘带多模态上下文依赖的示例;据此构建 CoCoNote,含 58,221 个样本。作者微调多种预训练代码模型并评测多个大语言模型,还提出分别编码数据上下文与代码/文本上下文的 DataCoder。实验显示数据上下文对数据整理代码生成很关键,DataCoder 有效。
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 data-wrangling 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 https://github.com/Jun-jie-Huang/CoCoNote.CCS CONCEPTS• Software and its engineering → Automatic programming.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2409-13551,
title = {Contextualized Data-Wrangling Code Generation in Computational Notebooks},
author = {Junjie Huang and Daya Guo and Chenglong Wang and Jiazhen Gu and Shuai Lu and Jeevana Priya Inala and Cong Yan and Jianfeng Gao and Nan Duan and Michael R. Lyu},
booktitle = {ASE},
year = {2024},
doi = {10.1145/3691620.3695503}
}