Abstract
In-Context Learning (ICL) allows Large Language Models (LLMs) to perform new tasks via few-shot prompting, yet it remains highly sensitive to the choice of demonstrations and label words. We introduce LICL (Logit separability-based In-Context Learning), a framework that optimizes these components by analyzing the model's internal logit distributions. LICL selects demonstration samples based on their "logit separability" and replaces traditional single-word labels with a sequence of highly discriminative, model-aligned words. Our experiments across seven classification datasets demonstrate that LICL significantly outperforms standard ICL baselines, particularly in complex multi-class scenarios.
Introduction
The performance of ICL is notoriously "brittle," often fluctuating wildly based on example selection, ordering, and the specific verbalizers used for labels. While existing research typically addresses sample selection or label optimization in isolation, few methods consider both or align these choices with the target model's internal representations. LICL addresses this by using the model's raw logits to identify samples and words that provide the clearest, most separable signals for a given task, moving beyond human-centric heuristics.
Methodology
The LICL framework operates through a two-pronged optimization strategy:
1. Logit Separability-Based Selection
Instead of selecting "typical" or semantically similar examples, LICL identifies samples that maximize the distance between the correct class logit and incorrect class logits. Two scoring mechanisms—Top-Logit Summation and Rank-Weighted Counting—are employed to rank and order the most instructive demonstrations within the prompt.
2. Multiple Class-Related Words (MCRW)
Standard labels (e.g., "Sentiment: positive") may be semantically narrow for an LLM. LICL constructs a "Refined Pool" of related words (e.g., "admire," "bravo") and uses a Sequential Forward Search to find the optimal combination of words to represent a class. This results in prompts like "Sentiment: positive good favorable," which provide a richer semantic signal aligned with the model's internal vocabulary.
Experimental Setup
The method was evaluated on seven diverse classification datasets, including sentiment analysis (SST-2, CR, IMDB), emotion classification (ISEAR, AMAN), question classification (TREC-6), and topic classification (AGNews). Primary testing was conducted on LLaMA2-7b and GPT2-xl, with further validation on larger models such as LLaMA3-8b and LLaMA2-13b.
Results and Discussion
LICL achieved substantial accuracy gains, outperforming vanilla ICL by an average of 3.11% on LLaMA2-7b and 11.58% on GPT2-xl. The most dramatic improvements were observed in multi-class tasks; for instance, LICL improved GPT2-xl's accuracy on the AGNews dataset by 23.68%.
Key findings include:
- Internal Alignment: Words that are semantically intuitive to humans are not always the most discriminative for the model. LICL identifies words the model already uses effectively to distinguish classes.
- Semantic Triangulation: Using multiple related words clarifies intent and increases robustness, especially when a single label word is ambiguous to the model.
- Separability over Typicality: Demonstrations that produce non-overlapping logit distributions are more effective than those that are merely "average" representations of a class.
Conclusion
LICL demonstrates that leveraging internal model signals—specifically logit separability—can significantly enhance the reliability and performance of In-Context Learning. While the current implementation is optimized for classification tasks and involves some computational overhead during the word-search phase, its success across various model scales suggests that logit-level alignment is a critical frontier for prompt engineering. Future work will explore the application of these principles to more complex reasoning and generation tasks.
Summary updated