A Comprehensive Guide to Mainstream LLM Architectures and Practical Selection
This article systematically reviews the core architectural elements of Large Language Models (LLMs), mainstream design branches, and the engineering trade-offs behind them. By analyzing the common Transformer decoder skeleton and five key dimensions of architectural differences—including attention mechanisms, feed-forward networks, normalization, positional encoding, and parameter sharing—developers can build a structured understanding of any new model. The guide also offers a practical approach to reading architecture diagrams and provides selection recommendations based on real-world scenarios such as inference cost, capability limits, long-context handling, and private deployment.
I. Why an “Architecture Landscape Map” is Needed
The evolution of Large Language Models (LLMs) is happening at a breakneck pace. Different models have made highly differentiated design choices in key components such as attention mechanisms, feed-forward networks, normalization techniques, and positional encodings. Relying solely on scattered papers and technical blogs makes it difficult for developers to establish a systematic cognitive framework, which is why comprehensive architectural overviews are highly valued in the developer community.
For frontline developers, understanding the architecture is not just an academic interest; it is a fundamental capability that directly impacts engineering decisions. For instance, when evaluating whether an open-source model fits a business scenario, you need to determine how its attention variant affects the cost of long-context inference. When fine-tuning a model, you must understand how the position of layer normalization affects training stability. When planning an inference deployment, you need to estimate how the expert routing structure constrains VRAM usage. None of these questions can be answered without a solid grasp of the architecture itself.
Using an “architectural landscape” as a guiding thread, this article systematically outlines the core architectural elements of LLMs, mainstream design branches, and the engineering trade-offs behind them, offering practical selection and learning recommendations.
II. The Common Skeleton of LLMs: The Transformer Decoder
Despite obvious differences among various models, almost all modern LLMs are built on the same skeleton: the decoder-only autoregressive Transformer. Its basic data flow can be summarized as follows:
- Input tokens are converted into vectors through an embedding layer;
- The vectors pass through several identically structured Transformer blocks sequentially. Each block contains an “attention sublayer + feed-forward network sublayer,” combined with residual connections and normalization;
- The final hidden state is mapped back to the vocabulary space via an output head to obtain the probability distribution for the next token;
- The output is generated token by token in an autoregressive manner.
This process can be described with a pseudo-code snippet:
def forward(token_ids):h = embedding(token_ids) # token embeddingfor block in transformer_blocks: # stacked Transformer blocksh = h + attention(norm(h)) # attention sublayer + residualh = h + feed_forward(norm(h)) # feed-forward sublayer + residuallogits = output_head(norm(h)) # map to vocabularyreturn logits
Once this common skeleton is understood, the differences between models can be attributed to different choices for several “replaceable components” within the skeleton. Let’s analyze these key components one by one.
III. Five Key Dimensions of Architectural Differences
3.1 Attention Mechanism: From MHA to GQA
Standard Multi-Head Attention (MHA) requires maintaining an independent Key-Value (KV) cache for each head during inference. As sequence length and model scale grow, the VRAM footprint of this cache expands rapidly. To mitigate this, the industry has developed several common variants:
- Grouped-Query Attention (GQA): Allows multiple query heads to share a set of KV heads. It significantly reduces cache overhead with almost no loss in quality, making it a mainstream choice today.
- Multi-Query Attention (MQA): All query heads share a single KV head. The compression is more aggressive but impacts expressive capability to some extent.
- Latent Attention designs: Compresses KV into a latent space via low-rank projection to further compress the cache. This is a direction that has gained considerable attention in recent years.
For developers, the attention variant directly affects the VRAM budget and throughput of the inference service. When planning a deployment, you should first confirm which attention structure the target model uses and estimate the resource requirements for long-context scenarios accordingly.
3.2 Feed-Forward Network: Dense Architecture vs. Mixture of Experts
In traditional dense models, every token passes through the same complete set of feed-forward network parameters. The Mixture of Experts (MoE) architecture replaces the feed-forward layer with multiple “expert” subnetworks, where a router selects a small number of experts to participate in the computation for each token. The core benefit is that the total parameter count can be vastly expanded while keeping the activated parameter count per inference relatively low, thereby improving model capacity under controllable training and inference costs.
However, MoE also introduces new engineering complexities:
- Load balancing: Auxiliary losses or routing strategies are needed to prevent uneven usage among experts.
- VRAM footprint: All expert parameters still need to be loaded, placing high demands on total VRAM.
- Communication overhead: Distributed deployment introduces additional cross-device communication through expert parallelism.
When making a selection, dense models win on deployment simplicity and predictable behavior, while MoE models win on the upper limit of capability at an equivalent inference cost. You must weigh these based on your own compute conditions and operational capabilities.
3.3 Normalization Strategy and Position
Modern models generally adopt simpler-to-compute normalization variants and move the normalization operation to the input of each sublayer (Pre-Norm) to improve training stability in deep models. Some models add extra normalization at the attention or feed-forward outputs to further suppress numerical fluctuations. These details may seem minor, but they directly affect convergence performance during large-batch training and are worth noting during deep fine-tuning.
3.4 Positional Encoding: RoPE as the De Facto Standard
Rotary Position Embedding (RoPE) injects positional information into attention computation via a rotation matrix. It offers good relative positional expression and extrapolation potential, making it the de facto standard. A series of extension techniques revolve around it, such as adjusting the base frequency and interpolation scaling, to support contexts longer than the training length during inference. When dealing with long-text scenarios, developers should confirm the implementation of the model’s context window to avoid directly assuming that “the nominal length equals the effective length.”
3.5 Parameter Sharing and Inter-layer Connections
Some models employ cross-layer parameter sharing, weighted inter-layer combinations, or differentiated layer depth configurations to compress size or improve efficiency. Such designs are particularly common in small-parameter models, aiming to achieve the highest possible capability density in edge-side or low-cost scenarios.
IV. How to Efficiently Read an Architecture Diagram
When facing a complete model architecture diagram, it is recommended to extract information in the following order:
- Scale parameters first: Number of layers, hidden dimensions, total parameters, and activated parameters to establish an overall sense of size.
- Attention structure next: Organization of heads, KV sharing strategy, to infer inference cache overhead.
- Feed-forward structure then: Whether MoE is used, number of experts, and routing count, to assess deployment complexity.
- Normalization and positional encoding: To determine the source of training stability design and long-context capability.
- Vocabulary and embeddings last: Vocabulary size impacts multilingual capability and encoding/decoding efficiency.
By following this fixed reading path, you can form a structured understanding of an unfamiliar model in a few minutes rather than getting lost in the details.
V. Practical Selection Recommendations
When translating architectural understanding into engineering decisions, you can approach it from the following angles:
- Inference cost-sensitive scenarios: Prioritize architectures with small activated parameter counts and low attention cache overhead. Dense small models or compressed models are often more suitable.
- Capability limit-prioritized scenarios: Consider MoE architectures with a large ratio between total and activated parameters to gain stronger capabilities while keeping inference costs under control.
- Long-context scenarios: Focus on attention variants and positional encoding extension schemes, and validate with real long-text tasks rather than just looking at the nominal window size.
- Private deployment scenarios: Prioritize architecture families with mature community ecosystems and comprehensive documentation to reduce adaptation and troubleshooting costs.
In enterprise-level implementations, you can also leverage general capabilities provided by cloud platforms to simplify engineering workloads, such as using object storage to manage model weights and corpora, using container platforms to orchestrate inference services, and combining logging services with monitoring and alerting systems to ensure online stability, thereby focusing your efforts on the business logic itself.
VI. Conclusion
Architectural innovation in LLMs continues to evolve rapidly, but the core principle remains the same: all designs seek a better balance among expressive capability, training efficiency, and inference cost. By mastering the analytical framework of the “common skeleton + key component differences,” developers can quickly understand any newly released model architecture and make rational technical selections, rather than being led astray by endless new buzzwords. The value of an architecture landscape map lies not in memorizing the parameters of every model, but in establishing a cognitive map onto which new knowledge can be mounted at any time.
