Elasticsearch 开放推理 API 增加了对 IBM watsonx.ai Slate 嵌入模型的支持

作者:来自 Elastic Saikat Sarkar

使用 Elasticsearch 向量数据库构建搜索 AI 体验时如何使用 IBM watsonx™ Slate 文本嵌入。

Elastic 很高兴地宣布,通过集成 IBM watsonx™ Slate 嵌入模型,我们的开放推理 API 功能得以扩展,这标志着我们与 IBM watsonx 团队持续合作的一个重要里程碑。通过此公告,Elasticsearch 用户可立即、轻松地访问 IBM 的 Slate 系列模型,而 IBM watsonx 社区则可利用 Elasticsearch 全面的 AI 搜索工具和经过验证的向量数据库功能。

Elastic 的开放推理 API(open inference API) 现正式发布,它使你能够创建端点并使用来自 IBM watsonx™ 等提供商的机器学习模型。IBM® watsonx™ AI 和数据平台包括核心组件和 AI 助手,旨在使用可信数据扩展和加速 AI 的影响。该平台具有开源 Slate 嵌入模型(slate-125m、slate-30m),用于检索增强生成、语义搜索和文档比较,以及在可信企业数据上训练的Granite 系列 LLMs

在本博客中,我们将解释在使用 Elasticsearch 向量数据库构建 Search AI 体验时如何使用 IBM watsonx™ Slate 文本嵌入。Elastic 现在支持使用这些文本嵌入,新的 semantic_text 字段默认对传入文本进行分块,以适应平台模型的标记限制。

先决条件和推理端点的创建

你需要一个 IBM Cloud® Databases for Elasticsearch 部署。你可以通过目录Cloud Databases CLI 插件Cloud Databases APITerraform 来配置一个。成功设置帐户后,你应该会进入 IBM Cloud 主页。

然后,你可以使用 IBM Cloud 的托管服务模型配置 Kibana 实例,并按照以下步骤连接到 Databases for Elasticsearch 实例 -

  • 为你的 Elasticsearch 部署设置管理员密码
  • 安装 Docker 以提取 Kibana 容器映像并将其连接到 Databases for Elasticsearch。

或者,如果你不想在本地运行 Kibana 或安装 Docker,则可以使用 IBM Cloud® Code Engine 部署 Kibana。有关详细信息,请参阅有关使用 Code Engine 部署 Kibana 并将其连接到 Databases for Elasticsearch 实例的文档。

生成 API 密钥

  • 转到 IBM watsonx.ai 并使用你的凭据登录。你将进入欢迎页面。

Elasticsearch 中的步骤

使用 Kibana 中的 DevTools,使用 watsonxai 服务为 text_embedding 创建推理端点:

PUT _inference/text_embedding/ibm_watsonx_embedding
{
    "service": "watsonxai",
    "service_settings": {
        "api_key": "<api_key>",
        "url": "xxx.ml.cloud.ibm.com",
        "model_id": "ibm/slate-30m-english-rtrvr",
        "project_id": "<project_id>",
        "api_version": "2023-05-29"
    }
}

成功创建推理端点后,你将收到以下响应:

{
  "inference_id": "ibm_watsonx_embedding",
  "task_type": "text_embedding",
  "service": "watsonxai",
  "service_settings": {
    "model_id": "ibm/slate-30m-english-rtrvr",
    "project_id": "<project_id>",
    "url": "xxx.ml.cloud.ibm.com",
    "api_version": "2023-05-29",
    "dimensions": 384,
    "similarity": "dot_product",
    "rate_limit": {
      "requests_per_minute": 120
    }
  },
  "task_settings": {}
}

生成嵌入 - generate embeddings

下面是为单个字符串生成 text_embedding 的示例:

POST _inference/text_embedding/ibm_watsonx_embedding
{
     "input": "Embed this text"
}

你将收到以下嵌入响应:

{
  "text_embedding": [
    {
      "embedding": [
        0.009380317,
        0.05560313,
        ...,        
        0.03804972
      ]
    }
  ]
}

此外,我们来看一个 semantic_text 映射示例

创建一个包含 semantic_text 字段的索引:

PUT books
{
 "mappings": {
   "properties": {
     "title": {
       "type": "text"
     },
     "semantic_text": {
       "type": "semantic_text",
       "inference_id": "ibm_watsonx_embedding"
     },
     "description": {
       "type": "text",
       "copy_to": [
         "semantic_text"
       ]
     }
   }
 }
}

将一些文档插入到创建的索引中:

POST /books/_bulk
{ "index": {"_id": "1" }}
{ "title": "The Art of Coding", "description": "A comprehensive guide to coding best practices.", "price": 39.99 }
{ "index": { "_id": "2" } }
{ "title": "Mysteries of the Universe", "description": "Exploring the unknown aspects of our universe.", "price":
24.50 }
{ "index": {"_id": "3" } }
{ "title": "The Journey Within", "description": "A deep dive into personal development.", "price": 18.75 }
{ "index": {"_id": "4" } }
{ "title": "The richest man in babylon", "description": "The Richest Man in Babylon by George S. Clason is a classic book that offers timeless financial wisdom through a series of parables set in ancient Babylon, one of history's wealthiest cities. The book conveys its lessons through stories of Babylonian citizens who learn to achieve wealth, prosperity, and happiness by following basic financial principles. The central character, Arkad, who is the richest man in Babylon, shares his wisdom on wealth-building with friends and fellow citizens. He explains how he started as a poor scribe but grew rich by adhering to a set of practical rules, which are presented as the Seven Cures for a Lean Purse and the Five Laws of Gold. The Seven Cures for a Lean Purse emphasize essential steps for accumulating wealth: saving at least ten percent of earnings, controlling expenses to live below one's means, making wise investments, protecting investments from loss, owning a home, ensuring future income, and continually increasing the ability to earn. The Five Laws of Gold focus on key principles such as accumulating money through savings, investing wisely, seeking advice from experienced investors, avoiding investments in unfamiliar areas, and steering clear of get-rich-quick schemes. The book uses various characters like Bansir, a chariot maker, and Kobbi, a musician, to illustrate common financial challenges, and they seek Arkad's guidance to achieve financial security, learning the importance of discipline, thrift, and prudent investment. Other stories, such as those of Dabasir, who faces challenges repaying debts, and Rodan, who learns about wise lending, further reinforce these principles. The book emphasizes that wealth is not a matter of luck or fate but a result of adhering to sound financial practices and cultivating a mindset geared towards saving, investing, and learning continuously. Through its simple yet profound lessons, the book provides readers with practical advice on personal finance, helping them understand the value of money management, disciplined saving, and wise investment strategies to build and maintain wealth over time.", "price": 18.75 }

接下来,使用 semantic_text 运行查询:

GET books/_search
{
 "query": {
    "semantic" : {
       "field": "semantic_text",
       "query": "maintain wealth over time"
     }
 }
}

你将收到以下查询的响应:

{
  ...,
  "hits": {
    "max_score": 0.86763954,
    "hits": [
      {
        "_index": "books",
        "_id": "4",
        "_score": 0.86763954,
        "_source": {
          "semantic_text": {
            "inference": {
              "inference_id": "ibm_watsonx_embedding",
              "model_settings": {
                "task_type": "text_embedding",
                "dimensions": 384,
                "similarity": "dot_product",
                "element_type": "float"
              },
              "chunks": [
                {
                  "text": "The Richest Man in Babylon by George S. Clason is a classic book that offers timeless financial wisdom through a series of parables set in ancient Babylon, one of history's wealthiest cities. The book conveys its lessons through stories of Babylonian citizens who learn to achieve wealth, prosperity, and happiness by following basic financial principles. The central character, Arkad, who is the richest man in Babylon, shares his wisdom on wealth-building with friends and fellow citizens. He explains how he started as a poor scribe but grew rich by adhering to a set of practical rules, which are presented as the Seven Cures for a Lean Purse and the Five Laws of Gold. The Seven Cures for a Lean Purse emphasize essential steps for accumulating wealth: saving at least ten percent of earnings, controlling expenses to live below one's means, making wise investments, protecting investments from loss, owning a home, ensuring future income, and continually increasing the ability to earn. The Five Laws of Gold focus on key principles such as accumulating money through savings, investing wisely, seeking advice from experienced investors, avoiding investments in unfamiliar areas, and steering clear of get-rich-quick schemes. The book uses various characters like Bansir, a chariot maker, and Kobbi, a musician, to illustrate common financial challenges, and they seek Arkad's guidance to achieve financial security, learning the importance of discipline, thrift, and prudent investment. Other stories, such as those of Dabasir, who faces challenges repaying debts, and Rodan, who learns about",
                  "embeddings": [
                    -0.0012952854,
                    0.054616664,
                    ...
                  ]
                },
                {
                  "text": " home, ensuring future income, and continually increasing the ability to earn. The Five Laws of Gold focus on key principles such as accumulating money through savings, investing wisely, seeking advice from experienced investors, avoiding investments in unfamiliar areas, and steering clear of get-rich-quick schemes. The book uses various characters like Bansir, a chariot maker, and Kobbi, a musician, to illustrate common financial challenges, and they seek Arkad's guidance to achieve financial security, learning the importance of discipline, thrift, and prudent investment. Other stories, such as those of Dabasir, who faces challenges repaying debts, and Rodan, who learns about wise lending, further reinforce these principles. The book emphasizes that wealth is not a matter of luck or fate but a result of adhering to sound financial practices and cultivating a mindset geared towards saving, investing, and learning continuously. Through its simple yet profound lessons, the book provides readers with practical advice on personal finance, helping them understand the value of money management, disciplined saving, and wise investment strategies to build and maintain wealth over time.",
                  "embeddings": [
                    -0.025139397,
                    0.054932922,
                    0.09041961,
                    ...
                  ]
                }
              ]
            }
          },
          "price": 18.75,
          "description": "The Richest Man in Babylon by George S. Clason is a classic book that offers timeless financial wisdom through a series of parables set in ancient Babylon, one of history's wealthiest cities. The book conveys its lessons through stories of Babylonian citizens who learn to achieve wealth, prosperity, and happiness by following basic financial principles. The central character, Arkad, who is the richest man in Babylon, shares his wisdom on wealth-building with friends and fellow citizens. He explains how he started as a poor scribe but grew rich by adhering to a set of practical rules, which are presented as the Seven Cures for a Lean Purse and the Five Laws of Gold. The Seven Cures for a Lean Purse emphasize essential steps for accumulating wealth: saving at least ten percent of earnings, controlling expenses to live below one's means, making wise investments, protecting investments from loss, owning a home, ensuring future income, and continually increasing the ability to earn. The Five Laws of Gold focus on key principles such as accumulating money through savings, investing wisely, seeking advice from experienced investors, avoiding investments in unfamiliar areas, and steering clear of get-rich-quick schemes. The book uses various characters like Bansir, a chariot maker, and Kobbi, a musician, to illustrate common financial challenges, and they seek Arkad's guidance to achieve financial security, learning the importance of discipline, thrift, and prudent investment. Other stories, such as those of Dabasir, who faces challenges repaying debts, and Rodan, who learns about wise lending, further reinforce these principles. The book emphasizes that wealth is not a matter of luck or fate but a result of adhering to sound financial practices and cultivating a mindset geared towards saving, investing, and learning continuously. Through its simple yet profound lessons, the book provides readers with practical advice on personal finance, helping them understand the value of money management, disciplined saving, and wise investment strategies to build and maintain wealth over time.",
          "title": "The richest man in babylon"
        }
      },
      ...
    ]
  }
}

结论

通过集成 IBM watsonx™ 文本嵌入,Elasticsearch Open Inference API 继续为开发人员提供增强的功能,以构建强大而灵活的 AI 驱动搜索体验。探索 watsonx.ai 提供的更多受支持的编码器基础模型

Elasticsearch 与行业领先的 Gen AI 工具和提供商进行了原生集成。查看我们的网络研讨会,了解如何超越 RAG 基础知识,或构建可用于生产环境的应用程序 Elastic Vector Database

要为你的用例构建最佳搜索解决方案,请立即开始免费云试用或在你的本地机器上试用 Elastic。

原文:Elasticsearch open inference API adds support for IBM watsonx.ai Slate embedding models - Search Labs

相关推荐
深圳南柯电子几秒前
深圳南柯电子|电子设备EMC测试整改:常见问题与解决方案
人工智能
Kai HVZ1 分钟前
《OpenCV计算机视觉》--介绍及基础操作
人工智能·opencv·计算机视觉
biter00886 分钟前
opencv(15) OpenCV背景减除器(Background Subtractors)学习
人工智能·opencv·学习
吃个糖糖12 分钟前
35 Opencv 亚像素角点检测
人工智能·opencv·计算机视觉
Mr.131 小时前
数据库的三范式是什么?
数据库
Cachel wood1 小时前
python round四舍五入和decimal库精确四舍五入
java·linux·前端·数据库·vue.js·python·前端框架
IT古董1 小时前
【漫话机器学习系列】017.大O算法(Big-O Notation)
人工智能·机器学习
凯哥是个大帅比1 小时前
人工智能ACA(五)--深度学习基础
人工智能·深度学习
Python之栈1 小时前
【无标题】
数据库·python·mysql