高级RAG技术:图解概述

Now it is time to get to the more sophisticated RAG techniques like Query transformation and Routing, both involving LLMs and thus representing agentic behaviour — some complex logic involving LLM reasoning within our RAG pipeline.

现在是时候进入更复杂的RAG技术,如查询转换和路由,两者都涉及LLM,因此代表了我们RAG流程中的代理行为 - 一些涉及LLM推理的复杂逻辑。

4. Query transformations

4. 查询转换

Query transformations are a family of techniques using an LLM as a reasoning engine to modify user input in order to improve retrieval quality. There are different options to do that.

查询转换是一类使用LLM作为推理引擎来修改用户输入以提高检索质量的技术。有不同的选择。

Query transformation principles illustrated

演示查询转换原则

If the query is complex, LLM can decompose it into several sub queries. For examle, if you ask:
_— “What framework has more stars on Github, Langchain or LlamaIndex?”,
_and it is unlikely that we’ll find a direct comparison in some text in our corpus so it makes sense to decompose this question in two sub-queries presupposing simpler and more concrete information retrieval:
_— “How many stars does Langchain have on Github?” — “How many stars does Llamaindex have on Github?”_They would be executed in parallel and then the retrieved context would be combined in a single prompt for LLM to synthesize a final answer to the initial query. Both libraries have this functional implemented — as a Multi Query Retriever in Langchain and as a Sub Question Query Engine in Llamaindex.

如果查询很复杂,LLM可以将其分解为几个子查询。例如,如果你问:
_—“Github上,Langchain和LlamaIndex哪个框架的星星更多?”
_并且在我们的语料库中很难找到直接的比较,那么将这个问题分解为两个子查询,假设更简单和更具体的信息检索:
_—“Langchain在Github上有多少颗星星?”——“Llamaindex在Github上有多少颗星星?”_它们将并行执行,然后将检索到的上下文合并为一个提示,供LLM综合生成对初始查询的最终答案。这两个库都实现了这个功能——Langchain中的多查询检索器和Llamaindex中的子问题查询引擎

  1. Step-back prompting uses LLM to generate a more general query, retrieving for which we obtain a more general or high-level context useful to ground the answer to our original query on. Retrieval for the original query is also performed and both contexts are fed to the LLM on the final answer generation step.

    回退提示 使用LLM生成更一般的查询,检索出我们可以在原始查询上获得更一般或高级上下文的查询。同时也执行原始查询的...

开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2024 iteam. Current version is 2.139.0. UTC+08:00, 2024-12-23 00:24
浙ICP备14020137号-1 $Map of visitor$