Table of Contents
Fetching ...

From Critique to Clarity: A Pathway to Faithful and Personalized Code Explanations with Large Language Models

Zexing Xu, Zhuang Luo, Yichuan Li, Kyumin Lee, S. Rasoul Etesami

TL;DR

This work addresses the challenge of generating faithful, personalized code explanations using large language models. It introduces an iterative refinement framework with two independent loops—faithfulness and personalization—augmented by prompt engineering, self-correction, and external-tool collaboration to produce explanations tailored to individual user backgrounds. The method leverages CodeContests data and Stack Overflow inquiry histories, demonstrating superior faithfulness (Pass@k) and personalization (Win Rate, Rouge-L, Word Overlap) over baselines and even commercial products. By enabling high-quality, user-aligned explanations and proposing avenues to generate large-scale silver explanations for fine-tuning, the approach holds practical value for developers and business stakeholders seeking clearer reasoning and alignment with goals.

Abstract

In the realm of software development, providing accurate and personalized code explanations is crucial for both technical professionals and business stakeholders. Technical professionals benefit from enhanced understanding and improved problem-solving skills, while business stakeholders gain insights into project alignments and transparency. Despite the potential, generating such explanations is often time-consuming and challenging. This paper presents an innovative approach that leverages the advanced capabilities of large language models (LLMs) to generate faithful and personalized code explanations. Our methodology integrates prompt enhancement, self-correction mechanisms, personalized content customization, and interaction with external tools, facilitated by collaboration among multiple LLM agents. We evaluate our approach using both automatic and human assessments, demonstrating that our method not only produces accurate explanations but also tailors them to individual user preferences. Our findings suggest that this approach significantly improves the quality and relevance of code explanations, offering a valuable tool for developers and stakeholders alike.

From Critique to Clarity: A Pathway to Faithful and Personalized Code Explanations with Large Language Models

TL;DR

This work addresses the challenge of generating faithful, personalized code explanations using large language models. It introduces an iterative refinement framework with two independent loops—faithfulness and personalization—augmented by prompt engineering, self-correction, and external-tool collaboration to produce explanations tailored to individual user backgrounds. The method leverages CodeContests data and Stack Overflow inquiry histories, demonstrating superior faithfulness (Pass@k) and personalization (Win Rate, Rouge-L, Word Overlap) over baselines and even commercial products. By enabling high-quality, user-aligned explanations and proposing avenues to generate large-scale silver explanations for fine-tuning, the approach holds practical value for developers and business stakeholders seeking clearer reasoning and alignment with goals.

Abstract

In the realm of software development, providing accurate and personalized code explanations is crucial for both technical professionals and business stakeholders. Technical professionals benefit from enhanced understanding and improved problem-solving skills, while business stakeholders gain insights into project alignments and transparency. Despite the potential, generating such explanations is often time-consuming and challenging. This paper presents an innovative approach that leverages the advanced capabilities of large language models (LLMs) to generate faithful and personalized code explanations. Our methodology integrates prompt enhancement, self-correction mechanisms, personalized content customization, and interaction with external tools, facilitated by collaboration among multiple LLM agents. We evaluate our approach using both automatic and human assessments, demonstrating that our method not only produces accurate explanations but also tailors them to individual user preferences. Our findings suggest that this approach significantly improves the quality and relevance of code explanations, offering a valuable tool for developers and stakeholders alike.
Paper Structure (24 sections, 3 equations, 2 figures, 3 tables)

This paper contains 24 sections, 3 equations, 2 figures, 3 tables.

Figures (2)

  • Figure 1: The Illustration of Iterative Code Explanation Refinement. The system generates code explanations through two iterative loops: a faithfulness loop to ensure technical accuracy, and a personalization loop to tailor the explanation to the user's background. The loops operate independently to optimize their respective objectives and navigate the potential trade-off between personalization and faithfulness
  • Figure 2: Win Rate