|
2 | 2 | <img src='logo.png' width='200'> |
3 | 3 | </p> |
4 | 4 |
|
5 | | -# arxiv2025_icl_investigation |
6 | | -[](https://put-here-your-paper.com) |
7 | | -[](https://opensource.org/licenses/Apache-2.0) |
8 | | -[](https://www.python.org/) |
9 | | -[](https://github.com/UKPLab/arxiv2025-icl-investigation/actions/workflows/main.yml) |
| 5 | +# Illusion or Algorithm? |
| 6 | +[](https://arxiv.org/abs/2505.11004) |
10 | 7 |
|
11 | | -This is the official template for new Python projects at UKP Lab. It was adapted for the needs of UKP Lab from the excellent [python-project-template](https://github.com/rochacbruno/python-project-template/) by [rochacbruno](https://github.com/rochacbruno). |
| 8 | +This repository contains the code to generate the data and results to the paper: [Illusion or Algorithm? Investigating Memorization, Emergence, and Symbolic Processing in In-Context Learning](https://arxiv.org/abs/2505.11004). |
12 | 9 |
|
13 | | -It should help you start your project and give you continuous status updates on the development through [GitHub Actions](https://docs.github.com/en/actions). |
| 10 | +> **Abstract:** Large-scale Transformer language models (LMs) trained solely on next-token prediction with web-scale data can solve a wide range of tasks after seeing just a few examples. The mechanism behind this capability, known as in-context learning (ICL), remains both controversial and poorly understood. Some studies argue that it is merely the result of memorizing vast amounts of data, while others contend that it reflects a fundamental, symbolic algorithmic development in LMs. In this work, we introduce a suite of investigative tasks and a novel method to systematically investigate ICL by leveraging the full Pythia scaling suite, including interim checkpoints that capture progressively larger amount of training data. By carefully exploring ICL performance on downstream tasks and simultaneously conducting a mechanistic analysis of the residual stream's subspace, we demonstrate that ICL extends beyond mere "memorization" of the training corpus, yet does not amount to the implementation of an independent symbolic algorithm. Our results also clarify several aspects of ICL, including the influence of training dynamics, model capabilities, and elements of mechanistic interpretability. Overall, our work advances the understanding of ICL and its implications, offering model developers insights into potential improvements and providing AI security practitioners with a basis for more informed guidelines. |
14 | 11 |
|
15 | | -> **Abstract:** The study of natural language processing (NLP) has gained increasing importance in recent years, with applications ranging from machine translation to sentiment analysis. Properly managing Python projects in this domain is of paramount importance to ensure reproducibility and facilitate collaboration. The template provides a structured starting point for projects and offers continuous status updates on development through GitHub Actions. Key features include a basic setup.py file for installation, packaging, and distribution, documentation structure using mkdocs, testing structure using pytest, code linting with pylint, and entry points for executing the program with basic CLI argument parsing. Additionally, the template incorporates continuous integration using GitHub Actions with jobs to check, lint, and test the project, ensuring robustness and reliability throughout the development process. |
16 | | -
|
17 | | -Contact person: [Federico Tiblias ](mailto:[email protected]) |
18 | | - |
19 | | -[UKP Lab](https://www.ukp.tu-darmstadt.de/) | [TU Darmstadt](https://www.tu-darmstadt.de/ |
20 | | -) |
| 12 | +Contact: [Jingcheng Niu ](mailto:[email protected]) and [Subhabrata Dutta ](mailto:[email protected]) |
| 13 | +@ [UKP Lab](https://www.ukp.tu-darmstadt.de/) | [TU Darmstadt](https://www.tu-darmstadt.de/) |
21 | 14 |
|
22 | 15 | Don't hesitate to send us an e-mail or report an issue, if something is broken (and it shouldn't be) or if you have further questions. |
23 | 16 |
|
| 17 | +## ICL Tasks |
24 | 18 |
|
25 | | -## Getting Started |
26 | | - |
27 | | -> **DO NOT CLONE OR FORK** |
28 | | -
|
29 | | -If you want to set up this template: |
30 | | - |
31 | | -1. Request a repository on UKP Lab's GitHub by following the standard procedure on the wiki. It will install the template directly. Alternatively, set it up in your personal GitHub account by clicking **[Use this template](https://github.com/rochacbruno/python-project-template/generate)**. |
32 | | -2. Wait until the first run of CI finishes. Github Actions will commit to your new repo with a "✅ Ready to clone and code" message. |
33 | | -3. Delete optional files: |
34 | | - - If you don't need automatic documentation generation, you can delete folder `docs`, file `.github\workflows\docs.yml` and `mkdocs.yml` |
35 | | - - If you don't want automatic testing, you can delete folder `tests` and file `.github\workflows\tests.yml` |
36 | | - - If you do not wish to have a project page, delete folder `static` and files `.nojekyll`, `index.html` |
37 | | -4. Prepare a virtual environment: |
38 | | -```bash |
39 | | -python -m venv .venv |
40 | | -source .venv/bin/activate |
41 | | -pip install . |
42 | | -pip install -r requirements-dev.txt # Only needed for development |
43 | | -``` |
44 | | -5. Adapt anything else (for example this file) to your project. |
45 | | - |
46 | | -6. Read the file [ABOUT_THIS_TEMPLATE.md](ABOUT_THIS_TEMPLATE.md) for more information about development. |
47 | | - |
48 | | -## Usage |
49 | | - |
50 | | -### Using the classes |
51 | | - |
52 | | -To import classes/methods of `arxiv2025_icl_investigation` from inside the package itself you can use relative imports: |
53 | | - |
54 | | -```py |
55 | | -from .base import BaseClass # Notice how I omit the package name |
56 | | - |
57 | | -BaseClass().something() |
58 | | -``` |
59 | | - |
60 | | -To import classes/methods from outside the package (e.g. when you want to use the package in some other project) you can instead refer to the package name: |
61 | | - |
62 | | -```py |
63 | | -from arxiv2025_icl_investigation import BaseClass # Notice how I omit the file name |
64 | | -from arxiv2025_icl_investigation.subpackage import SubPackageClass # Here it's necessary because it's a subpackage |
65 | | - |
66 | | -BaseClass().something() |
67 | | -SubPackageClass().something() |
68 | | -``` |
| 19 | +We produce the results in **Sections 4–6** of our paper using the ICL tasks implemented in this code base. These tasks are designed to probe different aspects of in-context learning, such as copying, symbolic substitution, and pattern induction. |
69 | 20 |
|
70 | | -### Using scripts |
71 | | - |
72 | | -This is how you can use `arxiv2025_icl_investigation` from command line: |
73 | | - |
74 | | -```bash |
75 | | -$ python -m arxiv2025_icl_investigation |
76 | | -``` |
| 21 | +See [`example.ipynb`](./example.ipynb) for runnable demos and usage instructions showing how we generate and evaluate these tasks across Pythia model checkpoints. |
77 | 22 |
|
78 | | -### Expected results |
| 23 | +## Singular Residual Stream Direction Analysis (SUDA) |
79 | 24 |
|
80 | | -After running the experiments, you should expect the following results: |
| 25 | +Finally, we present a mechanistic connection between the development of ICL competence and specialization in the residual stream’s subspace through Singular Unembedding Direction Analysis (SUDA). |
81 | 26 |
|
82 | | -(Feel free to describe your expected results here...) |
| 27 | +SUDA is a diagnostic method that projects the residual stream onto the singular vectors of the unembedding matrix, allowing us to trace how models allocate subspace as they learn to perform in-context learning. Specifically, we: |
83 | 28 |
|
84 | | -### Parameter description |
| 29 | +1. Compute a singular value decomposition of the unembedding matrix: $SVD(W_U) = UST^\top$. |
| 30 | +2. Project the residual stream activations onto individual directions in $V$. |
| 31 | +3. Measure the task-relevant signal captured by each direction by evaluating how well the model performs when using only a subset of directions. |
85 | 32 |
|
86 | | -* `x, --xxxx`: This parameter does something nice |
| 33 | +Across a diverse set of ICL tasks, we observe that while the performance trajectories vary (some tasks improve steadily, others show late or abrupt development) the underlying trend of internal structural formation in the residual stream remains consistent. This suggests that models consistently learn to specialize subspaces in a task-relevant way as training progresses. |
87 | 34 |
|
88 | | -* ... |
89 | | - |
90 | | -* `z, --zzzz`: This parameter does something even nicer |
91 | | - |
92 | | -## Development |
93 | | - |
94 | | -Read the FAQs in [ABOUT_THIS_TEMPLATE.md](ABOUT_THIS_TEMPLATE.md) to learn more about how this template works and where you should put your classes & methods. Make sure you've correctly installed `requirements-dev.txt` dependencies |
| 35 | +The implementation is available at [`icl_analysis/suda.py`](icl_analysis/suda.py). |
95 | 36 |
|
96 | 37 | ## Cite |
97 | 38 |
|
98 | 39 | Please use the following citation: |
99 | 40 |
|
100 | 41 | ``` |
101 | | -@InProceedings{smith:20xx:CONFERENCE_TITLE, |
102 | | - author = {Smith, John}, |
103 | | - title = {My Paper Title}, |
104 | | - booktitle = {Proceedings of the 20XX Conference on XXXX}, |
105 | | - month = mmm, |
106 | | - year = {20xx}, |
107 | | - address = {Gotham City, USA}, |
108 | | - publisher = {Association for XXX}, |
109 | | - pages = {XXXX--XXXX}, |
110 | | - url = {http://xxxx.xxx} |
| 42 | +@misc{niu2025illusionalgorithminvestigatingmemorization, |
| 43 | + title={Illusion or Algorithm? Investigating Memorization, Emergence, and Symbolic Processing in In-Context Learning}, |
| 44 | + author={Jingcheng Niu and |
| 45 | + Subhabrata Dutta and |
| 46 | + Ahmed Elshabrawy and |
| 47 | + Harish Tayyar Madabushi and |
| 48 | + Iryna Gurevych}, |
| 49 | + year={2025}, |
| 50 | + eprint={2505.11004}, |
| 51 | + archivePrefix={arXiv}, |
| 52 | + primaryClass={cs.CL}, |
| 53 | + url={https://arxiv.org/abs/2505.11004}, |
111 | 54 | } |
112 | | -``` |
113 | | - |
114 | | -## Disclaimer |
115 | | - |
116 | | -> This repository contains experimental software and is published for the sole purpose of giving additional background details on the respective publication. |
| 55 | +``` |
0 commit comments