LLM Architecture Evolution Through the Lens of Decoding Mechanisms
This article examines how autoregressive decoding, causal attention, and KV caching shape large language model architecture. It explains why decoder-only models became dominant, analyzes encoder-assisted decoding as a way to improve long-context efficiency, and provides a practical checklist for evaluating new architecture proposals.
LLM Architecture Evolution Through the Lens of Decoding Mechanisms
A recent technical report for an open-source large model has sparked considerable discussion. The report mentions that the model introduces a new “encoding” component. At first glance, many readers wondered whether this approach would abandon the industry’s mainstream decoder-only architecture and return to an early two-tower design. A careful reading of the full report shows that this is not the case. The model still has a single main body rather than a two-tower design with independent encoder and decoder components. To understand the motivation and value of this kind of new architecture, it is necessary to return to the basic process of large model inference and identify the bottlenecks in the current paradigm.
1. The Decoding Process of Large Models: The Starting Point for All Discussion
Mainstream large language models are almost universally built on an autoregressive generation paradigm. Autoregressive means that the model generates output token by token: at each step, it takes the existing sequence as input, predicts a probability distribution for the next token, appends the sampled new token to the end of the sequence, and repeats until it encounters an end-of-sequence marker or reaches a length limit.
At the computational level, this process has two key characteristics.
First, causal attention. In a decoder-only architecture, the attention matrix is constrained by a lower-triangular mask: the representation at position i can only “see” information from positions 1 through i and must never peek at the future. This constraint ensures consistency between training and inference behavior and allows the model to train in parallel (computing the loss for all positions in the sequence in one forward pass), while inference can only generate serially, token by token.
Second, the KV cache. Because the Key and Value tensors for historical tokens do not change during each generation step, engineering systems cache them to avoid redundant computation. Then, for each newly generated token, only one attention query needs to interact with all cached values, reducing complexity from O(n²) to O(n). But this comes at a cost: the cache itself grows linearly with sequence length, and in long-context scenarios, memory usage and memory bandwidth become hard constraints.
A simplified inference loop can be illustrated as follows:
def generate(model, prompt_ids, max_new_tokens):kv_cache = Noneids = prompt_idsfor _ in range(max_new_tokens):# Feed only the newest token; all history comes from the cachelogits, kv_cache = model.step(ids[:, -1:], kv_cache)next_id = sample(logits[:, -1])ids = concat(ids, next_id)if next_id == EOS:breakreturn ids
Understanding these two characteristics makes it clear why almost all subsequent architecture-level improvements revolve around “how to process long contexts more efficiently” and “how to compress the KV cache.”
2. Why Decoder-Only Instead of Encoder-Decoder
Early pretrained models explored multiple structures: pure encoders are good at understanding tasks but cannot directly generate; encoder-decoder two-tower structures perform well on sequence-to-sequence tasks such as machine translation and summarization. However, when models scale to tens or hundreds of billions of parameters, decoder-only gradually became the overwhelming mainstream choice. The reasons can be summarized in three points:
- The training objective is unified and scalable. Next-token prediction requires only raw text and does not need manually constructed paired data, making it naturally suited to internet-scale corpora. Massive unlabeled data is a prerequisite for scaling laws to take effect.
- The architecture is simple and engineering-friendly. A single stack means pipeline parallelism and tensor parallelism can be partitioned uniformly, reducing the difficulty of optimizing training and inference frameworks.
- Emergent capabilities are more in line with expectations. Extensive community experiments show that, under the same parameter and data budget, pure decoder structures are more stable in few-shot and instruction-following capabilities. The key capability of in-context learning is built on unified causal modeling.
Therefore, when a report mentions “introducing an encoding structure,” the reasonable judgment should not be “the architecture has regressed.” Instead, the question should be: what specific problem does this encoding component solve, and does it break the main framework of autoregressive generation?
3. A New Architecture Idea: Using “Encoding” to Assist “Decoding”
Taking this type of new approach discussed in the community as an example, its core idea can be abstracted as “context-encoding-enhanced decoding.” Without changing the final token-by-token generation method, it adds a lightweight bidirectional attention component that encodes the input context once, compresses the long prefix into a more compact representation, and then passes that representation to the decoder.
The value of this idea is mainly reflected at two levels.
First, it alleviates cache pressure in long contexts. When prompts are extremely long (for example, document question answering with tens of thousands of tokens or code repository-level analysis), storing the full KV cache for all prefixes is expensive. If an encoding component can compress static context into a small number of dense vectors, the decoder only needs to interact with these compressed representations at each generation step, significantly reducing memory and compute overhead.
Second, it leverages the understanding advantages of bidirectional attention. Causal masking limits how information can interact within the prefix: the representation of the first token in the prefix cannot reference the 1,000th token. Bidirectional encoding allows information to be fully exchanged within the context, which in theory can produce higher-quality context representations. This is especially suitable for scenarios such as retrieval augmentation and long-document understanding, where “understanding comes first and generation comes later.”
It is important to emphasize that this type of design is fundamentally different from a traditional two-tower structure: there are no two independently pretrained models. The encoding part and decoding part either share the same set of main parameters or are tightly coupled through joint training. Externally, it still behaves as one model and one inference process.
4. A General Methodology for Evaluating New Architectures
Faced with a steady stream of architecture improvement proposals, developers can use a general checklist to judge their value without being misled by marketing language:
- Does it change the generation paradigm? As long as output is still produced token by token autoregressively, mainstream inference frameworks (sampling, beam search, streaming output) can remain compatible, and migration costs are low.
- Is the bottleneck real? Improvements should target measurable pain points such as first-token latency, cache memory, and long-sequence throughput, not paper metrics.
- Are benefits and costs symmetric? An additional encoding component increases training complexity and first-forward overhead. Compression only pays off when the context is long enough and reused multiple times.
- How compatible is the ecosystem? Whether it can reuse existing inference optimizations such as quantization, speculative sampling, and paged caching often affects adoption more than the novelty of the architecture itself.
In enterprise applications, this kind of evaluation can also be combined with general cloud capabilities: for example, using container platforms to quickly set up controlled experiment environments, monitoring and alerting to observe latency distributions and resource consumption of different architectures under real traffic, and object storage to manage evaluation datasets. This enables data-driven selection conclusions rather than reliance on a single benchmark score.
5. Summary
The decoder-only architecture became mainstream because it trades extreme simplicity for scalability, but that does not mean it cannot be improved. The “encoding-enhanced decoding” idea discussed in this article is essentially a finer division of labor within the autoregressive framework: bidirectional attention is responsible for “reading” the context, while the causal decoder focuses on “writing” the output. For developers, the important thing is not to chase every new term, but to understand the fundamental constraints of the decoding process—causality, KV cache, and sequence length—and use them as a yardstick to calmly measure the real benefits of each architecture improvement. For the foreseeable future, architecture innovation around long-context efficiency will remain one of the most active directions in the industry and deserves continued attention.
