liu.seSearch for publications in DiVA
Change search
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • oxford
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf
Improving Quality in AI-Generated Code through Prompt Engineering: An Evaluation of the Impact of Prompting Techniques on Software Quality in Code Generated by Large Language Models
Linköping University, Department of Computer and Information Science.
2025 (English)Independent thesis Advanced level (degree of Master (Two Years)), 20 credits / 30 HE creditsStudent thesis
Abstract [en]

The use of Large Language Models (LLMs) for code generation is rapidly increasing. While previous investigations on the correctness of AI-generated code are widely present, less focus has been placed on the code's further quality attributes and how it can be improved. An aspect that can be equally important. This thesis aims to fill this gap by investigating how LLMs can be guided to generate code that aligns with software quality principles. Using a mixed methods approach, the study first identifies the aspects developers consider important for code quality through developer interviews and thematic analysis. Subsequently, experiments evaluate how (a) established prompt engineering strategies and (b) three state-of-the-art LLM models affect code quality across a range of programming tasks for class- and function-level code solutions. Quantitative evaluation uses cognitive complexity, maintainability index, and library usage metrics representing quality characteristics important for a few developers with 10 to 30 years of experience in the industry. The result shows that no prompting technique consistently improves code quality across the models compared to the zero-shot baseline. The effectiveness varies across models, with the larger ChatGPT model showing more responsiveness to guidance, for instance, its cognitive complexity-level on ClassEval was reduced on average from 0.92 to 0.70 with the Combined prompting technique. Although optimal prompting techniques are shown to be model-dependent, the potential for enhancing code quality through generic prompt techniques remains considerably constrained.

Place, publisher, year, edition, pages
2025. , p. 49
National Category
Computer and Information Sciences
Identifiers
URN: urn:nbn:se:liu:diva-217843OAI: oai:DiVA.org:liu-217843DiVA, id: diva2:1999528
Subject / course
Computer science
Supervisors
Examiners
Available from: 2025-12-09 Created: 2025-09-19 Last updated: 2025-12-09Bibliographically approved

Open Access in DiVA

fulltext(1957 kB)698 downloads
File information
File name FULLTEXT01.pdfFile size 1957 kBChecksum SHA-512
af6057d0192108e76f4019f7d392e63051537eacb5f9ff41d4c44453ae4ad8e26cf96916a2b6787b0d054a02197ff9998c03870dcae00f4b05bef2112695ae99
Type fulltextMimetype application/pdf

By organisation
Department of Computer and Information Science
Computer and Information Sciences

Search outside of DiVA

GoogleGoogle Scholar
Total: 700 downloads
The number of downloads is the sum of all downloads of full texts. It may include eg previous versions that are now no longer available

urn-nbn

Altmetric score

urn-nbn
Total: 1809 hits
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • oxford
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf