Gecko: An Efficient Neural Architecture Inherently Processing Sequences with Arbitrary Lengths

Xuezhe Ma, Shicheng Wen, Linghao Jin, Bilge Acun, Ruihang Lai, Bohan Hou, Will Lin, Hao Zhang, Songlin Yang, Ryan Lee, Mengxi Wu, Jonathan May, Luke Zettlemoyer, Carole-Jean Wu

TL;DR

GECKO is a novel neural architecture designed to handle sequences of virtually any length—up to 4 million tokens in testing—without the need for specialized context-extension tricks. By integrating sliding chunk attention with a new adaptive working memory, GECKO-7B outperforms Llama2-7B and Megalodon-7B in data efficiency and long-context retrieval, even rivaling the performance of models twice its size.

What Problem Does This Paper Address?

Standard Transformers are the backbone of modern AI, but they have a major flaw: their computational cost grows quadratically with sequence length ($O(n^2)$). This makes processing very long documents, like entire books or long codebases, prohibitively expensive. Furthermore, Transformers often struggle with "length extrapolation"—they fail when asked to process sequences longer than what they saw during training.

Alternative architectures like MEGA and Megalodon attempted to solve this using Exponential Moving Averages (EMA) and gated attention. However, they faced two hurdles:

  1. Vanishing Statistics: Their normalization methods caused the influence of new data to diminish as the sequence grew longer.
  2. Boundary Issues: Their "chunk-wise" attention mechanisms created "blind spots" at the edges of data chunks, leading to information loss.

GECKO aims to bridge these gaps, creating a model that is both hardware-efficient and capable of maintaining a stable "memory" over millions of tokens.

Methods

GECKO builds upon the Megalodon backbone but introduces three critical technical innovations:

  • Timestep Decay Normalization: In previous models, the cumulative mean and variance used for normalization would "stale" over time. GECKO introduces a decaying mechanism (similar to the momentum used in the Adam optimizer) that ensures the model maintains a consistent ratio of current vs. historical statistics, regardless of sequence length.
  • Sliding Chunk Attention (SCA): Traditional sliding window attention is computationally messy on GPUs. GECKO uses SCA, which processes data in non-overlapping chunks but allows each chunk to attend to the previous chunk as well. This provides a "lossless" short-term memory that propagates context across boundaries more efficiently than per-token windows.
Figure 2: Comparison of various sparse attention patterns. (a) Chunk-wise Attention: attention is restricted to separated chunks; (b) Sliding Window Attention: attention is restricted to fixed-size windows; (c) Sliding Chunk Attention: attention is assigned to both current and previous chunks.
  • Adaptive Working Memory (AWM): To capture information beyond the immediate sliding window, GECKO uses a linear attention mechanism acting as a compressed long-term memory. It employs a "position-aware online softmax kernel" and a "delta update rule" to dynamically erase redundant information and make room for new context without forgetting the distant past.
Figure 3: Adaptive working memory in GECKO. (a) illustrates how the memory is updated by compressing information from all previous and current chunks. (b) depicts how GECKO stores contextual information in short- and long-term memories in different components.

Datasets

The researchers conducted a strictly controlled comparison to ensure fair results:

  • Pretraining: The 7B model was trained on 2 trillion tokens using the same data mixture as Llama2. The 1.3B version used the Dolma v1.7 dataset.
  • Short-Context Benchmarks: Standard academic tests including MMLU, BoolQ, HellaSwag, and ARC.
  • Long-Context Evaluation: The Scrolls benchmark (for long-context QA) and a custom validation set of 1,500 books, each containing at least 4 million tokens.
  • Retrieval: Needle-in-a-Haystack (NIAH) and passkey retrieval tasks to test the model's ability to find specific facts hidden in massive contexts.

Key Insights and Ideas

  • Data Efficiency is the New King: GECKO-7B reached a training loss of 1.68, which is significantly better than Llama2-7B (1.75) and nearly matches Llama2-13B (1.67). This suggests that GECKO's architecture extracts more "knowledge" per token than the standard Transformer.
  • Smoothing the Boundaries: By using Sliding Chunk Attention, GECKO eliminates the "spikes" in loss that Megalodon suffered at chunk boundaries. This leads to much more stable next-token prediction across long sequences.
  • Retrieval Beyond the Window: Perhaps the most impressive "aha" moment is GECKO's retrieval capability. Even with a nominal attention window of 4K tokens, the model could successfully retrieve information from contexts up to 16K tokens (4x its window) thanks to its Adaptive Working Memory.

Key Results

  • Superior Scaling: As shown in the training curves, GECKO-7B consistently maintains a lower negative log-likelihood (NLL) than its direct competitors throughout the entire 2-trillion-token training run.
Figure 1: Negative log-likelihood for GECKO-7B, MEGALODON-7B, LLAMA2-7B and LLAMA2-13B, w.r.t processed tokens during training.
  • 4-Million Token Stability: In perplexity tests, GECKO's performance continued to improve (lower perplexity) as context length increased all the way to 4 million tokens, showing no signs of the "breaking" typically seen in Transformers.
  • Benchmark Dominance: On the Scrolls long-context QA tasks (NarrativeQA, Qasper, QMSum), GECKO-7B achieved the strongest performance among all models of similar scale, including those specifically fine-tuned for long contexts like YaRN-7B.
Perplexity continues to drop as GECKO processes up to 4 million tokens.

Limitations and Future Work

While GECKO shows remarkable retrieval capabilities, the authors note that the Adaptive Working Memory still has a bounded capacity. For "truly infinite" sequences, memory collisions—where new information overwrites old information—are inevitable.

Additionally, while GECKO-7B was compared fairly against Llama2 and Megalodon, newer models like Mistral-7B and Gemma-8B were trained on much larger datasets (up to 6T tokens), making a direct architectural comparison difficult. The authors suggest that scaling GECKO to even larger parameter counts and larger training sets is the logical next step.

Summary updated

BibTeX
@inproceedings{ma2026gecko,
  author = {Xuezhe Ma and Shicheng Wen and Linghao Jin and Bilge Acun and Ruihang Lai and Bohan Hou and Will Lin and Hao Zhang and Songlin Yang and Ryan Lee and Mengxi Wu and Jonathan May and Luke Zettlemoyer and Carole-Jean Wu},
  title = {{Gecko: An Efficient Neural Architecture Inherently Processing Sequences with Arbitrary Lengths}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=82JaGVBTxV},
}
Figure