本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
检索增强生成 (RAG) 通过检索和整合知识库中的信息来增强响应。在 Amazon Nova Sonic 中,RAG 是通过使用工具实现的。
知识库实施大纲
实现 RAG 需要以下元素:
-
配置工具-在您的
promptStart
活动中定义知识库搜索工具。 -
接收工具使用请求-当用户提出问题时,模型将调用知识库工具。
-
查询矢量数据库-针对您的矢量数据库执行搜索查询。
-
返回结果-将搜索结果发送回模型。
-
生成响应-模型将检索到的信息合并到其语音响应中。
知识库配置
以下是基础知识库工具的配置示例:
{
toolSpec: {
name: "knowledgeBase",
description: "Search the company knowledge base for information",
inputSchema: {
json: JSON.stringify({
type: "object",
properties: {
query: {
type: "string",
description: "The search query to find relevant information"
}
},
required: ["query"]
})
}
}
};