From General Language Models to Million-Token Contexts: A Comprehensive Technical Overview

    This article explores the evolution of large language models, focusing on three main development lines: general foundational capabilities, specialized capability injection through optimized architectures and reinforcement learning, and the expansion of context lengths to the million-token level. It covers technical strategies for general LLMs, Mixture of Experts (MoE), code intelligence, mathematical reasoning, multimodal understanding, and the engineering practices required to implement million-token context windows, providing a clear framework for architectural selection, training strategies, and engineering deployment.

    From General Language Models to Million-Token Contexts: A Comprehensive Technical Overview

    1. Main Evolution Lines: From “General Capabilities” to “Long-Context Intelligence”

    The evolution of large model research over the past two years has not been a linear stacking of single-point capabilities. Instead, it has advanced alternately around three main lines: First, how general language models can achieve stable, reusable foundational capabilities within a reasonable budget. Second, how specialized capabilities can be efficiently injected through data ratio optimization, architectural sparsification, and reinforcement learning. Third, how context length can be expanded from thousands of tokens to the million level while maintaining usability in long document understanding, code repository analysis, and multi-turn complex tasks. Understanding these three lines helps make clearer trade-offs between architecture selection, training strategies, and engineering deployment.

    Based on public technical materials, some open-source research teams have intensively published technical reports covering general language models, Mixture of Experts (MoE) architectures, code intelligence, mathematical reasoning, multimodal understanding, formal theorem proving, and document understanding. The research trajectory can be roughly divided into the “foundation period,” the “capability expansion period,” and the “long-context and systemization period.” The following sections are organized by technical theme rather than a simple timeline to highlight the inheritance relationships between methods.

    2. General Language Models: Long-Termism and Data Strategies

    General language models are the foundation of the entire technical system. The key to early work lies not only in parameter scale but in a “long-termism” training philosophy: emphasizing data quality, deduplication, curriculum design, training stability, and the long-term returns brought by scaling laws, rather than chasing short-term benchmark scores. Specifically, pre-training typically requires processing trillions of tokens, with model scales ranging from billions to hundreds of billions, and comprehensive evaluations on code, math, and reasoning tasks. Public materials show that such models can achieve capabilities close to closed-source general models under reasonable budgets, proving the engineering feasibility of the open-source route.

    The important lessons left from this stage are: First, data cleaning and ratio often impact the final capability more than simply increasing parameters; Second, loss spikes, gradient norms, and load balancing during training require dedicated monitoring; Third, evaluation cannot rely on a single benchmark but must cover multiple dimensions such as language understanding, code generation, mathematical reasoning, and instruction following. Long-termism is essentially an engineering methodology: treating data, computing power, and training strategies as a system that requires continuous optimization.

    3. Sparse Expert Architecture: Parameter Efficiency and Specialization

    The Mixture of Experts (MoE) architecture is a vital direction for improving parameter efficiency. Traditional dense models activate all parameters for each token, while MoE models only activate a subset of experts through a routing mechanism. Further designs introduce two key innovations: fine-grained expert segmentation and shared expert mechanisms. Fine-grained segmentation divides experts into smaller units, allowing routing to combine more specialized computational paths. Shared experts are open to all tokens, carrying general knowledge and reducing redundant learning among experts.

    The total parameters of such architectures can exceed tens of billions, but only about 30% of the parameters are activated per token, thereby increasing model capacity while keeping inference costs controllable. The technical challenges lie in routing stability, load balancing, and training throughput. A simplified forward process can be represented as:

    1. score = router(x)
    2. selected = top_k(score, k)
    3. out = sum(gate_i * expert_i(x) for i in selected)
    4. out = out + shared_expert(x)

    Here, the router needs to avoid expert collapse, where a few experts are overused. Shared experts need to be trained in coordination with routed experts to prevent the dispersion of general capabilities. The MoE architecture lays the foundation for many subsequent efficient models, but it is not a “free lunch”: routing overhead, communication overhead, and batch scheduling all affect actual throughput, requiring systematic optimization combined with hardware topology and inference frameworks.

    4. Code Intelligence: From Single-File Generation to Repository-Level Understanding

    Code intelligence is a crucial entry point for general models moving toward high-value scenarios. Code data is highly structured, has clear syntax constraints, and is verifiable through execution, making it suitable for capability enhancement via specialized pre-training. Relevant technical routes usually include: collecting code corpora from dozens of programming languages, performing deduplication, quality filtering, and license filtering; adding tasks like middle-content filling, cross-file dependencies, and comment generation during pre-training; and introducing instruction data and test cases during the fine-tuning stage.

    The capability evaluation of code models should not only look at single function generation but also cover completion, repair, explanation, test generation, and repository-level retrieval. Repository-level tasks require models to understand cross-file call relationships, dependency versions, and project structures, which directly drives the development of long-context capabilities. In engineering, a common practice is to split code into overlapping chunks, combine symbolic indexing and retrieval augmentation, and concatenate relevant fragments as context before generation. This controls the context length while preserving cross-file semantics.

    5. Mathematical Reasoning and Reinforcement Learning: Strategy Optimization to Reduce Training Costs

    Mathematical reasoning is an important scenario for testing the deep reasoning capabilities of models. Early routes typically followed “pre-training + supervised fine-tuning + reinforcement learning.” Traditional policy optimization methods often require maintaining both a policy model and a critic model, leading to large memory overhead. The idea of Group Relative Policy Optimization (GRPO) is to sample multiple outputs for the same problem and use intra-group relative performance to estimate advantages, thereby reducing reliance on an independent value network. Its core is not a complex reward model but obtaining stable learning signals through intra-group comparisons.

    A conceptual process is as follows:

    1. for prompt in batch:
    2. outputs = sample(policy, prompt, n)
    3. rewards = verify(outputs)
    4. advantage = normalize(rewards - mean(rewards))
    5. update(policy, outputs, advantage)

    Reward design usually focuses on answer correctness, format compliance, and the verifiability of the reasoning process. For math problems, symbolic verification or answer comparison can be used; for formal tasks, an interactive proof environment is needed to provide feedback. The engineering value of such methods lies in lowering the memory threshold for reinforcement learning and providing a reusable training paradigm for subsequent reasoning models. However, it should be noted that reward noise, sampling diversity, and training stability remain key challenges.

    6. Multimodality, Formal Proofs, and Document Understanding

    Multimodal understanding extends language models from pure text to images, tables, and layout information. Typical technologies include the alignment of visual encoders with language models, resolution adaptation, interleaved image-text pre-training, and instruction fine-tuning. Formal theorem proving requires models to generate checkable proof steps in an interactive proof environment, emphasizing search, policy learning, and verification loops. Document understanding falls in between, needing to handle layout, table structures, reading order, and cross-page references in long documents.

    The commonality among these directions is that models cannot rely solely on statistical correlations but must collaborate with external verifiers, retrievers, or toolchains. For example, formal proofs require proof assistants to check each step; document understanding requires layout parsing and table extraction; multimodal Q&A requires region localization and visual evidence. They also provide real-world demand for million-token contexts: a long report, a code repository, or a set of proof scripts often cannot be handled by simple truncation.

    7. Million-Token Contexts: Challenges, Methods, and Engineering Practices

    Expanding the context to a million tokens presents core challenges including: the quadratic complexity of attention computation, key-value cache consumption, position encoding extrapolation, insufficient distribution of training data lengths, and the “lost in the middle” problem in long contexts. Common methods can be categorized into several types: sparse attention and chunked attention to reduce computation; position interpolation and length extrapolation to improve position generalization; key-value cache compression and hierarchical memory to reduce VRAM usage; and retrieval augmentation and chunking to transform ultra-long inputs into a “retrieve + generate” pipeline.

    A general pseudo-code for long document processing is as follows:

    1. def answer(query, document, chunk_size, top_k):
    2. chunks = split_with_overlap(document, chunk_size)
    3. index = build_index(chunks)
    4. candidates = retrieve(query, index, top_k)
    5. context = merge_with_neighbors(candidates)
    6. return generate(query, context)

    During engineering deployment, both training and inference must be considered simultaneously: the training phase requires constructing long-dependency data to prevent models from only learning local patterns; the inference phase requires managing cache, batching, and streaming output; the evaluation phase must distinguish between “retrieving the answer” and “truly understanding the long context.” For enterprise applications, long context does not always replace retrieval augmentation; the two are often complementary: long context is suitable for tasks requiring global reasoning, while retrieval augmentation is suitable for scenarios with frequently updated knowledge and cost sensitivity.

    8. Evaluation and Deployment Recommendations

    Evaluating long-context models should establish a layered system: short-context foundational capabilities, long document Q&A, cross-segment reasoning, code repository understanding, multimodal document understanding, and robustness testing. Data contamination and evaluation leakage require special attention. For engineering selection, dense models are suitable for low-latency and simple deployment; sparse expert models are suitable for balancing capacity and cost; long-context capabilities should be used in conjunction with caching strategies, retrieval augmentation, and chunked parallelism. Ultimately, the value of technological evolution lies not in a single metric, but in whether it can form reproducible, evaluable, and maintainable system capabilities.