AdvancedWeekly lectures

Week 5 — Hierarchical Sparse Indexing

Retrieval · Sparse Attention · Indexing

Advanced

I — Long-context architecture

Overview

Even sparse attention is expensive if every indexer scans a million tokens. An early decoder indexer scores the full visible range, selects high-scoring blocks into a candidate pool, and later Reindex layers score only that pool.

What You Will Learn

Core Concepts

Candidate pool budget

2048\ \text{blocks}\times 8\ \text{positions}\Rightarrow \le 16{,}384\ \text{candidates}\Rightarrow \text{Top-}512

Context-independent deeper indexing

Later indexers only score the candidate pool, so their cost does not grow with context length.

Connection to graph retrieval

Both separate broad candidate discovery from expensive high-resolution reasoning.

Prerequisites

Work these pages on this site before the lecture.

Lecture notes

Even top-K attention is expensive if the indexer scores a million positions. Hierarchical indexing is coarse-to-fine: an early Full layer scores blocks, keeps a candidate pool, and later Reindex layers only score that pool. Deeper indexer cost becomes independent of N.

The silent failure mode is selection error: the true token’s block never enters the pool, so later layers cannot recover it. Your adversarial lab must drop the true block on purpose and watch recall collapse. That is the same shape as a GraphRAG candidate-generation miss (week 13).

Required readings

Lab / Implementation

Implement hierarchical top-K and measure recall vs exact global top-K as block/pool/Top-K vary; inject a case where the coarse stage drops the true block.

Not on this site (paper reading required)

Mastery Check


Part of CS/AI 684 — Efficient Long-Context Agent Systems.