r/learnmachinelearning • • 6d ago

can anyone help me understand

i ve 5+ years of experience in nodejs

i'm learning from 'build an llm from strach - Sebastian Raschka' ... chapter 3 has 'attention mechanism' .. i'm hitting the wall ..

most of the article and youtube vidoes .. it does that it does this ... i wanna understand what is happening .. any experience guys can help me out here ?

3 Upvotes

11 comments sorted by

4

u/UnderstandingOwn2913 6d ago

what is your question?

1

u/Effective_Potato_990 6d ago

What i understood, so far from the book 

  • Splitting text
  • Adding integer
  • Static Embedding 
  • Position Embedding
  • Where do i start with attention …

I understood that llm holds a value that says distance among each token in a sequence .. how how?

2

u/ModularMind8 6d ago

Small correction first: the model doesn't store a "distance" between tokens. Positional embeddings only say where each token sits. Attention works out how relevant each token is to every other token, fresh each time it runs on an input. Think of it like a lookup where every token gets three versions of itself, each made by multiplying its embedding by a learned weight matrix. For each token, you compare its query against every token's key with a dot product, which gives a similarity score. Softmax turns those scores into percentages that add up to 1. Then you take a weighted mix of all the values using those percentages. The result is a new, context-aware version of that token.

1

u/Effective_Potato_990 6d ago

seems like you have a very interactive course to understand these things .. how long you been working with LLM

1

u/T1lted4lif3 6d ago

I think the answer to their question is "yes" someone can help with respect to what attention does

2

u/Ok-Library1020 6d ago

Since you already code a lot, run the chapter's attention code on a short sentence and print the weights matrix. Seeing which token attends to which, and the shapes at each step, usually makes the QKV idea click faster than reading explanations.

1

u/Effective_Potato_990 6d ago

thats what planning exactly .. thanks ...

1

u/[deleted] 6d ago

[removed] — view removed comment

1

u/Effective_Potato_990 6d ago

thanks for the explanation, nanba ..

but i read it like one token only has two vector like static and position vector ... and other elements like Q, K, V ...

before pretraining, these are some random numbers ...

after training, it will be grouped based on meaning and context ..

am i missing something here ...?

the weight calculation based on the key, value among the words is attention???