Selective Shot Learning for Code Explanation

Paheli Bhattacharya, Rishabh Gupta


Abstract
Code explanation plays a crucial role in the software engineering domain, aiding developers in grasping code functionality efficiently. Recent work shows that the performance of LLMs for code explanation improves in a few-shot setting, especially when the few-shot examples are selected intelligently. State-of-the-art approaches for such Selective Shot Learning (SSL) include token-based and embedding-based methods. However, these SSL approaches have been evaluated on proprietary LLMs, without much exploration on open-source Code-LLMs. Additionally, these methods lack consideration for programming language syntax. To bridge these gaps, we present a comparative study and propose a novel SSL method (SSL_ner) that utilizes entity information for few-shot example selection. We present several insights and show the effectiveness of SSL_ner approach over state-of-the-art methods across two datasets. To the best of our knowledge, this is the first systematic benchmarking of various few-shot examples selection approaches using open-source Code-LLMs for the code explanation task.
Anthology ID:
2025.gem-1.12
Volume:
Proceedings of the Fourth Workshop on Generation, Evaluation and Metrics (GEM²)
Month:
July
Year:
2025
Address:
Vienna, Austria and virtual meeting
Editors:
Kaustubh Dhole, Miruna Clinciu
Venues:
GEM | WS
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
151–160
Language:
URL:
https://preview.aclanthology.org/corrections-2025-08/2025.gem-1.12/
DOI:
Bibkey:
Cite (ACL):
Paheli Bhattacharya and Rishabh Gupta. 2025. Selective Shot Learning for Code Explanation. In Proceedings of the Fourth Workshop on Generation, Evaluation and Metrics (GEM²), pages 151–160, Vienna, Austria and virtual meeting. Association for Computational Linguistics.
Cite (Informal):
Selective Shot Learning for Code Explanation (Bhattacharya & Gupta, GEM 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/corrections-2025-08/2025.gem-1.12.pdf