Exposing Attention Glitches with Flip-Flop Language Modeling

Why do large language models sometimes output factual inaccuracies and exhibit erroneous reasoning? The brittleness of these models, particularly when executing long chains of reasoning, currently seems to be an inevitable price to pay for their advanced capabilities of coherently synthesizing knowledge, pragmatics, and abstract thought. Towards making sense of this fundamentally unsolved problem, this work identifies and analyzes the phenomenon of attention glitches, in which the Transformer architecture's inductive biases intermittently fail to capture robust reasoning. To isolate the issue, we introduce flip-flop language modeling (FFLM), a parametric family of synthetic benchmarks designed to probe the extrapolative behavior of neural language models. This simple generative task requires a model to copy binary symbols over long-range dependencies, ignoring the tokens in between. We find that Transformer FFLMs suffer from a long tail of sporadic reasoning errors, some of which we can eliminate using various regularization techniques. Our preliminary mechanistic analyses show why the remaining errors may be very difficult to diagnose and resolve. We hypothesize that attention glitches account for (some of) the closed-domain hallucinations in natural LLMs.

Paper

References (100)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer 4Fu79/10 · confidence 4/52023-06-29

Summary

The paper introduces Flip-Flop Language Modeling (FFLM) to examine closed-domain hallucinations of Large Language Models (LLMs). Flip-Flop languages are synthetic benchmarks which model a single bit of memory and its operations: read (r), ignore (i), and write (w). For example, the string "w 1 i 0 r 1" is valid as the same bit was written and read, but "w 1 i 0 r 0" is invalid. The task of the Transformer is to attend to the last write operation and generate the correct bit for the read operation. The authors discover that the Transformer exhibits a long tail of reasoning errors even on this simple task (they call these attention glitches), and these errors are very hard to mitigate. Interestingly, the LSTM can perform the task perfectly, with 20x less training. They also introduce a preliminary study on the effect of attention sharpening on training Transformers to simulate the flip-flop automaton. Intuitively sharpening should help as the Transformer only needs to attend to the most recent write. They find that sharpening can indeed help but also introduce new errors.

Strengths

The paper provides very interesting and significant insights into the workings of the Transformer architecture. Some of the most interesting findings: - Transfomers make reasoning errors on the long tail - 1-layer LSTMs can learn the same task perfectly - Transformers exhibit high variance in the OOD test error between random seeds and even iterations withing the same training run - 10B-scale LLMs cannot solve the task robustly - architectural and regularization changes can have orders-the-magnitude effects on OOD performance - in contrast to LSTMs, it seems that completely eliminating attention glitches is not possible for Transformers Flip-flop languages are also interesting as they are realizable by self-attention (as the authors explain in lines 221-224), so they could represent a reasoning task which should actually be easier for LLMs. The paper is also very well written, I could not find any errors or opaque sections.

Weaknesses

I think the main weakness of the study is that it's limited to flip-flop languages. That being said, I think this is just because of the foundational nature of the study: examining other languages would be outside the scope of the paper and could be explored in future work. Still, although the findings are very interesting, some of them may be specific to flip-flop languages. For example, (R4), training on rare sequences, would be very hard to do in the general case of natural language, and so I'm not sure what (R4) means in the general case. Also, (R5) says that scaling improvements are orders of magnitude smaller, I wonder if that stands for natural language too as it's much more diverse. The authors include some natural language experiments isomorphic to a flip-flop language and a discussion about natural language in the Appendix. Even though Section 5.3 is a preliminary study it would be good to include some quantitaive results. I believe that Fig. 5 (d) is incorrect: the error marked in red should be $\sigma_0$ and $\sigma_1$. The notation $\Delta$ could be introduced, I don't think it's widely used in probability.

Questions

In the flip-flop language the value can be only 0 or 1. It could be interesting to extend the task to more values (like 0-15, or a single byte, 0-255). How worse do you think the Transformer and the natural LMs would perform in that case? Do you think that the LSTM would still perform very well? The attention sharpening regularization uses $-\Vert\alpha\Vert_{2}$, but usually $L_1$ norm is used for sparsification. I found the reasoning behind $L_\infty$ and entropy in the cited paper (Zhang et al.), but I still don't see how using $L_2$ norm sparsifies. Could you elaborate on this?

Rating

9: Very Strong Accept: Technically flawless paper with groundbreaking impact on at least one area of AI/ML and excellent impact on multiple areas of AI/ML, with flawless evaluation, resources, and reproducibility, and no unaddressed ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

4 excellent

Presentation

4 excellent

Contribution

4 excellent

Limitations

The limitations are addressed thoroughly in the Conclusion.

Reviewer ycg18/10 · confidence 4/52023-07-03

Summary

The paper identifies a simple task for which the Transformer architecture fails. The authors introduce flip-flop language modeling, towards quantifying the extrapolation capabilities of different architectures. Transformer models are determined to suffer from long tail errors, in a phenomenon termed "attention glitches". Throughout the paper, this new synthetic task is analysed and the failure modes of Transformer models are identified. The authors embark and compare different techniques to mitigate the failures. Some theoretical justification and some mechanistic interpretability are also provided.

Strengths

1. The paper discusses a very simple task for which recurrent networks triumph, but Transformer present failure cases, attributing these failures to the inductive bias of the model. The task proposed is very simple and adequately motivated. 2. Long range dependencies are a common failure case of Transformer models. FFLM allows for easy to check failures for reasoning tasks. 3. Extensive experiments with different regularizations are provided.

Weaknesses

1. I feel some of the implications and connections to Ji et al., 2023 are not highlighted. From Figure 3, depth does not seem to have a direct consequence on performance. 2. Although some theoretical justification is provided, assumptions are in cases too strong, i.e. linear positional encoding. 3. Although a series of regularization and other techniques are proposed to solve the errors, no clear solution is proposed that works.

Questions

1. It will be helpful to report errors as a function of difficulty. This can be done by presenting the errors as a function of sequence length (as done in Figure 3-right) or by also presenting errors as a function of different FFL tasks. If we define as $d$, the distance between the last write and the current read operation, is there a connection between the distribution of $d$ in the training set and the types of errors in the extrapolation set? How many examples of distance $d$ need to be presented for the model to generalize? For (possible) outliers $d$ in the training set, is the model fitting them correctly? There might be some interesting connections with Grokking [1, 2], where the model switches from a state of memorizing to one of generalizing. 2. Preposition 2 states that a 2-layer 1-head Transformer can represent FFL. Is there is practice any benefit with depth? 3. Other ways to decrease the entropy of the attention include the change of the temperature inside the softmax (which is not included in Proposition 3), or the method of [3]. Fixes: Figure 3 (left) x-axis is cropped (50 -> 500), also middle-right (10->10K). [1] Power, Alethea, et al. "Grokking: Generalization beyond overfitting on small algorithmic datasets." arXiv preprint arXiv:2201.02177 (2022). [2] Thilak, Vimal, et al. "The slingshot mechanism: An empirical study of adaptive optimizers and the grokking phenomenon." arXiv preprint arXiv:2206.04817 (2022). [3] Martins, André, et al. "Sparse and continuous attention mechanisms." Advances in Neural Information Processing Systems 33 (2020): 20989-21001.

Rating

8: Strong Accept: Technically strong paper, with novel ideas, excellent impact on at least one area, or high-to-excellent impact on multiple areas, with excellent evaluation, resources, and reproducibility, and no unaddressed ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

4 excellent

Presentation

4 excellent

Contribution

3 good

Limitations

The paper proposes a simple example to study failure in extrapolation of Transformer models. The authors identify the lack of correct inductive bias in the model as the major shortcoming. Although many different regularization techniques are proposed, no clear answer is given for this phenomenon. I believe that this will however steer the community towards the right direction, for answering fundamental questions what these models is concerned.

Reviewer vbMc6/10 · confidence 3/52023-07-04

Summary

This work studies the phenomenon of "attention glitches" in LLMs. Attention glitches are instances where an LLM's attention mechanism fails to capture long-range dependencies, resulting in factual inaccuracies or erroneous reasoning. The authors introduce a new synthetic benchmark called flip-flop language modeling (FFLM) to probe the extrapolative behavior of LLMs. FFLM is a simple generative task that requires an LLM to copy binary symbols over long-range dependencies, ignoring the tokens in between. The authors find that Transformer Transformer-based FFLMs suffer from a long tail of sporadic reasoning errors, even when the task is relatively simple.

Strengths

- The paper studies a critical problem on attention glitches for transformer-based models. It can potentially have a huge impact on the community. - The synthetic FFLM benchmark can be useful to study long-range dependency in a controllable way. - The findings/research questions provide more insights on the issue.

Weaknesses

- The paper discussed and aimed at drawing a connection between hallucination and long-range dependency, however, there is no further discussion on how these two terms interact with each other. - While it is understandable that the paper studied the behavior of attention glitches, there is no proposed path to fix the issue which limits the contribution of this work. - The setting is fully synthetic. It is unclear how any findings can be transferred into realistic and more complex tasks. - Some experimental settings that are critical to the conclusion are unclear, e.g., dataset construction and sequence lengths, tokenizer choice, etc.

Questions

- The paper showed that 1-layer LSTM works perfectly for FF while transformers are not. However, it is unclear to me whether that is due to an effect of overfitting (to the distribution of training data). Could authors elaborate more on this? - "We hypothesize that attention glitches occur in the internal algorithmic representations of Transformer models of natural language, and that they account for (a non-negligible portion of) the reasoning errors encountered in practice. " Is there a way to validate the hypothesis? - It would be great if the authors can release the code to reproduce the results.

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

2 fair

Presentation

2 fair

Contribution

3 good

Limitations

- It should be made clear that the full experiments and analysis are based on synthetic setting.

Reviewer FpxV6/10 · confidence 4/52023-07-05

Summary

This paper introduces Flip-Flop Language Modeling (FFLM), a synthetic benchmark designed to evaluate language model's (LMs) ability to perform operations on a single-bit of memory. LMs are evaluated on their ability to generalize to out-of-distribution (OOD) sequences. The training setups are varied along several axes including hyperparameters (random seed, training steps, weight decay, dropout), architectural changes (number of layers, hard vs. soft attention, positional encodings), and dataset properties (additional OOD data). In all cases, the LMs produce attention glitches, i.e., they exhibit errors in their reasoning. In contrast, an LSTM generalizes perfectly. The authors provide preliminary hypotheses explaining the failure modes.

Strengths

*Originality:* although synthetic benchmarks have been often studied in NLP, FFLM focuses on the smallest reasoning capability (memory on a single bit), reducing confounding factors driving mistakes. *Quality:* the experiments are comprehensive and cover most of the "standard" training and architectural tricks. Moreover, the FFLM benchmark is well-designed and is appropriately justified as a benchmark. These two factors lead to a useful analysis of current limitations of LMs. *Clarity:* the paper is well-written and figures + captions are self-explanatory *Significance:* understanding reasoning errors in LMs is a crucial step towards improving their reliability and thus future deployment in real-world systems. Moreover, this work provides a minimal benchmark with which to evaluate any proposed architectural changes to LMs.

Weaknesses

The main weakness with the work is a lack of actionable insights. Although several mechanistic hypotheses are proposed as to explaining the behavior behind the benchmark, they are not adequately explored nor clearly organized. This leads to the following concerns: **Evaluation concerns:** * *Lack of experiments studying whether the proposed hypotheses in Section 4.1 actually drive the errors examined.* I appreciate the compilation of possible hypotheses explaining the LM errors. However, there don't appear to be experiments attempting to falsify these hypotheses? For example, one could examine whether the LMs do indeed only attend to the previous $n$-tokens. **Clarity concerns:** * *Does not emphasize the benchmark properties of FFLM.* Although the authors defined success on FFLM as achieving 100% performance accuracy, if people are to evaluate their architectural innovations on FFLM, it would be helpful to have a more continuous notion of progress (rather than solved vs. unsolved). Possible suggestions include: * Defining a notion of difficultly of generalization. E.g., FFL(0.1) is harder than FFL(0.2) given training data from FFL(0.98). Perhaps one could introduce an easy and hard test set. * Classifying severity of failures. Is there perhaps some metric that would estimate how close the LM attention patterns match either the ideal solution or any other possible solution? Intuitively, there should be some distinction between the attention weights of a randomly-initialized network and the attention weights of a trained model with error (Figure 5d). Perhaps one metric could be the proportion of attention weight placed on all the previously encountered write tokens vs. on all other tokens * *Should have a clearer list of future directions.* I think it would help guide future work if there was a compiled list of actionable experiments and / or hypotheses to test that were provided in the appendix.

Questions

Questions: 1. Were there any other hypotheses explored in Section 4.1? It would be nice to have a more careful enumeration (perhaps by category) of the possible hypotheses driving the lack of OOD generalization. Moreover, one of the proposed mechanisms is already present in previous work. Typos: 1. Line 867: "the regularization indeed have" --> "the regularization indeed has"

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

3 good

Presentation

3 good

Contribution

3 good

Limitations

Although there appears to be a limitations section in Appendix A.4, I think it would be appropriate to more clearly note in the main body that this work does not posit a full list of possible mechanisms driving poor performance on FFLM nor will solving performance on FFLM constitute a transformer with robust reasoning.

Reviewer ZZvs6/10 · confidence 3/52023-07-06

Summary

This paper presents a paradigm for diagnosing one cause of closed-domain (intrinsic) hallucinations in large language models (LLMs) and presents its analysis results. To understand why LLMs can be factually inaccurate or prone to erroneous reasoning, the authors proposed a flip-flop language model (FFLM) task designed to verify behavior during extrapolation. By controlling the probability of ignoring behavior, the FFLM can generate sequences with both dense-and-short and sparse-and-long dependencies. This allows us to observe changes ofTransformer's learning outcomes and behavior between these sequences. The analysis revealed that occasional, long-tail inference failures cause errors, and currently, their occurrence cannot be predicted. Some of the effects can be mitigated with regularization, but they cannot be completely eliminated. The main claims are as follows: - Proposing the flip-flop language modeling task. This task is designed to probe issues during the inference of long sequences easily. - Transformers can learn flip-flop language, but regardless of dependency length, they occasionally cause long-tail errors. - To mitigate this attention glitch, several regularization techniques are verified. No method can resolve the problem entirely, though each technique has a certain effect. ### after rebuttal I increased my score from 5 to 6 based on the explanations provided in the feedback.

Strengths

- Proposal of FFLM, a controllable long-range dependency resolution task, under a simple task setting. The adjustability of the dependency range by the ignore action's probability is easy to understand. - According to the authors, this is the first attempt to attribute model hallucinations to a systematic architectural flaw in the Transformers. - Presenting various experimental results and possible explanations from many aspects. Unfortunately, none in this report are definitive causes and/or solutions (most are denied by exceptions), but they can be utilized as one of the initial investigation items in the analysis of natural language LM's hallucination. - It's interesting that LSTMs and 1-layer single Transformers can solve some issues, but multi-layer LSTMs are not good at the issues. This suggests the necessity of architectural innovations beyond just stacking self-attention layers.

Weaknesses

- While the paper presents several interesting results to the readers, currently, the manuscript does not provide a clear guideline on what steps should be taken to counteract hallucinations in natural language LLMs. The impression I get from the current manuscript is that 'our current knowledge does not pinpoint the cause of hallucinations in natural language LLMs'." - I found it interesting that LSTMs and 1-layer single Transformers sometimes performs better than the multi-layer LSTM. Why does this happen? I believe there must be important implications, so if I have overlooked the explanation, please point it out in the review answers.

Questions

This is just a simple idea: Consider a unit with more memory bits. Would it be possible to create a unit that defines the ignore probability for each bit independently? Is it possible that a multi-head attention can learn FFLM (with more bits) efficiently, by aligning the number of bits and heads?

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

4 excellent

Contribution

2 fair

Limitations

Well discussed in the manuscript.

Reviewer FpxV2023-08-13

Thank you for your details response.

I appreciate the proposed list of directions and hope they will be included in the paper. I would like to see this paper accepted but I am keeping my score.

Authorsrebuttal2023-08-21

We will make sure to include these discussion in the camera ready version. Thank you very much again for your support and for the valuable suggestions!

Reviewer 4Fu72023-08-13

Thank you for your response

Thank you for your insightful comments and for pointing out the quantitaive results in the Appendix. I also appreciate Figure 2 in the response. I believe that the paper will be even better with the proposed revisions. I still strongly believe that this negative result is very significant, the paper should be accepted, and it could be the basis for much future work. To emphasize this I increased my score to 9.

Reviewer ycg12023-08-15

Thank you for the additional results, I believe they are very valuable. The authors have address all my concerns. If I understand the "Additional Figure 3" correctly, the authors present the location of errors as a function of distance to the last read. As smaller distances are a lot more likely, perhaps it would make more sense to present the probability of error prediction as a function of that distance, i.e. how many errors were made for distance $d$, compared to how many instances of distance $d$ can be found. Overall, I find this work and the FFLM fascinating and valuable to future research, as a simple yet challenging toy experiment. I believe authors have addressed concerns from all reviewers. To reflect this I have increased my score.

Authorsrebuttal2023-08-16

Thank you for the follow-up and the encouraging feedback! **Clarification regarding the "errors vs. distance" plot:** Additional Figure 3 *does* normalize by the count (hence the label "fraction of errors"). You are correct that the distribution of denominators is extremely lopsided, due to the geometric distribution of dependency lengths; hence, the former plot (plotting counts instead of fractions) would be uninformative. (At the upper range, there may be undetected errors, due to rarity of such dependencies even under the FFL(0.98) distributions.) We'll clarify this upon merging into the manuscript.

Reviewer ZZvs2023-08-16

Thank you for the clarifications

Authors, thank you for your feedback! (and excuse me for typos...) Concerning "Why LSTM / smaller Transformers perform better": Yes, that is what I want to ask. The provided explanation sounds convincing to me. Thanks! I find the answers to my questions and fellow reviewers' questions are overall convincing and satisfactory. I'm leaning towards a more positive attitude, so I will increase my score to 6.

Authorsrebuttal2023-08-21

We are glad that our response addressed your concerns. Once again, thank you very much for the insightful discussions and support!

Area Chair XhKr2023-08-18

Thank you for the detailed response and for addressing the reviewers' points. We have pinged reviewer vbMc, and they will make sure to go over the rebuttal soon. Your AC

Reviewer vbMc2023-08-20

I'd like to thanks the authors for providing a very detailed explanation and I apologize for the late response. The responses particularly the general one helped clarify the paper a lot, and consequently I have raised my score to 6. Please do incorporate these points in the final paper.

Authorsrebuttal2023-08-21

Thank you very much again for the time and effort you've dedicated to reviewing our paper! We really appreciate your suggestions and will make sure that they are reflected in the camera ready version.

Program Chairsdecision2023-09-21

Decision

Accept (spotlight)

© 2026 NYSGPT2525 LLC