Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set our retriever as tools for agent #930

Open
Abirdcfly opened this issue Mar 26, 2024 · 0 comments
Open

set our retriever as tools for agent #930

Abirdcfly opened this issue Mar 26, 2024 · 0 comments
Milestone

Comments

@Abirdcfly
Copy link
Collaborator

Abirdcfly commented Mar 26, 2024

ref: https://blog.langchain.dev/conversational-retrieval-agents/

key code:
https://github.com/hwchase17/conversational-retrieval-agent/blob/8200b32265a89c598a1748b5ebbf717cf6d50221/streamlit.py#L32-L50

Let's compare this to the ConversationalRetrievalQA chain that most people use. The benefits that a conversational retrieval agent has are:

让我们将其与大多数人使用的 ConversationalRetrievalQA 链进行比较。会话式检索代理的好处是:

  1. Doesn't always look up documents in the retrieval system. Sometimes, this isn't needed! If the user is just saying "hi", you shouldn't have to look things up

并不总是在检索系统中查找文件。有时候,这是不需要的!如果用户只是说“嗨”,你不应该去查找东西

  1. Can do multiple retrieval steps. In ConversationalRetrievalQA, one retrieval step is done ahead of time. If that retrieval step returns bad results, then you're out of luck! But with an agent you can try a different search query to see if that yields better results

可以执行多个检索步骤。在 ConversationalRetrievalQA 中,提前完成一个检索步骤。如果检索步骤返回错误的结果,那么您就不走运了!但是有了代理,你可以尝试不同的搜索查询,看看是否会产生更好的结果

  1. With this new type of memory, you can maybe avoid retrieval steps! This is because it remembers ai <-> tool interactions, and therefore remembers previous retrieval results. If a follow-up question the user asks can be answered by those, there's no need to do another retrieval step!

有了这种新型的记忆,你也许可以避免检索步骤!这是因为它记住了 ai <-> tool 交互,因此记住了以前的检索结果。如果用户提出的后续问题可以通过这些来回答,则不需要执行另一个检索步骤!

  1. Better support for meta-questions about the conversation - "how many questions have I asked?", etc. Because the old chain dereferences questions to be "standalone" and independent of the conversation history in order to query the vector store effectively, it struggles with this type of question.

更好地支持关于对话的元问题-“我问了多少个问题?因为旧的链将问题解引用为“独立的”并且独立于对话历史以便有效地查询向量存储,所以它难以处理这种类型的问题。

Note, that there are some downsides/dangers:

注意,有一些缺点/危险:

  1. With agents, they can occasionally spiral out of control. That's why we've added controls to our AgentExecutor to cap them at a certain max amount of steps. It's also worth noting that this is a VERY focused agent, in that it's only given one tool (and a pretty simple tool at that). In general, the fewer (and simpler) tools an agent is given, the more likely it is to be reliable.

对于agents来说,他们偶尔会失控。这就是为什么我们在AgentExecutor中添加了控件,以将其限制在某个最大步骤数。同样值得注意的是,这是一个非常专注的代理,因为它只提供了一个工具(而且是一个非常简单的工具)。一般来说,给代理的工具越少(和越简单),它就越有可能是可靠的。

  1. By remembering ai <-> tool interactions, that can hog the context window occasionally. That's why we've included a flag to disable that type of memory, and more generally have made memory pretty plug-and-play.

通过记住 ai <-> tool 交互,这可能会偶尔占据上下文窗口。这就是为什么我们包含了一个标志来禁用这种类型的内存,并且更一般地使内存非常即插即用。

@bjwswang bjwswang added this to the v0.4.0 milestone Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants