ParaICL: Towards Parallel In-Context Learning

Xingxuan Li, Xuan-Phi Nguyen, Shafiq Joty, Lidong Bing

Abstract

In-Context Learning (ICL) has become a cornerstone of Large Language Model (LLM) utility, yet it faces a persistent "Goldilocks" problem: too few examples provide insufficient guidance, while too many overwhelm the model's context window, leading to performance degradation. We introduce ParaICL, a framework that enables LLMs to leverage large volumes of demonstration examples by processing them in parallel batches. By employing semantic sorting, a weighted average semantic objective, and an adaptive plausibility constraint, ParaICL consistently improves accuracy across reasoning, NLI, and coding tasks without the pitfalls of excessively long context prompts.

Introduction

Standard ICL typically prepends a few "shots" to a query. However, research indicates that LLMs often suffer from "lost in the middle" phenomena or general performance drops as input context grows. Furthermore, the specific choice and ordering of examples can be highly volatile. ParaICL addresses these limitations by breaking the linear prompt structure into a parallel architecture, allowing the model to utilize a diverse, large set of demonstrations while keeping individual prompts short and focused.

The ParaICL Framework

ParaICL transforms the standard ICL pipeline into a four-stage parallel process designed to maximize the utility of available demonstrations:

  1. Semantic Sorting: For a given test query, all available demonstration examples are ranked based on their semantic similarity to that query using embeddings (e.g., SimCSE).
  2. Parallel Batching: Instead of a single long string, examples are divided into $s$ parallel batches. This ensures that each individual prompt sent to the LLM remains within an optimal, manageable length.
  3. Weighted Average Semantic (WAS) Objective: The LLM processes each batch independently to generate a probability distribution for the next token. ParaICL then calculates a weighted average of these distributions, giving higher priority to batches containing examples most semantically similar to the query.
  4. Adaptive Plausibility Constraint: To prevent irrelevant or "noisy" batches from introducing errors, the framework applies a constraint inspired by contrastive decoding. It only considers tokens that the most semantically relevant batch deems plausible, effectively filtering out potential hallucinations.
The ParaICL framework: Demonstration examples are semantically sorted, batched, and processed in parallel. Results are merged using a weighted average and filtered by a plausibility constraint.

Experimental Evaluation

The framework was evaluated across a diverse range of benchmarks, including GSM8K (mathematical reasoning), ARC-Challenge (science questions), WinoGrande (commonsense), HellaSwag (NLI), and MBPP (coding). Testing included models such as Llama-2 (7B/13B), Mistral-7B, Llama-3.1-70B, and GPT-3.5-turbo.

Key Results

ParaICL consistently outperformed standard few-shot ICL and other sophisticated baselines like Parallel Context Window (PCW) and Structured Prompting (SP). On Llama-2-7B, ParaICL improved average accuracy by 1.2% to 2.7% across various shot settings. On Mistral-7B-Instruct-v0.2, gains reached up to 3.0% in 15-shot scenarios. The method proved effective for both open-source models and closed-source APIs where only top-5 log probabilities are accessible.

Comparative performance of ParaICL against standard ICL and other baselines across various benchmarks. ParaICL consistently achieves the highest accuracy.

Discussion and Insights

  • Context Length as a Bottleneck: Parallelism acts as a structural bypass for the limitations of long-context prompts, preventing the performance decay typically seen when scaling up the number of shots linearly.
  • Semantic Weighting: The study confirms that not all batches are equal; weighting output distributions based on query similarity allows the model to prioritize the most relevant guidance.
  • Noise Filtering: The Adaptive Plausibility Constraint is a crucial safety rail, ensuring that a single irrelevant batch does not derail the generation process.

Conclusion and Future Work

ParaICL offers a scalable, "plug-and-play" solution for enhancing ICL performance. While currently optimized for decoder-only models, future work will explore its application to encoder-decoder architectures and its integration with Retrieval-Augmented Generation (RAG) to dynamically pull batches from massive external databases. The authors also note that batch stability remains an area for optimization, as increasing the number of batches beyond a certain threshold can introduce instability.

Summary updated

BibTeX
@inproceedings{li2025paraicl,
  author = {Xingxuan Li and Xuan-Phi Nguyen and Shafiq Joty and Lidong Bing},
  title = {{ParaICL: Towards Parallel In-Context Learning}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.naacl-long.621},
}
Figure