← All questions
Training & Fine-tuningVery Hard· Gradients· Retrieval· Optimization

Why can’t you just backpropagate recall@k into the rewr...

Because retrieval involves an argsort operation, the output is not differentiable with respect to the query parameters in the standard sense. The function is piecewise-constant, meaning the gradient is zero almost everywhere. To optimize this, one must use a score-function estimator (like REINFORCE). This approach is computationally expensive, as it requires multiple retrieval calls per query during the training loop, and it requires a baseline to be subtracted from the reward to reduce high variance.

Code playground (Python)