Elastic AI agent builder 介绍(三)

在这篇文章里,我将使用 gpt-oss 大模型来展示如何在 AI agent builder 中进行使用。有关 gpt-oss 的安装请参考文章 "如何使用 Ollama 在本地设置和运行 GPT-OSS"。我们需要按照这篇文章来安装我们的 gpt-oss。

细心的开发者,可能在之前的版本中运行如下的查询:

我们研究了一下原因。这个其实就我们在写入文档时,我们的 mapping 是这样定义的:

复制代码
PUT /people
{
  "mappings": {
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "text"
      },
      "description": {
        "type": "text",
        "copy_to": "des_semantic"
      },
      "des_semantic": {
        "type": "semantic_text"
      },
      "sex": {
        "type": "keyword"
      },
      "age": {
        "type": "integer"
      },
      "address": {
        "type": "text"
      },
      "location": {
        "type": "geo_point"
      }
    }
  }
}

很显然,des_semantic 在没有定义端点的情况下,默认的就是使用系数向量模型 ELSER。我们可以参考文章 "Elasticsearch:使用推理端点及语义搜索演示"。在目前的阶段,由于 ELSER 模型不支持中文,这也导致我们的查询得不到想要的结果。我们可以采用多语言模型。

我们使用如下的 API 来获得所有的 endpoints:

我们可以看到已经为我们定制好的 .multilingual-e5-small-elasticsearch id。我们可以重新定义我们的索引 mapping:

复制代码
DELETE people

PUT /people
{
  "mappings": {
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "text"
      },
      "description": {
        "type": "text",
        "copy_to": "des_semantic"
      },
      "des_semantic": {
        "type": "semantic_text",
        "inference_id": ".multilingual-e5-small-elasticsearch"
      },
      "sex": {
        "type": "keyword"
      },
      "age": {
        "type": "integer"
      },
      "address": {
        "type": "text"
      },
      "location": {
        "type": "geo_point"
      }
    }
  }
}

然后,我们再次写入文档:

复制代码
POST /_bulk
{ "index" : { "_index" : "people", "_id" : "1" } }
{ "id": 1, "name" : "John Doe", "description" : "A software developer", "sex" : "Male", "age" : 30, "address" : "123 Elm Street, Springfield", "location": {"lat": 37.7749, "lon": -122.4194} }
{ "index" : { "_index" : "people", "_id" : "2" } }
{ "id": 2, "name" : "Jane Smith", "description" : "A project manager", "sex" : "Female", "age" : 28, "address" : "456 Maple Avenue, Anytown", "location": {"lat": 40.7128, "lon": -74.0060} }
{ "index" : { "_index" : "people", "_id" : "3" } }
{ "id": 3, "name" : "Alice Johnson", "description" : "A graphic designer", "sex" : "Female", "age" : 26, "address" : "789 Oak Lane, Metropolis", "location": {"lat": 34.0522, "lon": -118.2437} }
{ "index" : { "_index" : "people", "_id" : "4" } }
{ "id": 4, "name" : "Bob Brown", "description" : "A marketing specialist", "sex" : "Male", "age" : 32, "address" : "321 Pine Street, Gotham", "location": {"lat": 41.8781, "lon": -87.6298} }
{ "index" : { "_index" : "people", "_id" : "5" } }
{ "id": 5, "name" : "Charlie Davis", "description" : "An IT analyst", "sex" : "Male", "age" : 29, "address" : "654 Cedar Blvd, Star City", "location": {"lat": 29.7604, "lon": -95.3698} }
{ "index" : { "_index" : "people", "_id" : "6" } }
{ "id": 6, "name" : "Diana Prince", "description" : "A diplomat", "sex" : "Female", "age" : 35, "address" : "987 Birch Road, Themyscira", "location": {"lat": 39.9526, "lon": -75.1652} }
{ "index" : { "_index" : "people", "_id" : "7" } }
{ "id": 7, "name" : "Evan Wright", "description" : "A journalist", "sex" : "Male", "age" : 27, "address" : "213 Willow Lane, Central City", "location": {"lat": 33.4484, "lon": -112.0740} }
{ "index" : { "_index" : "people", "_id" : "8" } }
{ "id": 8, "name" : "Fiona Gallagher", "description" : "A nurse", "sex" : "Female", "age" : 31, "address" : "546 Spruce Street, South Side", "location": {"lat": 32.7157, "lon": -117.1611} }
{ "index" : { "_index" : "people", "_id" : "9" } }
{ "id": 9, "name" : "George King", "description" : "A teacher", "sex" : "Male", "age" : 34, "address" : "879 Elm St, Smallville", "location": {"lat": 39.7392, "lon": -104.9903} }
{ "index" : { "_index" : "people", "_id" : "10" } }
{ "id": 10, "name" : "Helen Parr", "description" : "A full-time superhero", "sex" : "Female", "age": 37, "address" : "123 Metro Avenue, Metroville", "location": {"lat": 47.6062, "lon": -122.3321} }

我们再次重新查询:

很显然,这次我们得到我们想要的答案了。

最近我们 Elastic 公司收购了 JINA。JINA 支持多模态的嵌入模型,它同时也支持多语言模型。我们可以参考文章 "使用 Jina Embeddings v2 在 Elasticsearch 中进行后期分块" 来进行测试。

相关推荐
五度易链-区域产业数字化管理平台5 小时前
金融级数据治理+企业级架构管控:五度易链的数据治理方案与技术路径
大数据·人工智能·金融·架构
guygg885 小时前
结合VD算法与IMM算法的卡尔曼滤波机动目标跟踪方法
人工智能·算法·目标跟踪
f***24115 小时前
Anaconda加速AI模型训练全攻略
人工智能
AI工程化实验室5 小时前
Agent 工程化:当“能跑的 Demo”遇上“不敢交付的系统”
人工智能
bruce_哈哈哈5 小时前
ai-agent 一个强大的辅助工具
ai
算法&大模型备案-考拉5 小时前
全国算法、大模型备案 奖励补贴政策整理(2026年1月)
人工智能·aigc·大模型备案·算法备案·算法备案奖励政策·大模型备案奖励政策·大模型登记
三翼鸟数字化技术团队5 小时前
搭建自己的MCP服务器
运维·服务器·人工智能
song150265372985 小时前
车身颜色 外观性能测试设备-太阳光模拟器
大数据
齐鲁大虾5 小时前
2026高考生填报志愿是保专业还是保学校
大数据·人工智能
guoketg5 小时前
Vision Transformer(ViT)的讲解和面试题目讲解
人工智能·python·深度学习·vit