Pith. sign in

REVIEW 3 major objections 5 minor 3 cited by

(How) Can Transformers Predict Pseudo-Random Numbers?

T0 review · 3 major / 5 minor · reviewed 2026-08-07 · deepseek-v4-flash

Pith's one-line read With enough capacity and training variety, GPT-style transformers predict LCG sequences with unseen parameters and moduli by learning the modulus's prime factorization and predicting each digit according to its period.

desk verdict Real capability result for full-period LCGs with a clean mechanistic story, but the title's 'pseudo-random numbers' overstates the tested regime. read the letter →

arxiv 2502.10390 v2 pith:QTWYAME4 submitted 2025-02-14 cs.LG cond-mat.dis-nncs.CRstat.ML

classification cs.LGcond-mat.dis-nncs.CRstat.ML MSC 68T0711K4565C10
keywords in-contextlearninglinearcongruentialgeneratorpseudo-randomnumberpredictionmechanisticinterpretabilityresiduesystemgrokkingtransformerdepthmodulararithmetic
verification ladder T0 review T1 audit T2 compute T3 formal

The pith

A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.

The reading

This paper asks whether a transformer can learn to predict the output of a linear congruential generator, a classic pseudo-random number generator defined by $x_{t+1} = (a x_t + c) \bmod m$. It argues that with enough model capacity and variety of training data, GPT-style transformers can predict LCG sequences in-context even when the parameters $(a, c)$ and, in the harder setting, the modulus $m$ have never been seen in training. The claim is demonstrated up to $m = 2^{32}$ for a fixed modulus and to unseen moduli up to $m_{\text{test}} = 2^{16}$. The paper also reverse-engineers the learned algorithm, showing that the model factorizes $m$, represents numbers in the associated residue number system, and predicts digit by digit using the fact that the $w$-th lowest base-$p$ digit of a maximum-period LCG has period $p^w$. A reader should care because the result is a concrete case where a general-purpose sequence model discovers and implements a nontrivial number-theoretic algorithm rather than memorizing outputs.

What carries the argument

The load-bearing object is the residue number system representation of LCG outputs together with the digit-period theorem that comes from the Hull-Dobell maximum-period condition. When the sequence has full period $m$, the $w$-th lowest base-$p_j$ digit of $x_t$ has period $p_j^w$, and skipping $r$ steps in the sequence shortens that period to $p_j^w / \gcd(r, p_j^w)$. This makes the prediction task progressively easier as the context grows: the model can look back $2^k$ steps, copy the lowest $k$ bits, and read the higher bits from the simplified sequence, which explains the ladder-shaped accuracy curve with jumps at the $2^k$-th positions. The same construction, generalized to arbitrary prime-power factors of $m$, is the algorithm that the interpretability analysis attributes to the trained transformer.

What would settle it

Evaluate the unseen-modulus model on a held-out modulus with a large prime factor, for example $m_{\text{test}} = 2^{11} \cdot 101$, using the same six-layer recipe; if test accuracy does not reach the same 60-percent threshold with sublinear context scaling, then the demonstrated generalization is confined to smooth moduli, confirming that the mechanism's reliance on short-period prime-power digits is the reason. This is a measurement the paper does not report, and its outcome would delimit the central claim.

Watch

Extended reading notes

Core claim

The central claim is that transformers trained on LCG sequences do not memorize the training data but learn the underlying arithmetic structure, and that this structure is exactly the digit-wise periodicity of maximum-period LCGs. For a modulus $m = p_1^{w_1} \cdots p_q^{w_q}$, each number can be written in the residue number system as its tuple of residuals modulo $p_j^{w_j}$, and each base-$p_j$ digit has period $p_j^w$. The trained model's embedding layer groups numbers by their residues modulo prime powers, its attention heads look back $2^k$ (or $p_j^k$) steps in the context to exploit the $r$-step recurrence, and its MLP neurons fire with periodic patterns that constructively interfere at the correct next number. In the unseen-modulus setting the model first estimates $m$ greedily from the largest number in context, then applies the same digit-wise mechanism; a patching experiment that swaps in features from a sequence with a different modulus steers the model's predictions accordingly. The paper claims this mechanism generalizes to moduli up to $2^{32}$ in the fixed-modulus case, with the required context length scaling sublinearly as roughly $m^{1/4}$.

Load-bearing premise

The entire test regime is restricted to maximum-period LCGs whose parameters satisfy the Hull-Dobell theorem, and the unseen-modulus scaling results use only smooth moduli (powers of 2 and 3); a claim that transformers predict 'pseudo-random numbers' in general would go beyond the evidence.

Editorial extensions

If this is right

  • One attention head in a single transformer layer already solves the fixed-modulus task for composite $m$, so the digit-period shortcut is a low-complexity algorithm once the modulus is known.
  • Generalizing to an unseen modulus requires a sharp minimum of three layers, and accuracy collapses below that depth; the modulus-estimating head and the prime-factor-specialized heads are both necessary components.
  • The context length needed for perfect or near-perfect prediction grows sublinearly with the modulus, roughly $m^{1/4}$ in the fixed-modulus case and $m^{0.24}$ to $m^{0.33}$ for unseen moduli, so larger numbers do not demand proportionally more examples.
  • The tokenization base matters: a base aligned with the modulus's prime factors, such as $256 = 2^8$ versus $243 = 3^5$, makes the periodic structure visible to the model and improves scaling.
  • Training on long-period sequences alone is sufficient for generalization; training on short-period sequences teaches only copying and does not transfer.

Reading between the lines

Editorial extensions of the paper, not claims the author makes directly.

  • The digit-period mechanism predicts that transformers trained this way will fail on moduli that admit no small prime-power factor structure, such as primes or products of two large primes, in the fixed-modulus regime; the paper already observes this failure for a single prime in Appendix C, and generalizing that test would delineate the method's boundary sharply.
  • Because low-order digits carry the strongest periodic signal, small errors in the estimated modulus are tolerable; this suggests a testable robustness property and, conversely, an adversarial weakness, namely that generators which truncate or mask low-order bits, such as the PCG family, should be substantially harder to predict with this mechanism.
  • The reported shrinking of the usable hyperparameter range as $m$ grows suggests that the 'sufficient capacity and training variety' premise hides a real engineering cost: each modulus scale may need its own learning-rate and weight-decay re-tuning, which the paper does not quantify as a scaling law.
  • The sublinear context scaling invites a natural extrapolation test: predict the required context length for $m$ beyond $2^{32}$ from the power law, then check whether a model trained on the same family reaches 100 percent accuracy there; a deviation would reveal where the digit-copying shortcut stops being learned.
Share X Bluesky LinkedIn Reddit HN

Editorial analysis

A structured set of objections, weighed in public.

Desk editor's note, referee report, and a circularity audit.

Referee Report

3 major / 5 minor

Summary. This paper studies whether GPT-style transformers can learn to predict the next output of linear congruential generators (LCGs) from in-context examples. It considers two settings: a fixed modulus (FM), with held-out (a,c) pairs, and an unseen-modulus (UM) setting, where test moduli are excluded from training. The authors report that a one-layer, single-head transformer solves FM for composite moduli up to m=2^32 using base-b tokenization, while UM requires at least three layers and generalizes to unseen moduli up to m_test=2^16. Through PCA, attention-masking, head-pruning, and patching experiments, they argue that the model factorizes the modulus into prime powers, represents numbers in an RNS, copies low digits using r-step recurrences, and, in the UM case, estimates the modulus from the largest context value. They also report that the number of in-context elements needed for high accuracy scales as m^gamma with gamma around 1/4 (FM) or 0.24-0.33 (UM). The test distribution is restricted to Hull-Dobell-valid parameters, and the large-scale UM experiments use only m_test = 2^k, 3^k.

Significance. If the results hold, the paper provides one of the more complete mechanistic accounts of a nontrivial in-context learning algorithm in transformers, with correct digit-period derivations in Appendix F, held-out parameter evaluation, excluded test moduli, and causal interventions (attention masking, head pruning, and activation patching) that support the proposed algorithm. The authors also open-source their code, which supports reproducibility. The sublinear context-scaling finding for smooth moduli is interesting and may inform studies of algorithmic reasoning. However, the demonstrated capability is narrower than the title suggests: the experiments cover only maximum-period LCGs, and the scaled-up unseen-modulus results cover only powers of 2 and 3. The paper is therefore a strong case study of a structured subclass of LCG sequences rather than a general statement about pseudo-random number prediction.

major comments (3)
  1. [§1.2, §5.2, App. C] The results support a narrower claim than the title and abstract. Section 1.2 explicitly limits all evaluation to sequences obeying the Hull-Dobell conditions, so test LCGs have maximal period T_m = m; Section 5.2 restricts the unseen-modulus scaling experiments to m_test = 2^k, 3^k; and Appendix C shows that in the fixed-modulus setting the model fails on the prime modulus m = 2039 within the same budget. The algorithmic story in Section 4.1 and Appendix F also relies on the maximum-period property to obtain digit periods p^w. The abstract's statement that transformers 'can perform in-context prediction of LCG sequences with unseen moduli and parameters' should therefore be qualified to full-period LCGs, with scaled-up evidence only for moduli that are powers of 2 and 3, or the experiments need to be extended to non-Hull-Dobell parameters and moduli with large prime factors.
  2. [§5.1, §5.2, Fig. 12-13] The sublinear context-scaling law is claimed for 'the modulus' in general but is fit only on m = 2^k in the FM setting and on m_test = 2^k, 3^k in the UM setting. These are exactly the moduli where the RNS digit-period mechanism provides many low-period digits. For a modulus with a large prime factor, the highest digit has period comparable to m and the copying shortcut is unavailable, so there is no reason to expect the same exponent; the fixed-modulus prime result in Appendix C is a concrete indication that the behavior differs. The scaling claims should be explicitly restricted to smooth moduli, or supported by experiments on mixed-prime and prime moduli at scale.
  3. [§4.2, Qualitative Algorithm; §1.2] The claim that the fixed-modulus algorithm 'works for arbitrary a, c, x0 for a given m' is stronger than what is tested and stronger than the derivation supports. The r-step copying of low digits is derived under the Hull-Dobell/full-period assumption; for a generic LCG with shorter period, the w-th digit need not have period p^w, and Appendix C shows the model does not learn such sequences within the same budget. The sentence should be restricted to Hull-Dobell-valid (a,c), or supported by experiments on non-maximum-period LCGs.
minor comments (5)
  1. [§2.1, App. A.1] The number of sampled moduli is denoted n_m in Section 2.1 but appears as n_p in Appendix A.1; please harmonize the notation.
  2. [§4.2, Eq. (5)] Equation (5) is described as an 'empirical proof'; since the identity is only verified numerically in Figure 23(b), the wording should be 'empirically verified relation' rather than 'proof'.
  3. [Fig. 13] The figure captions should render the tokenization bases as 2^8 and 3^5, not '28' and '35'; the superscripts appear to have been lost in the text.
  4. [§6, Limitations] The Limitations paragraph mentions the scale m ≤ 2^32 but omits the two more important restrictions: all tests use Hull-Dobell-valid parameters, and the scaled-up unseen-modulus experiments use only powers of 2 and 3.
  5. [Throughout] There are several typographical errors ('exlude', 'hyperpamraters', 'Futhermore', 'accoverall') that should be corrected in a final pass.

Circularity Check

0 steps flagged · score 2.0 of 10

No substantive circularity: the central generalization claims are evaluated against held-out (a,c) pairs and unseen moduli excluded from training, and the interpretability claims are supported by causal ablations and independent mathematical derivations.

full rationale

The paper's core claims are benchmarked externally rather than by construction. In the fixed-modulus setting, Section 2.1 states that test (a,c) pairs are 'not considered while generating the training dataset' (64 held-out values), and in the unseen-modulus setting the test moduli Mtest are 'reserved exclusively for evaluation' and excluded from training, so the model is tested on moduli it never saw during training. The interpretability mechanism (RNS digit periods and r-step copying) is derived from the Hull-Dobell theorem and standard LCG period facts in Appendix F, not from a self-citation chain; the attention-masking, head-pruning, and patching experiments provide causal evidence for the claimed circuit roles rather than merely renaming observed patterns. The base-3 tokenization crossover in Section 5.2 is a falsifiable prediction that succeeded as predicted. The self-citations (Doshi et al. 2024a,b; He et al. 2024) appear only as related-work context and are not load-bearing evidence for any central claim. The main caveat is a scope restriction, not circularity: testing is limited to full-period Hull-Dobell-valid LCGs (Section 1.2) and, for the unseen-modulus scaling experiments, smooth moduli mtest = 2^k, 3^k (Section 5.2); this narrows the headline claim about 'pseudo-random numbers' and is a scope/correctness risk, but it does not make any derivation equivalent to its inputs. The circularity burden is therefore essentially absent beyond minor, non-load-bearing self-citation, matching a low score of 2.

Assumptions & free parameters 3 free parameters · 5 assumptions · 0 invented entities

The mathematical backbone (digit-period lemma, Hull-Dobell theorem, RNS uniqueness) is standard or derived in Appendix F. The empirical claims are grounded in held-out evaluation and causal ablations rather than in fitted parameters, with the exception of the scaling exponents gamma, which are power-law fits to the measured data. No new entities are postulated.

free parameters (3)
  • Scaling exponent gamma (fixed modulus) = gamma near 1/4 (Figure 12b)
    Power-law fit to the measured number of in-context elements required for 100% accuracy across m = 2^16 to 2^32; descriptive of the model's behavior, not derived or predicted in advance.
  • Scaling exponent gamma (unseen modulus) = 0.24 to 0.33 (Figure 13)
    Power-law fit to measured context lengths for 60% accuracy across mtest = 2^k, 3^k up to 2^16; varies with tokenization base, a fitted property of the trained models.
  • Training diversity rule nm at least mtest/4 = nm at least mtest/4
    Hand-chosen data-generation rule asserted to be sufficient for UM generalization; marked in Appendix A.1 as a result not shown, yet it drives the default training set composition.
assumptions (5)
  • standard math Hull-Dobell theorem: for coprime (c, m), with prime-divisor and mod-4 conditions on a - 1, the LCG has maximal period T_m = m.
    Invoked in Section 1.2 to define the test distribution and in Appendix F to derive digit periods; restricts all evaluation to maximum-period LCGs.
  • standard math Digit-period lemma: for maximum-period LCGs, the w-th lowest base-p digit has period p^w along the sequence.
    Derived in Appendix F.1-F.2 from Hull-Dobell; the entire RNS mechanism account and the 2^k attention pattern depend on it.
  • standard math Residue Number System representation is unique for pairwise-coprime prime-power factors of m.
    Used in Section 4.1 to define the digit-wise target representations the model is claimed to learn; standard result attributed to Garner (1959).
  • domain assumption The reverse-engineered algorithm is the mechanism of the trained checkpoints, not merely a post hoc description.
    Supported by attention-masking, head-pruning, and patching experiments in Sections 4.2-4.3, but PCA and attention structure alone are correlational; the paper analyzes specific checkpoints and assumes typicality.
  • domain assumption Evaluation is restricted to the Hull-Dobell maximum-period family and, in Section 5.2, to smooth moduli (2^k, 3^k).
    Section 1.2 states all test sequences obey Hull-Dobell; Section 5.2 focuses on powers of 2 and 3. Generalization to non-maximal-period or large-prime-factor moduli is untested and not claimed with evidence.

how reviews work

0 comments
Cite this review

Pith. "Pith review of (How) Can Transformers Predict Pseudo-Random Numbers?." pith.science (2026). https://pith.science/paper/QTWYAME4

@misc{pith2026250210390,
  author       = {Pith},
  title        = {Pith review of: (How) Can Transformers Predict Pseudo-Random Numbers?},
  year         = {2026},
  howpublished = {\url{https://pith.science/paper/QTWYAME4}},
  note         = {Machine review of arXiv:2502.10390}
}
abstract

Transformers excel at discovering patterns in sequential data, yet their fundamental limitations and learning mechanisms remain crucial topics of investigation. In this paper, we study the ability of Transformers to learn pseudo-random number sequences from linear congruential generators (LCGs), defined by the recurrence relation $x_{t+1} = a x_t + c \;\mathrm{mod}\; m$. We find that with sufficient architectural capacity and training data variety, Transformers can perform in-context prediction of LCG sequences with unseen moduli ($m$) and parameters ($a,c$). By analyzing the embedding layers and attention patterns, we uncover how Transformers develop algorithmic structures to learn these sequences in two scenarios of increasing complexity. First, we investigate how Transformers learn LCG sequences with unseen ($a, c$) but fixed modulus; and demonstrate successful learning up to $m = 2^{32}$. We find that models learn to factorize $m$ and utilize digit-wise number representations to make sequential predictions. In the second, more challenging scenario of unseen moduli, we show that Transformers can generalize to unseen moduli up to $m_{\text{test}} = 2^{16}$. In this case, the model employs a two-step strategy: first estimating the unknown modulus from the context, then utilizing prime factorizations to generate predictions. For this task, we observe a sharp transition in the accuracy at a critical depth $d= 3$. We also find that the number of in-context sequence elements needed to reach high accuracy scales sublinearly with the modulus.

Figures

Figures reproduced from arXiv: 2502.10390 by the authors.

Figure 1
Figure 1. Accuracy of predicting the last number (token) in the sequence: phase diagrams w.r.t. various depths and nheads values. (a) mtest = 2048, constant width: dmodel = 768. (b) mtest = 4096, width scaled proportionally: dmodel = 128 × nheads. setting but not in the UM setting. In [PITH_FULL_IMAGE:figures/full_fig_p003_1.png] view at source ↗
Figure 2
Figure 2. Training/test accuracy curves for predicting last number (token). (a) FM: (m = 2048, depth = 1, nheads = 1, dmodel = 768) Test accuracy “groks” when training accuracy reaches near￾100%. (b) UM: (mtest=2048, depth = 6, nheads = 4, dmodel = 768) Test accuracy “groks” simultaneously with training accuracy on sequences with period longer than context length (Tm > L = 256), indicating delayed discovery of underlying rule… view at source ↗
Figure 4
Figure 4. FM: Test accuracy for m = 2048, depth = 1, nheads = 1, dmodel = 768, averaged over a, c, and seeds. (a) Test accuracy w.r.t. token positions. Ladder-like structure appears, with jumps occurring at 2 k -th positions. (b) We represent numbers as an eleven-digit binary number (2048 = 211) and compute the per￾digit test accuracy of model predictions. We begin by analyzing the average accuracy of a trained Transformer mo… view at source ↗
Figures from the paper (30 more)
Figure 6
Figure 6. Figure 6: (a). We observe that the model retains the ability to copy the k lowest bits, but loses the ability to predict the higher bits. (ii) Next, we repeat the above ablation experi￾ment while masking out the attention to all keys except the two positions t − 2 k and t − 2 k−…
Figure 7
Figure 7. Figure 7: FM: (m = 211, a = 1589, c = 629) (a) Attention weights: each query attends most strongly to the tokens 2 k and 2 k−1 distance backward, for the highest possible value of k, enabling copying of lowest k bits. The other faint lines facilitate the prediction of higher bit…
Figure 8
Figure 8. Figure 8: UM: PCA analysis of the embedding layer. trained on multiple moduli, it cannot form a closed circle by identifying a unique 0 value [PITH_FULL_IMAGE:figures/full_fig_p007_8.png]
Figure 10
Figure 10. Figure 10: UM: Attention head (layer 1, head 6) specialized in esti￾mating mtest. (a) Queries attend to largest keys; (b) the head pro￾duces features with the highest cosine similarity to mtest; (c) patch￾ing this head with features from sequences with mpatch = 1024 (same a, c) …
Figure 11
Figure 11. Figure 11: Visualization of base-b tokenization and abacus embed￾dings. Abacus embedding 1 is shared by all the digits within the integer, while Abacus embedding 2 varies within the digit but is shared by all integers. via the Hull-Dobell theorem, setting na = nc = 1024 (See App…
Figure 12
Figure 12. Figure 12: (a), we test our model on both spectrally optimal Steele multipliers (Steele & Vigna, 2021) and arbitrary mul￾tipliers for m = 232. While achieving 100% test accuracy with equal in-context sequence lengths, the model performs consistently worse on Steele-generated seq…
Figure 13
Figure 13. Figure 13: UM: The number of in-context sequence elements needed for 60% test accuracy grows sublinearly with modulus m, depending on compatibility between m and tokenization. (a) Base-2 8 tokenization; (b) base-3 5 tokenization. 6. Conclusion We have investigated Transformer tr…
Figure 14
Figure 14. Figure 14: The impact of training dataset parameters (nm, na, nc) on unseen modulus task performance. Generalization to Unseen Modulus (UM): For the test dataset, we first select a set of test moduli Mtest = {mtest} that would be reserved exclusively for evaluation. For each tes…
Figure 15
Figure 15. Figure 15: Heatmap of test accuracy of a 6 layer Transformer with learning rate and weight decay as the axes. As the modulus is increased from 1024 to 16, 384 the range of hyperparameters resulting in reasonable accuracy becomes narrow. are highly sensitive to minute changes in …
Figure 16
Figure 16. Figure 16: Test accuracy and train/test loss for m = 2048 = 211, depth=1. (a,b,c) nheads = 1 (d,e,f) nheads = 4. (a) (b) (c) n_heads = 1 n_heads = 4 (d) (e) (f) [PITH_FULL_IMAGE:figures/full_fig_p015_16.png]
Figure 17
Figure 17. Figure 17 [PITH_FULL_IMAGE:figures/full_fig_p015_17.png]
Figure 18
Figure 18. Figure 18: FM: Comparison between m = 2039 (prime) and m = 2048 (power-of-two), with both models trained for 50,000 steps. Each model has depth 2 and dmodel = 1024. The test set consists of sequences with the same periods, while the training set includes arbitrary multipliers no…
Figure 19
Figure 19. Figure 19: UM: Test accuracy comparison between m = 2039 (prime), m = 1801 (prime) and m = 2048 (power-of-two). The model was trained for 100,000 steps on a dataset consisting of 262,144 sequences with 512 distinct training moduli not present in the test set. 512 768 1024 1280 E…
Figure 20
Figure 20. Figure 20: Test accuracy heatmaps of with depth and embedding dimensions as the two axes. E. Training Time Interpretability In this section, we examine the order in which training sequences with different periods are learned during training. For this experiment, we consider a si…
Figure 21
Figure 21. Figure 21: (left) Comparison of the training accuracy of sequences with different periods relative to the context length 512, (center) Accuracy when the model is only trained on sequences with period < 512, (right) Accuracy when the model is trained on sequences with period > 51…
Figure 22
Figure 22. Figure 22: Test accuracy vs token positions for m = 2048 = 211, depth=1, various values of a, c. (a,b) nheads = 1 (c,d) nheads = 4. The accuracies for different a and c are exactly on top of each other. (a) (b) (c) (d) (f) (e) nheads = 1 nheads = 4 [PITH_FULL_IMAGE:figures/full…
Figure 23
Figure 23. Figure 23: Test accuracy for m = 2048 = 211, depth=1, nheads ∈ {1, 4}, dmodel = 768. (a,d) Test accuracy averaged over a, c and initial seeds. (b,e) Multiplication of per-digit test accuracies – matches exactly with the average test accuracy. (c,f) Per-digit accuracy in binary r…
Figure 24
Figure 24. Figure 24: Test accuracy for m = 7776 = 25 3 5 , depth=1, nheads ∈ {1, 4}, dmodel = 768. (a,d) Test accuracy averaged over a, c and initial seeds. (b,e) Multiplication of per-digit test accuracies – matches exactly with the average test accuracy. (c,f) Per-digit accuracy in RNS …
Figure 25
Figure 25. Figure 25: Projections along Top 6 principal components of the embedding matrix, for m = 512, depth=1, nheads = 1, dmodel = 768. 20 [PITH_FULL_IMAGE:figures/full_fig_p020_25.png]
Figure 26
Figure 26. Figure 26: Projections along Top 6 principal components of the embedding matrix, for m = 7776, depth=1, nheads = 1, dmodel = 768. 21 [PITH_FULL_IMAGE:figures/full_fig_p021_26.png]
Figure 27
Figure 27. Figure 27: Projections along Top 6 principal components of the embedding matrix, for m = 1800, depth=1, nheads = 1, dmodel = 768. 22 [PITH_FULL_IMAGE:figures/full_fig_p022_27.png]
Figure 28
Figure 28. Figure 28: PCA analysis of first-layer heads. Although the ordering of numbers varies, the grouping behavior discussed in Section 4.3 remains invariant to changes in a, c, m, x0, and t. Note that the last head is the head that appears in [PITH_FULL_IMAGE:figures/full_fig_p023_28.png]
Figure 29
Figure 29. Figure 29: Per-digit accuracy for mtest = 2048 after pruning specific attention heads. (a) Results from the same model used in Section 4.3, identical to [PITH_FULL_IMAGE:figures/full_fig_p024_29.png]
Figure 30
Figure 30. Figure 30: Per-digit accuracy for mtest = 2352 after pruning specific attention heads. (a) Results from the same model used in Section 4.3, identical to [PITH_FULL_IMAGE:figures/full_fig_p024_30.png]
Figure 31
Figure 31. Figure 31: Patching experiments following the setting of [PITH_FULL_IMAGE:figures/full_fig_p025_31.png]
Figure 32
Figure 32. Figure 32: Attention patterns and token distance statistics for layer 2, head 3 of the model analyzed in Section 4.3. (a1, b1) Results for a sequence with mtest = 2048, a = 5, and c = 31. The statistics reveal that the model consistently looks back at distances that are multiple…
Figure 33
Figure 33. Figure 33: Test accuracy vs. Number index for m = 220. First Row: Three models trained on the same dataset, each using a unique PyTorch random seed that controls model initialization and batch shuffling. Second Row: Three models trained on different datasets, with each dataset g…
Figure 34
Figure 34. Figure 34: Test accuracy vs Number index for m = 232. First Row: Three models trained on the same dataset, each using a unique PyTorch random seed that controls model initialization and batch shuffling. Second Row: Three models trained on different datasets, with each generated …
Figure 35
Figure 35. Figure 35: Median number of in-context sequence elements required to achieve 100% test accuracy across five runs. The shaded region represents the min-max range. 28 [PITH_FULL_IMAGE:figures/full_fig_p028_35.png]
Figure 36
Figure 36. Figure 36: Test accuracy vs Number index. In (a), the moduli 2048 and 16384 (blue curves) have the same root 2 as the tokenization base 256. The model performs better on these two moduli. In (b), the moduli 2178 and 19683 (orange curves) have the same root 3 as the tokenization …

Discussion (0). Sign in to comment.

Forward citations

Cited by 3 Pith papers

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score. Full citation record

  1. Learning Pseudorandom Numbers with Transformers: Permuted Congruential Generators, Curricula, and Interpretability

    cs.LG 2025-10 conditional novelty 7.0 of 10

    Transformers can in-context predict PCG outputs on unseen parameters; required context length scales as sqrt(m), and curriculum training with smaller moduli is necessary for large moduli.

  2. Pseudorandom Streams within Diffusion Models Act as Learnable Inputs That Affect Generation Quality

    cs.LG 2026-08 conditional novelty 6.0 of 10

    A diffusion model's training loss and output quality depend measurably on which pseudorandom orbit supplies its randomness, even after marginal-statistics control.

  3. Sequential Correlations Change In-Context Learning: Effective Context Length and Architectural Mismatch

    stat.ML 2026-07 conditional novelty 6.0 of 10

    Within-context token correlations reduce ICL to an effective shorter i.i.d. context length, while query–context correlations lower error and favor softmax over linear attention.

Reference graph

Works this paper leans on

38 extracted references · 19 canonical work pages · cited by 3 Pith papers

  1. [1]

    Transformers learn to implement preconditioned gradient descent for in-context learning

    Ahn, K., Cheng, X., Daneshmand, H., and Sra, S. Transformers learn to implement preconditioned gradient descent for in-context learning. In Oh, A., Neumann, T., Globerson, A., Saenko, K., Hardt, M., and Levine, S. (eds.), Advances in Neural Information Processing Systems, volume 36, pp.\ 45614--45650. Curran Associates, Inc., 2023. URL https://openreview....

  2. [2]

    What learning algorithm is in-context learning? investigations with linearmodels, 2023

    Aky \"u rek, E., Schuurmans, D., Andreas, J., Ma, T., and Zhou, D. What learning algorithm is in-context learning? investigations with linearmodels, 2023. URL https://openreview.net/forum?id=0g0X4H8yN4I

  3. [3]

    and Li, Y

    Allen-Zhu, Z. and Li, Y. Physics of language models: Part 1, learning hierarchical language structures. 2024. URL https://arxiv.org/abs/2305.13673

  4. [4]

    Amigo, G., Dong, L., and Marks Ii, R. J. Forecasting pseudo random numbers using deep learning. In 2021 15th International Conference on Signal Processing and Communication Systems (ICSPCS), pp.\ 1--7, 2021. doi:10.1109/ICSPCS53099.2021.9660301

  5. [5]

    and Wyart, M

    Cagnetta, F. and Wyart, M. Towards a theory of how the structure of language is acquired by deep neural networks. arXiv preprint arXiv:2406.00048, 2024

  6. [6]

    M., Favero, A., and Wyart, M

    Cagnetta, F., Petrini, L., Tomasini, U. M., Favero, A., and Wyart, M. How deep neural networks learn compositional data: The random hierarchy model. Physical Review X, 14 0 (3): 0 031001, 2024

  7. [7]

    and Zou, D

    Chen, X. and Zou, D. What can transformer learn with varying depth? case studies on sequence learning tasks. In Forty-first International Conference on Machine Learning, 2024. URL https://openreview.net/forum?id=YNbCbcGyXE

  8. [8]

    Three models for the description of language

    Chomsky, N. Three models for the description of language. IRE Transactions on information theory, 2 0 (3): 0 113--124, 1956

Show all 38 references
  1. [9]

    K., Catt, E., Cundy, C., Hutter, M., Legg, S., Veness, J., and Ortega, P

    Delétang, G., Ruoss, A., Grau-Moya, J., Genewein, T., Wenliang, L. K., Catt, E., Cundy, C., Hutter, M., Legg, S., Veness, J., and Ortega, P. A. Neural networks and the chomsky hierarchy, 2023. URL https://arxiv.org/abs/2207.02098

  2. [10]

    To grok or not to grok: Disentangling generalization and memorization on corrupted algorithmic datasets

    Doshi, D., Das, A., He, T., and Gromov, A. To grok or not to grok: Disentangling generalization and memorization on corrupted algorithmic datasets. In The Twelfth International Conference on Learning Representations, 2024 a . URL https://openreview.net/forum?id=UHjE5v5MB7

  3. [11]

    Grokking modular polynomials, 2024 b

    Doshi, D., He, T., Das, A., and Gromov, A. Grokking modular polynomials, 2024 b . URL https://arxiv.org/abs/2406.03495

  4. [12]

    An image is worth 16x16 words: Transformers for image recognition at scale

    Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., Uszkoreit, J., and Houlsby, N. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on...

  5. [13]

    Garner, H. L. The residue number system. In Papers Presented at the the March 3-5, 1959, Western Joint Computer Conference, IRE-AIEE-ACM '59 (Western), pp.\ 146–153, New York, NY, USA, 1959. Association for Computing Machinery. ISBN 9781450378659. doi:10.1145/1457838.1457864. ...

  6. [14]

    Grokking modular arithmetic, 2023

    Gromov, A. Grokking modular arithmetic, 2023. URL https://arxiv.org/abs/2301.02679

  7. [15]

    Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks

    He, T., Doshi, D., Das, A., and Gromov, A. Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks. In The Thirty-eighth Annual Conference on Neural Information Processing Systems, 2024. URL https://openreview.net/forum?id=aVh9KRZdRk

  8. [16]

    In-context learning creates task vectors, 2023

    Hendel, R., Geva, M., and Globerson, A. In-context learning creates task vectors, 2023

  9. [17]

    Hull, T. E. and Dobell, A. R. Random number generators. SIAM Review, 4 0 (3): 0 230--254, 1962. doi:10.1137/1004061. URL https://doi.org/10.1137/1004061

  10. [18]

    Knuth, D. E. The art of computer programming, volume 2 (3rd ed.): seminumerical algorithms. Addison-Wesley Longman Publishing Co., Inc., USA, 1997. ISBN 0201896842

  11. [19]

    Learning skillful medium-range global weather forecasting

    Lam, R., Sanchez-Gonzalez, A., Willson, M., Wirnsberger, P., Fortunato, M., Alet, F., Ravuri, S., Ewalds, T., Eaton-Rosen, Z., Hu, W., et al. Learning skillful medium-range global weather forecasting. Science, 382 0 (6677): 0 1416--1421, 2023

  12. [20]

    In-context vectors: Making in context learning more effective and controllable through latent space steering, 2024

    Liu, S., Ye, H., Xing, L., and Zou, J. In-context vectors: Making in context learning more effective and controllable through latent space steering, 2024

  13. [21]

    and Hutter, F

    Loshchilov, I. and Hutter, F. Decoupled weight decay regularization. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=Bkg6RiCqY7

  14. [22]

    Uncovering a universal abstract algorithm for modular addition in neural networks, 2025

    McCracken, G., Moisescu-Pareja, G., Letourneau, V., Precup, D., and Love, J. Uncovering a universal abstract algorithm for modular addition in neural networks, 2025. URL https://arxiv.org/abs/2505.18266

  15. [23]

    R., Kailkhura, B., Bhatele, A., Geiping, J., Schwarzschild, A., and Goldstein, T

    McLeish, S., Bansal, A., Stein, A., Jain, N., Kirchenbauer, J., Bartoldson, B. R., Kailkhura, B., Bhatele, A., Geiping, J., Schwarzschild, A., and Goldstein, T. Transformers can do arithmetic with the right embeddings, 2024. URL https://arxiv.org/abs/2405.17399

  16. [24]

    Progress measures for grokking via mechanistic interpretability

    Nanda, N., Chan, L., Lieberum, T., Smith, J., and Steinhardt, J. Progress measures for grokking via mechanistic interpretability. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=9XFSbDPmdW

  17. [25]

    In-context learning and induction heads

    Olsson, C., Elhage, N., Nanda, N., Joseph, N., DasSarma, N., Henighan, T., Mann, B., Askell, A., Bai, Y., Chen, A., et al. In-context learning and induction heads. arXiv preprint arXiv:2209.11895, 2022

  18. [26]

    O'Neill, M. E. Pcg : A family of simple fast space-efficient statistically good algorithms for random number generation. 2014. URL https://api.semanticscholar.org/CorpusID:3489282

  19. [27]

    Grokking: Generalization beyond overfitting on small algorithmic datasets

    Power, A., Burda, Y., Edwards, H., Babuschkin, I., and Misra, V. Grokking: Generalization beyond overfitting on small algorithmic datasets. arXiv preprint arXiv:2201.02177, 2022

  20. [28]

    and Wolf, L

    Press, O. and Wolf, L. Using the output embedding to improve language models. In Proceedings of the 15th Conference of the European Chapter of the Association for Computational Linguistics: Volume 2, Short Papers, pp.\ 157--163, 2017

  21. [29]

    Language models are unsupervised multitask learners

    Radford, A., Wu, J., Child, R., Luan, D., Amodei, D., and Sutskever, I. Language models are unsupervised multitask learners. 2019

  22. [30]

    Rivest, R. L. Cryptography and machine learning. In International Conference on the Theory and Application of Cryptology, pp.\ 427--439. Springer, 1991

  23. [31]

    J., Casper, S., Tegmark, M., Saunders, W., Bau, D., Todd, E., Geiger, A., Geva, M., Hoogland, J., Murfet, D., and McGrath, T

    Sharkey, L., Chughtai, B., Batson, J., Lindsey, J., Wu, J., Bushnaq, L., Goldowsky-Dill, N., Heimersheim, S., Ortega, A., Bloom, J., Biderman, S., Garriga-Alonso, A., Conmy, A., Nanda, N., Rumbelow, J., Wattenberg, M., Schoots, N., Miller, J., Michaud, E. J., Casper, S., Tegma...

  24. [32]

    and Vigna, S

    Steele, G. and Vigna, S. Computationally easy, spectrally good multipliers for congruential pseudorandom number generators, 2021. URL https://arxiv.org/abs/2001.05304

  25. [33]

    N., Kaiser, L., and Polosukhin, I

    Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS'17, pp.\ 6000–6010, Red Hook, NY, USA, 201...

  26. [34]

    Transformers learn in-context by gradient descent, 2023

    von Oswald, J., Niklasson, E., Randazzo, E., Sacramento, J., Mordvintsev, A., Zhmoginov, A., and Vladymyrov, M. Transformers learn in-context by gradient descent, 2023

  27. [35]

    Chain-of-thought prompting elicits reasoning in large language models, 2023

    Wei, J., Wang, X., Schuurmans, D., Bosma, M., Ichter, B., Xia, F., Chi, E., Le, Q., and Zhou, D. Chain-of-thought prompting elicits reasoning in large language models, 2023. URL https://arxiv.org/abs/2201.11903

  28. [36]

    and Nanda, N

    Zhang, F. and Nanda, N. Towards best practices of activation patching in language models: Metrics and methods. In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=Hf17y6u9BC

  29. [37]

    The clock and the pizza: Two stories in mechanistic explanation of neural networks

    Zhong, Z., Liu, Z., Tegmark, M., and Andreas, J. The clock and the pizza: Two stories in mechanistic explanation of neural networks. In Thirty-seventh Conference on Neural Information Processing Systems, 2023. URL https://openreview.net/forum?id=S5wmbQc1We

  30. [38]

    write newline

    " write newline "" before.all 'output.state := FUNCTION n.dashify 't := "" t empty not t #1 #1 substring "-" = t #1 #2 substring "--" = not "--" * t #2 global.max substring 't := t #1 #1 substring "-" = "-" * t #2 global.max substring 't := while if t #1 #1 substring * t #2 gl...

Pith tools

Reviewed August 7, 2026 · model on record in the stance chip above.