Abstract
In-context learning (ICL) performance in Large Language Models (LLMs) is highly sensitive to the choice of demonstration examples. For Machine Translation (MT), traditional selection methods often rely on superficial lexical or semantic similarities, neglecting structural complexity. We present SCOI (Syntax-augmented COverage-based In-context example selection), a learning-free approach that selects examples by alternating between maximizing syntactic and lexical coverage. Our method ensures that the selected set of demonstrations collectively represents both the vocabulary and the grammatical structures of the test input. Experiments on XGLM and Alpaca models across multiple language pairs demonstrate that SCOI consistently outperforms existing learning-free methods and even rivals specialized learning-based scorers.
Introduction
In-context learning has revolutionized the application of Large Language Models, but its effectiveness is notoriously dependent on the specific examples provided in the prompt. In the context of Machine Translation, most existing selection methods focus on "superficial" features like word overlap (BM25) or semantic similarity via embeddings. However, high-quality translation requires more than just vocabulary matching; it requires navigating complex syntactic structures. If a test sentence contains a nested clause, examples that only share words but possess simple structures may fail to guide the LLM correctly. Furthermore, many methods select examples independently, leading to redundant demonstrations that do not adequately cover the full complexity of the test input.
Methodology: The SCOI Framework
SCOI treats example selection as a set-level coverage problem. Instead of finding the most similar individual sentences, it builds a set of examples that collectively cover the features of the test input through a dual-metric approach.
1. Simplified Tree-to-Polynomial Algorithm
To represent syntax, SCOI converts dependency trees into polynomials where each term represents a path from the root to a node. To make this practical for massive translation datasets, the authors simplified the algorithm to run in quadratic time ($O(n^2)$), ensuring efficiency even with long sentences.
2. Dual Coverage Metrics
- Syntactic Coverage: Measures how well the paths in the test sentence's dependency tree are represented across the selected examples.
- Lexical Coverage: Measures the proportion of word overlap between the test input and the example set.
3. Alternating Selection Strategy
Using a greedy algorithm, SCOI selects examples sequentially. It picks the first (and all odd-numbered) examples to maximize syntactic coverage and the second (and all even-numbered) examples to maximize lexical coverage. This "best of both worlds" approach ensures the prompt is balanced between structural and vocabulary relevance.
Experimental Setup
The researchers evaluated SCOI across six translation directions (German, French, and Russian, both into and out of English) using the FLORES-101 evaluation set. Massive example databases were drawn from Europarl and ParaCrawl. Experiments were conducted on XGLM (7.5B) and Alpaca (7B) to demonstrate the method's robustness across different architectures.
Key Results and Insights
SCOI achieved the highest average COMET scores among all tested learning-free methods. Notably, in specific cases like Russian-to-English translation on the Alpaca model, SCOI—which requires no training—outperformed the CTQ Scorer, a method that requires training a specific regression model for each language pair.
Key insights from the study include:
- Complementary Information: Lexical and syntactic information are often complementary. By explicitly alternating between the two, SCOI forces the prompt to be more informative than single-metric approaches.
- Set-Level Superiority: Selecting a set that covers the input is superior to picking the "Top-K" most similar items independently, as it significantly reduces redundancy.
- Structural Accuracy: Case studies indicated that SCOI helps LLMs maintain correct formal structures (e.g., complex noun phrases) where word-matching methods like BM25 often resort to inaccurate paraphrases.
Limitations and Future Work
While effective, SCOI relies on external dependency parsers (like spaCy). Weaknesses in a parser for a specific language can degrade selection quality. Additionally, while the polynomial algorithm is efficient, the initial dependency parsing of millions of sentences remains a computational bottleneck. Future work may explore hybrid approaches that incorporate semantic embeddings or adapt the method for low-resource languages where reliable syntactic parsers are unavailable.
Summary updated