Semantic and Lexical Retrieval-Augmented Large Language Models for Code Summarization

As software systems grow, automatic code summarization is vital for program comprehension and maintenance. While Large Language Models (LLMs) excel at this task, they often generate verbose, incomplete, or hallucinated summaries when relying solely on source code. Retrieval-augmented generation (RAG) addresses this by incorporating external code-summary examples. However, existing single-strategy retrievers struggle to capture both deep semantic similarity and precise keyword matching. To overcome these limitations, we propose HyRALLM, a hybrid retrieval-augmented LLM framework. First, a dense retriever is constructed via cross-modal contrastive learning for semantic alignment, which is then integrated with a keyword-based sparse retriever. During the generation stage, the retrieved context is utilized to guide the LLM in generating summaries, and the quality of the generated summaries is further enhanced through a multi-candidate strategy and a post-processing discrimination mechanism. Experiments on the JCSD and PCSD benchmark datasets demonstrate that HyRALLM achieves highly competitive performance across BLEU, ROUGE-L, METEOR, and CIDEr metrics. Additional analyses confirm our framework effectively improves summary quality, reduces semantic deviation, and enhances generation robustness.

Authors

Institutions

Publication Details

Journal
International Journal of Software Engineering and Knowledge Engineering
Published
2026-12-02
DOI
https://doi.org/10.1142/s0218194027500100
Primary Topic
Software Engineering Research
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
article

Semantic and Lexical Retrieval-Augmented Large Language Models for Code Summarization

Chunli Xie, Chunpeng Kang, Wei Zhu, Jiawei Wang
5 links
International Journal of Software Engineering and Knowledge Engineering
Software Engineering Research
article

Semantic and Lexical Retrieval-Augmented Large Language Models for Code Summarization

Chunli Xie, Chunpeng Kang, Wei Zhu, Jiawei Wang
article en

Abstract

As software systems grow, automatic code summarization is vital for program comprehension and maintenance. While Large Language Models (LLMs) excel at this task, they often generate verbose, incomplete, or hallucinated summaries when relying solely on source code. Retrieval-augmented generation (RAG) addresses this by incorporating external code-summary examples. However, existing single-strategy retrievers struggle to capture both deep semantic similarity and precise keyword matching. To overcome these limitations, we propose HyRALLM, a hybrid retrieval-augmented LLM framework. First, a dense retriever is constructed via cross-modal contrastive learning for semantic alignment, which is then integrated with a keyword-based sparse retriever. During the generation stage, the retrieved context is utilized to guide the LLM in generating summaries, and the quality of the generated summaries is further enhanced through a multi-candidate strategy and a post-processing discrimination mechanism. Experiments on the JCSD and PCSD benchmark datasets demonstrate that HyRALLM achieves highly competitive performance across BLEU, ROUGE-L, METEOR, and CIDEr metrics. Additional analyses confirm our framework effectively improves summary quality, reduces semantic deviation, and enhances generation robustness.

International Journal of Software Engineering and Knowledge Engineering
Twitter (United States) (US)
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon