When Many-Shot Prompting Fails: An Empirical Study of LLM Code Translation

Amirkia Rafiei Oskooei, Kaan Baturalp Cosdan, Husamettin Isiktas, Mehmet S. Aktas
10/19/2025
cs.SEcs.AIcs.CL

No confident code implementation found for this paper.

Abstract

Large Language Models (LLMs) with vast context windows offer new avenues for in-context learning (ICL), where providing many examples ("many-shot" prompting) is often assumed to enhance performance. We investigate this assumption for the complex task of code translation. Through a large-scale empirical study of over 90,000 translations, we systematically evaluate the impact of scaling in-context examples from zero-shot to many-shot configurations of up to 625 examples, with prompts spanning from approximately 100,000 to 800,000 tokens. Our findings reveal a "many-shot paradox": while static similarity metrics may modestly improve with more examples, functional correctness consistently peaks with few-shot prompting (5-25 examples). Providing substantially more examples often degrades this crucial functional performance. This study highlights that for code translation, the quality of a few well-chosen examples outweighs sheer quantity, challenging the universal efficacy of "more is better" for ICL and underscoring the task-dependent nature of optimal prompting strategies. Our results have significant implications for effectively leveraging LLMs in software engineering.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{oskooei2025when,
  title  = {When Many-Shot Prompting Fails: An Empirical Study of LLM Code Translation},
  author = {Amirkia Rafiei Oskooei and Kaan Baturalp Cosdan and Husamettin Isiktas and Mehmet S. Aktas},
  year   = {2025},
  eprint = {2510.16809},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.16809v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.16809.svg)](https://codeofpaper.com/paper/2510.16809)

Discussion