Expand description
Attention-Weighted Context Assembly.
Scientific basis:
- Treisman (1980), “A feature-integration theory of attention” — cognitive resources are allocated proportionally to information density, not uniformly.
- Transformer Self-Attention (Vaswani et al., 2017) — weighted focus on informative regions.
Applied here: when assembling context from multiple search results, we:
- Score each chunk’s information density (unique tokens / total tokens)
- Detect redundancy between selected chunks (token-level overlap)
- Allocate token budget proportionally to density, not uniformly
- Aggressively truncate low-density chunks
Structs§
- Chunk
Density - Information density metrics for a code chunk.
Functions§
- attention_
weighted_ assembly - Assemble context with attention-weighted budget allocation.
- compute_
density - Compute information density for a chunk.
- compute_
redundancy - Compute pairwise redundancy between two chunks (0.0 = unique, 1.0 = identical).
- truncate_
to_ budget - Truncate content to fit within a token budget (approximate by chars/4).