0Pricing
NLP Academy · Lezione

Multi-head attention e posizioni

Molte prospettive e consapevolezza dell'ordine

Multi-head attention e posizioni è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

One Head Is Limiting

A single attention head can track only one kind of relationship at a time. Real language needs many patterns noticed at once. 🧠

Many Heads, Many Views

Multi-head attention runs several attention computations in parallel, each with its own learned projections and its own focus.

What Each Head Learns

One head might track subject-verb links while another follows pronouns. Together they capture a far richer picture of the sentence.

Split the Dimensions

The model splits its vector size across heads, so each head works in a smaller subspace. The total compute stays roughly the same.

d_head = d_model // num_heads

Combine the Heads

After each head produces an output, you concatenate them and pass the result through one more linear layer to mix the views.

out = concat(head_1, head_2, ...) @ W_o

Attention Ignores Order

Self-attention treats input as a set, so by itself it cannot tell "dog bites man" from "man bites dog." It is order-blind.

Adding Position Information

To fix this, we inject a positional encoding into each word so the model knows where every token sits in the sequence.

Sinusoidal Encodings

The original Transformer uses fixed sine and cosine waves of different frequencies to give each position a unique, smooth signature.

pe[pos, 2i] = sin(pos / 10000 ** (2*i/d))

Added, Not Appended

Position vectors are added to the word embeddings, not stuck on the end. So each token carries both meaning and place together.

x = token_embeddings + positional_encoding

Learned Positions Too

Many modern models replace fixed waves with learned position embeddings, trained alongside everything else for flexibility.

Why Both Matter

Multi-head attention sees many relationships; positional encodings restore order. Together they let the Transformer truly understand sequences. ✨

Quick Check

Let us test positions and heads.

Recap

You saw how multi-head attention captures many relationships in parallel, while positional encodings give the model a sense of order. 🎯

Domande Frequenti

La lezione «Multi-head attention e posizioni» è gratuita?

Sì — il testo completo di «Multi-head attention e posizioni» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.

Cosa imparerò in «Multi-head attention e posizioni»?

Molte prospettive e consapevolezza dell'ordine Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare NLP Academy?

Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Multi-head attention e posizioni»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione NLP Academy?

Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. L'idea dell'attention
  2. Self-attention passo dopo passo
  3. Multi-head attention e posizioni
  4. All'interno del blocco Transformer
← Torna a NLP Academy