---
title: 'Neural Query Reranker (NQR): Methods & Applications'
url: https://www.emergentmind.com/topics/neural-query-reranker-nqr
type: topic
---

# Neural Query Reranker (NQR): Methods & Applications

A Neural Query Reranker (NQR) is a neural module that alters the output of an upstream retrieval or query-answering stage after an initial query has already been processed. In the literature represented here, NQR denotes several closely related but non-identical mechanisms: an attention-based listwise reranker over candidate search results [1702.06106], an interactive entity-score adjustment model for knowledge-graph query answering with soft constraints [2508.13663], a reranker-feedback mechanism that updates a retriever’s query representation during inference [2305.11744], and a Transformer reranker that selects the best generated query expansion before BM25 retrieval [2305.17080]. This suggests that NQR is best understood as a family of neural post-ranking operators whose target of reranking may be result lists, entity scores, candidate expansions, or the query representation itself.

## 1. Scope and canonical task formulations

Across these works, NQR is positioned after a first-stage system has already produced either candidate items or a score vector. The reranker then applies additional learned structure to refine the ranking without replacing the upstream model outright.

| Setting | Upstream stage | NQR output |
|---|---|---|
| Attention-based learning to rank | Query plus candidate set of $T$ results | A permutation of $R_1,\dots,R_T$ |
| KG query answering with soft constraints | Base QA model $a(q)\in\mathbb R^{|\mathcal V|}$ | Adjusted entity scores $a^{(t)}(q)[e]$ |
| Relevance feedback at inference | Bi-encoder retrieval plus cross-encoder reranking | Updated query vector $Q'$ for second retrieval |
| Query expansion for open-domain QA | Query expansion model plus BM25 | Single selected expansion $e^\*$ |

The first formulation treats reranking as a listwise permutation problem over a fixed candidate set. The second treats reranking as an additive correction to a full entity-score distribution. The third modifies the query embedding so that a second retrieval step better matches reranker judgments. The fourth predicts which expanded query will produce the best retrieval behavior under BM25 [1702.06106; 2508.13663; 2305.11744; 2305.17080].

A common misconception is that reranking necessarily means rescoring documents alone. The cited works show broader usage: reranking can target images or text results, knowledge-graph entities, generated query expansions, or the query vector itself [1702.06106; 2508.13663; 2305.11744; 2305.17080].

## 2. Attention-based listwise reranking

The attention-based learning-to-rank model of “An Attention-Based Deep Net for Learning to Rank” operates on a query $Q$ and a candidate set of $T$ results $R_1,\dots,R_T$ [1702.06106]. Separate embedding layers produce $M$ embeddings $\{q_1,\dots,q_M\}$ for the query and $N$ embeddings $\{r_{t1},\dots,r_{tN}\}$ for each result $R_t$. The embeddings can be trained with convolutional neural networks or the word2vec model; for text, word2vec embeddings are used, and for images, deep CNN feature vectors are used.

Its central mechanism is a double attention module. At each decoding step $t$, the model computes attention over the $M$ query embeddings and over the $N$ result embeddings. With pooling functions $g(\cdot)$ and $h_n(\cdot)$, previous decoder state $z_{t-1}$, and previous attention weights $\alpha_{t-1}$ and $\beta_{t-1}$, the pre-softmax attention scores are
$$
e_{tm} = e_{ATT}(z_{t-1},q_m,g(r_1\dots r_T),\alpha_{t-1},\beta_{t-1}),
$$
and
$$
f_{tn} = f_{ATT}(z_{t-1},q,h_n(r_1\dots r_T),\alpha_{t-1},\beta_{t-1}).
$$
After normalization,
$$
\alpha_t = \mathrm{softmax}(e_t), \qquad \beta_t = \mathrm{softmax}(f_t),
$$
the model forms context vectors
$$
c_t = \sum_{m=1}^M \alpha_{tm} q_m, \qquad d_t = \sum_{n=1}^N \beta_{tn} h_n(r_1\dots r_T),
$$
and updates the decoder with
$$
z_t = \phi(z_{t-1},c_t,d_t).
$$

Listwise scoring is then performed over the remaining candidates. For each unselected candidate $R_{t'}$,
$$
d_{t,t'} = \sum_{n=1}^N \beta_{tn} r_{t',n},
$$
and the score is
$$
s_{t,r_{t'}} = d_{t,t'}^T W c_t + d_{t,t'}^T V z_t.
$$
The next ranked item is selected from the softmax distribution over unchosen candidates,
$$
P(r_t = R_{t'} \mid r_1\dots r_{t-1}) =
\frac{\exp(s_{t,r_{t'}})}{\sum_{R_j\notin\{r_1\dots r_{t-1}\}} \exp(s_{t,r_j})}.
$$
Decoding can be performed with beam search or greedily.

Training uses either a softmax listwise negative log-likelihood,
$$
L_{\mathrm{soft}} = -\sum_{t=1}^T \log P(r_t=\text{ground-truth}\mid \text{history}),
$$
or a hinge-loss variant, denoted AttRN-HL, with
$$
L(r_t,r_{t'}) = \max\{0,\,1-s_{t,r_t}+s_{t,r_{t'}}\},
$$
and total hinge loss
$$
L_{\mathrm{hinge}} = \sum_{t=1}^T \sum_{r_{t'}\notin\{r_1\dots r_{t-1}\}} L(r_t,r_{t'}).
$$
Regularization consists of $L^2$ weight decay on all $W_l$ and embedding-CNN weights, together with dropout in pretrained CNNs. The architecture is also explicitly described as a second-stage reranker: a first-stage ranker retrieves top-$K$ items, after which the attention model rescoring replaces the original top-$K$ ranking [1702.06106].

## 3. Interactive NQR for knowledge-graph query answering

The 2025 NQR for knowledge graphs is designed for interactive query answering with soft entity constraints [2508.13663]. A base QA model $a$ takes a logical FOL query $q$ and returns a score vector
$$
a(q)\in\mathbb R^{|\mathcal V|},
$$
where $a(q)[e]$ measures how likely entity $e$ satisfies the hard logical constraints of the query. NQR is layered on top of this base model and uses user-provided examples of preferred entities ($l=1$) and non-preferred entities ($l=0$).

After $t$ interactions, the preference set is
$$
P(t)=\{(e_i,l_i)\}_{i=1}^t,
$$
with
$$
P^+ = \{e\mid (e,1)\in P(t)\}, \qquad P^- = \{e\mid (e,0)\in P(t)\}.
$$
The reranked score is additive:
$$
a^{(t)}(q)[e] = a^{(0)}(q)[e] + f_\theta(e,P(t)).
$$
The original score vector also induces a probability distribution
$$
u(e)=\frac{\exp(a^{(0)}[e])}{\sum_{e'} \exp(a^{(0)}[e'])}.
$$

The model contains two modules: a Preference Embedding Module $g_\theta$ and a Score Adjustment Module. The preference module forms a matrix $\mathbf M\in\mathbb R^{t\times(d+1)}$ whose $i$th row is $[\mathbf e_i;l_i]$, where $\mathbf e_i\in\mathbb R^d$ is a pretrained entity embedding. A single self-attention layer is applied over the $t$ rows, followed by layer normalization, then a linear layer with ReLU, and finally mean-pooling across the rows to produce a single preference embedding $\mathbf m\in\mathbb R^d$. The score-adjustment module concatenates
$$
[\mathbf m;\mathbf e;a^{(0)}[e]]\in\mathbb R^{2d+1},
$$
passes it through a two-layer MLP, and outputs the scalar adjustment $f_\theta(e,P(t))$. For $d=1000$, the paper specifies self-attention over $\mathbb R^{t\times 1001}$, reduction back to $\mathbb R^{1000}$ after LayerNorm and Linear+ReLU, concatenation to $\mathbb R^{2001}$, then Linear+ReLU to $\mathbb R^{1000}$ and Linear+Tanh to $\mathbb R^1$.

Training optimizes a two-part objective. The preference margin loss is
$$
\mathcal L_{\mathrm{pref}}(t)
=
\sum_{e^+\in P^+}\sum_{e^-\in P^-}
\max\bigl(0,\gamma + a^{(t)}[e^-]-a^{(t)}[e^+]\bigr),
$$
and the answer-distribution preservation term is
$$
\mathcal L_{\mathrm{ans}}(t)
=
D_{\mathrm{KL}}(u\|v)
=
\sum_e u(e)\log\frac{u(e)}{v(e)},
$$
where $v(e)=\mathrm{softmax}(a^{(t)})[e]$. The total loss is
$$
\mathcal L(t)=\mathcal L_{\mathrm{pref}}(t)+\lambda\,\mathcal L_{\mathrm{ans}}(t).
$$
Optimization uses Adam for 300 epochs over the training set of 1-hop queries, sampling random $t$-sized prefixes of the preference sequence.

The interaction protocol is incremental. The system first computes $a^{(0)}$. At each interaction, a user labels one entity as preferred or non-preferred, NQR computes $a^{(t)}$, and the revised ranking is presented. In experiments, the interaction budget satisfies $t\le 10$. This formulation is explicitly intended to capture soft constraints that are vague or context-dependent while preserving the original answers to the query as much as possible [2508.13663].

## 4. Query-side reranking in retrieve-and-rerank systems

A related form of neural query reranking appears in ReFIT, where the reranker provides relevance feedback to the retriever during inference [2305.11744]. The retriever is a bi-encoder with separate Transformers $E_Q(\cdot)$ and $E_P(\cdot)$ and pooled vectors
$$
Q_{(q)} = \mathrm{Pool}(E_Q(q))\in\mathbb R^d, \qquad
P_{(p)} = \mathrm{Pool}(E_P(p))\in\mathbb R^d.
$$
Retrieval uses the dot-product score
$$
s_r(q,p)=Q_{(q)}^T P_{(p)}.
$$
The reranker is a cross-encoder $E_R(\cdot)$ over the concatenated sequence $[\mathrm{CLS}]\,q\,[\mathrm{SEP}]\,p$ with a feed-forward head $F(\cdot)$ that produces
$$
s_c(q,p)=F(\mathrm{CLS}(E_R(q,p)))\in\mathbb R.
$$

ReFIT’s key step is to convert the reranker scores over the top-$K$ retrieved candidates into a soft distribution
$$
D^{ce}(p_i)=\mathrm{softmax}_i(s_c(q,p_i)/T),
$$
compare it with the retriever-induced distribution
$$
D^r(p_i)=\mathrm{softmax}_i(Q^T P_i),
$$
and minimize the KL divergence
$$
L_{kl}=\sum_i D^{ce}(p_i)\log\frac{D^{ce}(p_i)}{D^r(p_i)}
$$
with respect to the query vector $Q$ alone. The algorithm performs $N$ small gradient steps,
$$
Q_{t+1}=Q_t-\eta \nabla_{Q_t} L_{kl},
$$
and then executes a second retrieval pass using the updated query vector. The method is explicitly “lightweight” because only the query vector is updated; model parameters remain fixed.

EAR provides another query-side reranking formulation for open-domain question answering [2305.17080]. It first generates a diverse set of candidate expansions and then uses a query reranker to choose the single best expansion before BM25 retrieval. Two rerankers are defined. The retrieval-independent (RI) version takes
$$
[\mathrm{CLS}]\,q\,\text{“?”}\,e_i\,[\mathrm{SEP}],
$$
while the retrieval-dependent (RD) version takes
$$
[\mathrm{CLS}]\,q\,\text{“?”}\,e_i\,[\mathrm{SEP}]\,d_i\,[\mathrm{SEP}],
$$
where $d_i$ is the top-1 passage retrieved by BM25 for $(q,e_i)$. Both are implemented with DeBERTa-V3-base from HuggingFace. The final $[\mathrm{CLS}]$ hidden state $h_{CLS}$ is mapped to a scalar
$$
\hat y_i \equiv M_\theta(q,e_i)
$$
or
$$
\hat y_i \equiv M_\theta(q,e_i,d_i),
$$
with lower score indicating a better predicted BM25 rank for the gold passage.

Training uses a pairwise hinge-style contrastive ranking loss. If $r_i$ is the true rank of the gold passage under expansion $e_i$, then for pairs with $r_i<r_j$,
$$
\mathcal L_{\mathrm{Rank}}
=
\sum_{i,j:r_i<r_j}
\max\Bigl(0,\ s_\theta(q,e_i)-s_\theta(q,e_j)+\alpha(r_j-r_i)\Bigr),
$$
or, for the retrieval-dependent model,
$$
\mathcal L_{\mathrm{Rank}}
=
\sum_{i,j:r_i<r_j}
\max\Bigl(0,\ s_\theta(q,e_i,d_i)-s_\theta(q,e_j,d_j)+\alpha(r_j-r_i)\Bigr).
$$
At inference, the reranker scores all sampled expansions, selects
$$
e^\*=\arg\min_i \hat y_i,
$$
and issues $(q,e^\*)$ to BM25 for final retrieval. The design is explicitly motivated by the observation that the best query expansion is often not selected by greedy decoding [2305.17080].

## 5. Optimization criteria and evaluation regimes

The optimization objectives used across NQR variants differ substantially because the reranked object differs. The attention-based listwise reranker uses either listwise negative log-likelihood over a permutation or a hinge loss over selected and unselected candidates [1702.06106]. The KG NQR combines a margin-based preference objective with a KL term that keeps the adjusted score distribution close to the original QA distribution [2508.13663]. ReFIT uses pure KL distillation from reranker scores to retriever scores, but only over the top-$K$ candidates seen at inference time [2305.11744]. EAR uses a pairwise hinge loss whose margin scales with the difference between true BM25 ranks of the gold passage under different expansions [2305.17080].

These objectives suggest two recurring design requirements. First, the reranker should express a correction signal that is sharper than the upstream model’s native score. Second, in several settings, the reranker is not intended to discard the original ranking entirely. This is explicit in the KG setting, where the KL term preserves the answer distribution, and in ReFIT, where the reranker acts as a teacher for query refinement rather than as a stand-alone scorer [2508.13663; 2305.11744].

Evaluation is likewise task-specific. The attention-based listwise model reports MAP and $NDCG_p$ with $p=3,5$ [1702.06106]. The KG NQR evaluates Pairwise Accuracy (PA) at interaction $t$, together with MRR and Hits@$k$ on the adjusted scores, filtered to remove other correct answers [2508.13663]. ReFIT is measured primarily by Recall@100 across text, multilingual, cross-lingual, and multi-modal benchmarks [2305.11744]. EAR reports top-5 accuracy and related retrieval accuracy for open-domain question answering, with separate in-domain, out-of-domain, and zero-shot transfer analyses [2305.17080].

## 6. Empirical behavior, limitations, and conceptual distinctions

The attention-based listwise reranker reports strong results on both image retrieval and text querying [1702.06106]. On MNIST, the best model is AttRN-HL with MAP error $0.44\%\pm0.01\%$, $NDCG_3$ error $0.65\%\pm0.02\%$, and $NDCG_5$ error $0.52\%\pm0.02\%$. On CIFAR-10, the best AttRN-HL results are MAP error $13.41\%\pm0.07\%$, $NDCG_3$ error $15.61\%\pm0.08\%$, and $NDCG_5$ error $14.55\%\pm0.07\%$. On 20 Newsgroups, the best topic-level results are obtained by AttRN-SM with MAP error $14.78\%\pm0.01\%$, $NDCG_3$ error $16.87\%\pm0.02\%$, and $NDCG_5$ error $16.28\%\pm0.01\%$; for superclass relevance, the best AttRN-SM results are MAP error $30.14\%\pm0.01\%$, $NDCG_3$ error $12.93\%\pm0.02\%$, and $NDCG_5$ error $17.82\%\pm0.01\%$. Its ablations show that increasing the number of embeddings steadily reduces error up to approximately seven embeddings, while mean versus max pooling has negligible effect below $0.02\%$.

The KG NQR is evaluated on extensions of FB15k-237 and Hetionet with automatically generated soft-constraint preference sets [2508.13663]. FB15k-237 is reported with $14{,}505$ entities, $237$ relations, $310\text{K}$ edges, $8{,}472$ training 1-hop queries, and $24{,}435$ validation and $24{,}505$ test complex queries of $14$ types. Preference sets are generated by embedding answer descriptions with a pretrained text model, applying hierarchical agglomerative clustering with average linkage and cosine distance, and selecting clusters that cover at least $20\%$ of the answer set. Key findings are qualitative but precise: cosine similarity reranking achieves the highest PA but rapidly degrades MRR and Hits@10 as $t$ grows; RankNet is more stable in PA but drifts heavily from the original ranking and yields low MRR; NQR produces the best balance, with PA increasing smoothly while MRR and Hits@10 remain close to the original QA model. The KL-divergence term is described as crucial, since ablating it by setting $\lambda=0$ leads to aggressive reranking that harms global QA performance. Runtime is stated as $O(|\mathcal V|+t^2)$ per query, dominated by applying the MLP over all $|\mathcal V|$ entities.

ReFIT demonstrates that reranker feedback can improve retrieval recall rather than merely reranking a fixed candidate set [2305.11744]. On English BEIR, average Recall@100 is $66.8\%$ for Contriever, $67.6\%$ for Retrieve & Rerank with $K=125$, and $69.0\%$ for ReFIT with $K=100$ and $N=1000$. On multilingual Mr.TyDi, the average Recall@100 values are $87.0$, $88.1$, and $89.9$ respectively. On cross-lingual MKQA, they are $65.6$, $66.4$, and $68.3$. On MSRVTT text-to-video retrieval, BLIP-ITC achieves Recall@100 of $92.1$, Retrieve & Rerank with BLIP-ITM and $K=125$ reaches $92.3$, and ReFIT with $K=100$, $N=1000$ reaches $93.1$. The latency trade-off reported on CPU is $40$ ms for first retrieval only, approximately $1580$ ms for Retrieve & Rerank with $K=100$, approximately $1965$ ms for $K=125$, and approximately $1920$ ms for ReFIT with $K=100$, $N=1000$.

EAR isolates the effect of reranking generated expansions before sparse retrieval [2305.17080]. On Natural Questions top-5 accuracy, BM25 yields $43.8\%$, DPR $68.3\%$, GAR with greedy decoding $60.8\%$, EAR-RI $63.2\%$, EAR-RD $69.3\%$, and the oracle best-of-50 upper bound $81.9\%$. On TriviaQA top-5 accuracy, BM25 yields $67.7\%$, DPR $72.7\%$, GAR $71.8\%$, EAR-RI $73.4\%$, EAR-RD $77.6\%$, and oracle best-of-50 $85.0\%$. In zero-shot transfer from NQ training to WebQuestions testing, DPR achieves $52.7\%$, GAR $50.0\%$, EAR-RI $53.7\%$, EAR-RD $59.5\%$, and oracle best-of-50 $78.9\%$. Candidate-size ablations on NQ top-5 show EAR-RD at $69.3\%$ for $n=50$, $68.7\%$ for $n=20$, $67.6\%$ for $n=10$, and $66.3\%$ for $n=5$, compared with the GAR baseline at $60.8\%$ for $n=1$. The paper also reports complementarity between query reranking and passage reranking: applying a BERT-based passage reranker over EAR-RD’s final BM25 list raises NQ top-5 from $69.3\%$ to $73.7\%$.

The limitations identified in this literature are correspondingly heterogeneous. The KG NQR currently ignores the structure of the query graph itself, does not address soft constraints on intermediate variables, and relies on auto-generated preference labels rather than human preference data [2508.13663]. ReFIT incurs additional inference-time cost because of the extra reranker pass and gradient updates, even though the update is restricted to the query vector [2305.11744]. EAR depends on candidate expansion quality and shows its strongest gains in the retrieval-dependent variant that includes BM25’s top-1 passage as additional context [2305.17080]. Taken together, these findings indicate that NQR is not a single architecture but a recurring neural strategy for post hoc ranking correction under diverse retrieval and query-answering regimes.

Source: https://www.emergentmind.com/topics/neural-query-reranker-nqr