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

Bo Peng, Daniel Goldstein, Quentin Gregory Anthony, Alon Albalak, Eric Alcaide, Stella Biderman, Eugene Cheah, Teddy Ferdinan, Kranthi Kiran Gv, Haowen Hou, Satyapriya Krishna, Ronald McClelland Jr., Niklas Muennighoff, Fares Obeid, Atsushi Saito, Guangyu Song, Haoqin Tu, Ruichong Zhang, Bingchen Zhao, Qihang Zhao, Jian Zhu, Rui-Jie Zhu

TL;DR

This paper introduces Eagle (RWKV-5) and Finch (RWKV-6), new recurrent neural network (RNN) architectures that aim to combine the parallelizable training of Transformers with the efficient inference of RNNs. By incorporating matrix-valued states and dynamic recurrence mechanisms, these models achieve competitive performance on various benchmarks while maintaining RNN-like inference efficiency. The authors also introduce a new multilingual dataset and tokenizer to support broader language coverage.

What Problem Does This Paper Address?

The dominant Transformer architecture, while powerful, suffers from quadratic complexity with respect to sequence length, making it computationally expensive for long sequences. Traditional RNNs offer linear inference complexity but struggle with parallelization during training and capturing long-range dependencies. This paper addresses the challenge of developing sequence models that can achieve both efficient training and inference, bridging the gap between Transformers and RNNs. The authors aim to improve upon the existing RWKV architecture by enhancing its expressivity and performance without sacrificing its core efficiency advantages.

Methods

The paper introduces two new architectures: Eagle (RWKV-5) and Finch (RWKV-6), building upon the RWKV-4 architecture.

  • Eagle (RWKV-5): This version enhances RWKV-4 with:
  • Multi-headed matrix-valued states: Replacing vector-valued states with matrix-valued ones to improve expressivity.
  • Reformulated receptance and an additional gating mechanism: To further refine the model's ability to process information.
  • Finch (RWKV-6): This architecture further builds upon Eagle by introducing:
  • Data-dependent functions for time-mixing and token-shift modules: Utilizing parameterized linear interpolations for more dynamic processing.
  • Novel use of Low Rank Adaptation (LoRA): To allow trainable weight matrices to augment learned data decay vectors in a context-dependent manner.
  • Data-dependent Token Shift: This mechanism allows the model to dynamically decide how much new vs. old information to incorporate per time step, based on the input.

The authors also developed a RWKV World Tokenizer using Trie-based greedy matching for efficient multilingual tokenization and a new RWKV World v2 dataset with 1.12 trillion tokens.

Datasets

  • Training: RWKV World v2 dataset (1.12 trillion tokens), a new multilingual dataset designed to improve performance on multilingual and code data.
  • Evaluation: The models were evaluated on various common English-only and multilingual text benchmarks, including LAMBADA, XCOPA, XNLI, PAWS-X, XStoryCloze, xWinogrande, and others. They also evaluated on associative recall, music modeling, and vision-language benchmarks.

Key Insights and Ideas

  • Matrix-valued states are key to expressivity: The shift from vector-valued to matrix-valued states in Eagle significantly boosts the model's ability to capture complex patterns.
  • Data-dependent recurrence unlocks dynamic behavior: Finch's use of data-dependent mechanisms for token-shift and decay allows for more flexible and context-aware processing, moving beyond fixed patterns.
  • LoRA integration offers efficient augmentation: Applying LoRA to decay parameters in Finch provides a computationally efficient way to introduce context-dependent adaptations.
  • Multilingualism is achievable with targeted data and tokenization: The creation of RWKV World v2 and a specialized tokenizer demonstrates a path towards building more inclusive LLMs.
  • RNNs can rival Transformers: The continued progress in RWKV architectures shows that RNNs, with the right architectural innovations, can achieve competitive performance with Transformers, especially in terms of inference efficiency.

Key Results

  • Competitive Performance: Eagle and Finch models achieved competitive performance across a wide variety of benchmarks, often outperforming similarly sized models.
  • Multilingual Strength: The models demonstrated strong capabilities on multilingual benchmarks.
  • Efficiency: The architectures maintain the efficient inference characteristics of RNNs, with O(1) time complexity per token.
  • Scalability: The authors trained models up to 7.5 billion parameters (Eagle) and 3.1 billion parameters (Finch), demonstrating scalability.
  • Tokenizer Speed: The custom RWKV tokenizer (Rust implementation) achieved significantly higher speeds (90.32 MB/s) compared to other popular tokenizers.
  • MQAR Improvement: Finch showed extremely high accuracy in MQAR tasks, outperforming many non-transformer architectures.
  • Long Context: Eagle and Finch showed significant improvements over RWKV-4 on long context tasks (PG19 dataset).

Limitations and Future Work

  • Corpus Size: The RWKV World v2 dataset (1.12 trillion tokens) is smaller than those used for some contemporary models (e.g., LLaMA2). Expanding the corpus and training for multiple epochs are suggested future directions.
  • Embedding Quality: Eagle showed promising results as an embedding model on MTEB, but further work is needed to aggregate information content effectively.
  • Larger Models: The authors plan to train and release larger versions of Finch (7B and 14B parameters).
  • Mixture of Experts: Exploring Mixture of Experts (MoE) is suggested for further cost reduction and performance extension.
  • Further Optimization: While Finch shows excellent speed scaling, further optimization of its CUDA implementation is possible for even greater speed increases and parallelization.

Summary updated

BibTeX
@inproceedings{peng2024eagle,
  author = {Bo Peng and Daniel Goldstein and Quentin Gregory Anthony and Alon Albalak and Eric Alcaide and Stella Biderman and Eugene Cheah and Teddy Ferdinan and Kranthi Kiran GV and Haowen Hou and Satyapriya Krishna and Ronald McClelland Jr. and Niklas Muennighoff and Fares Obeid and Atsushi Saito and Guangyu Song and Haoqin Tu and Ruichong Zhang and Bingchen Zhao and Qihang Zhao 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