Cross-Attention Weight Distribution: Reverse-Engineering Salience Scoring in Transformer Rerankers
This article dissects cross‑encoder attention patterns to recover salience scores, enabling transparent and high‑precision rerankers in generative search pipelines.
- Cross‑attention weights can be aggregated to produce deterministic salience scores for reranking.
- High‑variance attention heads reveal key semantic cues that dominate ranking decisions.
- Integrating salience extraction into existing pipelines adds negligible latency while improving transparency.
Cross‑Encoder Architecture and Attention Layout
The CrossEncoder concatenates QueryEmbedding and PassageEmbedding into a single token sequence, then passes it through Transformer layers that compute self‑attention across all tokens. Each attention head outputs a weight matrix, and the aggregated weights linking query tokens to passage tokens form the passage’s salience score.
To isolate salience, we average the query‑to‑passage attention across all heads and layers, then normalize by the maximum weight per passage. This yields a scalar salience vector that can be directly compared across candidates, enabling deterministic reranking without additional model inference.
- Extract per‑head query‑to‑passage weights
- Aggregate across layers to form salience vector
- Normalize by passage length to mitigate bias
Weight Distribution Metrics and Salience Extraction
Statistical tests such as Kolmogorov‑Smirnov or Jensen‑Shannon divergence between head distributions can quantify head importance. Heads with high divergence from the mean distribution are prime candidates for feature extraction in downstream ranking models.
- Compute per‑head weight variance
- Apply divergence metrics to rank heads
- Select top‑k heads for feature vector construction
Benchmark your domain across ChatGPT, Perplexity & Claude
Inspect live AI citations, bot crawler telemetry, and schema readiness in a single pass.