Fine-Tuning Mistral 7b Large Language Model For Python Query Response And Code Generation: A Parameter Efficient Approach

Authors

DOI:

https://doi.org/10.21015/vtcs.v12i1.1885

Abstract

The research delves into the concept of fine-tuning and its unique application to Python queries and code generation. This process involves adjusting the model's parameters to make it more proficient in responding to Python-only queries and generating corresponding code. It underscores the untapped potential of fine-tuning large language models and the significance of combining Parameter-Efficient fine-tuning with quantization to reduce memory usage. This was achieved by the pre-trained language model’s fine-tuning and meticulously evaluating and contrasting it with its base model. Notably, the model was fine-tuned to proficiently respond to Python-only queries and generate corresponding code, a novel and intriguing application of fine-tuning. We utilized Mistral7B-Instruct version 0.2 as our base large language model for fine-tuning. The dataset, sourced from Kaggle, was a collection of Python Question-Answer pairs. Before fine-tuning, we meticulously cleaned and organized the dataset, ensuring its quality by arranging it in descending order based on their rankings. This rigorous and thorough approach instills confidence in the reliability of our results. Our research shows that the fine-tuned model outperformed the base Mistral7B Instruct version 0.2 model in BERTScore and demonstrated a significant performance boost when compared with the HumanEval metric. This clear and substantial improvement further affirms the effectiveness of our approach. Our research is a step forward in the realm of large language models, specifically in the coding sphere. It showcases a substantial improvement in understanding Python queries and generating code snippets. This has profound implications for the current trajectory of Natural Language Generation and Generative AI fields. Our findings act as a pivotal catalyst for further progress.

References

Stack Overflow. (n.d.). Retrieved from https://stackoverflow.com/

Rao, N., Bansal, C., Zimmermann, T., Awadallah, A. H., & Nagappan, N. (2020). Analyzing web search behavior for software engineering tasks. In 2020 IEEE International Conference on Big Data (Big Data) (pp. 768–777). IEEE

Skripchuk, J., Bennett, N., Zhang, J., Li, E., & Price, T. (2023). Analysis of novices’ web-based help-seeking behavior while programming. In Proceedings of the 54th ACM Technical Symposium on Computer Science Education V. 1 (pp. 945–951)

Bird, C., Ford, D., Zimmermann, T., Forsgren, N., Kalliamvakou, E., Lowdermilk, T., & Gazit, I. (2022). Taking Flight with Copilot: Early insights and opportunities of AI-powered pair-programming tools. Queue, 20(6), 35–57

Imai, S. (2022). Is GitHub copilot a substitute for human pair-programming? An empirical study. In Proceedings of the ACM/IEEE 44th International Conference on Software Engineering: Companion Proceedings (pp. 319–321).

Liu, J., Tang, X., Li, L., Chen, P., & Liu, Y. (2023). Which is a better programming assistant? A comparative study between chatgpt and stack overflow. Retrieved from http://arXiv:2308.13851

Dondio, P., & Shaheen, S. (2020). Is Stackoverflow an effective complement to gaining practical knowledge compared to traditional computer science learning? In Proceedings of the 11th International Conference on Education Technology and Computers, ICETC ’19 (pp. 132–138). New York, NY, USA: Association for Computing Machinery

Wang, S., Chen, T.-H., & Hassan, A. E. (2020). How do users revise answers on technical q&a websites? A case study on stack overflow. IEEE Transactions on Software Engineering, 46(9), 1024–1038

Ross, S. I., Martinez, F., Houde, S., Muller, M., & Weisz, J. D. (2023). The programmer’s assistant: Conversational interaction with a large language model for software development. In Proceedings of the 28th International Conference on Intelligent User Interfaces (pp. 491–514)

Priyan Vaithilingam, Tianyi Zhang, and Elena L Glassman. 2022. Expectation vs. experience: Evaluating the usability of code generation tools powered by large language models. In Chi conference on human factors in computing systems extended abstracts. 1–7

Mangrulkar, S., Gugger, S., Debut, L., Belkada, Y., & Paul, S. (2022). PEFT: State-of-the-art Parameter-Efficient Fine-Tuning methods. Retrieved from https://github.com/huggingface/peft, 2022

Lomshakov, Vadim & Kovalchuk, Sergey & Omelchenko, Maxim & Nikolenko, Sergey & Aliev, Artem. (2023). Fine-Tuning Large Language Models for Answering Programming Questions with Code Snippets. 10.1007/978-3-031-36021-3_15

Papineni, Kishore & Roukos, Salim & Ward, Todd & Zhu, Wei Jing. (2002). BLEU: A method for automatic evaluation of machine translation. 10.3115/1073083.1073135

Zhang, T., Kishore, V., Wu, F., Weinberger, K. Q., & Artzi, Y. (2020). Bertscore: Evaluating text generation with Bert. Retrieved from http://arXiv:1904.09675

Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. 2021. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374 (2021)

OpenAI. (2023). ChatGPT: Optimizing language models for dialogue. Retrieved from https://openai.com/blog/chatgpt

Jason Wei, Maarten Bosma, Vincent Y Zhao, Kelvin Guu, Adams Wei Yu, Brian Lester, Nan Du, Andrew M Dai, and Quoc V Le. 2021. Finetuned language models are zero-shot learners. arXiv preprint arXiv:2109.01652 (2021)

Strobelt, H., Webson, A., Sanh, V., Hoover, B., Beyer, J., Pfister, H., & Rush, A. M. (2022). Interactive and visual prompt engineering for ad-hoc task adaptation with large language models. IEEE Transactions on Visualization and Computer Graphics, 29(1), 1146–1156

Chaozheng Wang, Yuanhang Yang, Cuiyun Gao, Yun Peng, Hongyu Zhang, and Michael R Lyu. 2022. No more finetuning? An experimental evaluation of prompt tuning in code intelligence. In Proceedings of the 30th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 382–394

Edward J Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. 2021. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685 (2021)

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention is all you need. Advances in neural information processing systems 30 (2017)

Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. 2023. Qlora: Efficient finetuning of quantized llms. arXiv preprint arXiv:2305.14314 (2023)

Li, Y., Li, Z., Zhang, K., Dan, R., Jiang, S., & Zhang, Y. (2023). ChatDoctor: A medical chat model fine-tuned on a large language model Meta-AI (LLaMA) using medical domain knowledge. Retrieved from http://arXiv:2303.14070

Yang, H., Liu, X.-Y., & Wang, C. D. (2023). FinGPT: Open-Source Financial Large Language Models. FinLLM Symposium at IJCAI 2023, arXiv preprint arXiv:2306.06031

Touvron, H., Martin, L., Stone, K., Albert, P., Almahairi, A., Babaei, Y., Bashlykov, N., Batra, S., Bhargava, P., Bhosale, S., et al. (2023). Llama 2: Open foundation and fine-tuned chat models. Retrieved from http://arXiv:2307.09288

Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Rozière, B., Goyal, N., Hambro, E., Azhar, F., et al. (2023). Llama: Open and efficient foundation language models. Retrieved from http://arXiv:2302.13971

Rozière, B., Gehring, J., Gloeckle, F., Sootla, S., Gat, I., Tan, X. E., Adi, Y., Liu, J., Remez, T., Rapin, J., et al. (2023). Code llama: Open foundation models for code. Retrieved from http://arXiv:2308.12950

Stanford alpaca: an instruction-following llama model. (2023). Retrieved from https://github.com/tatsu-lab/stanford_alpaca

Beutel, G., Geerits, E., & Kielstein, J. T. (2023). Artificial hallucination: GPT on LSD? Crit Care, 27, 148.10.1186/s13054-023-04425-6

A multitask, multilingual, multimodal evaluation of chatgpt on reasoning, hallucination, and interactivity. (2023). Retrieved from http://arXiv:2302.04023

Salvagno, M., Taccone, F. S., & Gerli, A. G. (2023). Artificial intelligence hallucinations. Crit Care, 27, 180.10.1186/s13054-023-04473-y

Kabir, S., N., D., Kou, B., & Zhang, T. (2023). Who Answers It Better? An In-Depth Analysis of ChatGPT and Stack Overflow Answers to Software Engineering Questions. Retrieved from http://arXiv:2308.02312

Goodrich, B., Rao, V., Liu, P. J., & Saleh, M. (2019). Assessing the factual accuracy of generated text. In Proceedings of the 25th ACM SIGKDD international conference on knowledge discovery & data mining (pp. 166–175)

Borji, A. (2023). A categorical archive of chatgpt failures. Retrieved from http://arXiv:2302.03494

Guo, B., Zhang, X., Wang, Z., Jiang, M., Nie, J., Ding, Y., Yue, J., & Wu, Y. (2023). How close is chatgpt to human experts? comparison corpus, evaluation, and detection. Retrieved from http://arXiv:2301.07597

Jiang, A. Q., Sablayrolles, A., Mensch, A., Bamford, C., Chaplot, D. S., Casas, D. D., Bressand, F., Lengyel, G., Lample, G., Saulnier, L., Lavaud, L. R., Lachaux, M., Stock, P., Scao, T. L., Lavril, T., Wang, T., Lacroix, T., & Sayed, W. E. (2023). Mistral 7B. Retrieved from http://arXiv:2310.06825

Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of deep bidirectional transformers for language understanding. In NAACL-HLT

Downloads

Published

2024-06-30

How to Cite

Samo, H., Ali, K., Memon, M., Abbasi, F. A., Koondhar, M. Y., & Dahri, K. (2024). Fine-Tuning Mistral 7b Large Language Model For Python Query Response And Code Generation: A Parameter Efficient Approach. VAWKUM Transactions on Computer Sciences, 12(1), 205–217. https://doi.org/10.21015/vtcs.v12i1.1885