ICL CIPHERS: Quantifying "Learning'' in In-Context Learning via Substitution Ciphers

Zhouxiang Fang, Aayush Mishra, Muhan Gao, Anqi Liu, Daniel Khashabi

TL;DR

This paper introduces "ICL CIPHERS," a novel method for evaluating In-Context Learning (ICL) by reformulating tasks using substitution ciphers. By comparing LLM performance on decipherable (bijective) vs. undecipherable (non-bijective) ciphers, they provide a way to quantify "task learning" (TL) beyond simple "task retrieval" (TR), showing LLMs can indeed learn these novel, abstract mappings.

What Problem Does This Paper Address?

Large Language Models (LLMs) exhibit In-Context Learning (ICL), a fascinating ability to perform tasks based on examples provided in the prompt without explicit fine-tuning. However, a key challenge is disentangling whether an LLM is merely retrieving a previously learned pattern from its pre-training data (Task Retrieval, TR) or genuinely learning a new task or mapping on the fly (Task Learning, TL). Existing methods for measuring TL often rely on abstracting labels or using simplified tasks, which might still allow LLMs to leverage implicit knowledge from their pre-training data, thus confounding the results. The authors aim to create a more robust method to isolate and quantify TL.

Methods

The core innovation is ICL CIPHERS, a framework that transforms existing tasks into new ones using substitution ciphers. The process involves:

  1. Substitution: A subset of tokens in the input text (demonstrations and test cases) are replaced with other tokens from the lexicon.
  2. BIJECTIVE Ciphers: This is the key. A bijective mapping ensures that each original token is consistently replaced by the same new token, and importantly, this mapping is reversible. This means the original task structure is preserved in an abstract sense, allowing for potential "deciphering."
  3. NON-BIJECTIVE Ciphers: For comparison, they also use non-bijective ciphers where tokens are replaced randomly and irreversibly. This serves as a baseline representing a more chaotic, undecipherable transformation.

The hypothesis is that if an LLM can perform better on BIJECTIVE ciphers than NON-BIJECTIVE ones, it indicates an ability to learn the underlying, albeit obscured, task structure, thus demonstrating TL. They also employ "priority sampling" for demonstrations, prioritizing those that contain ciphered tokens relevant to the test case, to better expose the model to the learning signal.

Datasets

The authors evaluate their method on four well-established datasets:

  • SST-2: A binary sentiment classification task.
  • Amazon: A binary sentiment classification task (specifically, the "All_Beauty" category).
  • HellaSwag: A commonsense reasoning task involving sentence completion.
  • WinoGrande: A pronoun resolution task.

Key Insights and Ideas

  • Bijective Ciphers as a Measure of TL: The fundamental insight is that a reversible, albeit abstract, transformation (BIJECTIVE cipher) provides a solvable but novel task. Success on this task, compared to an irreversible, noisy transformation (NON-BIJECTIVE cipher), strongly suggests the model is learning the underlying pattern rather than just recalling it.
  • LLMs Can Decipher: The results show that LLMs can indeed perform better on BIJECTIVE ciphered tasks, indicating they can learn and apply these abstract, reversible mappings. This is a significant finding, suggesting a capacity for learning beyond simple pattern matching.
  • The Gap is Consistent: While the performance gap between BIJECTIVE and NON-BIJECTIVE ciphers might be small, it is consistently observed across various models and datasets, lending credibility to the method.
  • Interpretability Hints: Probing LLM internal representations suggests that models develop a preference for the substituted tokens in BIJECTIVE ciphers as they see more occurrences, hinting at an internal decoding process.

Key Results

  • LLMs consistently achieve higher accuracy on tasks reformulated with BIJECTIVE ciphers compared to NON-BIJECTIVE ciphers. For instance, on the Amazon dataset with Llama 3.1 (8B), BIJECTIVE ciphers yielded a 7.1% higher accuracy on average.
  • This performance gap is statistically significant across most tested configurations, as confirmed by McNemar's tests.
  • The effect of shuffle rate (proportion of substituted tokens) shows that moderate rates (around 0.4-0.6) yield the largest performance gaps, suggesting a balance between making the task challenging and keeping it solvable.
  • The findings hold across different numbers of demonstrations (few-shot settings), model sizes (Llama 3.1 8B vs. 70B), and even for instruction-tuned models, indicating the robustness of the method.

Limitations and Future Work

  • Deviation from Natural Language: Ciphered text is inherently unnatural, which might make the task excessively challenging and potentially introduce biases. The authors suggest exploring alternative ways to measure learning while maintaining task naturalness.
  • Model and Dataset Scope: While the study covers several models and datasets, expanding to more and larger models (like GPT-4, Gemini) and diverse task types would strengthen the findings.
  • Aligned Models: Aligned models (e.g., instruction-tuned) might behave differently, potentially losing some in-context learning capabilities. Future work could adapt the task formulation for such models.
  • Interpretability Depth: While initial probing shows promise, more advanced interpretability techniques could offer deeper insights into the underlying mechanisms of deciphering.
  • Quantifying "Learning": The authors acknowledge that achieving a perfect distinction between "learning" and "retrieval" might be impossible, as learning often involves some level of retrieval. Their method offers a way to quantify learning, but further work is needed to fully understand the complementarity of these approaches.

Summary updated

BibTeX
@misc{fang2025icl,
  author = {Zhouxiang Fang and Aayush Mishra and Muhan Gao and Anqi Liu and Daniel Khashabi},
  title = {{ICL CIPHERS: Quantifying "Learning'' in In-Context Learning via Substitution Ciphers}},
  year = {2025},
  eprint = {2504.19395},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.19395},
}
Figure