<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Mattias Brunnert - Elasticsearch Labs]]></title>
    <description><![CDATA[Articles and tutorials from the Search team at Elastic]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Mattias Brunnert - Elasticsearch Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1121c0bf0e8a6e65/6a88da6340a1841030ef456f/search-labs-thumbnail.png</url>
      <link>https://www.elastic.co/cn/search-labs/author/mattias-brunnert</link>
    </image>
    <link>https://www.elastic.co/cn/search-labs/author/mattias-brunnert</link>
    <atom:link href="https://www.elastic.co/cn/search-labs/rss/author/mattias-brunnert.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[cn]]></language>
    <lastBuildDate>Mon, 14 Sep 2026 05:24:37 GMT</lastBuildDate>
  <item>
    <title><![CDATA[以最低得分阈值确保语义精确性]]></title>
    <description><![CDATA[通过设定最低得分阈值提升语义精确性。本文提供语义搜索与混合搜索的实操案例。 ]]></description>
    <content:encoded><![CDATA[<p>语义搜索为检索相关性开辟了全新可能。以 ELSER、E5、Jina Embedding v4 为代表的高质量稀疏-稠密混合模型，通过解析词义而非简单关键词匹配返回相关结果。然而，这类模型在处理长尾查询或索引缺乏相关内容时，可能返回无关结果，这种特性既可能导致用户困惑，也会造成大型语言模型 (LLM) 的算力资源浪费。</p><p>本文将介绍如何使用最低得分参数来提高语义搜索结果的精确度。如想测试本博客文章中提供的示例，请访问 <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/ensuring-semantic-precision-with-minimum-score/ensuring_semantic_precision_with_minimum_score.ipynb">相关 Jupyter 笔记本</a>。</p><h2>背景：精确率和召回率</h2><p>在搜索相关性中，<em>精确率</em>和<em>召回率</em>是关键概念。强烈建议尚不熟悉这些内容的读者查阅相关资料。以下是摘要。</p><ul><li><p><strong>精确率：</strong>返回的搜索结果中与用户相关的比例。</p></li><li><p><strong>召回率：</strong>搜索结果集中包含的语料库中所有相关文档的百分比。</p></li></ul><p>或者换句话说，精确率<strong>只</strong>返回相关结果，而召回率则返回<strong>所有</strong>相关结果。可以想象，这些需求经常相互冲突。语义搜索往往具有很高的召回率，但在精确率方面可能会不理想。继续阅读，了解如何避免这种情况。</p><h2>推出最低得分参数</h2><p>min_score参数通过设定最低得分阈值提升检索精度，系统将自动过滤得分低于该阈值的匹配结果，从而精简结果集。以下是一个简单的示例：</p>GET search-movies/_search
{
  "retriever": {
    "linear": {
      "min_score": 4,
      "retrievers": [
        ...
      ]
    }
  }
}<h2>得分归一化</h2><p>设置最低得分阈值固然可行，但并非所有语义模型都能返回适用于静态阈值的分值。以 ELSER 为例，它所返回的分值是无界得分。<a href="https://huggingface.co/intfloat/e5-small#faq">有些</a>密集模型得分是密集聚类的，只有在特定查询的背景下才有意义。</p><p>对于大多数语义搜索情况，我们建议在应用“min_score”之前使用归一化方法。归一化确保文档得分在规定区间内。Elasticsearch 检索器提供了两种此类<a href="https://www.elastic.co/docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever#linear-retriever-normalizers">归一化器</a>，即“l2_norm”和“minmax”。最常用的是“minmax”，因为它简单易懂，在很多情况下都很有效。“minmax”的主要属性包括：</p><ul><li><p>文档分数分布在 0 到 1 之间。</p></li><li><p>得分最高的文件总是记为 1 分。</p></li><li><p>得分最低的文件总是记为 0 分。</p><ul><li><p>这可能会使其不太适合关键字搜索。更多讨论请参见“混合搜索”部分。</p></li></ul></li></ul><p>以下是一个包含<code>min_score</code>规范化语义查询的示例。排名窗口参数已增加到 500，使系统能够返回从第 100 条开始的更长结果列表。</p>GET search-movies/_search
{
  "size": 100,
  "_source": [
    "title", "overview"
  ],
  "retriever": {
    "linear": {
      "rank_window_size": 500,
      "min_score": 0.25,
      "retrievers": [
        {
          "normalizer": "minmax",
          "retriever": {
            "standard": {
              "query": {
                "semantic": {
                  "field": "overview_vector",
                  "query": "superhero movie"
                }
              }
            }
          }
        }
      ]
    }
  }
}<p>当前参数已设置为高于生产环境的常规值，以便我们全面检验搜索结果质量并针对性优化输出。</p><h2>使用线性检索器的混合搜索</h2><p>对于混合搜索，最简单的方法是归一化所有分数，分配权重，并应用最低得分。请注意，通过选择总和为 1 的权重，可以将总分控制在 0-1 的范围内。这样使得最终得分易于解读，且便于调整 <code>min_score</code>。以下是一个示例：</p>GET search-movies/_search
{
  "size": 100,
  "_source": ["title", "overview","keywords"],
  "retriever": {
    "linear": {
      "rank_window_size": 500,
      "min_score": 0.25,
      "retrievers": [
        {
          "weight": 0.6,
          "normalizer": "minmax",
          "retriever": {
            "standard": {
              "query": {
                "semantic": {
                  "field": "overview_vector",
                  "query": "superhero movie"
                }
              }
            }
          }
        },
        {
          "weight": 0.4,
          "normalizer": "minmax",
          "retriever": {
            "standard": {
              "query": {
                "multi_match": {
                  "query": "superhero movie",
                  "fields": ["overview","keywords", "title"],
                  "type": "cross_fields",
                  "minimum_should_match": "2"
                }
              }
            }
          }
        }
      ]
    }
  }
}<h2>使用 RRF 的混合搜索</h2><p>使用 BM25 时，我们通常通过其他方式控制精度，例如使用<code>AND</code> 操作符或<code>minimum_should_match</code> 。此外，由单个、精确和罕见术语组成的查询自然会导致搜索结果较少，而且往往都是高度相关的结果。这就可能导致：</p><ul><li><p>在 BM25 检索器中，排名靠后的结果即使绝对 BM25 分值接近头部结果，仍会被赋予较低的归一化分数。</p></li><li><p>将极低的 BM25 分值与语义分值相加，总分即可近似为语义分值。</p></li><li><p>缺少 BM25 分值参考可能导致 <code>min_score threshold</code> 丢弃该文档。</p></li></ul><p>作为解决方案，我们可以改用倒数排序融合 (RRF) 来结合 BM25 和语义结果。该方法通过关注各结果集中的文档位置而非原始分值，巧妙规避了不同检索算法评分体系难以直接比较的技术难题。在这种情况下，<code>min_score</code> 仅应用于语义检索器。</p>GET search-movies/_search
{
  "_source": ["title", "overview","keywords"],
  "retriever": {
    "rrf": {
      "rank_window_size": 500,
      "retrievers": [
        {
          "linear": {
            "rank_window_size": 500,
            "min_score": 0.25,
            "retrievers": [
              {
                "normalizer": "minmax",
                "retriever": {
                  "standard": {
                    "query": {
                      "semantic": {
                        "field": "overview_vector",
                        "query": "superhero movie"
                      }
                    }
                  }
                }
              }
            ]
          }
        },
        {
          "standard": {
            "query": {
              "multi_match": {
                "query": "superhero movie",
                "fields": ["overview", "keywords","title"],
                "type": "cross_fields",
                "minimum_should_match": "2"
              }
            }
          }
        }
      ]
    }
  }
}<h2>结论</h2><p>通过采用 <code>min_score</code>，我们已验证可有效降低语义检索算法因高召回率导致的结果集中误报数量。要了解有关检索器的更多信息，请参阅本<a href="https://www.elastic.co/search-labs/blog/elasticsearch-retrievers">博文</a>和<a href="https://www.elastic.co/docs/solutions/search/retrievers-overview">Elasticsearch 文档</a>。</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/semantic-precision-minimum-score</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/semantic-precision-minimum-score</guid>
    <category><![CDATA[相关性]]></category>
    <category><![CDATA[混合搜索]]></category>
    <dc:creator><![CDATA[Mattias Brunnert]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd4a3fba607900049/6a170e0fcdacbf8fe17d2a7a/8b3b5910abfe16d48d309341a0027008b16c4340-720x420.jpg" length="0" type="image/jpeg"/>
    <pubDate>Fri, 20 Feb 2026 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>