# Understanding and Improving Length Generalization in Recurrent Models

순환 모델의 길이 일반화 이해 및 개선

Ruiz, Ricardo Buitrago, Gu, Albert · arXiv · 2025년 7월 3일

- **연구 문제** 순환 모델은 학습 문맥을 넘는 긴 시퀀스에서 성능이 떨어지는 길이 일반화 실패를 보이며, 이 논문은 그 원인을 상태 분포의 제한으로 설명하고 구조 변경 없이 적용할 수 있는 학습 개입을 제안합니다.
- **연구 방법** 위치별 perplexity로 길이 일반화를 정의하고, 초기 상태를 다른 시퀀스의 최종 상태 또는 가우시안 샘플로 바꾸는 State Passing과 Fitted Noise 같은 post-training 개입을 적용합니다.
- **주요 결과** State Passing은 Mamba-2 공식 체크포인트를 100 steps 후학습하여 긴 시퀀스에서 perplexity 발산을 줄였고, BABILong과 passkey retrieval 등 긴 문맥 과제에서도 개선을 보고합니다.

## 순환 모델이 학습 문맥을 넘으면 무너지는 문제

Mamba와 선형 어텐션 계열 같은 순환 모델은 상태 공간 모델 형태로 문맥을 하나의 상태에 압축하므로 계산량이 시퀀스 길이에 선형으로 늘어납니다. 이론적으로는 상태를 계속 굴리면 학습 때보다 긴 입력도 처리할 수 있지만, 실제로는 학습 문맥 길이를 넘는 순간 성능이 크게 떨어지는 경우가 많습니다. 이 논문은 이 현상을 길이 일반화 실패로 정의하고, 왜 실패하는지와 학습 단계에서 쉽게 고칠 수 있는지를 묻습니다. 기존 해결책은 Mamba의 내부 상태 갱신 방식을 바꾸거나 긴 시퀀스로 처음부터 다시 학습하는 방식이 많아, 다른 순환 구조로 옮기기 어렵다는 제약이 있었습니다. 저자들은 실패의 원인을 학습 중 상태 분포가 어떻게 제한되는지에서 찾고, 그 원인을 바탕으로 구조 변경 없이 적용할 수 있는 학습 개입을 검토합니다.

## 위치별 perplexity로 정의한 길이 일반화와 미탐색 상태 가설

논문은 위치별 perplexity를 각 위치 t에서 모델이 달성하는 perplexity를 데이터셋에 대해 평균낸 값으로 정의하고, 이를 이용해 길이 일반화를 판정합니다. 학습 문맥 길이 안에서 얻은 최소 위치별 perplexity를 기준으로, 더 긴 위치의 값들이 그 기준 이하로 유지되면 모델이 길이 일반화한다고 봅니다. 이 판정 기준을 사용해 학습 문맥이 짧을수록 긴 위치에서 값이 벌어지고, 학습 토큰 수를 과도하게 늘리면 실패가 나타난다는 관찰을 보고합니다. 이 관찰을 설명하기 위해 저자들은 미탐색 상태 가설을 제시합니다. 가설은 모델이 허용 가능한 상태 분포 전체가 아니라 그중 일부만 학습하면 길이 일반화에 실패한다는 것입니다.

이 가설은 저자들이 실험 결과로부터 세운 설명이며, 논문 전체가 이를 모든 순환 모델에 대해 증명했다고 보기는 어렵습니다.

![Figure 3: Position-wise perplexities of a Mamba-2 85m model trained for different number of tokens with a context of 1024 on the Pile (Gao et al. 2020). 2.5x m…](https://refivu.com/papers/f9cd6a9a-de1d-4e94-a91d-e03ad7e1036c/figures/figure-4ec3dcc534995ff928ceaa1e9344669f.png?thumb=512)

**Figure 3** : Position-wise perplexities of a Mamba-2 85m model trained for different number of tokens with a context of 1024 on the Pile (Gao et al. 2020). 2.5x means that the model is trained for 2.5 times what Chinchilla scaling laws dictate for that model size. Thus, the checkpoints correspond to a range between 4.25B and 34B tokens. In this case, the failure to length general- ize occurs after training for more than 7.5x Chinchilla laws.

[원문](https://arxiv.org/abs/2507.02782v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Ruiz, Ricardo Buitrago, Gu, Albert · Understanding and Improving Length Generalization in Recurrent Models · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.

## Effective Remembrance로 과거 토큰의 영향을 읽는 방법

Effective Remembrance는 전체 문맥 x0:T로 얻은 출력 분포와 최근 부분 문맥 xt:T로 얻은 출력 분포 사이의 거리로 정의됩니다. 기본 거리는 total variation이며, 이 값은 0과 1 사이에 놓입니다. 값이 0에 가까우면 t 이전의 토큰을 제거해도 예측이 거의 같아 모델이 그 과거를 효과적으로 기억하지 않는다는 뜻이고, 값이 크면 과거 토큰을 제거할 때 예측이 크게 바뀝니다. 논문은 T를 학습 문맥의 네 배로 두고 Mamba는 8192, GLA는 2048에서 측정합니다. 실패하는 모델은 멀리 떨어진 초기 토큰에 크게 의존하는 곡선을 보이며, 이는 0 위치 근처의 고정된 초기 상태에 과적합했다는 해석과 연결됩니다.

이 지표는 거리 선택에 대한 부록 분석에서 total variation, Jensen-Shannon, cosine 기반 거리 사이에서 곡선 모양이 크게 다르지 않다고 보고됩니다.

## 초기 상태를 바꾸는 학습 개입들

논문의 핵심 개입은 학습 시작 시의 상태 h\_{-1}을 0이 아닌 값으로 바꾸는 것입니다. 0이 아닌 초기 상태를 쓰면 상태 갱신식은 초기 상태가 최종 상태와 출력에 더해지는 항을 갖게 됩니다. 가장 효과가 컸던 State Passing은 현재 시퀀스의 초기 상태로 다른 시퀀스의 최종 상태를 사용하는 방식이며, 학습 중 0으로 초기화하는 경우를 확률 0.1로 섞어 짧은 문맥 입력도 잘 처리하게 합니다. Fitted Noise는 학습 중 각 층과 헤드의 최종 상태 평균과 분산을 β=0.1의 이동 평균으로 추정하고, 그 가우시안 분포에서 초기 상태를 샘플링합니다. Random Noise는 모든 값을 고정 분산의 독립 가우시안으로 샘플링하는 가장 단순한 방식입니다.

논문은 Mamba-2 공식 체크포인트를 이 방식으로 100 post-training steps 동안만 추가 학습하며, 이는 pre-training 예산의 약 0.02%에 해당한다고 보고합니다.

![Figure 4: Norm of the full state of the Mamba-2 130m of- ficial checkpoints versus the sequence position𝑡(ℎ 𝑡 in the notation of Section 2.2). The norm is take…](https://refivu.com/papers/f9cd6a9a-de1d-4e94-a91d-e03ad7e1036c/figures/figure-edf8c1f5733092e2101da7c98e7c85e0.png?thumb=512)

**Figure 4** : Norm of the full state of the Mamba-2 130m of- ficial checkpoints versus the sequence position𝑡(ℎ 𝑡 in the notation of Section 2.2). The norm is taken across all ele- ments of the state in all layers. The Mamba-2 130m post- trained with State Passing (Section 4.1) produces states whose standard deviation do not significantly change af- ter the training context𝑇=2048. In contrast, the official Mamba-2 checkpoint reaches a standard deviation almost twice as large at position𝑡=8192than the one at position 𝑡=2048.

[원문](https://arxiv.org/abs/2507.02782v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Ruiz, Ricardo Buitrago, Gu, Albert · Understanding and Improving Length Generalization in Recurrent Models · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.

## 긴 문맥 과제와 TBTT 비교로 본 효과

State Passing은 Mamba-2 780m 모델을 2048 길이로 학습하거나 미세조정한 뒤 BABILong의 few shot 및 finetuned 설정에서 평가되었습니다. 논문은 이 개입이 긴 문맥 추론에서 길이 외삽 능력을 높인다고 보고합니다. Passkey retrieval에서는 공식 Mamba-2 체크포인트를 표준 미세조정하거나 Fitted Noise로 미세조정해 비교했습니다. 이 비교에서 Fitted Noise fine-tuning 모델은 표준 fine-tuning보다 적어도 두 배 긴 시퀀스를 풀었고, 780m 모델은 256k 길이에서 완전한 정확도를 기록했습니다. 합성 복사 과제는 45 million 파라미터 모델을 길이 50에서 100 사이 시퀀스로 처음부터 학습하고 길이 300에서 평가한 설정입니다.

이 설정에서 Mamba-2의 문자 정확도는 0.27, State Passing을 적용한 경우는 0.47로 보고됩니다. TBTT는 State Passing과 매우 유사한 성능을 보여, 논문은 핵심이 긴 시퀀스 처리 자체보다 도달 가능한 상태 분포를 탐색하는 데 있다고 해석합니다.

![Table 1: Length generalization results for the synthetic copying task (Jelassi et al. 2024), which consists of copying an arbitrary sequence of tokens. The mod…](https://refivu.com/papers/f9cd6a9a-de1d-4e94-a91d-e03ad7e1036c/figures/figure-8521277d38cb9b3185094bb959d7ae4c.png?thumb=512)

**Table 1** : Length generalization results for the synthetic copying task (Jelassi et al. 2024), which consists of copying an arbitrary sequence of tokens. The models have 45 million parameters, are initialized randomly and trained on 1 million sequences of length between 50 and 100. They are evaluated on sequences of length 300. The State Passing intervention greatly improves length generalization.

[원문](https://arxiv.org/abs/2507.02782v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Ruiz, Ricardo Buitrago, Gu, Albert · Understanding and Improving Length Generalization in Recurrent Models · 원문 그림 인용 · 원본 PDF 10쪽에서 그림 영역을 추출했습니다.

## 개입의 한계와 아직 남은 질문

Random Noise 개입은 370m 모델에서는 약간 개선을 보였지만 780m과 1.3b 모델에서는 길이 일반화 문제를 고치지 못했습니다. 저자들은 Mamba-2의 실제 도달 가능한 상태 분포가 큰 모델에서 독립 가우시안과 많이 다르기 때문이라고 해석합니다. Fitted Noise도 1.3b 모델에서는 여전히 실패했으며, 저자들은 독립 샘플링이 큰 모델의 복잡한 상태 의존성을 재현하지 못한다는 가설을 제시합니다. Random Noise는 σ 값에 민감해 너무 작으면 효과가 없고 너무 크면 성능을 해칩니다. 또한 저자들은 State Passing이 다른 모델 구조에서 어떻게 작동하는지, 시계열 지향 모델이나 하이브리드 모델에서도 같은 효과가 나는지는 향후 연구로 남겨 둡니다.

![Figure 12: Position-wise perplexity of Mamba-2 125m post-trained for 100 steps with random initial state at different standard deviations𝜎. This post-training…](https://refivu.com/papers/f9cd6a9a-de1d-4e94-a91d-e03ad7e1036c/figures/figure-35c8c5d8f29645b8c168c9a7b56609af.png?thumb=512)

**Figure 12** : Position-wise perplexity of Mamba-2 125m post-trained for 100 steps with random initial state at different standard deviations𝜎. This post-training technique enables length generalization, but if the noise level is too high it hurts performance.

[원문](https://arxiv.org/abs/2507.02782v2) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Ruiz, Ricardo Buitrago, Gu, Albert · Understanding and Improving Length Generalization in Recurrent Models · 원문 그림 인용 · 원본 PDF 19쪽에서 그림 영역을 추출했습니다.

## 논문 정보

- **저자**: Ruiz, Ricardo Buitrago, Gu, Albert
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2025년 7월 3일
- **등록일**: 2026년 10월 30일
- **수정일**: 2025년 10월 12일
- **버전**: v2
- **arXiv**: 2507.02782
- **원문 이용 조건**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **제공 범위**: 논문 정보, 해설, 허용된 원문 그림

[논문 원문 ↗](https://arxiv.org/abs/2507.02782v2) · [원문 PDF ↗](https://arxiv.org/pdf/2507.02782v2)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 초록

Recently, recurrent models such as state space models and linear attention have become popular due to their linear complexity in the sequence length. Thanks to their recurrent nature, in principle they can process arbitrarily long sequences, but their performance sometimes drops considerably beyond their training context lengths-i.e. they fail to length generalize. In this work, we provide comprehensive empirical and theoretical analysis to support the unexplored states hypothesis, which posits that models fail to length generalize when during training they are only exposed to a limited subset of the distribution of all attainable states (i.e. states that would be attained if the recurrence was applied to long sequences). Furthermore, we investigate simple training interventions that aim to increase the coverage of the states that the model is trained on, e.g. by initializing the state with Gaussian noise or with the final state of a different input sequence. With only 500 post-training steps ($\\sim 0.1\\%$ of the pre-training budget), these interventions enable length generalization for sequences that are orders of magnitude longer than the training context (e.g. $2k\\longrightarrow 128k$) and show improved performance in long context tasks, thus presenting a simple and efficient way to enable robust length generalization in general recurrent models.

## 원문 인용

Ruiz, Ricardo Buitrago, Gu, Albert (2025). Understanding and Improving Length Generalization in Recurrent Models. arXiv:2507.02782v2. https://arxiv.org/abs/2507.02782v2

**BibTeX**

```
@misc{buitrago2025understanding,
  title = {{Understanding and Improving Length Generalization in Recurrent Models}},
  author = {Ruiz, Ricardo Buitrago and Gu, Albert},
  year = {2025},
  eprint = {2507.02782},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.02782v2}
}
```

## 이 논문의 용어

- [Mamba-2](https://refivu.com/terms/caf9f0e79adb-mamba-2)
- [truncated backpropagation through time](https://refivu.com/terms/e873452387c0-truncated-backpropagation-through-time)
- [BABILong](https://refivu.com/terms/1b7d28fcf0f9-babilong)
- [length generalization](https://refivu.com/terms/d707487b3d55-length-generalization)
- [Chinchilla scaling laws](https://refivu.com/terms/e4592bab75cb-chinchilla-scaling-laws)
- [passkey retrieval](https://refivu.com/terms/5c967bdf0089-passkey-retrieval)

## 다른 논문 해설

- [Improving Multi-Class Calibration through Normalization-Aware Isotonic Techniques](https://refivu.com/papers/b6c283c7-33a6-4837-bc33-2a99b929d4c9-improving-multi-class-calibration-through-normalization.md)
- [Dichotomy of Feature Learning and Unlearning: Fast-Slow Analysis on Neural Networks with Stochastic Gradient Descent](https://refivu.com/papers/d22616f1-d062-41c9-96ea-b861b94b978c-dichotomy-of-feature-learning-and-unlearning-fast-slow.md)
- [All ERMs Can Fail in Stochastic Convex Optimization Lower Bounds in Linear Dimension](https://refivu.com/papers/611959d0-945b-4f84-8df3-5f73eeb4b0d9-all-erms-can-fail-in-stochastic-convex-optimization.md)
- [Armijo Line-search Can Make (Stochastic) Gradient Descent Provably Faster](https://refivu.com/papers/2d604ce5-f2ec-49fe-88c5-5d0fd711c821-armijo-line-search-can-make-stochastic-gradient-descent.md)
- [Dimension-Independent Convergence of Underdamped Langevin Monte Carlo in KL Divergence](https://refivu.com/papers/206df735-cc15-48eb-9820-3e1c893270c1-dimension-independent-convergence-of-underdamped-langevin.md)
- [Intrinsic Task Symmetry Drives Generalization in Algorithmic Tasks](https://refivu.com/papers/6029a9e0-e1c4-49b8-b05f-aeeaa51e8355-intrinsic-task-symmetry-drives-generalization-in-algorithmic.md)
- [h1: Bootstrapping LLMs to Reason over Longer Horizons via Reinforcement Learning](https://refivu.com/papers/647b6b77-64d1-4597-a263-33cd7128dae7-h1-bootstrapping-llms-to-reason-over-longer-horizons.md)
- [Learn to Change the World: Multi-level Reinforcement Learning with Model-Changing Actions](https://refivu.com/papers/b3c3d38b-1a78-4269-b2bb-d40f6bf43e0c-learn-to-change-the-world-multi-level-reinforcement.md)
- [Efficient Parallel Samplers for Recurrent-Depth Models and Their Connection to Diffusion Language Models](https://refivu.com/papers/262ed432-5b97-462f-a0f1-44ba3791e072-efficient-parallel-samplers-for-recurrent-depth-models-and.md)
- [Log Neural Controlled Differential Equations: The Lie Brackets Make a Difference](https://refivu.com/papers/b0189c51-3e6b-4a2d-b5e4-d6cc22afeba1-log-neural-controlled-differential-equations-the-lie.md)
- [Teaching Transformers Causal Reasoning through Axiomatic Training](https://refivu.com/papers/6619489a-beeb-475b-beb3-a75c121f0ef3-teaching-transformers-causal-reasoning-through-axiomatic.md)
- [Polybasic Speculative Decoding Through a Theoretical Perspective](https://refivu.com/papers/74f9df3c-47ca-4679-a2bd-c22f74c31c78-polybasic-speculative-decoding-through-a-theoretical.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/f9cd6a9a-de1d-4e94-a91d-e03ad7e1036c-understanding-and-improving-length-generalization-in)
