AGENT SKILL

0.4.5-understand-attention_mechanism

[0.4.5] The core operation allowing each token to attend to all others; scaled dot-product attention is the standard.

License 许可
MIT
最近更新
2026-10-09
Stars
★ 0
Forks
0

01 前言 Front Matter

name
0.4.5-understand-attention_mechanism
description
[0.4.5] The core operation allowing each token to attend to all others; scaled dot-product attention is the standard.

03 SKILL.md 正文

understand-attention_mechanism

CALL NUMBER: llm_memory_and_context_engineering.attention_mechanism : deep_context_window(13) DEFINITION: The core operation allowing each token to attend to all others; scaled dot-product attention is the standard. Memory and context are both outputs of attention computation.

Invoke this skill to understand attention_mechanism down to its primitives. The RELATIVE ROOT below is the least-fixed-point closure of everything it bundles from — the full import cone, grouped by the lib each prim comes from. Projected from a prover-typed KB (MAP/SWI-Prolog consistency gate): every reference below resolves.

THE RELATIVE ROOT (the import cone, by lib)

from deep_context_window

  • context_boundary (d4): The hard edge position within context where context_overflow triggers if exceeded; exactly context_length minus one for the output region.
  • context_resize_event (d4): The runtime mechanism or policy invoked when context_length must accommodate inputs exceeding current capacity; involves reallocation or overflow handling.
  • context_scaling_factor (d4): The multiplier relating raw context_length to effective_context; models with improved attention patterns achieve factors closer to one.
  • input_token_budget (d4): The portion of context_length reserved and available for prompt tokens, retrieved context, and system instructions before generation begins.
  • max_model_tokens (d4): The absolute token ceiling of the model architecture; synonymous with context_length when no additional constraints apply.
  • maximum_position (d4): The highest valid integer position index representable by the position_embedding scheme within context_length; equal to max_model_tokens minus one for zero-indexed sequences.
  • output_token_limit (d4): The portion of context_length reserved for generated tokens; equals context_length minus input_token_budget minus overhead tokens.
  • overflow_threshold (d4): The position or token count at which the model behavior shifts from normal processing to truncation or error; often slightly below context_boundary.
  • token_boundary_marker (d4): The positional delimiter marking the transition from input context to output generation; tokens before this marker are provided context, tokens after are to be generated.
  • context_capacity_ratio (d5): The ratio of tokens actively processed to total available context_length; quantifies context_utilization as used_capacity divided by max_model_tokens.
  • token_headroom (d5): The arithmetic difference between current position or token count and context_boundary; the remaining room before overflow_threshold is reached.
  • position_index (d5): Ordinal integer from zero to context_window_boundary representing each token's location in the sequence; each index must be encodable by the position_embedding scheme in use
  • sequence_position (d5): The ordinal index of a token within the full context sequence; constrained to be less than or equal to maximum_position.

from llm_memory_and_context_engineering

  • attention_saturation (d1): Condition where attention weights become uniform across long context; signals reduced context_utilization and effective_context shrinkage
  • attention_sinks (d1): Special tokens that accumulate disproportionate attention mass, enabling efficient long-context modeling without explicit positional encoding
  • attention_weighting (d1): Distribution of attention scores across context tokens; reveals what the model considers relevant to current generation
  • cross_attention (d1): Attention mechanism where queries attend to a separate context (e.g., retrieved documents); enables retrieval_augmented_generation
  • hard_attention (d1): Attention focusing on single positions; non-differentiable but efficient; approximated by soft attention in practice
  • kv_cache (d1): The key-value tensors cached during transformer self-attention to avoid recomputing activations for previously-seen tokens
  • self_attention (d1): The mechanism by which transformer models relate each token position to all other positions; the quadratic bottleneck in context_length scaling
  • soft_attention (d1): Attention producing weighted averages over all positions; differentiable but computationally expensive at scale
  • sparse_attention (d1): Attention patterns that compute fewer than n² pairwise interactions, reducing memory_efficient_attention cost at the cost of expressiveness
  • context_window (d2): The finite token sequence an LLM can process in a single forward pass; defines the maximum input + output capacity bounded by architecture or inference config
  • effective_context (d2): Portion of context_window the model actually leverages for any given generation; often less than the full window due to attention patterns
  • context_caching (d2): Storing computed key-value pairs from prior forward passes to avoid recomputation on repeated or overlapping context prefixes
  • prefix_caching (d2): Caching the KV tensors for shared prefixes (system prompt, few-shot examples) so they aren't recomputed per request; reduces latency and compute for repeated contexts.
  • working_memory (d2): The transient token budget allocated for active reasoning within a single model call; scratch space for chain_of_thought and intermediate results
  • context_length (d3): Total number of tokens (input + output) an LLM supports; the hard ceiling on how much text can be loaded into context_window at once
  • context_overflow (d3): The failure state where total input exceeds context_window, causing silent truncation or errors depending on the client library
  • context_utilization (d3): How effectively the model uses all available context tokens; metrics include attention entropy, retrieval accuracy at various positions, task performance variation with position.
  • flash_attention (d3): A memory-efficient attention algorithm using tiling and recomputation to avoid materializing the full n×n attention matrix in HBM
  • position_embedding (d3): Encoding that injects positional information into token representations since attention is permutation-invariant. Choices: sinusoidal, RoPE, ALiBi. Affects how context scales.
  • ring_attention (d3): Distributed sliding_window_attention across multiple devices with communication-avoiding algorithms for very long sequences
  • sliding_window (d3): Fixed-size contiguous subset of recent tokens kept in working_memory as new tokens arrive and old ones are evicted
  • truncation_strategy (d3): Policy for removing old context when context_overflow occurs; options include FIFO, importance-weighted, and semantic summarization
  • chain_of_thought (d3): Producing intermediate reasoning steps before final answer; when demonstrated in context, subsequent reasoning follows the pattern. A form of contextual procedural memory.
  • memory_efficiency (d3): Ratio of useful information retained per unit of memory storage or context_token budget
  • memory_hierarchy (d3): The layered structure of LLM memory: immediate context (working), retrieved context (RAG), fine-tuned weights (parametric), external stores (vector DB). Each layer has different latency/capacity tradeoffs.

CONSUMERS (what needs this)

in_context_learning, working_memory


Projected from the llm memory and context engineering KB (438 concepts / 213 relations) — consistency-typed by MAP; the facet list after the colon IS the cross-lib dependency web.

(leaf — this is an actual skill.)

04 同仓库更多 Skills