· Xiaojing Yang · NLP and LLMs · 2 min read

中文

Attention Mechanism

Attention as a learned way to decide what context matters for each token.

Core idea

Attention lets each token ask which other tokens are relevant right now.

1. The intuition

Attention is a relevance mechanism. For each position, the model computes how strongly it should use information from other positions.

Self-attention
Input embeddings
one vector per token
Queries
what this token seeks
Keys
what each token offers
Scores
query-key similarity
Values
information mixed into output

2. Q, K, V

The common explanation is: query asks a question, key describes what a token contains, and value carries the information to be combined. The attention weights decide how much each value contributes.

Attention(Q, K, V) = softmax(QKᵀ / √d) V

3. Why it helped NLP

Attention made long-distance dependencies easier to model and helped translation systems align source and target content more flexibly.

RNN bottleneck

Information must pass through sequential hidden states.

Attention view

Each position can directly access relevant positions.

4. My research connection

For technical translation, attention-like mechanisms matter because target terms must depend on specific source terms, not only general sentence fluency. However, attention weights are not automatically explanations; evaluation still needs error analysis.

Takeaway

Attention is the mechanism that made contextual representation central to modern NLP.

Interview pattern

My interview answer would usually be:

  1. define the concept in one sentence;
  2. explain the data flow;
  3. name the main failure mode;
  4. connect it to evaluation, multilinguality, or fine-tuning.

References

Share:
Back to Blog

Related Posts

View All Posts »
FoundationsNLP and LLMsEN

Fine-Tuning Transformers

How pretrained language models are adapted to a task or domain with supervised data.

FoundationsNLP and LLMsEN

LLM Evaluation and Failure Modes

A practical map of LLM evaluation risks: hallucination, prompt sensitivity, bias, contamination, and brittle benchmarks.

FoundationsNLP and LLMsEN

NLP Evaluation

Why NLP evaluation needs metrics, uncertainty, human judgment, and task-specific error analysis.