Table of Contents
Fetching ...

Scaling Context, Not Parameters: Training a Compact 7B Language Model for Efficient Long-Context Processing

Chen Wu, Yin Song

TL;DR

MegaBeam-Mistral-7B demonstrates that a compact 7B language model can efficiently scale to a 512K-context window through targeted training and system-level optimizations. By combining four-phase continual pretraining, RoPE theta tuning, bf16 precision management for RoPE, Ring Attention-based sequence parallelism, and XLA compilation memory fixes, the approach achieves strong long-context performance across HELMET, RULER, and BABILong benchmarks, including a competitive 35% on 512K BABILong without RAG. The results show robust retrieval, multi-hop tracing, and in-context learning at long horizons, with notable open-source impact and practical applicability to compliance monitoring and verification. Remaining gaps in multi-fact and multi-hop reasoning at extreme contexts point to avenues for future architectural and training refinements to further close the gap with larger models.

Abstract

We present MegaBeam-Mistral-7B, a language model that supports 512K-token context length. Our work addresses practical limitations in long-context training, supporting real-world tasks such as compliance monitoring and verification. Evaluated on three long-context benchmarks, our 7B-parameter model demonstrates superior in-context learning performance on HELMET and robust retrieval and tracing capability on RULER. It is currently the only open model to achieve competitive long-range reasoning on BABILong at 512K context length without RAG or targeted fine-tuning. Released as fully open source under the Apache 2.0 license, the model has been downloaded over 100,000 times on Hugging Face. Model available at: https://huggingface.co/aws-prototyping/MegaBeam-Mistral-7B-512k

Scaling Context, Not Parameters: Training a Compact 7B Language Model for Efficient Long-Context Processing

TL;DR

MegaBeam-Mistral-7B demonstrates that a compact 7B language model can efficiently scale to a 512K-context window through targeted training and system-level optimizations. By combining four-phase continual pretraining, RoPE theta tuning, bf16 precision management for RoPE, Ring Attention-based sequence parallelism, and XLA compilation memory fixes, the approach achieves strong long-context performance across HELMET, RULER, and BABILong benchmarks, including a competitive 35% on 512K BABILong without RAG. The results show robust retrieval, multi-hop tracing, and in-context learning at long horizons, with notable open-source impact and practical applicability to compliance monitoring and verification. Remaining gaps in multi-fact and multi-hop reasoning at extreme contexts point to avenues for future architectural and training refinements to further close the gap with larger models.

Abstract

We present MegaBeam-Mistral-7B, a language model that supports 512K-token context length. Our work addresses practical limitations in long-context training, supporting real-world tasks such as compliance monitoring and verification. Evaluated on three long-context benchmarks, our 7B-parameter model demonstrates superior in-context learning performance on HELMET and robust retrieval and tracing capability on RULER. It is currently the only open model to achieve competitive long-range reasoning on BABILong at 512K context length without RAG or targeted fine-tuning. Released as fully open source under the Apache 2.0 license, the model has been downloaded over 100,000 times on Hugging Face. Model available at: https://huggingface.co/aws-prototyping/MegaBeam-Mistral-7B-512k
Paper Structure (12 sections, 6 figures)

This paper contains 12 sections, 6 figures.

Figures (6)

  • Figure 1: Overview of MegaBeam's training methodology: four sequential phases
  • Figure 2: Accumulated memory pre-allocation by XLA compiler under two chunk size configurations. The orange line (larger chunks) demonstrates reduced memory footprint compared to the blue line (smaller chunks) throughout the HLO graph, with peak memory reduction of 186GB.
  • Figure 3: Model performance comparison on RULER benchmark: top shows 128K context length results, bottom shows average performance across context lengths from 8K to 128K.
  • Figure 4: Performance comparison on BABILong benchmark at 64K and 128K context lengths
  • Figure 5: In-Context Learning performance comparison on HELMET, showing MegaBeam's leading performance across multiple context lengths
  • ...and 1 more figures