Markov Chain Estimation with In-Context Learning

Simon Lepage, Jeremie Mary, David Picard
8/5/2025
cs.LG

No official code found. Best implementation: Simon-Lepage/MarkovICL (2 stars, Apache-2.0, last commit 2025-08-13).

Abstract

We investigate the capacity of transformers to learn algorithms involving their context while solely being trained using next token prediction. We set up Markov chains with random transition matrices and we train transformers to predict the next token. Matrices used during training and test are different and we show that there is a threshold in transformer size and in training set size above which the model is able to learn to estimate the transition probabilities from its context instead of memorizing the training patterns. Additionally, we show that more involved encoding of the states enables more robust prediction for Markov chains with structures different than those seen during training.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Implementation for "Markov Chain Estimation with In-Context Learning"

20PythonAug 13, 20251 years agoApache-2.0

Similar Papers

Cite this paper

@article{lepage2025markov,
  title  = {Markov Chain Estimation with In-Context Learning},
  author = {Simon Lepage and Jeremie Mary and David Picard},
  year   = {2025},
  eprint = {2508.03934},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.03934v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.03934.svg)](https://codeofpaper.com/paper/2508.03934)

Discussion