Principled Top-$k$ Selection for Language Models with Hybrid Gradients

Xuchen Gong, Junfei Sun, Tian LiarXiv 2026

TL;DR

This paper introduces a principled surrogate objective for training "top-$k$" selection modules, a core component in Retrieval-Augmented Generation (RAG) and Mixture-of-Experts (MoEs). By deriving a hybrid gradient that combines policy-gradient (for exploration) and supervised-gradient (for exploitation) components, the authors provide a mathematically sound way to teach models not just how to weigh selected items, but crucially, which items to select from a large pool of candidates.

What Problem Does This Paper Address?

Modern LLM architectures frequently rely on sparse selection: RAG systems must pick $k$ relevant documents from a massive database, and MoE layers must route tokens to $k$ specific experts. However, the "top-$k$" operation is inherently non-differentiable.

Existing training methods often fall into two traps:

  1. Weak Signals: Standard end-to-end training usually only provides gradients for the items already selected. This means the model learns how to adjust the weights of the "winners" but receives no direct signal about the "losers" it should have picked.
  2. Heuristics: Many researchers rely on ad-hoc tricks like adding Gaussian noise or using proxy gradients that lack a solid theoretical foundation.

As the candidate pool size ($m$) grows, the search space for the best subset expands combinatorially ($O(m^k)$), making the selection problem significantly harder to optimize.

Figure 3: Selection module is harder to optimize as m increases.

Methods

The authors propose a set-level surrogate objective. Instead of selecting items deterministically, they model the selection as sampling a subset $I$ of size $k$ from a distribution $\pi_\theta$.

The core innovation is the derivation of the Hybrid Gradient. When you take the gradient of their objective, it naturally decomposes into two parts:

  • Policy Gradient: Similar to REINFORCE in reinforcement learning, this term provides a signal for "what items to select" by exploring unselected candidates. To reduce the high variance typical of policy gradients, they use a "leave-one-out" batch loss as a baseline.
  • Supervised Gradient: This term provides a signal for "how to weigh each item" within the already selected set, improving exploitation.

To manage the inherent bias-variance tradeoff, they introduce a hyperparameter $\lambda$ to scale the policy gradient component. A $\lambda$ of 1 gives an unbiased but high-variance gradient, while a smaller $\lambda$ introduces some bias but stabilizes training.

Datasets

The researchers evaluated their approach across three distinct settings:

  • Synthetic Regression: A stylized task where the ground-truth "best" items are known, allowing for precise measurement of selection accuracy.
  • Retrieval-Augmented Generation (RAG): Fine-tuning rerankers for Qwen-2.5-1.5B and Llama-3.2-3B using Wikitext-103 (language modeling), Natural Questions (NQ), and TriviaQA (question answering). They used Wikipedia (2018) as the document datastore.
  • Mixture-of-Experts (MoE): Training MoE models from scratch on Wikitext-103 to test expert routing efficiency.

Key Insights and Ideas

  • The "Winner's Curse" in Gradients: The paper highlights that traditional top-$k$ training is biased toward exploitation. Without the policy gradient component, selection modules struggle to "discover" better candidates outside their current top-$k$ choices.
  • The $\lambda$ Knob: The authors demonstrate that the optimal $\lambda$ is usually between 0 and 1. This "hybrid" approach outperforms both purely supervised methods ($\lambda=0$) and purely unbiased policy methods ($\lambda=1$).
  • Scalability Challenges: They theoretically and empirically prove that selection becomes exponentially harder as the candidate pool $m$ increases, emphasizing the need for the richer training signals provided by their hybrid gradient.
Figure 1: Our method out- performs prior ones that abandon or approximate the policy gradient.

Key Results

  • Higher Accuracy: In synthetic tasks, the hybrid method improved top-1 selection accuracy by over 20% compared to baselines that approximate or ignore the policy gradient.
  • Better RAG Performance: On NQ and TriviaQA, the method consistently outperformed strong baselines like REPLUG and ICRALM. It achieved up to a 3.5% increase in document recall.
  • MoE Efficiency: When training MoEs from scratch, the hybrid gradient achieved significantly lower perplexity. For a "128 choose 3" expert configuration, it outperformed the supervised-only baseline by 2.0 points and the unbiased update rule by 7.0 points in perplexity.
Figure 2: Our framework (left) and its applications to RAG and MoE. Middle: In RAG, given input query x, the reranker selects a subset of the most relevant documents to augment x to predict the target y. RAG has one selection and prediction module in total, with the prediction module (i.e., LM) frozen in our setting. Right: In each MoE layer, given the input hidden state x, the router selects a subset of expert models to compute the output hidden state y. The full MoE model contains multiple MoE layers of selection and aggregation, with both the selection and prediction modules trainable.

Limitations and Future Work

  • Hyperparameter Tuning: While the authors provide a "recipe" for selecting $\lambda$ (reducing it if the policy gradient norm overwhelms the supervised one), the optimal value remains problem-dependent and requires some manual tuning.
  • Scale: The experiments were conducted on relatively small to mid-sized models (up to 3B parameters). Testing the hybrid gradient on frontier-scale models (70B+) is a logical next step.
  • Computational Overhead: Sampling subsets and computing the hybrid gradient adds some complexity to the training loop, though the authors note it only requires one forward pass.

Summary updated

Abstract

Selecting the best $k$ items out of $m$ candidates is a critical component of modern large language model systems, such as document selection in Retrieval-Augmented Generation (RAG) and expert routing in Mixture-of-Experts (MoEs). However, training these selection modules remains challenging due to weak gradient signals and suboptimal exploration-exploitation tradeoffs. Furthermore, prior works often rely on heuristics, lacking principled objectives and approaches that explicitly model and solve the top-$k$ selection problem. In this work, we propose a principled objective for training selection modules, whose gradient naturally provides richer training signals in a hybrid form---containing a supervised-gradient component and a policy-gradient component. We show that the selection problem becomes harder as $m$ increases, and our algorithm converges at rate $O(1/\sqrt{T})$, with the optimal upper bound achieved by balancing between bias and variance. Practically, we apply our method to a set of tasks involving top-$k$ selection, including synthetic regression problems, RAG, and MoE systems, showing that our method outperforms the baselines in next-token prediction perplexity and QA accuracy.
BibTeX
@misc{gong2026principled,
  author = {Xuchen Gong and Junfei Sun and Tian Li},
  title = {{Principled Top-$k$ Selection for Language Models with Hybrid Gradients}},
  year = {2026},
  eprint = {2610.04162},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.04162},
}
Figure