Task-Adaptive Embedding Refinement via Test-time LLM Guidance

Ariel Gera, Shir Ashury-Tahan, Gal Bloch, Ohad Eytan, Assaf ToledoarXiv 2026

TL;DR

This paper introduces a test-time query optimization method that refines text embeddings on the fly using feedback from a generative Large Language Model (LLM) on a tiny subset of documents. By updating only the query vector via gradient descent while keeping model weights frozen, this approach brings the zero-shot flexibility and instruction-following capabilities of LLMs to embedding-based retrieval at a fraction of the corpus-scale computational cost.

What Problem Does This Paper Address?

Embedding models are the backbone of modern large-scale retrieval systems and Retrieval-Augmented Generation (RAG) pipelines because they are incredibly fast and cheap to evaluate. However, they lack flexibility: they struggle with complex, ad-hoc user instructions (e.g., "retrieve accomplishments of the Hubble telescope but exclude details of repairs") and zero-shot binary classification tasks across a massive corpus.

While generative LLMs excel at these nuanced tasks out-of-the-box, running a full LLM pipeline over millions of documents to find or classify relevant text is computationally prohibitive and suffers from high latency. The authors address this gap by creating a hybrid approach that injects LLM intelligence directly into the embedding space at test time.

Figure 1: Examples of full-corpus separation tasks over different collections of documents.

Methods

The authors propose LLM-Guided Test-Time Query Optimization, a form of pseudo-relevance feedback that operates entirely at inference time:

  1. Initial Ranking: The system uses a standard embedding model ($m_e$) to encode the user query ($q$) and retrieve the top-$K$ (typically $K=20$) most similar documents from the corpus.
  2. LLM Teacher Feedback: A more capable generative LLM ($m_t$) evaluates only these top-$K$ documents, outputting a relevance score for each query-document pair based on the token log-probabilities of generating a "yes" or "no" response.
  3. Gradient-Based Refinement: The query embedding vector ($z$) is optimized for a small number of steps (e.g., $T=100$ iterations using the Adam optimizer). The objective minimizes the Kullback–Leibler (KL) divergence between the embedding model's similarity distribution over the top-$K$ documents and the LLM's teacher distribution. Crucially, the embedding model's weights remain completely frozen—only the query vector itself is modified.
  4. Full Corpus Re-ranking: The refined query embedding is then used to re-score and re-rank the entire corpus.

The optimization process itself is highly efficient, introducing a modest overhead of under 100 milliseconds (excluding the time taken for the LLM API calls).

Datasets

The approach was evaluated across a diverse set of challenging search and classification benchmarks:

  • REALSCHOLARQUERY: Real-world expert-annotated queries for computer science papers from arXiv.
  • CLINC150: A customer service intent-classification dataset spanning 150 distinct intent categories.
  • ARGKP-21: A key-point matching dataset requiring pairwise matching between free-text arguments and high-level key points.
  • FOLLOWIR: A benchmark specifically designed to evaluate an IR system's ability to follow complex instructions, constraints, and negations.
  • BANKING77 & NFCORPUS: Additional datasets used to validate fine-grained banking intent detection and medical literature retrieval, respectively.

Key Insights and Ideas

  • Finding a Better Vantage Point: Dimensionality reduction (PCA) visualizations revealed that the optimization process doesn't simply pull the query embedding toward the center of mass of positive documents. Instead, it maneuvers the query vector to a "better vantage point"—a highly discriminative region of the embedding space that cleanly separates positive and negative instances.
  • Beyond Local Reranking: Traditional reranking only shuffles the top-$K$ documents. By updating the query embedding itself, the benefits of the LLM's feedback propagate across the entire corpus, surfacing relevant documents that were completely missed in the initial top-$K$ retrieval pass.
  • Outperforming HyDE: The method was compared against Hypothetical Document Embeddings (HyDE), a popular zero-shot technique where an LLM generates a "fake" document to use as a query. HyDE actually degraded performance on these specialized datasets by introducing noise and embedding drift, whereas the proposed test-time optimization consistently yielded substantial gains.
Figure 2: Example results of LLM-guided test-time query optimization. (a) Precision-recall curve for an individual intent query from CLINC150 (with Qwen3-Embedding-0.6B as the embedding model), comparing results before and after the query refinement procedure. The plot legend denotes the corresponding average precision (AP) scores. (b) Recall@K (aggregated across queries) for E5-Mistral-7B on REALSCHOLARQUERY. Query refinement is based on LLM feedback scores for the top-20 documents. The dashed line depicts results when using the original query embeddings to calculate the similarity scores, but reranking just the top-20 documents based on the feedback.

Key Results

The authors evaluated their method across five state-of-the-art embedding models (including Qwen3-Embedding, Llama-Embed-Nemotron, and E5-Mistral) using Mistral-Small-3.2-24B-Instruct as the teacher model.

  • Consistent MAP Gains: The refined queries delivered consistent improvements in Mean Average Precision (MAP) across all models and tasks, achieving an average MAP improvement of 12% overall.
  • Task-Specific Boosts: Relative performance gains reached up to +25% on literature search and intent detection tasks.
  • Teacher Agnosticism: The performance gains were robust across different LLM teachers, showing similar improvements whether using Mistral, GPT-4, Qwen3.5, or DeepSeek-V3.

Limitations and Future Work

  • Dependency on Teacher Quality: The effectiveness of the refinement is intrinsically bound to the accuracy of the LLM teacher. Any systematic biases or conceptual errors in the LLM's judgments will be encoded directly into the optimized query embedding.
  • The Initial Retrieval Bottleneck: If the initial embedding model fails to retrieve any relevant documents within the top-$K$ set, the LLM teacher will have no positive examples to learn from, rendering the feedback signal significantly less informative.
  • Future Directions: The authors suggest exploring active learning strategies to select more informative documents for LLM feedback (rather than just the top-$K$), exploring list-wise or set-wise LLM scoring to reduce inference costs, and extending the paradigm to multimodal settings like image classification and visual search.

Summary updated

BibTeX
@misc{gera2026task,
  author = {Ariel Gera and Shir Ashury-Tahan and Gal Bloch and Ohad Eytan and Assaf Toledo},
  title = {{Task-Adaptive Embedding Refinement via Test-time LLM Guidance}},
  year = {2026},
  eprint = {2605.12487},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.12487},
}
Figure