# 检索

**知识库 Q\&A AI 应用中的检索模式**

在构建知识库 Q\&A AI 应用时，如果应用中关联了多个知识库，服务层支持两种检索模式：N 对 1 检索和多路径检索。

**检索设置**

**N 对 1 检索**

在 N 对 1 检索模式中，代理（Agent）根据用户意图和知识描述独立确定并选择与之最匹配的单一知识库进行相关文本查询。该模式适用于知识库各自独立且数量较少的应用。N 对 1 检索依赖模型的推理能力，根据用户意图选择最相关的知识库。在推理知识时，知识作为代理的工具，通过意图推理进行选择；工具描述基本上就是知识描述。

当用户上传知识时，系统会自动总结每个知识库。为了在此模式下获得最佳检索结果，可以在“知识 -> 设置 -> 知识描述”中查看系统生成的摘要描述，并检查该内容是否总结了知识的核心内容。

**N 对 1 检索的技术流程图：**

<figure><img src="/files/3FOXArzjLqoSao2K0hlT" alt=""><figcaption></figcaption></figure>

因此，当知识库数量过多或知识描述缺乏足够的区分时，此模式的召回效果可能会受到影响。该模式更适合知识库较少的应用。

**多路径检索**

多路径检索模式基于用户意图，同时匹配所有知识库，从多个知识库查询相关文本块，并在重排序步骤后，从多路径查询结果中选择与用户问题最匹配的最佳结果。需要配置重排序模型的 API。在多路径检索模式中，搜索引擎从与应用关联的所有知识库中检索与用户查询相关的文本内容，合并多路径召回的结果，并使用重排序模型对检索到的文档进行语义重排序。

多路径检索不依赖模型的推理能力或知识描述，因此在多知识搜索中可以实现更高质量的召回结果。此外，加入重排序步骤可以有效改善文档的召回率。因此，在创建与多个知识库关联的知识库 Q\&A 应用时，我们建议将检索模式配置为多路径检索。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.din.lol/din-cook-data-for-ai/chinese/din-cao-zuo-yu-jie-shao/comprehensive-network-architecture/fu-wu-ceng-ai-dai-li-gong-ju-bao/rag-jian-suo-zeng-qiang-sheng-cheng/jian-suo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
