Transformers Explained Visually

(poloclub.github.io)

Comments

andblac 12 hours ago
Nicely done. For me the most fascinating thing about attention heads is the place where Attention matrix is already computed and is getting multiplied by Value vector. It behaves exactly like pushing Value vector through Dense layer of ordinary network where Attention matrix forms weights of that layer. So attention head is trained to construct this small single layer network dynamically during inference from Key and Query. And that's the point. That's rarely underlined in explanations of LLMs architecture and for me it's quite amazing that it works so well. This mechanism easy to observe in this particular visualization if you click through it.
est 5 hours ago
It seem that everyone is getting into details of how transformers work, but I am more interested in why other setups didn't work.

Or is it?

laurentiurad 1 hour ago
Did something similar using a SimCity-like simulator for how LLMs work: https://laurentiugabriel.github.io/token-town/
robrenaud 12 hours ago
Regarding the temperature explanation:

> "Instead of picking the highest-probability token, we can use different selection strategies to balance safety and creativity in the generated text".

Safety is definitely the wrong word here.

Temperature 0 generated text actually has a weird "lack of surprise" character that makes it seem artificial. [1]

> "high-probability texts can be dull or repetitive. Humans use language as a means of communicating information, aiming to do so in a simultaneously efficient and error-minimizing manner; in fact, psycholinguistics research suggests humans choose each word in a string with this subconscious goal in mind."

I'd completely drop the dropout explanation. It's just not part of the modern recipe anymore, AFAICT.

As for the ambitious goal of explaining transformers with a single interactive visualization, I just have a hard time imagining a person is going to newly understand both word embeddings (word2vec blew my mind in 2014) and also gain an understanding of attention.

I am making my own visualizations for a presentation on "Full Bandwidth Transformers"[2] that I am giving tomorrow at the Deep Learning Study Group (SF) (on zoom for the non-locals)[3]. It's not meant to be stand alone/context free, but I'd love some feedback.

https://rrenaud.github.io/fullbandwidth_transformer_viz/

[1] https://arxiv.org/abs/2202.00666 [2] https://arxiv.org/abs/2608.08888 [3] https://www.meetup.com/deep-learning-sf/events/316601593/

shinyoo 1 hour ago
Visualization is definitely a good way to learn new things. And I also would like to recommend https://bbycroft.net/llm . It has beautiful graphs, clear animations and good introductions, explainng the LLM inference cores well
maciejzj 3 hours ago
One of the better visualisations I've seen with the exception of Q/K/V weights and how they are presented. I believe they should be put more upfront since they are the core learnable parameter of attention. IMO, they should also be part of the "Head N of M" block since each head has its own weights (although they all can be collapsed into one huge matrix computation).
utopcell 13 hours ago
Great site, intuitive description. I also found [1] very useful in the past.

[1] https://bbycroft.net/llm

jwpapi 13 hours ago
Damn that page took down my Chromebook, never happened before..
jasonjmcghee 11 hours ago
For the uninitiated, I can't recommend enough, The Illustrated Transformer:

https://jalammar.github.io/illustrated-transformer/

E-Reverance 12 hours ago
I get that this is for explaining GPT-2, but I really hope laymen don't use it as an example of how modern models work (ex. absolute positional encoding is no longer used)

edit: I know that it mentions its not modern, but these kinds of details have major implications in terms of the representations a model can learn, which is in many ways the most important part!

noncovalence 8 hours ago
Hm, I wonder why my laptop is suddenly pulling about 5 fps while I'm just browsing HN?

The nefarious "2.2 GB RAM usage within 10 seconds" tab open in the background:

bilsbie 12 hours ago
I never understood the thinking behind the separate key query value matrixes? What are they doing exactly?
ftumminello 10 hours ago
Why did the inner EE in me think this was going to be a power transformer lol
trumbitta2 2 hours ago
This is not about Optimus Prime and the gang, is it?
tanseydavid 13 hours ago
Nice work. I really appreciate this tool for enhancing my limited understanding the mechanism(s) behind attention and LLMs.
unixhero 6 hours ago
Can it do Jev too?
npodbielski 2 hours ago
I have no idea why but I was thinking about Optimus Prime and Megatron when I was clicking the link. I was a bit disappointed.

That is good too though.

dionian 9 hours ago
Great UI and it was very helpful to me as a newcomer
esseph 13 hours ago
This is not at all what I was hoping for. Expected a lot more Unicron.
throw0101a 12 hours ago
As someone with an EE degree (though a sysadmin), this use of the term "transformer" is constantly confusing. :)

(Also "cryto" for cryptocurrency rather than cryptography.)