Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 29

LLM Architecture: Open-weight vs. Proprietary Models

Recommended resources

Introduction

Welcome back. In our previous lessons, we've systematically dissected the key components that constitute modern Large Language Models. We've explored Rotary Positional Embeddings (RoPE), the critical role of the KV-cache and its optimization through Grouped-Query Attention (GQA), and most recently, the evolution of activation functions to the now-standard SwiGLU.

This lesson marks the culmination of our "Modern LLM Architectures and Optimizations" module. Having understood the individual parts, we will now assemble them to fulfill the learning outcome: Analyze and compare the architectural choices (e.g., MoE, GQA, attention window) of leading open-weight (LLaMA 3, Mistral) and proprietary (GPT-4, Claude 3) models.

Your goal is to become an elite AI engineer, and a key skill is not just knowing what these components are, but understanding why specific architectural choices are made. We will move beyond a simple feature list to analyze the engineering trade-offs—performance versus cost, latency versus accuracy, and depth versus width—that define the current state of the art.


The Modern "Standard": A Llama-like Baseline

Let's begin by establishing a baseline. The original 2017 Transformer was an encoder-decoder model. Today, the dominant paradigm for generative text models is the decoder-only architecture. Models from the Llama family are excellent examples of this modern standard, incorporating many of the optimizations we've studied.

Transformer vs LLaMA Architecture Comparison
This diagram contrasts the original Transformer's encoder-decoder structure with the streamlined, decoder-only architecture of Llama. Llama integrates key modern optimizations like RMSNorm, RoPE, SwiGLU, and GQA with a KV-Cache, which have become standard practice.

A typical modern decoder-only LLM architecture, exemplified by models like Llama 3, includes:

  • Pre-Normalization: Using RMSNorm before the attention and FFN layers for training stability.
  • Rotary Positional Embeddings (RoPE): For robust length extrapolation.
  • Grouped-Query Attention (GQA): To reduce the KV-cache size and improve inference speed.
  • SwiGLU Activation: In the feed-forward network for enhanced expressiveness.

This combination represents a powerful and efficient baseline. Now, let's explore the major architectural divergences and specializations built upon this foundation.


A Tour of Modern LLM Architectures

To see how these components are combined in practice, we'll turn to a comprehensive comparison of recent LLM architectures. The following resource by Sebastian Raschka provides an excellent, in-depth analysis of the design choices behind many leading models.

You can either watch the selected segments of the video or read the corresponding sections in the article—both cover the same material. The video offers a narrated walkthrough, while the article may be faster for targeted reading.

The Big LLM Architecture Comparison

Dr. Sebastian Raschka's "The Big LLM Architecture Comparison" is a fantastic survey of the architectural landscape. We will use it as our guide to compare several key models and understand their unique design choices.

Please watch the following segments, focusing on the specific architectural innovations discussed for each model: DeepSeek V3 (MoE & MLA): 01:46 - 24:52 (Focus on the concepts of Mixture-of-Experts and Multi-Head Latent Attention). OLMo 2 (Normalization): 24:52 - 35:10 (Note the subtle but important differences in normalization placement). Gemma 3 (Sliding Window Attention): 35:10 - 44:28 (Understand this technique for efficient long-context handling). Llama 4 (MoE): 47:54 - 50:01 (See how another major player adopts MoE). GPT-OSS (Width vs. Depth): 01:07:59 - 01:14:40 (Analyze the trade-offs between making a model deeper vs. wider).

Alternatively, you can read the corresponding sections from the article version.

The Big LLM Architecture Comparison

This is the article version of the video above. Use the table of contents on the left of the page to navigate to the relevant sections.

Please read the following sections: Section 1: DeepSeek V3/R1 (Focus on 1.1 Multi-Head Latent Attention and 1.2 Mixture-of-Experts). Section 2: OLMo 2 (Focus on 2.1 Normalization Layer Placement and 2.2 QK-Norm). Section 3: Gemma 3 (Focus on 3.1 Sliding Window Attention). Section 5: Llama 4 (Focus on the MoE implementation and comparison to DeepSeek). Section 9: GPT-OSS (Focus on 9.1 Width Versus Depth and 9.2 Expert configuration).


Synthesizing the Key Architectural Choices

Having reviewed those models, let's distill the information into a clear comparative framework. The design of a modern LLM involves a series of strategic choices along several key axes.

1. Sparsity: Mixture-of-Experts (MoE) vs. Dense

This is arguably the most significant architectural fork in the road for large-scale models.

  • Dense Models (e.g., Llama 3 8B/70B, Qwen3-dense): Every parameter is used for every token. They are generally simpler to train and fine-tune but become computationally expensive at massive scale.
  • Sparse MoE Models (e.g., DeepSeek V3, Mixtral, Llama 4, GPT-4, Claude 3): Only a fraction of the model's parameters (the "experts") are activated for each token. This allows for a huge total parameter count (and thus, more stored knowledge) while keeping inference costs manageable.
    • Trade-off: MoE introduces training complexity (e.g., router stability, load balancing) but dramatically reduces inference FLOPs.

2. Attention Mechanism and Context Window

The quadratic complexity of attention is a primary engineering challenge, leading to several solutions.

  • Grouped-Query Attention (GQA): The current industry standard (Llama 3, Mistral, Qwen3). It offers a great balance between the performance of Multi-Head Attention (MHA) and the extreme efficiency of Multi-Query Attention (MQA).
  • Sliding Window Attention (SWA): Used in models like Gemma 3 and gpt-oss. It restricts attention to a local window, drastically reducing KV-cache size for long sequences. Often used in a hybrid approach with a few full attention layers to maintain global context.
  • Multi-Head Latent Attention (MLA): A DeepSeek innovation. Instead of reducing heads (like GQA) or context (like SWA), it compresses the key and value tensors before caching, trading a small amount of extra compute for significant memory savings.

3. Model Shape: Depth vs. Width

Given a fixed parameter budget, engineers can choose to build a model that is "deep" (more layers) or "wide" (larger embedding and hidden dimensions).

  • Deeper Models (e.g., Qwen3): More sequential operations, potentially leading to higher latency. However, more layers can allow for more complex transformations and feature extraction with fewer parameters.
  • Wider Models (e.g., GPT-OSS, Mistral Small): Fewer layers but more parameters per layer. This structure is often more friendly to parallelization, potentially resulting in higher token-per-second throughput at the cost of higher memory usage per layer.

Summary of Architectural Choices

Here is a simplified table comparing some of the models you've studied.

Model Family Key Architectural Features Design Philosophy
Llama (Meta) GQA, RoPE, SwiGLU. Llama 4 adopts MoE. A strong, well-balanced "standard" architecture. Focus on efficiency and performance in dense models, now exploring MoE.
Mistral GQA, RoPE, SwiGLU. Some models use SWA. Known for wider, shallower architectures. Optimized for low-latency inference and high throughput. Aims to deliver top performance in efficient packages.
DeepSeek MoE with many experts, shared expert, Multi-Head Latent Attention (MLA). Pushing the boundaries of efficient scale. Heavy focus on custom, memory-saving techniques like MLA and MoE.
Gemma (Google) GQA, RoPE, SwiGLU, heavy use of Sliding Window Attention (SWA). Strong focus on efficient long-context handling through SWA, providing a robust open-weight model family.
Proprietary Rumored to use MoE (GPT-4, Claude 3). Often pioneers in scale and context length (e.g., Claude's 200k+ window). Maximizing raw capability and performance, often being the first to deploy large-scale MoE architectures.
Test your understanding!

Imagine two new 100-billion-parameter models are released:

  • Model A ("Cheetah"): A dense model with 40 layers, a wide FFN, and uses GQA.
  • Model B ("Elephant"): An MoE model with 80 layers and 15B active parameters, using full Multi-Head Attention.

Based on these architectural choices, which model would you likely choose for:

  1. A latency-sensitive, high-throughput chatbot application?
  2. Fine-tuning on a custom dataset with limited VRAM?
  3. A task requiring the absolute maximum knowledge capacity stored in the weights?
Show answer
  1. Chatbot (Latency-sensitive): Model A ("Cheetah") is the better choice. Its wider, shallower architecture (40 layers) is more parallelizable, leading to lower latency. Being a dense model also simplifies the inference stack.
  2. Fine-tuning (Limited VRAM): Model B ("Elephant"). While the total parameter count is 100B, fine-tuning techniques like LoRA primarily operate on the active parameters. With only 15B active parameters, Model B would likely be much cheaper to fine-tune than the 100B dense Model A.
  3. Maximum Knowledge: Model B ("Elephant"). The MoE architecture allows it to pack 100B parameters' worth of knowledge, which it can access sparsely. The 100B dense model has the same raw parameter count, but the MoE approach is designed to scale knowledge capacity beyond what's computationally feasible for dense inference.

Conclusion

This lesson has been a capstone for our study of LLM architecture. You've seen that modern models are not monolithic creations but are assembled from a toolbox of sophisticated components. The final design is a carefully balanced equation of trade-offs, optimized for a specific set of goals.

Key Takeaways:

  • There is a "standard" modern architecture (Llama-like), but significant variations exist to optimize for specific goals.
  • Mixture-of-Experts (MoE) is the key technology for scaling model size while keeping inference computationally feasible.
  • Attention variants (GQA, SWA, MLA) are crucial for managing the KV-cache, enabling longer context windows and faster inference.
  • The shape of a model—depth versus width—is a fundamental design choice that impacts latency, memory, and parallelization.
  • Leading models like Llama, Mistral, DeepSeek, and others each represent a unique point in this complex design space, reflecting different engineering priorities.

What's Next?

You have now completed the module on Transformer architectures and optimizations. You have a solid grasp of how these models are built, from the individual sub-layers to the high-level design philosophies of state-of-the-art systems.

In our next module, "Training and Scaling Large Language Models," we will shift our focus from what the models are to how they are made. We'll begin with the very first step in the data pipeline: tokenization. You'll learn about methods like Byte-Pair Encoding (BPE) and understand how the way we chop up text has a profound impact on a model's performance, vocabulary, and ability to handle diverse languages.