Amazon Bedrock 知识库智能体检索教程
AWS 机器学习和博客发布实践文章,演示如何用 LangChain 在 Amazon Bedrock Managed Knowledge Bases 上使用智能体检索。文章对比标准 Retrieve API 的单次混合检索与 AgenticRetrieveStream API 的多步规划循环:后者把多部分问题拆成子查询、判断证据是否充足,不足时再次检索,并可用 generate_response 直接返回带引用的答案。文中还给出两条路径的 IAM 权限配置、成本差异以及各自适用场景。
对需要回答多意图问题的 RAG 应用来说,把查询规划交给托管知识库可以减少“检索到相关内容却答不全”的情况,但开发者需要在延迟与成本之间做取舍。
When a user asks the support assistant, a Retrieval Augmented Generation (RAG) application built with LangChain to compare two products across three dimensions, they’re effectively posing six questions simultaneously. Similarity search uses a single query vector to encapsulate all the intents. The retriever then generates the best approximation of the average of those intents. The resulting answer comes back concise. The search executes without errors. The relevance scores look reasonable. Yet the retrieved chunks, while topically relevant, only cover a fraction of what the question actually asked.
In this post, we showcase a RAG application on Amazon Bedrock Managed Knowledge Base with LangChain. We run the same multi-part question through standard and agentic retrieval, and read the trace events to see the plan the model produced. We also cover what the two retrieval paths cost and when the cheaper one is the right choice.
Agentic retrieval is available on Amazon Bedrock Managed Knowledge Base. Instead of one search, Amazon Bedrock Managed Knowledge Base plans the retrieval. It breaks the question into sub-queries, runs them, judges whether it has enough evidence, and searches again if it doesn’t. The langchain-aws package exposes both agentic and standard retrieval, so you can use either from a LangChain application.
#Amazon Bedrock#Amazon Bedrock Managed Knowledge Bases#LangChain#AWS#langchain-aws