[Paper Review] Evaluating Instruction-Tuned Large Language Models on Code Comprehension and Generation
This study evaluates 10 open-source instruction-tuned LLMs on four code-related tasks (defect detection, clone detection, assertion generation, code summarization) across zero-shot, few-shot, and fine-tuning settings, revealing strong zero-shot performance and notable few-shot variability and cost implications.
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.
Motivation & Objective
- Assess zero-shot generalization of instruction-tuned LLMs on code-related tasks.
- Evaluate few-shot in-context learning and shot-selection strategies for code tasks.
- Examine the impact of fine-tuning on downstream code comprehension and generation tasks.
- Provide practical guidance on model choice, cost-performance trade-offs, and future directions in code intelligence.
Proposed method
- Compare 10 open-source instructed LLMs (6B–16B) across four code tasks using standardized prompts.
- Use three settings: zero-shot, one-shot (with three shot-selection strategies), and task-specific fine-tuning with LoRA.
- Employ task-specific prompts for defect detection, clone detection, assertion generation, and code summarization.
- Measure performance with task-appropriate metrics (accuracy, F1, exact match) and use ChatGPT as a judge for code summarization evaluation.
- Evaluate memory and time costs during fine-tuning and inference.
- Incorporate a sampling scheme for datasets (train/val/test) and standardized prompt design per model.
Experimental results
Research questions
- RQ1RQ1: How do instruction-tuned LLMs perform on code comprehension and generation tasks in the zero-shot setting?
- RQ2RQ2: How do instruction-tuned LLMs perform in the few-shot setting and what is the impact of shot-selection strategies?
- RQ3RQ3: How do instruction-tuned LLMs perform after further fine-tuning on downstream tasks?
- RQ4RQ4: What are the memory and time costs of using instruction-tuned LLMs during fine-tuning and inference?
Key findings
- In zero-shot, instructed LLMs are competitive with, or outperform, small SOTA models on several tasks; larger model size does not guarantee better zero-shot performance.
- Few-shot demonstrates overall performance gains from demonstrations, but can cause instability and performance drops with longer inputs; BM25-based shot selection is beneficial for generation tasks but not clearly superior for classification tasks.
- Fine-tuning with LoRA further improves task performance; instructed LLMs after fine-tuning outperform small SOTA models and similar-scaled models without instruction tuning.
- Across models of similar size, memory costs are not always higher than small SOTA models, but time costs can be substantially larger in both fine-tuning and inference.
- The study provides practical guidance on model choice, shot strategies, and cost-performance trade-offs for code-related tasks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.