Data-driven automated generation of unit test code faces challenges of low coverage and poor readability, struggling to meet the increasing demand for testing. Recently, Large Language Models (LLMs) have shown great potential in code generation tasks. However, LLMs still face the issues of catastrophic forgetting and limited resources. To address these problems, this work proposes an efficient fine-tuning training method for LLMs for generating unit test codes via a multi-task prompt learning scheme. We design a source mask prompt to guide the model in learning the critical patterns for code generation. To fully leverage the cross-domain relationships, we initialize a target mask prompt by transferring the source mask prompt to the target domain. We effectively use cross-domain mapping attention to interpolate the previously isolated source unified prompts to derive Target instance-level prompts, ensuring better adapting pre-trained multi-task knowledge to downstream code generation tasks with limited resources. Experimental results indicate that our method outperforms other methods on the public SF110 Corpus of Classes dataset. Compared to the state-of-the-art code generation model DeepSeek-Coder, our method achieves improvements of 15.5%, 16.8%, and 14.4% in the evaluation metrics of compilation rate, branch coverage, and line coverage, respectively.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

An Efficient Fine-Tuning Strategy of Large Language Models for Unit Test Code Generation via Multi-Task Prompt Learning

  • Gang Chen,
  • Xinyi Liu,
  • Bin Chen,
  • Zeke Li,
  • Haiwei Fan,
  • Peng Cao,
  • Guangqi Wen

摘要

Data-driven automated generation of unit test code faces challenges of low coverage and poor readability, struggling to meet the increasing demand for testing. Recently, Large Language Models (LLMs) have shown great potential in code generation tasks. However, LLMs still face the issues of catastrophic forgetting and limited resources. To address these problems, this work proposes an efficient fine-tuning training method for LLMs for generating unit test codes via a multi-task prompt learning scheme. We design a source mask prompt to guide the model in learning the critical patterns for code generation. To fully leverage the cross-domain relationships, we initialize a target mask prompt by transferring the source mask prompt to the target domain. We effectively use cross-domain mapping attention to interpolate the previously isolated source unified prompts to derive Target instance-level prompts, ensuring better adapting pre-trained multi-task knowledge to downstream code generation tasks with limited resources. Experimental results indicate that our method outperforms other methods on the public SF110 Corpus of Classes dataset. Compared to the state-of-the-art code generation model DeepSeek-Coder, our method achieves improvements of 15.5%, 16.8%, and 14.4% in the evaluation metrics of compilation rate, branch coverage, and line coverage, respectively.