SpanCS: Span-level Code-switching for Cross-lingual Code Generation
-
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.
-
-