Abstract
Standard In-context Learning (ICL) relies on the availability of labeled examples for a specific target task. However, in many real-world scenarios, labeled data for novel tasks is scarce or non-existent. This paper explores Cross-Task In-context Learning (CT-ICL), a framework where Large Language Models (LLMs) leverage examples from semantically similar source tasks to solve novel target tasks. Our findings demonstrate that smaller models, such as LLaMA-2 7B, benefit significantly from this approach, achieving a 107% average performance improvement over zero-shot baselines by "borrowing" reasoning pathways from known tasks.
Introduction
In-context Learning has revolutionized how we interact with LLMs, allowing them to adapt to new tasks via a few demonstrations in a prompt. Despite its success, ICL typically assumes the existence of a task-specific dataset. When faced with "novel tasks"—those with zero labeled examples or specialized domains—smaller models often struggle to perform in a zero-shot setting. While frontier models like GPT-4 possess high zero-shot capabilities, smaller, more efficient models require additional guidance. This research investigates whether LLMs can generalize across tasks, using the logic and structure of one task to solve another.
Methodology
Cross-Task Prompting Framework
The researchers proposed a structured prompt format designed to facilitate knowledge transfer across task boundaries. The prompt consists of:
- Source Task Definition: A clear description of a known, labeled task.
- Source Examples: Labeled input-output pairs from the source task.
- Target Task Definition: A description of the new, novel task to be solved.
- Target Input: The specific query for the novel task.
Semantic Example Selection
To ensure the source examples were relevant to the target query, the study utilized Sentence-BERT to calculate semantic similarity. Rather than providing random examples from a source library, the system selects examples that are semantically closest to the target input, ensuring the model can map the underlying logic effectively.
Pseudo-Labeling and Bootstrapping
For scenarios where no target labels exist, the authors employed CT-ICL to generate "pseudo-labels" for a small subset of the target data. These generated examples were then used as standard in-task examples. This self-bootstrapping method proved highly effective, performing nearly as well as models provided with human-labeled "gold" data.
Experimental Setup
The study utilized a diverse task library to evaluate generalization capabilities:
- Source Tasks (10): Included ARC-Easy (science), AG-news (classification), BoolQ (reading comprehension), MNLI (inference), and SST2 (sentiment).
- Target Tasks (5): Focused on challenging or domain-specific areas: ARC-Challenge, Financial-Phrasebank, MedMCQA (medical), SciQ (science), and Social-i-QA (social reasoning).
- Models: Evaluated across LLaMA-2 7B, LLaMA-2 13B, and GPT-3.5, covering 50 unique source-target pairs.
Key Insights
The U-Shaped Activation Correlation
Through mechanistic interpretability, the authors analyzed internal model activations. They discovered a "U-shaped" correlation between task similarity and performance across layers. Correlation is high in early layers (semantic processing) and late layers (task execution), but dips in the middle. This suggests that the actual "transfer" of logic occurs late in the model's processing chain, where the model maps the source task's execution pattern onto the target task's requirements.
Disproportionate Gains for Smaller Models
The impact of CT-ICL was most pronounced in smaller models. LLaMA-2 7B saw a staggering 107% improvement over zero-shot performance, while LLaMA-2 13B improved by 18.6%. In contrast, GPT-3.5 saw a modest 3.2% gain. This indicates that CT-ICL helps smaller models activate reasoning pathways that are already inherently accessible to larger models in a zero-shot context.
The Importance of Semantic Alignment
Success in CT-ICL is highly dependent on the relationship between the source example and the target input. Randomly selected source examples often resulted in 0% accuracy. Furthermore, models occasionally suffered from a "copying effect," where they would output labels from the source task's label space (e.g., providing a sentiment label for a medical question) if the alignment was not sufficiently clear.
Results and Discussion
The results confirm that CT-ICL is a viable alternative to traditional ICL when task-specific data is unavailable. In several instances, a single example from a semantically similar source task was as effective as an example from the target task itself.
However, the method has limitations. If a target task is entirely "alien"—sharing no semantic or structural overlap with the source library—the effectiveness of the transfer drops. Future work is required to understand the "circuit-level" mechanics of how Transformers route this information and to develop more robust "task vectors" that can trigger these pathways without the risk of label space confusion.
Summary updated