Visual Guides to understand the basics of Large Language Models
This is a living document and will be continually updated.
Last update: 10th August, 2024. Added Transformer Explainer
Today, the world is abuzz with LLMs, short for Large Language Models. Not a day passes without the announcement of a new language model, fueling the fear of missing out in the AI space. Yet, many still struggle with the basic concepts of LLMs, making it challenging to keep pace with the advancements. This article is aimed at those who would like to dive into the inner workings of such AI models to have a solid grasp of the subject. With this in mind, I present a few tools and articles that can help solidify the concepts and break down the concepts of LLMs so they can be easily understood.
Table of Contents
· 1. The Illustrated Transformer by Jay Alammar · 2. The Illustrated GPT-2 by Jay Alammar · 3. Transformer Explainer: Interactive Learning of Text-Generative Models · 4. LLM Visualization by Brendan Bycroft · 5. Generative AI exists because of the transformer – Financial Times · 6. Tokenizer tool by OpenAI · 7. Understanding GPT tokenizers by Simon Willison · 8. Chunkviz by Greg Kamradt · 9. Do Machine Learning Models Memorize or Generalize? -An explorable by PAIR · 10. Color-Coded Text Generation · Conclusion
1. The Illustrated Transformer by Jay Alammar

I'm sure many of you are already familiar with this iconic article. Jay was one of the earliest pioneers in writing technical articles with powerful visualizations. A quick run through this blog site will make you understand what I'm trying to imply. Over the years, he has inspired many writers to follow suit, and the idea of tutorials changed from simple text and code to immersive visualizations. Anyway, back to the illustrated Transformer. The transformer architecture is the fundamental building block of all Language Models with Transformers (LLMs). Hence, it is essential to understand the basics of it, which is what Jay does beautifully. The blog covers crucial concepts like:
- A High-Level Look at The Transformer Model
- Exploring The Transformer's Encoding and Decoding Components
- Self-Attention
- Matrix Calculation of Self-Attention
- The Concept of Multi-Headed Attention
- Positional Encoding
- The Residuals in The Transformer Architecture
- The Final Linear and Softmax Layer of The Decoder
- The Loss Function in Model Training
He has also created a "Narrated Transformer" video, which is a gentler approach to the topic. Once you are done with this blog post, the Attention Is All You Need paper, and the official Transformer blog post would be great add-ons.
Link: https://jalammar.github.io/illustrated-transformer/
2. The Illustrated GPT-2 by Jay Alammar

Another great article from Jay Alammar – the illustrated GPT-2. It is a supplement to the Illustrated Transformer blog, containing more visual elements to explain the inner workings of transformers and how they've evolved since the original paper. It also has a dedicated section for applications of transformers beyond language modeling.