---
title: Head Relevance Vectors (HRVs)
url: https://www.emergentmind.com/topics/head-relevance-vectors-hrvs
type: topic
---

# Head Relevance Vectors (HRVs)

Head Relevance Vectors (HRVs) quantify the task-specific or concept-level contribution of individual heads within attention-based neural architectures, enabling the principled identification, selection, and manipulation of the most discriminative or semantically aligned heads without intrusive model modifications. HRVs have been formalized, utilized, and experimentally validated across domains including multimodal LLMs, text-to-image generative models, attention-based retrieval/reranking, audio representation learning, and causal LLM steering.

## 1. Mathematical Formulations and Notational Scope

HRVs are typically constructed as per-head vectors or scalars reflecting each head's relevance to a downstream objective or human-interpretable visual concept. Across transformers with $L$ layers and $H$ heads per layer, the model-wise HRV is a concatenation of per-layer vectors $\mathrm{HRV}_\ell \in \mathbb R^H$ for $\ell = 1,\ldots,L$, resulting in $\mathrm{HRV} \in \mathbb R^{L \cdot H}$ or, for cross-attention, $\mathrm{HRV}_n \in \mathbb R^H$ per concept $C_n$.

For attention-based visual relevance in multimodal LLMs [2506.05344], scalar scores $v_{\ell,h}$ for head $(\ell,h)$ are defined as:
\[
v_{\ell,h} = S_{\ell,h} \bigg/ \sum_{\ell',h'} S_{\ell',h'}
\]
where $S_{\ell,h} = \sum_{i=1}^N \text{hit}_{\ell,h}(y_i)/|I_{y_i}|$ and $\text{hit}_{\ell,h}(y_i)=1$ iff the maximal-attention key for output token $y_i$ falls within the set $I_{y_i}$ of image tokens associated with $y_i$.

In concept-aligned diffusion models [2412.02237], an HRV for concept $C_n$ is defined as:
\[
\mathrm{HRV}_{n} \in \mathbb R^H
\]
where each element counts (and is later L1-normalized across heads) the number of generations in which head $h$ most responds to $C_n$.

For contrastive retrieval, a relevance score per head is given by an InfoNCE-like contrast between positive and negative document attention [2510.02219]:
\[
S_{\mathrm{CoRe}}(h) = 
\frac{  \exp(s_{\text{pos}}^h / t) }
      {  \exp(s_{\text{pos}}^h / t) + \sum_i \exp(s_{\text{neg},i}^h / t) }
\]
where $s_d^h$ is the mean attention from query to document $d$ under head $h$.

In causal LLM steering [2506.08359], per-head HRVs are constructed as the concatenation of the (discrete or latent) units within a VQ-AE representation identified as behavior-discriminative via supervised contrast.

## 2. Algorithms for HRV Computation

### Training-Free Response Analysis (SparseMM)

- Extract all $A_{\ell,h}$ attention matrices for a set of $N$ annotated image-text pairs.
- For each output token $y_i$, determine the set $I_{y_i}$ (image tokens corresponding to $y_i$).
- For each head, increment $S_{\ell,h}$ by $1/|I_{y_i}|$ if $\operatorname{argmax}_t [A_{\ell,h}]_{i,t} \in I_{y_i}$.
- Normalize all $S_{\ell,h}$ over heads to get $v_{\ell,h}$.
- HRVs are then per-layer vectors $[v_{\ell,1},...,v_{\ell,H}]^\top$.

### Mechanistic Interpretability in Diffusion Models

- Given $N$ concepts and $H$ heads, for each prompt, timestep, and head, find the concept $n^*$ with top average spatial activation.
- Increment $\mathrm{HRV}_{n^*}[h]$.
- After all data, normalize each $\mathrm{HRV}_n$ so that $\sum_{h=1}^H \mathrm{HRV}_n[h] = H$.

### Contrastive Retrieval Head Scoring

- Aggregate per-head query-to-document attention for both gold and negative documents.
- Apply a softmax-based contrastive metric $S_{\mathrm{CoRe}}(h)$.
- Select top heads by average $S_{\mathrm{CoRe}}(h)$ over samples.

### Latent Disentanglement for Behavioral Relevance

- Train, per head, a VQ-AE on last-token activations, partition code as per semantic units.
- Add a supervised contrastive loss forcing separation of encodings from aligned vs violating behaviors.
- Designate as HRV the units with high class-separability; final score is given by a binary classification (AUC) of generated codes.

### Audio Relevance Heads

- Decompose time-frequency filterbank output into $H$ sub-bands, each processed by a two-layer FC network to generate a soft mask $R_h$ over sub-band bins.
- The relevance mask $R_h$ serves as the HRV for head $h$.

## 3. Applications and Empirical Insights

HRVs have driven advances in model efficiency, interpretability, retrieval, and controlled generation:

| Application         | Head Selection Criterion                    | Empirical Highlights                                           |
|---------------------|---------------------------------------------|---------------------------------------------------------------|
| SparseMM MLLMs      | Visual alignment via token attribution      | <5% heads suffice for visual tasks, 1.38× speedup, 52% memory reduction [2506.05344] |
| Cross-attn Diffusion| Human concept-alignment in CA heads         | HRVs enable concept-strengthening, reducing polysemy errors from 63%→15.9% [2412.02237] |
| Retrieval Reranking | InfoNCE-style contrast of gold vs negatives | <1% heads optimal, +1–4 nDCG points, 20% latency/40% memory savings after layer pruning [2510.02219] |
| Audio Classification| Mask generation over local TF sub-bands     | 10–23% accuracy gains at <0.1% param increase [2107.14793]   |
| Causal LLM Steering | VQ-AE/contrastive latent separation         | 20% accuracy boost for truthfulness interventions [2506.08359]|

Preserving only the top-$K$ heads by HRV scores often matches or outperforms full-head baselines, with heads concentrated in mid-layers and task-relevant heads forming a small, robust subset.

## 4. Inference Manipulation and Resource Allocation

SparseMM operationalizes HRVs for memory and compute savings by asymmetric KV-cache allocation [2506.05344]:

- Each head $(\ell,h)$ receives a combined KV budget:
  \[
  b_{\ell,h} = w + r + b_{\ell,h}^{\text{score}}
  \]
  with local window $w$, uniform baseline $r$, and remaining cache allocated in proportion to $v_{\ell,h}$.
- During decoding, heads retain only their most-attended keys up to their respective $b_{\ell,h}$.
- Ablating low-relevance heads (95%+) yields negligible accuracy drop; on DocVQA, 5.3% of full cache suffices for Qwen2-VL-7B.

In generative vision models [2412.02237], HRVs enable direct rescaling of per-head cross-attention weights for concept strengthening and adjusting:
- For desired concept $C_d$, rescale CA maps as $A^{(t,h)}_{i,j^*} \leftarrow \mathrm{HRV}_d[h] \cdot A^{(t,h)}_{i,j^*}$.
- For both desired and undesired concepts, interpolate head-wise as $r = 2\,\mathrm{HRV}_d - 1\,\mathrm{HRV}_u$.

For causal behavioral steering, HRVs identify which heads to intervene on and provide per-head importance weights for steering vectors [2506.08359].

## 5. Interpretability, Clustering, and Specialization

HRVs empirically align with human-specified or downstream concepts:
- Ordered weakening: systematically ablating heads in order of decreasing HRV for a concept causes earlier and steeper loss of that concept in generative output [2412.02237].
- In clustering analyses, HRVs for semantically similar concepts cluster distinctly in the HRV space, reinforcing interpretability claims.
- In audio, visualizing $R_h$ demonstrates functional specialization—e.g., one head accentuating high-frequency transients, another heightening low-frequency backgrounds [2107.14793].
- In retrieval, aggregation over a single high-relevance head can outperform full-head schemes [2510.02219].

## 6. Limitations and Prospective Developments

Limitations include:
- Degraded ranking/weak interpretability for diffuse or ambiguous concepts (e.g., numeracy, facial expressions) [2412.02237].
- Simple HRV normalizations may be inadequate for very large head counts ($H>1000$); alternative scaling or clamping may be needed [2412.02237].
- For causal interventions, incomplete disentanglement or over-pruning can limit transferability [2506.08359].

Prospective directions span:
- Fully automated pipelines for target token/concept selection.
- Improved HRV normalization for large-head models.
- Extension to other architectures (e.g., non-diffusion multimodal models).
- Deeper investigation of HRVs in self-attention vs. cross-attention, and the effects of architecture or fine-tuning.

## 7. Summary Table: HRV Methodologies in Recent Literature

| Domain/Model            | HRV Definition             | Selection/Analysis Method        | Notable Results                  | Reference         |
|-------------------------|----------------------------|----------------------------------|----------------------------------|-------------------|
| MLLMs (SparseMM)        | Visual token attribution   | Training-free response analysis  | <5% heads needed for accuracy, 1.38× speed, 52% KV reduction | [2506.05344]      |
| Text-to-Image Diffusion | Concept activation counts  | CA map activation + clustering   | 4–12% metric gains, drastic polysemy error drop               | [2412.02237]      |
| Retrieval/Reranking     | InfoNCE contrast           | Contrastive gold-vs-neg analysis | 1% heads optimal; layer pruning yields efficiency             | [2510.02219]      |
| Audio Representation    | Sub-band context masking   | Per-head 2-layer nets, end-to-end| +10–23% accuracy improvements over baseline                   | [2107.14793]      |
| Causal LLM Steering     | VQ-AE latent partitioning  | Behavior discriminative contrast | 20–81.5% boost in target steering, zero-shot transfer         | [2506.08359]      |

Across all observed settings, HRVs offer a principled, interpretable, and efficient mechanism for fine-grained network analysis, head selection, memory/computation savings, and targeted model control.

Source: https://www.emergentmind.com/topics/head-relevance-vectors-hrvs