# 2025-04-25

## Metadata
- Author: [[nick young]]
- Full Title: 2025-04-25
- Category: #articles
- Summary: insert summary
- My notes:
- Document Tags: [[generating philosophy paper]] [[llm summary]] [[LLM summary]]
- Summary: This article explains how large language models use a mechanism called self-attention to understand the relationships between words in a sentence. By predicting the next word in a sequence, the models learn to capture complex patterns in language. The process allows them to generate coherent and contextually relevant text based on prompts they receive.
- URL: https://www.nickyoung.eu/daily+notes/2025-04-25
## LLM Chats
## NotebookLM
## LLM Audio
## Highlights
> The primary mechanism for establishing relationships between these position-aware token representations within each layer of the transformer is self-attention, often implemented as multi-head self-attention. For each token, its vector representation is linearly projected to create three vectors: a Query (Q), a Key (K), and a Value (V). The Query vector can be thought of as representing the token's request for information relevant to its context. The Key vector acts as a label describing the kind of information the token offers. The Value vector contains the actual content or features of the token to be potentially shared. To determine relevance, the Query vector of a token ((q*i)) forms dot products with the Key vectors of all other tokens ((k_j)) within its accessible context. These dot products measure the similarity or compatibility between the information requested ((q_i)) and the information offered ((k_j)). The resulting scores are typically scaled by the square root of the key vector dimensionality ((1/\sqrt{d_k})) to stabilise training. These scaled scores are then passed through a softmax function, which normalises them into a probability distribution ((\alpha*{ij})) across all source tokens (j). These (\alpha*{ij}) values are the attention weights, summing to 1 for each query token (i). Each attention weight (\alpha*{ij}) determines how much of the corresponding Value vector (v*j) should contribute to the output representation of token (i). The final output for token (i) from the self-attention mechanism is a weighted sum of all Value vectors in the context: (\sum_j \alpha*{ij} v_j). This process allows each token to dynamically construct its updated representation by selectively drawing information from other tokens based on learned notions of relevance for the current context. Multi-head attention performs this QKV calculation multiple times in parallel within a layer, using different learned projection matrices for each 'head'. This allows different heads to specialise in capturing different types of relationships (e.g., syntactic vs. semantic) simultaneously, leading to a richer overall representation after their outputs are concatenated and linearly projected. ([View Highlight](https://read.readwise.io/read/01jsp35eq7qhrwgb8hxa3a8w1d))
> The prompt's influence operates as a 'soft program' rather than a set of rigid instructions. Because the attention scores are continuous values derived from vector interactions, and the entire network is differentiable, the prompt does not steer the model through discrete symbolic manipulation. Instead, the sequence of prompt tokens establishes an initial pattern of activations and biases the high-dimensional attention landscape within the network. This makes certain computational pathways through the learned weights, and thus certain types of continuations, more probable than others. For example, a prompt containing examples of a specific task (in-context learning) or explicit instructions can activate the representations and processing patterns the model learned during training were associated with performing that task or following such instructions, thereby increasing the likelihood of generating an appropriate response. System instructions or meta-instructions embedded in the input stream exploit this same mechanism. ([View Highlight](https://read.readwise.io/read/01jsp3yzayhqq3xkydc8axm4z0))
> From a mechanistic standpoint within the transformer architecture, these "reasoning" strings are simply sequences of tokens like any other. They are processed through the same embedding, attention, and FFN layers. Their particular utility arises because they introduce new, explicit content into the sequence that subsequent attention layers can access. By making intermediate computational states persistent and attendable within the sequence context, they effectively augment the model's ability to perform complex, multi-step tasks, analogous to how a human uses an external scratch-pad or shows their working to manage complexity and track progress during problem-solving. ([View Highlight](https://read.readwise.io/read/01jsp4kzsj988hgvwdhxw8zatq))
> Many sophisticated capabilities, such as translation, question answering, summarisation, and code generation, appear to emerge as a consequence of increasing scale – specifically, the number of model parameters, the volume and diversity of training data, and the computational budget for training. These behaviours often arise without being explicitly programmed or trained as distinct tasks. Instead, they emerge because accurately modelling the statistical patterns required for next-token prediction on a sufficiently large and diverse dataset implicitly requires learning representations that are capable of supporting these tasks. For instance, accurately predicting the next word in a translation requires implicitly understanding the source sentence and translation principles. Accurately answering a question based on a provided text requires implicitly understanding both question and text. These capabilities develop because they represent distributionally effective strategies for the model to minimise its fundamental prediction error. ([View Highlight](https://read.readwise.io/read/01jsp4rq7j8sy191q0kph4s3rf))