# 重排序

混合搜索结合了多种搜索技术的优点，以实现更好的检索结果。然而，不同搜索模式的结果需要在提供给大型模型之前进行合并和归一化（将数据转换为统一的标准范围或分布，以便更好地比较、分析和处理）。这就需要引入一个评分系统：重排序模型（Rerank Model）。

**重排序模型的作用**

重排序模型通过根据候选文档与用户问题的语义匹配度重新排序候选文档列表，从而改善语义排序的结果。它通过计算用户问题与每个候选文档之间的相关性得分，返回按相关性从高到低排序的记录列表。常见的重排序模型包括 Cohere Rerank、bge-reranker 等。

**重排序的必要性**

1. **初始搜索**：通常在进行重排序之前会有一次初始搜索，因为计算查询与数百万文档之间的相关性得分效率低下。因此，重排序通常被放置在搜索过程的最后，使其适合合并和排序来自不同搜索系统的结果。
2. **单一搜索模式的应用**：重排序不仅适用于合并来自不同搜索系统的结果。在单一搜索模式下，引入重排序步骤也可以有效提高文档的召回率，例如在关键词搜索后添加语义重排序。
3. **限制文本块数量**：在将相关文本块提供给大型模型之前，通常会限制传递的文本块数量（即 TopK，可以在重排序模型参数中设置）。这是因为大型模型的输入窗口有大小限制（通常为 4K、8K、16K、128K Token 计数），需要根据所选模型的输入窗口大小选择合适的分段策略和 TopK 值。
4. **内容相关性**：即使模型的上下文窗口足够大，过多的召回块可能会引入低相关性的内容，从而降低答案的质量。因此，重排序的 TopK 参数不一定越大越好。

**重排序的优势**

重排序不是搜索技术的替代，而是增强现有搜索系统的辅助工具。其最显著的优势在于提供了一种简单且低复杂度的方法来改善搜索结果，并允许用户在不进行重大基础设施修改的情况下将语义相关性整合到现有的搜索系统中。


---

# 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/zhong-pai-xu.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.
