Semantic Similarity Loss for Neural Source Code Summarization
Not on the map. Why?
Abstract (arXiv)
This paper presents a procedure for and evaluation of using a semantic similarity metric as a loss function for neural source code summarization. Code summarization is the task of writing natural language descriptions of source code. Neural code summarization refers to automated techniques for generating these descriptions using neural networks. Almost all current approaches involve neural networks as either standalone models or as part of a pretrained large language models e.g., GPT, Codex, LLaMA. Yet almost all also use a categorical cross-entropy (CCE) loss function for network optimization. Two problems with CCE are that 1) it computes loss over each word prediction one-at-a-time, rather than evaluating a whole sentence, and 2) it requires a perfect prediction, leaving no room for partial credit for synonyms. In this paper, we extend our previous work on semantic similarity metrics to show a procedure for using semantic similarity as a loss function to alleviate this problem, and we evaluate this procedure in several settings in both metrics-driven and human studies. In essence, we propose to use a semantic similarity metric to calculate loss over the whole output sentence prediction per training batch, rather than just loss for each word. We also propose to combine our loss with CCE for each word, which streamlines the training process compared to baselines. We evaluate our approach over several baselines and report improvement in the vast majority of conditions.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 40 of its 81 references that are in the map. First posted on arXiv 14 Aug 2023.
Builds on
40 of 81 references.
References · 40
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,380
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
- 2016Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translationcited by 1,475
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2015Sequence Level Training with Recurrent Neural Networkscited by 576
- 2018Universal Sentence Encodercited by 489
- 2022A Systematic Evaluation of Large Language Models of Codecited by 363
- 2018code2vec: Learning Distributed Representations of Codecited by 250
- 2023Pretraining Language Models with Human Preferencescited by 247
- 2018code2seq: Generating Sequences from Structured Representations of Codecited by 179
- 2020A Transformer-based Approach for Source Code Summarizationcited by 133
28 more
- 2022Few-shot training LLMs for project-specific code-summarizationcited by 129
- 2018The Adverse Effects of Code Duplication in Machine Learning Models of Codecited by 126
- 2023The Programmer's Assistant: Conversational Interaction with a Large Language Model for Software Developmentcited by 96
- 2020Retrieval-Augmented Generation for Code Summarization via Hybrid GNNcited by 89
- 2019Beyond BLEU: Training Neural Machine Translation with Semantic Similaritycited by 84
- 2022Experiences from Using Code Explanations Generated by Large Language Models in a Web Software Development E-Bookcited by 84
- 2020Improved Code Summarization via a Graph Neural Networkcited by 79
- 2019A Neural Model for Generating Natural Language Summaries of Program Subroutinescited by 77
- 2018Multi-Reward Reinforced Summarization with Saliency and Entailmentcited by 73
- 2023Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learningcited by 72
- 2021Studying the Usage of Text-To-Text Transfer Transformer to Support Code-Related Taskscited by 70
- 2021Language-Agnostic Representation Learning of Source Code from Structure and Contextcited by 63
- 2019Recommendations for Datasets for Source Code Summarizationcited by 46
- 2017ParaNMT-50M: Pushing the Limits of Paraphrastic Sentence Embeddings with Millions of Machine Translationscited by 44
- 2022Automatic Code Documentation Generation Using GPT-3cited by 37
- 2020Improved Automatic Summarization of Subroutines via Attention to File Contextcited by 34
- 2023Automatic Code Summarization via ChatGPT: How Far Are We?cited by 34
- 2021Code Structure Guided Transformer for Source Code Summarizationcited by 30
- 2021Project-Level Encoding for Neural Source Code Summarization of Subroutinescited by 24
- 2022Are We Building on the Rock? On the Importance of Data Preprocessing for Code Summarizationcited by 22
- 2020A Multi-Perspective Architecture for Semantic Code Searchcited by 20
- 2022Assemble Foundation Models for Automatic Code Summarizationcited by 17
- 2019A Survey of Automatic Generation of Source Code Comments: Algorithms and Techniquescited by 15
- 2022Semantic Similarity Metrics for Evaluating Source Code Summarizationcited by 14
- 2021Action Word Prediction for Neural Source Code Summarizationcited by 11
- 2023A Language Model of Java Methods with Train/Test Deduplicationcited by 7
- 2022A Decade of Code Comment Quality Assessment: A Systematic Literature Reviewcited by 5
- 2023Autonomy Is An Acquired Taste: Exploring Developer Preferences for GitHub Botscited by 4
Built on by
Citing papers per year: 2023: 2; 2024: 0; 2025: 3.
5 papers.
- 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Codecited by 62
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasetscited by 16
- 2023Just-in-Time Detection of Silent Security Patchescited by 7
- 2025Large Language Models are Qualified Benchmark Builders: Rebuilding Pre-Training Datasets for Advancing Code Intelligence Taskscited by 6
- 2025AI-Mediated Code Comment Improvementcited by 0
- 2025AI-Mediated Code Comment Improvement13 May 2025
- 2025Large Language Models are Qualified Benchmark Builders: Rebuilding Pre-Training Datasets for Advancing Code Intelligence Tasks28 Apr 2025
- 2025Large Language Models (LLMs) for Source Code Analysis: applications, models and datasets21 Mar 2025
- 2023Just-in-Time Detection of Silent Security Patches2 Dec 2023
- 2023Unifying the Perspectives of NLP and Software Engineering: A Survey on Language Models for Code14 Nov 2023