Human-Like Code Quality Evaluation through LLM-based Recursive Semantic Comprehension

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Xu, Fangzhou, Zhang, Sai, Xing, Zhenchang, Zhang, Xiaowang, Han, Yahong, Feng, Zhiyong
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913592009293824
author Xu, Fangzhou
Zhang, Sai
Xing, Zhenchang
Zhang, Xiaowang
Han, Yahong
Feng, Zhiyong
author_facet Xu, Fangzhou
Zhang, Sai
Xing, Zhenchang
Zhang, Xiaowang
Han, Yahong
Feng, Zhiyong
contents Code quality evaluation involves scoring generated code quality based on a reference code for a specific problem statement. Currently, there are two main forms of evaluating code quality: match-based evaluation and execution-based evaluation. The former requires the collection of a large number of test cases, making a huge cost. The latter relies on superficial code matching as an evaluation metric, which fails to accurately capture code semantics. Moreover, extensive research has demonstrated that match-based evaluations do not truly reflect code quality. With the development of large language models (LLMs) in recent years, studies have proven the feasibility of using LLMs as evaluators for generative tasks. However, due to issues like hallucinations and uncertainty in LLMs, their correlation with human judgment remains at a lower level, making the direct use of LLMs for code quality evaluation challenging. To address these issues, we propose Human-Like Code Quality Evaluation through LLM-based Recursive Semantic Comprehension (HuCoSC). We employ a recursive approach to enable LLMs to comprehend portions of code semantics independently each time, obtaining the code semantics through multiple interactions with LLMs. We designed a Semantic Dependency Decoupling Storage to make independent analysis feasible, allowing LLMs to achieve more accurate semantics by breaking down complex problems. Finally, the generated code is scored based on a semantic comparison between the reference code and itself. Experimental results indicate that HuCoSC surpasses existing state-of-the-art methods in terms of correlation with human experts and correlation with code execution.
format Preprint
id arxiv_https___arxiv_org_abs_2412_00314
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Human-Like Code Quality Evaluation through LLM-based Recursive Semantic Comprehension
Xu, Fangzhou
Zhang, Sai
Xing, Zhenchang
Zhang, Xiaowang
Han, Yahong
Feng, Zhiyong
Software Engineering
Code quality evaluation involves scoring generated code quality based on a reference code for a specific problem statement. Currently, there are two main forms of evaluating code quality: match-based evaluation and execution-based evaluation. The former requires the collection of a large number of test cases, making a huge cost. The latter relies on superficial code matching as an evaluation metric, which fails to accurately capture code semantics. Moreover, extensive research has demonstrated that match-based evaluations do not truly reflect code quality. With the development of large language models (LLMs) in recent years, studies have proven the feasibility of using LLMs as evaluators for generative tasks. However, due to issues like hallucinations and uncertainty in LLMs, their correlation with human judgment remains at a lower level, making the direct use of LLMs for code quality evaluation challenging. To address these issues, we propose Human-Like Code Quality Evaluation through LLM-based Recursive Semantic Comprehension (HuCoSC). We employ a recursive approach to enable LLMs to comprehend portions of code semantics independently each time, obtaining the code semantics through multiple interactions with LLMs. We designed a Semantic Dependency Decoupling Storage to make independent analysis feasible, allowing LLMs to achieve more accurate semantics by breaking down complex problems. Finally, the generated code is scored based on a semantic comparison between the reference code and itself. Experimental results indicate that HuCoSC surpasses existing state-of-the-art methods in terms of correlation with human experts and correlation with code execution.
title Human-Like Code Quality Evaluation through LLM-based Recursive Semantic Comprehension
topic Software Engineering
url https://arxiv.org/abs/2412.00314