Improving Code Generation Based on LoRA Fine-Tuning
Abstract
With the growing popularity of chatbot programs like ChatGPT and DeepSeek, people are no longer content with merely simple text for the content they generate. With the popularization of the IT and Internet industries, the demand for generating code based on natural language descriptions is increasing day by day. This paper will experimentally demonstrate how fine-tuning the CodeLlama model based on Parameter Efficient fine-tuning (PEFT), especially low-rank adaptive (LoRA) technology, optimizes and improves the generation of Python code, and use authoritative evaluation indicators to prove this point. We will conduct research on code generation by drawing on datasets such as HumanEval and APPs. Then, we will fine-tune the existing baseline model using fine-tuning techniques. We will comprehensively evaluate the generation results before and after fine-tuning using the pass@k metric, plot the results in a chart for comparison, and draw conclusions accordingly. The experimental results show that, on the whole, the Code Llama model before and after LoRA fine-tuning has a significant improvement in the pass rate of the generated code. However, under different indicators, the improvement effect varies slightly. Under the evaluation system of pass@k, the greater the k value, the higher the absolute percentage increase, but the lower the relative percentage increase. Under the condition that other factors remain unchanged, although increasing the rank of the fine-tuning matrix can improve the pass rate of the generated code, the training time will significantly increase, indicating certain limitations.
References
- Li, C., Shi, C., Pan, M., et al. (2025). Code comment generation method based on semantic reranking. Journal of Software, 1–20.
- Gao, Z., Wang, Q., Chen, A., Liu, Z., Wu, B., Chen, L., & Li, J. (2024). Parameter-efficient fine-tuning with discrete Fourier transform. arXiv preprint arXiv: 2405.03003.
- Wang, Y. (2023). Asymmetric LoRA: Breaking the symmetry of low-rank adaptation for efficient fine-tuning. In Proceedings of the 40th International Conference on Machine Learning (PMLR 202, pp. 34567–34579).
- Zhang, L. (2023). PLoRA: Periodic low-rank adaptation for overcoming the low-rank bottleneck in parameter-efficient fine-tuning. Advances in Neural Information Processing Systems, 36.
- Zeng, H. (2024). Astraios: A comprehensive study of parameter-efficient fine-tuning methods for large language models. Transactions on Machine Learning Research.
- Liu, J. (2024). SF-UTG: Structure-aware fine-tuning for unit test generation using abstract syntax trees and data flow graphs. IEEE Transactions on Software Engineering, 50(3), 345–362.
- OpenAI. (2021). Evaluating large language models trained on code. Retrieved from https: //github.com/openai/human-eval
- Lyu, Z., Li, X., Xie, Z., & Li, M. (2025). Top Pass: Improve code generation by pass@k-maximized code ranking. Frontiers of Computer Science, 19(8), 198341.
- Wang, Q. (2024). A systematic review of evaluation methods for code generation: Metrics, benchmarks, and beyond. ACM Computing Surveys, 56(8), 1–38.
- Chen, M. (2023). CodeT: Multi-programming language code generation via test-driven synthesis. In Proceedings of the 61st ACM SIGPLAN Symposium on Programming Language Design and Implementation (pp. 112–126).
- Arabzadeh, N., Kiseleva, J., et al. (2023). AgentEval: A novel framework for evaluating LLM-powered applications. arXiv preprint arXiv: 2310.01470.
- Lee, T. (2024). FLAMe: A foundation model for automatic evaluation. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing.
- He, J. (2024). Secure-Instruct: Enhancing code security through instruction tuning with synthetic vulnerability data. In Proceedings of the 32nd ACM SIGSOFT International Symposium on the Foundations of Software Engineering (pp. 245–257).
- Tufano, R. (2024). Large language models for code-related tasks: An empirical study on code review, commit message generation, and code change completion. ACM Transactions on Software Engineering and Methodology, 33(2), 1–35.