TL;DR
Retrieval-Augmented Generation (RAG) for tool use often fails due to misaligned embeddings caused by poor documentation or imperfect models. This paper introduces Online-Optimized RAG (ORAG), a plug-and-play framework that continually updates tool embeddings at deployment time using simple binary feedback (like task success or failure). It achieves state-of-the-art retrieval accuracy with negligible latency overhead and requires absolutely no changes to the underlying Large Language Model (LLM).
What Problem Does This Paper Address?
When LLMs use external tools or APIs, they rely on a retriever to match the user's query to the right tool description within a vector space. However, in production, this retrieval often breaks down due to embedding misalignment. This happens when tool documentation is noisy or sparse, the embedding model is suboptimal, or user phrasing shifts over time.
Because traditional RAG pipelines freeze their embeddings after offline training, they cannot adapt to real-world failures. This leads to incorrect tool selection, causing the downstream LLM to fail the task or waste API calls backtracking.
Methods
The authors propose Online-Optimized RAG (ORAG). Instead of fine-tuning the query embedding model (which is often a black-box API) or modifying the LLM planner, ORAG dynamically updates the tool/item embeddings during live deployment.
- Bandit-Style Feedback: The system doesn't need to know the "ground truth" optimal tool. It only requires a binary signal indicating whether the selected tool succeeded or failed (e.g., via user thumbs up/down or automated unit tests).
- Importance-Weighted Online Gradient Descent: When a tool is selected and succeeds, its vector is pulled closer to the query vector to increase future similarity. If it fails, it is pushed away. Crucially, the embeddings of unselected tools are also adjusted slightly away to maintain proper mathematical contrast across the softmax distribution.
- Versatile Variants: The framework natively supports extensions like $K$-retrieval with an LLM reranker, time-varying databases (adding/removing tools dynamically), and multi-hop retrieval pipelines.
Datasets
The framework was evaluated across several challenging benchmarks:
- Tool Use: UltraTool (complex real-world planning scenarios) and three sub-tasks from ToolRet (ToolRet-Web, ToolRet-Code, and ToolRet-Customized).
- Information Retrieval: The FiQA benchmark.
- Multi-Hop Reasoning: MultiHopRAG.
Key Insights and Ideas
- Optimize the Catalog, Not the Model: Modifying the tool database embeddings rather than the query model is computationally lightweight and avoids degrading the query model's performance on other unrelated tasks.
- Exploration-Free Learning: Unlike traditional multi-armed bandit algorithms that force random, explicit exploration (which hurts user experience), ORAG leverages the natural stochasticity of the retriever's softmax distribution.
- Fixing Bad Models and Docs: The online updates can make a smaller, weaker embedding model perform comparably to a much larger model, and can effectively "repair" the performance loss caused by poorly written documentation.
Key Results
- Consistent Accuracy Gains: Across all benchmarks, ORAG significantly boosted Recall@10 and NDCG@10. For instance, optimizing the weaker
text-embedding-v4model allowed it to outperform the raw, unoptimizedtext-embedding-3-largemodel on several tasks. - High Efficiency: Heavy cross-encoder rerankers drastically increase latency. In contrast, ORAG achieves comparable accuracy gains with almost zero inference latency overhead because the embedding updates happen via lightweight, post-interaction gradients.
- Multi-Hop Success: In multi-hop settings (MultiHopRAG), integrating ORAG improved end-to-end question-answering accuracy from 0.55 to 0.68.
Limitations and Future Work
- Hyperparameter Sensitivity: The performance depends on choosing an appropriate learning rate ($\eta$). While a standard time-varying schedule ($c/\sqrt{t}$) works well, automated tuning could make deployment even simpler.
- Probability Calibration: The retrieval probabilities are directly tied to embedding scores; the authors note that incorporating formal calibration techniques could further refine retrieval confidence.
- Feedback Complexity: The current model relies heavily on binary success/failure signals. Extending the framework to handle richer, nuanced, or delayed feedback remains an open area for future research.
Summary updated