高级检索

SpanCS:面向跨语言代码生成的片段级语码转换

SpanCS: Span-level Code-switching for Cross-lingual Code Generation

  • 摘要: 跨语言代码生成旨在将英语到代码的生成能力迁移至其他自然语言。翻译-训练(Translate-Train)和语码转换(Code-Switching)是实现跨语言迁移的两类经典数据增广方法,两者优势互补但尚未有效结合。为此,该文提出了一种面向跨语言代码生成的片段级语码转换(SpanCS)方法。首先,该方法利用语码转换框架关联源语言上下文与目标语言片段,以促进多种语言的交互和对齐。其次,该方法利用翻译-训练方法从完整的源语言翻译中提取目标语言片段,以保证增广数据与原始数据间的语义一致性。为了公平地评价多种自然语言之间代码生成的性能差异,该文通过人工翻译与校验,基于HumanEval构建了包含10种自然语言的多语言代码生成评测基准MHumanEval。该基准上的三个主干模型的实验结果表明,SpanCS在跨语言代码生成任务上一致优于前人的数据增广方法。

     

    Abstract: Cross-lingual code generation aims to transfer the ability of generating code from English to other natural languages (NLs). Translate-train and Code-switching are two common data augmentation (DA) approaches for cross-lingual transfer, which complement each other but have not been effectively combined. We propose a span-level code-switching (SpanCS) approach for cross-lingual code generation. First, it leverages the code-switching framework to correlate source language context and target language span to model the interaction and alignment among multiple languages. Second, it utilizes the translate-train approach to extract target language span from a complete source language translation, ensuring the semantic consistency between augmented data and original data. To fairly evaluate the discrepancy of code generation across multiple NLs, we construct MHumanEval, a multilingual code generation benchmark that includes 10 NLs, based on HumanEval via manual translation and verification. Experiments on this benchmark for three mainstream LLMs show that SpanCS consistently outperforms conventional DA approaches for cross-lingual code generation.

     

/

返回文章
返回