From Dense Models to Million-Token Context: How LLMs Evolved
Large language models are shifting from simply scaling parameters toward getting more useful capability from limited compute. This article traces that path through mixture-of-experts architectures, fine-grained and shared experts, code-specific training and evaluation, vision-language alignment, and the engineering challenges of million-token context windows.
In recent years, large language model development has moved beyond simply increasing parameter counts. The focus is now on how limited compute can produce higher effective capability. Research has concentrated on four areas: sparsifying model architectures, training on code and other specialized data, fusing multimodal information, and running efficient inference with context windows at the million-token scale. Taken together, these directions show how modern language models have progressed from general text modeling toward more complex intelligent systems.
1. From Dense Models to Mixture-of-Experts
A conventional dense language model activates every network parameter for each input token. When a model has tens or even hundreds of billions of parameters, one forward pass increases matrix computation, memory demand, and communication bandwidth together. Adding parameters usually improves representational power, but not every input needs the full body of knowledge.
Mixture-of-experts (MoE) architectures split a large network into relatively independent expert modules. A router then selects a small number of experts based on the input. The model can keep a large total parameter count while limiting how many parameters actually participate in computing each token.
The process can be summarized as follows:
Input token↓Router computes expert scores↓Select a few highly relevant experts↓Experts process the token in parallel↓Weighted merge of outputs
This design has two direct benefits:
- Higher total capacity: The model can hold more parameters and more knowledge patterns.
- Controlled compute cost: Each token activates only part of the expert set, so not every parameter is recomputed.
Traditional MoE designs also have clear drawbacks. With few experts, each of them large, routing is coarse. One expert may handle several unrelated tasks and remain insufficiently specialized. Load can also be uneven: some experts are called frequently while others stay underused.
2. Fine-Grained Expert Splitting for More Flexible Routing
An important improvement is to split large experts into more, smaller expert units. Compared with a handful of large experts, fine-grained experts offer richer combinations.
A single token may need grammar, domain knowledge, and reasoning at the same time. A coarse design can choose only one or two large experts. A fine-grained design can assemble a better-matched path from several small experts. Experts no longer have to own an entire task; they can develop clearer divisions of capability.
Fine-grained splitting matters in three ways:
1. Stronger expert specialization
During training, different experts can adapt to different data patterns, such as code completion, natural-language understanding, mathematical reasoning, or structured information extraction. Clearer boundaries help the model form modular capabilities.
2. Better composition
Complex tasks rarely depend on a single skill. Fine-grained experts let the model combine several capability modules dynamically and adapt more effectively to complex instructions.
3. Higher parameter utilization
With smaller experts and more flexible routing, a model can reach a wider variety of parameters under a fixed activation budget and reduce inefficient use of large parameter blocks.
More experts also make routing and communication harder to manage. Training must balance expert capacity, routing overhead, parallelism, and cross-device data exchange. Otherwise, communication cost can cancel the theoretical advantage of sparse computation.
3. Shared Experts for Stable General Capability
Relying only on routed experts creates another problem. General knowledge may be learned repeatedly by multiple experts, wasting parameters. When routing changes, basic language ability can also become unstable.
Shared experts address this by keeping some modules active on every computation. Those modules handle general semantics, basic language patterns, and cross-task ability. Input-specific work is left to dynamically routed experts.
The structure can be expressed as:
Final representation = shared expert output + routed expert output
Shared experts act as a foundation, while dynamic experts handle specialized processing. Together, they preserve stable general ability and still activate more specialized computation paths for each input.
In practice, shared experts can help with several issues:
- Reducing the chance that different experts relearn the same basic knowledge
- Improving convergence stability early in training
- Reducing the effect of routing fluctuation on outputs
- Providing a consistent language representation across tasks
One representative large sparse model has 145 billion total parameters, while each token activates about 28.5% of that total. It keeps high model capacity while using a compute scale closer to a smaller dense model, showing the parameter-efficiency potential of sparse architectures.
4. Code-Specific Training: From General Language to Program Understanding
Code differs clearly from ordinary natural language. Programs have strict syntax, explicit structure, variable dependencies, and an executability requirement. A model must do more than produce plausible text; the result also has to satisfy compilation, execution, and logical correctness.
Language models trained for code usually need to address the following issues:
1. Data cleaning
Code repositories can contain duplicate files, generated files, invalid fragments, noisy comments, and incomplete functions. Without cleaning, a model may learn repeated patterns or memorize incorrect implementations.
2. Multilingual coverage
Programming languages differ in syntax, type systems, concurrency models, and runtime environments. Covering many languages helps a model learn more general program structure, but it also creates data-mix problems. High-resource languages can crowd out low-resource ones, so sampling needs to be balanced.
3. Aligning code with natural language
Real development tasks include requirements, interface descriptions, error logs, and implementations. Pairing code with natural-language explanations strengthens the model’s ability to move from requirements to implementation and from errors to fixes.
4. Executability checks
Code quality should not be judged only by text similarity. More reliable evaluation combines compilation, unit tests, static analysis, and runtime results.
One code-focused model family spans roughly 1.3B to 33B parameters and was pretrained on about 2 trillion tokens of code across 87 programming languages. Its significance is not scale alone. It shows that a dedicated data mix and training objective can substantially improve program generation, completion, and understanding.
5. What to Measure When Evaluating Code Models
Code-model evaluation should separate fluent language from program correctness. Common measures include:
- Syntactic correctness: whether generated code parses or compiles
- Unit-test pass rate: whether the implementation matches expected behavior
- Code-completion accuracy: whether missing code is predicted correctly
- Bug-fixing ability: whether the model can locate and correct issues from logs
- Cross-language transfer: whether it can adapt to a new language with few examples
- Security: whether it introduces privilege escalation, injection, or unsafe calls
For enterprise use, engineering measures should be added as well, including maintainability, dependency complexity, runtime resource use, and review cost. A single benchmark score does not fully represent a model’s value in a real development workflow.
6. From Text Models to Vision-Language Models
The key to multimodal models is not simply feeding images into a model. It is building an effective mapping between visual information and language space. That usually involves three stages:
- Visual encoding: convert an image into a set of visual features.
- Modality alignment: map those features into a representation space the language model can use, through a projection layer or adapter.
- Joint generation: the language model uses visual and text information for question answering, description, reasoning, or information extraction.
During training, data quality matters more than simply adding more images. Image-text pairs need accurate correspondence, and the data should cover charts, documents, interfaces, scene images, and complex layouts.
Capability limits also need careful evaluation. A model that can describe an image may still fail to read small text accurately. Recognizing objects does not mean it has reliable spatial reasoning. Evaluation should cover visual question answering, text recognition, chart understanding, region localization, and multi-step reasoning.
7. The Core Challenge of Million-Token Context
Once a context window reaches the million-token scale, the issue is no longer only whether memory is sufficient. Position representation, attention computation, information retrieval, and output stability all become part of the problem.
Standard self-attention usually grows quadratically with sequence length. Expanding a sequence by tens of times and computing the full attention matrix creates enormous compute and memory pressure. Long-context systems therefore usually combine techniques such as:
- Chunked attention
- Sparse attention
- A mix of local and global attention
- Key-value cache compression
- Hierarchical retrieval and summarization
- Extended positional encodings for long text
- Distributed sequence parallelism
Long context also has a “readable but not findable” problem. A model may receive a large amount of text and still miss critical information in the middle. Evaluation should not look only at maximum window length. It should test key-information retrieval, multi-document association, cross-section reasoning, and long-range references.
8. A General Method for Building Efficient Models
Overall, modern language models have not advanced through a single technical breakthrough. Progress comes from joint optimization of data, architecture, training, and inference.
First, choose the model form according to the task. General question answering, code generation, and visual understanding place different demands on data and structure. Scaling parameters alone does not solve those differences.
Second, manage the compute budget as two separate parts: total parameter capacity and per-token activation cost. The advantage of MoE models is that sparse activation raises total capacity while controlling actual computation.
Third, data engineering should run through the whole pipeline. Deduplication, filtering, quality grading, language-ratio control, and data-mixing strategy often directly affect the final result.
Finally, evaluation must stay close to real tasks. Beyond offline benchmarks, latency, memory, throughput, stability, security, and deployment cost all matter. Research becomes practically valuable only when model capability and engineering constraints are both satisfied.
From dense models to mixture-of-experts, then to code-specific training, vision-language fusion, and million-token context, the technical thread remains the same: help models understand more information across a wider range of tasks, while completing reliable inference at lower compute and deployment cost. That remains the central direction for continued optimization of large-model systems.
