NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Evaluating Instruction-Tuned Large Language Models on Code Comprehension and Generation

Zhiqiang Yuan, Junwei Liu, Qiancheng Zi, Mingwei Liu, Xin Peng, Yiling LouarXiv 2023

Abstract

In this work, we evaluate 10 open-source instructed LLMs on four representative code comprehension and generation tasks. We have the following main findings. First, for the zero-shot setting, instructed LLMs are very competitive on code comprehension and generation tasks and sometimes even better than small SOTA models specifically fine-tuned on each downstream task. We also find that larger instructed LLMs are not always better on code-related tasks. Second, for the few-shot setting, we find that adding demonstration examples substantially helps instructed LLMs perform better on most code comprehension and generation tasks; however, the examples would sometimes induce unstable or even worse performance. Furthermore, we find widely-used BM25-based shot selection strategy significantly outperforms the basic random selection or fixed selection only on generation problems. Third, for the fine-tuning setting, we find that fine-tuning could further improve the model performance on downstream code comprehension and generation tasks compared to the zero-shot/one-shot performance. In addition, after being fine-tuned on the same downstream task dataset, instructed LLMs outperform both the small SOTA models and similar-scaled LLMs without instruction tuning. Based on our findings, we further present practical implications on model and usage recommendation, performance and cost trade-offs, and future direction.

Introduction

While Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language processing, their application in software engineering (SE) has often been evaluated through a narrow lens, primarily focusing on "NL-to-Code" generation. However, the software development lifecycle encompasses a much broader range of tasks, including debugging, identifying code clones, generating test assertions, and documenting logic.

Furthermore, much of the existing research relies on closed-source models, which limits transparency and reproducibility. This study addresses this gap by rigorously evaluating 10 open-source instruction-tuned models—such as Vicuna, Alpaca, and WizardCoder—across a diverse spectrum of code comprehension and generation tasks to understand their true utility in real-world SE environments.

Methodology

The evaluation framework encompasses 10 open-source models (ranging from 6B to 16B parameters) compared against 5 baseline models. These were tested across three distinct scenarios:

  1. Zero-Shot: Models solve tasks without prior examples.
  2. Few-Shot (One-Shot): Models are provided with a single demonstration. Three selection strategies were compared: Fixed, Random, and BM25-based (similarity-based retrieval).
  3. Fine-Tuning: Models were specialized using Low-Rank Adaptation (LoRA), a parameter-efficient method that avoids retraining the entire network.
The instruction tuning pipeline for transforming foundation models into instruction-tuned LLMs.

Datasets and Tasks

The study utilized four widely recognized SE benchmarks:

  • Devign: Defect Detection (identifying vulnerabilities).
  • BigCloneBench: Clone Detection (identifying semantically similar code).
  • ATLAS: Assertion Generation (creating test oracles).
  • CodeSearchNet: Code Summarization (generating natural language descriptions).

For Code Summarization, the researchers employed ChatGPT as a "judge" to evaluate semantic accuracy and readability, moving beyond traditional metrics like BLEU that often fail to capture code intent.

Key Insights and Results

The Scale Paradox and Domain Tuning

One of the most significant findings is that larger models do not always yield better results. In several instances, 7B parameter models outperformed 13B or 16B counterparts, suggesting that the quality and diversity of instruction data are more critical than raw parameter count. Additionally, models tuned on general instructions (e.g., Vicuna) often rivaled or surpassed those tuned specifically on code (e.g., CodeAlpaca), indicating that general reasoning capabilities are highly transferable to programming tasks.

As shown in the experimental results, model performance is often sensitive to the length of the input tokens. While some models maintain stability, others show significant variance as the complexity of the code snippet increases.

Performance of various LLMs on Defect Detection and Assert Generation tasks across different token lengths.

Zero-Shot vs. Fine-Tuning

In zero-shot settings, models like WizardCoder-15B achieved 54.4% accuracy on defect detection, nearly matching specialized state-of-the-art (SOTA) models (58.7%). However, fine-tuning remains the gold standard for peak performance. After LoRA fine-tuning, ChatGLM-6B reached 61.0% on defect detection and 96.9% on clone detection, effectively surpassing both original SOTA models and un-tuned larger LLMs.

The Role of Examples

Adding a single example (one-shot) generally boosts performance, especially for models that struggle with zero-shot prompts. However, this can introduce instability, where the model becomes biased toward the label provided in the example. For generation tasks, BM25-based selection proved to be a "silver bullet," significantly outperforming random selection.

Discussion and Limitations

Despite their promise, instruction-tuned LLMs face several hurdles. They are highly sensitive to prompt wording, and there is a persistent risk of data leakage from pre-training sets. Furthermore, from a practical standpoint, these models are significantly more resource-intensive than small, specialized SOTA models. For real-time applications, the trade-off between the high performance of LLMs and the efficiency of smaller models must be carefully considered.

Conclusion

Instruction-tuned LLMs represent a powerful shift in code comprehension and generation. While they are competitive out-of-the-box, strategic fine-tuning and intelligent example selection are necessary to unlock their full potential. Future work should focus on more efficient tuning methods and automated evaluation protocols that reduce reliance on closed-source models for assessment.

Summary updated

BibTeX
@misc{yuan2023evaluating,
  author = {Zhiqiang Yuan and Junwei Liu and Qiancheng Zi and Mingwei Liu and Xin Peng and Yiling Lou},
  title = {{Evaluating Instruction-Tuned Large Language Models on Code Comprehension and Generation}},
  year = {2023},
  eprint = {2308.01240},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.01240},
}
Figure