A Semantic and Lexical Analysis of LLM-Generated Responses in Comparison with Stack Overflow Answers

Large Language Models (LLMs) have become indispensable tools in programming education and professional software development. However, their output quality remains poorly characterized, particularly in terms of the semantic and linguistic quality of the explanatory text. Traditional evaluation metrics such as ROUGE primarily rely on lexical overlap and therefore only partially reflect the semantic adequacy of code explanations. This study proposes a multi-metric evaluation framework integrating semantic embeddings and lexical metrics to assess the quality of explanations generated by LLMs. We conducted experiments on 442 question-answer pairs produced by human experts regarding Python programming language from Stack Overflow, comparing them with GPT-4o-mini outputs. Three embedding models (MiniLM-L6, MPNet-Base, Paraphrase-MiniLM) were employed to compute the measure of semantic similarity by using cosine similarity, and ROUGE metrics (ROUGE-1, ROUGE-2, ROUGE-L) were used for lexical analysis. Results reveal a high semantic alignment (cosine similarity: 0.65–0.75) but substantially lower lexical overlap (ROUGE:0.10–0.32), indicating that LLMs produce semantically sound yet lexically distinct explanations. Pearson correlation analysis reveals weak to moderate correlations (r=0.29–0.47) between semantic and lexical metrics, suggesting that traditional metrics alone are insufficient for a comprehensive evaluation. Statistical testing (paired t-tests, p < 0.001) shows significant differences among embedding models, with MPNet-Base achieving the highest semantic consistency. Our findings underscore the critical need for multidimensional evaluation frameworks in assessing LLM-generated explanations, particularly in technical domains where semantic accuracy is crucial.

Authors

Institutions

Publication Details

Journal
Sakarya University Journal of Computer and Information Sciences
Published
2026-10-27
DOI
https://doi.org/10.35377/saucis...1865546
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
article

A Semantic and Lexical Analysis of LLM-Generated Responses in Comparison with Stack Overflow Answers

Kürşat Mustafa Karaoğlan, Yasin Ortakcı, Kerem Can CELEPKOLU
1 links
Sakarya University Journal of Computer and Information Sciences
Software Engineering Research
article

A Semantic and Lexical Analysis of LLM-Generated Responses in Comparison with Stack Overflow Answers

Kürşat Mustafa Karaoğlan, Yasin Ortakcı, Kerem Can CELEPKOLU
article en

Abstract

Large Language Models (LLMs) have become indispensable tools in programming education and professional software development. However, their output quality remains poorly characterized, particularly in terms of the semantic and linguistic quality of the explanatory text. Traditional evaluation metrics such as ROUGE primarily rely on lexical overlap and therefore only partially reflect the semantic adequacy of code explanations. This study proposes a multi-metric evaluation framework integrating semantic embeddings and lexical metrics to assess the quality of explanations generated by LLMs. We conducted experiments on 442 question-answer pairs produced by human experts regarding Python programming language from Stack Overflow, comparing them with GPT-4o-mini outputs. Three embedding models (MiniLM-L6, MPNet-Base, Paraphrase-MiniLM) were employed to compute the measure of semantic similarity by using cosine similarity, and ROUGE metrics (ROUGE-1, ROUGE-2, ROUGE-L) were used for lexical analysis. Results reveal a high semantic alignment (cosine similarity: 0.65–0.75) but substantially lower lexical overlap (ROUGE:0.10–0.32), indicating that LLMs produce semantically sound yet lexically distinct explanations. Pearson correlation analysis reveals weak to moderate correlations (r=0.29–0.47) between semantic and lexical metrics, suggesting that traditional metrics alone are insufficient for a comprehensive evaluation. Statistical testing (paired t-tests, p < 0.001) shows significant differences among embedding models, with MPNet-Base achieving the highest semantic consistency. Our findings underscore the critical need for multidimensional evaluation frameworks in assessing LLM-generated explanations, particularly in technical domains where semantic accuracy is crucial.

Sakarya University Journal of Computer and Information Sciences(Advanced Online Publication)
Karabük University (TR)
Quality education
Openalex Percentile: Top 6%
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
A Semantic and Lexical Analysis of LLM-Generated Responses in Comparison with Stack Overflow Answers — Kürşat Mustafa Karaoğlan, Yasin Ortakcı, et al. · Sakarya University Journal of Computer and Information Sciences (2026) | TGRS Research Map | TGRS