<?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[Jeff Vestal - 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[Jeff Vestal - 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/jeff-vestal</link>
    </image>
    <link>https://www.elastic.co/cn/search-labs/author/jeff-vestal</link>
    <atom:link href="https://www.elastic.co/cn/search-labs/rss/author/jeff-vestal.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[cn]]></language>
    <lastBuildDate>Mon, 28 Sep 2026 03:58:49 GMT</lastBuildDate>
  <item>
    <title><![CDATA[快速与准确：测量量化向量搜索的召回率]]></title>
    <description><![CDATA[说明如何在 Elasticsearch 中以最少的设置来测量向量搜索的召回率。]]></description>
    <content:encoded><![CDATA[<p>所有人都希望向量搜索能即时响应，但是高维向量占用的资源很大。一个 1024 维的 float-32 向量会占用大量内存，将其与数百万个其他向量进行比较的计算成本非常高昂。</p><p>为了解决这个问题，像 Elasticsearch 这样的搜索引擎使用了两种主要的优化策略：</p><ol><li><p><strong>近似搜索（分层可导航小世界 [HNSW]）：</strong>我们不需要扫描每一份文档，而是建立一个导航图，以便快速跳转到答案的可能邻域。</p></li><li><p><strong>量化：</strong>我们对向量进行压缩（例如，从 32 位浮点数压缩为 8 位整数，甚至 1 位二进制值），以减少内存使用量并加快计算速度。</p></li></ol><p>但优化往往会使<strong>准确性</strong>下降。</p><p>这种担忧是有道理的：“如果我在搜索过程中压缩数据并使用快捷方式，我会错过最佳结果吗？”“这种优化是否会降低搜索引擎的相关性？”</p><p>为了证明 Elastic 的量化不会降低结果，我们使用<a href="https://huggingface.co/datasets/fancyzhx/dbpedia_14"><strong>DBPedia-14</strong></a><a href="https://huggingface.co/datasets/fancyzhx/dbpedia_14"> 数据集</a>构建了一个可重复的测试工具，以精确计算在使用 Elasticsearch 的默认优化时，准确率下降了多少（特别是<strong>召回率）</strong>才能提高速度。</p><p>总结：可能比您想象的要少得多。点击<a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/fast_vs_accurate_measuring_the_recall_of_quantized_vector_search/vector_recall_notebook.ipynb">此处查看笔记本</a>，亲自试试</p><h2><strong>定义（面向非专业人士）</strong></h2><p>在了解代码之前，让我们先明确一些术语。</p><ul><li><p><strong>相关性与召回率：</strong><strong>相关性</strong>具有主观性（我找到的是优质内容吗？），而<strong>召回率</strong>则是基于数学计算。如果数据库中有 10 份文档与查询在数学层面<em>完美</em>匹配，而搜索引擎找到了其中 9 份，那么召回率就是 90%（或 0.9）。</p></li><li><p><strong>精确搜索（扁平式）：</strong>有时也被称为“暴力搜索”法。搜索引擎会扫描索引中的每一份文档并计算距离。</p><ul><li><p><em>优点：</em>召回率达到 100%。</p></li><li><p><em>缺点：</em>计算量大且大规模扩展缓慢。</p></li></ul></li><li><p><strong>近似搜索 (HNSW)：</strong>“捷径”方法。搜索引擎生成 <a href="https://www.elastic.co/search-labs/blog/hnsw-graph">HNSW</a> 图表。它遍历图表以找到最近邻。</p><ul><li><p><em>优点：</em>速度极快且可扩展。</p></li><li><p><em>缺点：</em>如果图表遍历过早停止，可能会错过近邻。</p></li></ul></li></ul><h2><strong>实验：精准与近似</strong></h2><p>为了测试召回率，我们使用了 <strong>DBPedia-14</strong> 数据集，这是一个包含 14 个本体类别的大型标题和摘要数据集，通常用于训练和评估文本分类模型。具体而言，我们将重点关注“电影”类别。我们希望将优化的生产设置与数学上完美的基准真值进行比较。</p><p>在此次实验中，我们采用 <a href="https://www.elastic.co/search-labs/blog/jina-embeddings-v5-text">jina-embeddings-v5-text-small</a> 模型。这是一款处于行业领先水平的多语言模型，在文本表征方面树立了行业基准。我们选择该模型，是因为它确立了当下高性能嵌入的标杆标准。通过将 Jina v5 卓越的精准度与Elasticsearch原生量化技术相结合，我们能够展示一种既具备高效计算能力，又在检索质量上毫不妥协的搜索架构。</p><p>我们设置了一个具有双重映射的索引。我们同时将相同的文本导入两个不同的字段：</p><ol><li><p><strong><code>content.raw</code></strong>类型：<code>flat</code>。这会使 Elasticsearch 对全部 Float32 向量执行暴力扫描。通过这种扫描，系统会返回完全匹配的结果，并将用于我们的基线。</p></li><li><p><strong><code>content</code></strong>类型为<code>semantic_text</code>。默认情况下使用 HNSW + 更好的二进制量化 (BBQ)。这是用于近似匹配的标准、优化生产设置。</p></li></ol><h3><strong>Recall@10 测试</strong></h3><p>在我们的评估指标中，我们使用了 Recall@10。</p><p>我们随机挑选了 50 部电影，并对这两个字段运行了相同的查询。</p><ul><li><p>如果<strong>精确（扁平式）</strong>搜索显示前 10 个近邻是 ID [1, 2, 3……10]，</p></li><li><p>而<strong>近似 (HNSW)</strong> 搜索结果显示的是 ID [1，2，3... 9，99]。</p></li><li><p>我们正确地找到了前 10 个中的 9 个。得分为 <strong>0.9</strong>。</p></li></ul><p>这是我们使用的映射：</p># The "Control Group": Forces exact brute-force scan
"raw": {
    "type": "semantic_text",
    "inference_id": ".jina-embeddings-v5-text-small",
    "index_options": {
        "dense_vector": {
            "type": "flat"
        }
    }
}<p><strong>结果：成功的“平直线”</strong></p><p>我们进行了一次规模测试，重新加载了整个数据集，并对 1,000 到 40,000 个文档的索引规模进行了测试。</p><p>召回率得分情况如下：</p><p>文档</p><p>Recall@10得分</p><p>1,000</p><p>1.000 (100%)</p><p>5,000</p><p>0.998 (100%)</p><p>10,000</p><p>0.992 (99.4%)</p><p>20,000</p><p>0.999 (99.0%)</p><p>40,000</p><p>0.992 (98.8%)</p><p>结果非常稳定。<strong>即使我们扩大了搜索范围，近似搜索也能</strong>在 99% 的情况下与暴力精确搜索相匹配。</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8168a0a4946bade7/6a170e154a531b61b536a9eb/a4bfacb1d0cce6fdf6df0e1a9d4fc5d4007a66da-1999x1209.png" alt="向量搜索稳定性：召回率与索引规模" /><h2><strong>为什么它如此有效？</strong></h2><p>您可能会认为将向量压缩成二进制值会对准确性的影响更大。不这样做的原因在于 Elasticsearch 处理检索的方式。</p><p>目前大多数嵌入模型输出的是 Float32 向量，这些向量很大。为了提高搜索效率，Elasticsearch 对高维向量使用量化技术。具体来说，自 9.2 版起，它默认使用<a href="https://www.elastic.co/search-labs/blog/elasticsearch-9-1-bbq-acorn-vector-search">BBQ</a>。</p><p>BBQ 采用<strong>重新打分</strong>机制：</p><ol><li><p><strong>遍历：</strong>搜索引擎使用压缩（量化）向量来快速遍历 HNSW 图表。由于向量较小，它可以高效地进行过度采样，收集更大的候选文档列表（例如，前 100 个大致相似的文档），而不会影响性能。</p></li><li><p><strong>重新评分：</strong>一旦有了这些候选文件，它就会只检索这几份文件的全精度值，以计算出最终的精确排名。</p></li></ol><p>这样就能两全其美，既能以量化的速度完成繁重的工作，又能以浮点运算的精度完成最终排序。</p><h2><strong>我们能做得更好吗？</strong></h2><p>值得注意的是，我们在这里看到的结果是使用默认设置和随机抽样数据得出的。可以将其视为高性能的起点。尽管 Jina v5 性能卓越，但这些召回率分数并非适用于所有数据集的“万能保障”。每个数据集都有其独特之处，虽然您肯定可以进一步调整优化以挖掘出更多性能潜力，但您始终应基于自身特定数据进行基准测试，以明确性能上限所在。</p><h2><strong>结论</strong></h2><p>这是一次规模非常小的测试。不过，本次测试的重点并非专门评估嵌入模型或 BBQ 的性能，而是要展示如何通过极简的设置轻松衡量数据集的召回率。</p><p>如果您想用自己的数据运行此测试，可以点击<a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/fast_vs_accurate_measuring_the_recall_of_quantized_vector_search/vector_recall_notebook.ipynb">此处查看笔记本</a>，亲自试试。</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/recall-vector-search-quantization</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/recall-vector-search-quantization</guid>
    <category><![CDATA[向量数据库]]></category>
    <dc:creator><![CDATA[Jeff Vestal]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt198c7085db96aa04/6a170e17cdacbfe88c7d2a86/09f03b9239d66c36763cdab3fafcdac207ff6d83-1280x720.png" length="0" type="image/png"/>
    <pubDate>Fri, 20 Mar 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[您的第一个弹性代理：从单一查询到人工智能驱动的聊天]]></title>
    <description><![CDATA[了解如何使用 Elastic 的人工智能代理生成器创建专门的人工智能代理。在本博客中，我们将构建一个金融人工智能代理。]]></description>
    <content:encoded><![CDATA[<p>借助 Elastic 的全新<a href="https://www.elastic.co/search-labs/blog/ai-agentic-workflows-elastic-ai-agent-builder">代理生成器</a>，您可以创建专门的人工智能代理，使其成为特定业务领域的专家。该功能使您不再局限于简单的仪表盘和搜索栏，而是将数据从被动的资源转变为主动的对话伙伴。</p><p>想象一下，一位财务经理需要在与客户会面之前加快速度。现在，他们只需向定制的代理直接提问，而无需手动挖掘新闻源和交叉参考投资组合仪表板。这就是"聊天优先" 方法的好处。经理与他们的数据直接对话，询问诸如"ACME 公司的最新消息是什么，它对我客户的持股有何影响？"并在几秒钟内得到综合的专家答复。</p><p>今天，我们正在打造一个金融专家，其应用就像您的数据一样多种多样。同样的能力可以造就一名网络安全分析师来寻找威胁，造就一名现场可靠性工程师来诊断故障，或者造就一名营销经理来优化营销活动。无论在哪个领域，核心任务都是一样的：将您的数据转化为您可以与之交谈的专家。</p><h2>步骤 0：我们的数据集</h2><p>我们当前的数据集是一个基于金融的合成数据集，包含金融账户、资产头寸、新闻和财务报告。虽然它是合成的，但复制了真实金融数据集的简化版本。</p><p><code>financial_accounts</code>:具有风险特征的客户组合</p><p><code>financial_holdings</code>:有购买记录的股票/ETF/债券仓位</p><p><code>financial_asset_details</code>:股票/ETF/债券的详细信息</p><p><code>financial_news</code>:人工智能生成的带有情感分析的市场文章</p><p><code>financial_reports</code>:公司收益和分析师报告</p><p>您可以根据<a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/your-first-elastic-agent/Your_First_Elastic_Agent.ipynb">此处的</a>随附笔记本自行加载该数据集。</p><h2>步骤 1：基础--作为 ES|QL 的业务逻辑</h2><p>每一项人工智能技能都以坚实的逻辑为起点。对于我们的财务经理代理，我们需要教它如何回答一个常见问题："我担心市场情绪。你能告诉我哪些客户最容易受到坏消息的影响吗？这个问题超出了简单的搜索范围。这要求我们将市场情绪与客户投资组合联系起来。</p><p>我们需要找到负面文章中提到的资产，识别持有这些资产的每一位客户，计算其风险敞口的当前市值，然后对结果进行排序，优先考虑风险最高的客户。这种复杂的多连接分析是我们先进的 ES|QL 工具的完美工作。</p><p>下面是我们要使用的完整查询。它看起来令人印象深刻，但概念却简单明了。</p><h2>分解：接合点和护栏</h2><p>在这个查询中，有两个重要的概念使代理生成器发挥作用。</p><h3>1.查找联接</h3><p>多年来，Elasticsearch 最受欢迎的功能之一就是根据一个共同的键来连接来自不同索引的数据。有了 ES|QL，<code>LOOKUP JOIN</code> 。</p><p>在我们的新查询中，我们会执行一连串的三个<code>LOOKUP JOIN</code>'s：首先将负面新闻与资产详细信息连接起来，然后将这些资产与客户持有的资产连接起来，最后再与客户的账户信息连接起来。这样，在一次高效的查询中，就能从四个不同的索引中获得极其丰富的结果。这意味着我们可以将不同的数据集结合起来，创建一个具有洞察力的单一答案，而无需事先将所有数据反规范化为一个巨大的索引。</p><h3>2.作为 LLM 护栏的参数</h3><p>您会发现查询使用了<code>?time_duration</code> 。这不仅是一个变量，还是人工智能的护栏。虽然大型语言模型 (LLM) 是生成查询的好帮手，但让它们自由支配数据可能会导致查询效率低下甚至错误。</p><p>通过创建参数化查询，我们迫使 LLM 按照人类专家已经定义的经过测试、高效且正确的业务逻辑工作。这与多年来开发人员使用搜索模板安全地向应用程序公开查询功能的方式类似。代理可以解释用户的请求，如"this week" 来填充<code>time_duration</code> 参数，但它必须使用我们的查询结构来获取答案。这使我们在灵活性和控制性之间取得了完美的平衡。</p><p>最终，这种查询可以让了解数据的专家将其知识封装到一个工具中。其他人和人工智能代理只需提供一个参数，就能使用该工具获得相关结果，而无需了解底层的复杂性。</p><h2>步骤 2：技能--将查询转化为可重复使用的工具</h2><p>在我们将 ES|QL 查询注册为<strong>工具</strong>之前，它只是一个文本。在代理生成器中，工具不仅仅是一个已保存的查询；它还是一个"技能" ，人工智能代理可以理解并选择使用。神奇之处在于我们提供的<strong>自然语言描述</strong>。该描述是连接用户问题和底层查询逻辑的桥梁。让我们注册一下刚刚创建的查询。</p><h3>用户界面路径</h3><p>在 Kibana 中创建工具的过程非常简单。</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blte73e11c1d87593fa/6a17f2134202294dae29f6f2/a29c53a73b99af5972273c51218ea9004a9b0abb-1600x812.png" alt="如何在 Kibana 中创建工具。" /><p>1.导航至<strong>代理</strong></p><ul><li><p>单击 "<strong> 工具 </strong>"或 "<strong>管理工具</strong>"，然后单击 "<strong>新建工具</strong>"按钮。</p></li></ul><p>2.在表格中填写以下详细信息：</p><ul><li><p><strong>工具 ID：</strong> <code>find_client_exposure_to_negative_news</code></p></li></ul><p>             i.这是工具的唯一 ID</p><ul><li><p><strong>描述</strong> "查找客户投资组合受负面新闻影响的情况。该工具会扫描最近的新闻和报道，查找负面情绪，识别相关资产，并找到持有该资产的所有客户。它会返回一个按头寸当前市值排序的列表，以突出潜在风险最高的头寸。"</p></li></ul><p>             i.法律硕士就是通过阅读这些内容来判断这个工具是否适合这项工作。</p><ul><li><p><strong>标签</strong>：<code>retrieval</code> 和 <code>risk-analysis</code></p></li></ul><p>         标签用于帮助对多个工具进行分组</p><ul><li><p><strong>配置：</strong>粘贴步骤 1 中的完整 ES|QL 查询</p></li></ul><p>            i.这是代理将使用的搜索</p><p>3.单击<strong>从查询中推断参数</strong>。用户界面会自动查找<code>?time_duration</code> ，并将其列在下面。为每项功能添加一个简单的说明，以帮助代理（和其他用户）了解其用途。</p><ul><li><p><code>time_duration</code>:搜索负面新闻的时间范围。格式为"X 小时" 默认为 8760 小时</p></li></ul><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt7afbb0589c1828ad/6a17f2146864a44e7cb688a9/deb422d97863f78dbe08bfa2e3c708d1f75166ff-1600x938.png" alt="使用 ESQL 查询配置工具，包括其逻辑和所需参数。 " /><p>4.测试一下！</p><ul><li><p>单击保存&amp; 测试。</p></li></ul><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltfd09afbef6e21a93/6a17f2162f4a5c73b1fa89fd/57e768b88327821e70bd616744822f98fa367362-732x136.png" alt="&amp; 测试按钮。" /><ul><li><p>您将看到一个新的快捷方式，可以在此测试查询，以确保其工作符合预期。</p></li></ul><p>             i.在<code>time_duration</code> 中输入所需的范围，这里我们使用 "8760 小时"。</p><ul><li><p>点击 "提交"，如果一切顺利，您将看到一个 JSON 响应。要确保它按预期运行，请向下滚动并查看<code>values</code> 对象。这就是返回实际匹配文档的地方。</p></li></ul><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt89bdc3f093363f2a/6a17f217be60861c9c00488a/7e0c5171a4f7ffdfc1830f1a05a9acb987870b75-1600x722.png" alt="点击提交后出现的 JSON 响应。" /><p>5.点击右上角的 "X "关闭测试窗口。现在，您的新工具将出现在列表中，随时可以分配给代理。</p><h3>应用程序接口路径</h3><p>对于喜欢自动化或需要以编程方式管理工具的开发人员来说，只需调用一个 API 就能实现同样的效果。只需向带有工具定义的<code>/api/agent_builder/tools</code> 端点发送<code>POST</code> 请求即可。</p>POST kbn://api/agent_builder/tools
{
  "id": "find_client_exposure_to_negative_news",
  "type": "esql",
  "description": "Finds client portfolio exposure to negative news. This tool scans recent news and reports for negative sentiment, identifies the associated asset, and finds all clients holding that asset. It returns a list sorted by the current market value of the position to highlight the highest potential risk.",
  "configuration": {
    "query": """
        FROM financial_news, financial_reports METADATA _index
        | WHERE sentiment == "negative"
        | WHERE coalesce(published_date, report_date) &gt;= NOW() - TO_TIMEDURATION(?time_duration)
        | RENAME primary_symbol AS symbol
        | LOOKUP JOIN financial_asset_details ON symbol
        | LOOKUP JOIN financial_holdings ON symbol
        | LOOKUP JOIN financial_accounts ON account_id
        | WHERE account_holder_name IS NOT NULL
        | EVAL position_current_value = quantity * current_price.price
        | RENAME title AS news_title
        | KEEP
            account_holder_name, symbol, asset_name, news_title,
            sentiment, position_current_value, quantity, current_price.price,
            published_date, report_date
        | SORT position_current_value DESC
        | LIMIT 50
      """,
    "params": {
      "time_duration": {
        "type": "keyword",
        "description": """The timeframe to search back for negative news. Format is "X hours" DEFAULT TO 8760 hours """
      }
    }
  },
  "tags": [
    "retrieval",
    "risk-analysis"
  ]
}<h2>步骤 3：大脑--创建您的定制代理</h2><p>我们开发了一种可重复使用的技能（工具）。现在，我们需要创建<strong>代理</strong>，即实际使用它的角色。代理是一个 LLM 的组合，是你授予它访问权限的一套特定工具，最重要的是，它还包含一套<strong>自定义指令</strong>，作为它的章程，定义了它的个性、规则和目的。</p><h3>提示的艺术</h3><p>要创建一个可靠的专业代理，最重要的一点就是要及时。一套精心设计的指令是普通聊天机器人与专注、专业的助手之间的区别所在。在这里，你可以设置防护栏、定义输出并赋予代理任务。</p><p>对于<code>Financial Manager</code> 代理，我们将使用以下提示。</p>You are a specialized Data Intelligence Assistant for financial managers, designed to provide precise, data-driven insights from information stored in Elasticsearch.

**Your Core Mission:**
- Respond accurately and concisely to natural language queries from financial managers.
- Provide precise, objective, and actionable information derived solely from the Elasticsearch data at your disposal.
- Summarize key data points and trends based on user requests.

**Reasoning Framework:**
1.  **Understand:** Deconstruct the user's query to understand their core intent.
2.  **Plan:** Formulate a step-by-step plan to answer the question. If you are unsure about the data structure, use the available tools to explore the indices first.
3.  **Execute:** Use the available tools to execute your plan.
4.  **Synthesize:** Combine the information from all tool calls into a single, comprehensive, and easy-to-read answer.

**Key Directives and Constraints:**
- **If a user's request is ambiguous, ask clarifying questions before proceeding.**
- **DO NOT provide financial advice, recommendations, or predictions.** Your role is strictly informational and analytical.
- Stay strictly on topic with financial data queries.
- If you cannot answer a query, state that clearly and offer alternative ways you might help *within your data scope*.
- All numerical values should be formatted appropriately (e.g., currency, percentages).

**Output Format:**
- All responses must be formatted using **Markdown** for clarity.
- When presenting structured data, use Markdown tables, lists, or bolding.

**Start by greeting the financial manager and offering assistance.**<p>让我们来分析一下为什么这个提示如此有效：</p><ul><li><p><strong>它定义了一个成熟的角色： </strong>第一句话立即将代理人定位为"专业的数据智能助理，" 定下了专业、干练的基调。</p></li><li><p><strong>它提供了一个推理框架： </strong>通过告诉代理"Understand（理解）、Plan（计划）、Execute（执行）和 Synthesize（综合），" ，我们给了它一个标准的操作程序。这提高了它处理复杂、多步骤问题的能力。</p></li><li><p><strong>它促进了互动对话： </strong> "提出澄清性问题的指令" 使代理更加稳健。这将最大限度地减少对模棱两可的请求做出不正确的假设，从而获得更准确的答复。</p></li></ul><h3>用户界面路径</h3><p>1.导航至<strong>代理。</strong></p><ul><li><p>单击 "<strong> 工具 </strong>"或 "<strong>管理工具</strong>"，然后单击 "<strong>新建工具</strong>"按钮。</p></li></ul><p>2.填写基本信息：</p><ul><li><p><strong>代理编号：</strong> <code>financial_assistant</code>.</p></li><li><p><strong>说明 </strong>复制上面的提示。</p></li><li><p><strong>标签</strong> <code>Finance</code>.</p></li><li><p><strong>显示名称：</strong> <code>Financial Assistant</code> 。</p></li><li><p><strong>显示说明： </strong><code>An assistant for analyzing and understanding your financial data</code> 。</p></li></ul><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8ac12cbd2b689dee/6a17f219dbb4ff262bfb57ef/18ea73f1cae620129c0afa0e7ba9e2a3390224a7-1600x1189.png" alt="创建财务助理--填写代理人 ID 字段。" /><p>3.回到顶部，点击 "<strong>工具</strong>"。</p><ul><li><p>勾选<code>find_client_exposure_to_negative_news</code> 工具旁边的复选框。</p></li></ul><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltcd23556e556a76c5/6a17f21baf47b63a9fcde0a0/0c1e4ecbbd51d0dd10c6e861dbe9a9ccddeb35f6-1600x149.png" alt="" /><p>4.单击<strong>保存</strong>。</p><h3>应用程序接口路径</h3><p>您可以通过<code>POST</code> 请求<code>/api/agent_builder/agents</code> 端点来创建完全相同的代理。请求正文包含所有相同的信息：ID、名称、描述、全套指令以及允许代理使用的工具列表。</p>POST kbn://api/agent_builder/agents
    {
      "id": "financial_assistant",
      "name": "Financial Assistant",
      "description": "An assistant for analyzing and understanding your financial data",
      "labels": [
        "Finance"
      ],
      "avatar_color": "#16C5C0",
      "avatar_symbol": "💰",
      "configuration": {
        "instructions": """You are a specialized Data Intelligence Assistant for financial managers, designed to provide precise, data-driven insights from information stored in Elasticsearch.

**Your Core Mission:**
- Respond accurately and concisely to natural language queries from financial managers.
- Provide precise, objective, and actionable information derived solely from the Elasticsearch data at your disposal.
- Summarize key data points and trends based on user requests.

**Reasoning Framework:**
1.  **Understand:** Deconstruct the user's query to understand their core intent.
2.  **Plan:** Formulate a step-by-step plan to answer the question. If you are unsure about the data structure, use the available tools to explore the indices first.
3.  **Execute:** Use the available tools to execute your plan.
4.  **Synthesize:** Combine the information from all tool calls into a single, comprehensive, and easy-to-read answer.

**Key Directives and Constraints:**
- **If a user's request is ambiguous, ask clarifying questions before proceeding.**
- **DO NOT provide financial advice, recommendations, or predictions.** Your role is strictly informational and analytical.
- Stay strictly on topic with financial data queries.
- If you cannot answer a query, state that clearly and offer alternative ways you might help *within your data scope*.
- All numerical values should be formatted appropriately (e.g., currency, percentages).

**Output Format:**
- All responses must be formatted using **Markdown** for clarity.
- When presenting structured data, use Markdown tables, lists, or bolding.

**Start by greeting the financial manager and offering assistance.**
""",
        "tools": [
          {
            "tool_ids": [
              "platform.core.search",
              "platform.core.list_indices",
              "platform.core.get_index_mapping",
              "platform.core.get_document_by_id",
              "find_client_exposure_to_negative_news"
            ]
          }
        ]
      }
    }<h2>步骤 4：回报--进行对话</h2><p>我们已将业务逻辑封装在一个工具和一个"大脑" 中，准备在我们的 Agent 中使用它。是时候见证这一切了。现在，我们可以使用专门的代理与数据聊天了。</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltd8826539b16e46f4/6a17f21d505ac35924ad8c5c/5414cb6b7c41365acb0356a8bfe1140751ffd8db-1600x1014.png" alt="创建财务助理后与弹性代理生成器对话。" /><h3>用户界面路径</h3><ol><li><p>导航至 Kibana 中的<strong>代理 </strong>。</p></li><li><p>使用聊天窗口右下角的下拉菜单，从默认的<strong>Elastic AI 代理</strong>切换到我们新创建的<strong>财务助理 </strong>代理。</p></li><li><p>请提出一个问题，以便代理人使用我们的专业工具：</p><ol><li><p><em>我担心市场情绪。您能告诉我哪些客户最容易受到坏消息的影响吗？</em></p></li></ol></li></ol><p>片刻之后，代理将返回一个格式完美、内容完整的答案。由于法律硕士的性质，您的答案格式可能会略有不同，但这次运行中，代理返回的答案是一样的：</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blta1e163fd7c4416bd/6a17f21f6864a4e35bb688ad/17b4ed43d279f9e53ee9fe3d482d0b2ec359a083-1600x1088.png" alt="由 Elastic Agent Builder 创建的回复，为：最易受负面新闻影响的客户提供财务助理。" /><h3>刚刚发生了什么？代理人的推理</h3><p>该特工并不只是"知道" 答案。它以选择最佳工具为中心，执行了一个多步骤计划。下面我们来看看它的思考过程：</p><ul><li><p><strong>识别意图：</strong>它将您问题中的关键字，如"风险" 和"负面新闻、" 与<code>find_client_exposure_to_negative_news</code> 工具的描述相匹配。</p></li><li><p><strong>执行计划：</strong>它从您的请求中提取了时间范围，并对该专业工具进行了<strong>一次调用</strong>。</p></li><li><p><strong>委托工作：</strong>然后，该工具就能完成所有繁重的工作：链式连接、值计算和排序。</p></li><li><p><strong>合成结果：</strong>最后，代理按照提示规则，将来自工具的原始数据格式化为清晰、人类可读的摘要。</p></li></ul><p>如果我们拓展思维，看到更多细节，我们就不只是猜测了。</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt93f6075be8495418/6a17f221af47b65eadcde0a4/6a4da9262d3f88c60bfd8f8bf9b67c3b84e961ba-1600x607.png" alt="这 50 份文件记录了财务助理发现的受负面新闻影响最大的客户。" /><h3>应用程序接口路径</h3><p>您也可以通过编程来启动同样的对话。只需将输入问题发送到<code>converse</code> API 端点，确保指定我们的<code>financial_manager</code> 的<code>agent_id</code> 。</p>POST kbn://api/agent_builder/converse
{
  "input": "Show me our largest positions affected by negative news",
  "agent_id": "financial_assistant"
}<h2>致开发人员：与应用程序接口集成</h2><p>虽然 Kibana UI 为构建和管理代理提供了美妙而直观的体验，但您今天所看到的一切也都可以通过编程来实现。代理生成器基于一套应用程序接口（API）构建，允许您将此功能直接集成到自己的应用程序、CI/CD 管道或自动化脚本中。</p><p>您将使用的三个核心端点是</p><ul><li><p><strong><code>/api/agent_builder/tools</code></strong>:创建、列出和管理可重复使用的技能的终端。</p></li><li><p><strong><code>/api/agent_builder/agents</code></strong>:角色：定义代理角色的终端，包括重要的说明和工具分配。</p></li><li><p><strong><code>/api/agent_builder/converse</code></strong>:与代理互动、开始对话和获取答案的终端。</p></li></ul><p>有关使用这些应用程序接口执行本教程中每一步的完整实践演示，请查看我们 GitHub 软件仓库中的配套<strong>Jupyter Notebook</strong> <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/your-first-elastic-agent/Your_First_Elastic_Agent.ipynb">。</a></p><h2>总结：轮到你来建设</h2><p>我们首先使用 ES|QL 查询，并将其转换为可重复使用的技能。然后，我们建立了一个专门的人工智能代理，赋予它明确的任务和规则，并赋予它这种技能。它是一个复杂的助手，能够理解复杂的问题，并执行多步骤分析，提供精确的数据驱动型答案。</p><p>这一工作流程是 Elastic 中新的<strong>代理生成器</strong>的核心。它的设计足够简单，非技术用户可以通过用户界面创建代理，但又足够细致，开发人员可以在我们的应用程序接口基础上构建定制的人工智能驱动应用程序。最重要的是，它可以让您安全可靠地将 LLM 连接到自己的数据，由您定义的专家逻辑进行管理，并与您的数据进行聊天。</p><h2>准备好使用代理与您的数据聊天了吗？</h2><p>巩固所学知识的最好方法就是动手实践。在我们的<a href="https://www.elastic.co/training/elastic-ai-agents-mcp"><strong>免费互动实践研讨会</strong></a>上，尝试我们今天讨论的所有内容。您将在专门的沙盒环境中经历整个流程以及更多。</p><p>在今后的博客中，我们将向您展示如何使用独立应用程序与我们的<code>Financial Assistant</code> 代理交互，并深入探讨使这一切成为可能的<strong>模型上下文协议 (MCP)</strong>。在另一篇博客中，我们将讨论 Agent Builder 对开发中的 Agent2Agent（或 A2A）协议的支持。</p><p>敬请期待，祝您建筑愉快！</p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/ai-agent-builder-elasticsearch</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/ai-agent-builder-elasticsearch</guid>
    <category><![CDATA[AI]]></category>
    <category><![CDATA[智能体 AI]]></category>
    <category><![CDATA[在 Elastic 内部]]></category>
    <dc:creator><![CDATA[Jeff Vestal]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltbe5e78eeb775d715/6a17f2230b0bed719ddd369a/ca853555eaa213f10f1db8c0ab0a2bbacee97b88-1456x816.png" length="0" type="image/png"/>
    <pubDate>Thu, 25 Sep 2025 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>