Eagle and Finch: RWKV with Matrix-Valued States and Dynamic Recurrence

Bo Peng, Daniel Goldstein, Quentin Anthony, Alon Albalak, Eric Alcaide, Stella Biderman, Eugene Cheah, Xingjian Du, Teddy Ferdinan, Haowen Hou, Przemysław Kazienko, Kranthi Kiran Gv, Jan Kocoń, Bartłomiej Koptyra, Satyapriya Krishna, Ronald McClelland Jr., Jiaju Lin, Niklas Muennighoff, Fares Obeid, Atsushi Saito, Guangyu Song, Haoqin Tu, Cahya Wirawan, Stanisław Woźniak, Ruichong Zhang, Bingchen Zhao, Qihang Zhao, Peng Zhou, Jian Zhu, Rui-Jie Zhu

TL;DR

Eagle (RWKV-5) and Finch (RWKV-6) are the latest evolutions of the RWKV architecture, designed to bridge the gap between the efficiency of Recurrent Neural Networks (RNNs) and the expressive power of Transformers. By introducing multi-headed matrix-valued states and dynamic, data-dependent recurrence, these models achieve competitive performance on massive benchmarks while maintaining $O(1)$ inference complexity and $O(N)$ training complexity.

What Problem Does This Paper Address?

For years, the AI field has faced a fundamental trade-off. Transformers, the engine behind models like GPT-4, offer incredible performance but suffer from "quadratic complexity"—as the input sequence gets longer, the computational cost grows exponentially ($O(N^2)$). Conversely, traditional RNNs are highly efficient ($O(1)$ inference) but are notoriously difficult to train in parallel and often struggle to capture long-range dependencies as effectively as Transformers.

The authors address this by refining the RWKV (Receptance Weighted Key Value) architecture. They aim to create a model that scales linearly like an RNN during inference but can be trained with the massive parallelism of a Transformer, all while matching (or beating) the accuracy of state-of-the-art models.

Comparative analysis of RWKV-4/5/6 and other LLM architectures regarding time and memory complexity.

Methods

The paper introduces two major architectural iterations:

  1. Eagle (RWKV-5): The primary shift here is from vector-valued states to matrix-valued states. In previous versions, the model's "memory" was a simple vector; Eagle uses a multi-headed matrix, significantly increasing the model's expressive capacity. It also introduces SiLU gating and removes the Sigmoid activation from the "receptance" (the query-like term), allowing it to function more like the attention mechanism in Transformers.
  2. Finch (RWKV-6): Finch takes flexibility a step further by introducing dynamic recurrence. In Eagle, the rate at which the model "forgets" information (decay) was a fixed learned parameter. In Finch, this decay is data-dependent—the model uses a new function called "data-dependent linear interpolation" (ddlerp) and Low-Rank Adaptation (LoRA) to decide, based on the current input, how much of the past state to retain or discard.
Figure 1: RWKV architecture overview. Left: time-mixing and channel-mixing blocks; top-right: RWKV time-mixing block as RNN cell; center-bottom: token-shift module in FeedForward module and Eagle time-mixing; bottom-right: token-shift module in Finch time-mixing. All shape anno- tations assume a single head for simplicity. Dashed arrows (left, top-right) indicate a connection in Finch, but not in Eagle.

Additionally, the authors developed the RWKV World Tokenizer, a Trie-based greedy matching system designed to be faster and more inclusive of non-European languages compared to standard Byte-Pair Encoding (BPE).

Datasets

The models were trained on the new RWKV World v2 Dataset, a massive 1.12 trillion-token corpus. The mix is roughly 70% English, 15% multilingual (covering a wide array of underrepresented languages), and 15% programming code.

Evaluation spanned a diverse range of benchmarks:

  • Standard NLP: LAMBADA, HellaSwag, PIQA, and SciQ.
  • Multilingual: xStoryCloze, xWinoGrande, and xCOPA.
  • Long Context: The Bamboo benchmark and PG19 test set.
  • Multimodal: Irish ABC music sheet dataset, LLaVA-1.5 for vision, and AudioSet for audio tasks.

Key Insights and Ideas

  • The Matrix Memory Bank: By using matrix-valued states, the model acts like a memory bank where each row can decay at its own rate. This allows the model to "store" different types of information with varying levels of persistence.
  • Context-Aware Forgetting: The move to dynamic recurrence in Finch is a game-changer. It allows the model to effectively "flag" important information for inclusion in the data stream while ignoring noise, mimicking the way induction heads work in Transformers but within an RNN framework.
  • Pareto Frontier Shift: The authors demonstrate that for a given number of training FLOPs, Eagle and Finch represent a substantial improvement in the Pareto frontier for multilingual benchmarks, achieving higher accuracy than competing open models at similar compute scales.

Key Results

  • Competitive Performance: Eagle-7B outperforms the previous RWKV-4-7B across the board and achieves results competitive with LLaMA-2 7B and Falcon-7B on English benchmarks.
  • Multilingual Superiority: On multilingual tasks, Eagle and Finch significantly outperform similarly sized models, validating the effectiveness of the new tokenizer and dataset.
  • Associative Recall: Finch achieves extremely high accuracy in synthetic associative recall tasks, outperforming other non-transformer architectures like Mamba in certain configurations.
  • Efficiency at Scale: Speed and memory benchmarks confirm that Finch scales linearly with sequence length, making it roughly 4.2x faster than Flash Attention at a 16k sequence length.

Limitations and Future Work

The authors identify a few areas for improvement:

  • Embedding Quality: While Eagle provides high-quality context embeddings, it currently underperforms on the Massive Text Embedding Benchmark (MTEB). The authors suggest that a better aggregation method for the internal state is needed.
  • Data Scale: Although 1.12 trillion tokens is large, it is still smaller than the datasets used for models like LLaMA-3. Expanding the corpus is a high priority.
  • Scaling Up: The team plans to release larger versions of Finch (7B and 14B parameters) and explore Mixture of Experts (MoE) to further reduce inference and training costs.

Summary updated

BibTeX
@inproceedings{peng2024eagle,
  author = {Bo Peng and Daniel Goldstein and Quentin Anthony and Alon Albalak and Eric Alcaide and Stella Biderman and Eugene Cheah and Xingjian Du and Teddy Ferdinan and Haowen Hou and Przemysław Kazienko and Kranthi Kiran GV and Jan Kocoń and Bartłomiej Koptyra and Satyapriya Krishna and Ronald McClelland Jr. and Jiaju Lin and Niklas Muennighoff and Fares Obeid and Atsushi Saito and Guangyu Song and Haoqin Tu and Cahya Wirawan and Stanisław Woźniak and Ruichong Zhang and Bingchen Zhao and Qihang Zhao and Peng Zhou and Jian Zhu and Rui-Jie Zhu},
  title = {{Eagle and Finch: RWKV with Matrix-Valued States and Dynamic Recurrence}},
  booktitle = {COLM},
  year = {2024},
  url = {https://openreview.net/forum?id=soz1SEiPeq},
}
Figure