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

devtools/2024/11/23 20:49:18/
aidu_pl">

作者:来自 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 API 或 Terraform 来配置一个。成功设置帐户后,你应该会进入 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 云并使用你的凭据登录。你将进入欢迎页面。

  • 转到 API 密钥页面。
  • 创建 API 密钥。

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


http://www.ppmy.cn/devtools/136379.html

相关文章

android general boot loader(rust安装后的build过程)

按照ahttps://cs.android.com/android/platform/superproject/main//main:bootable/libbootloader/gbl/的guide做android general boot loader下载以及build 注意事项&#xff1a; 1. bazel-bootstrap 安装参考 https://zhuanlan.zhihu.com/p/661422615 2. 根据实际情况确认…

自动语音识别(ASR)与文本转语音(TTS)技术的应用与发展

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

泛微E9与金蝶云星空的集成方案:实现审批流程与财务管理的无缝对接

泛微E9与金蝶云星空的集成方案&#xff1a;实现审批流程与财务管理的无缝对接 背景介绍&#xff1a; 在企业日常运营中&#xff0c;泛微OA-E9和金蝶云星空是两个关键的系统。泛微OA-E9是一款广受企业青睐的办公自动化软件&#xff0c;它通过流程管理、文档管理、协同办公等模…

如何利用Java爬虫获得1688店铺详情

在数字化时代&#xff0c;数据已成为企业决策的重要依据。对于电商平台而言&#xff0c;获取竞争对手的店铺详情对于市场分析、产品定位等具有重要意义。本文将详细介绍如何利用Java编写爬虫&#xff0c;获取1688店铺详情&#xff0c;并提供实际的代码示例。 1. 背景介绍 1688…

桥接模式 (Bridge Pattern)

桥接模式 (Bridge Pattern) 桥接模式是一种 结构型设计模式&#xff0c;用于将抽象部分与实现部分分离&#xff0c;使它们可以独立变化。它通过组合的方式取代继承&#xff0c;将不同维度的变化解耦&#xff0c;从而提高系统的灵活性。 原理 核心思想&#xff1a;将一个对象的…

大模型基本能力评测---知识利用

文章目录 闭卷问答开卷问答知识补全主要问题知识利用(Knowledge Utilization)能力对于大语言模型非常关键,它赋予了模型执行知识密集型任务的能力,如回答常识性问题或基于知识信息进行相关推理。为了充分发挥这一能力,大语言模型需要在预训练阶段学习到丰富的世界语义知识…

RHCE 函数与数组

第六章、函数和数组 6.1 函数 函数几乎是学习所有的程序设计语言时都必须过的一关。对于学习过其他的程序语言的用户来说&#xff0c;函数可能并不陌生。但是Shell中的函数与其他的程序设计语言的函数有许多不同之处。为了使用户了解Shell中的函数&#xff0c;本节将介绍函数…

【bug】python常见的错误以及解决办法

有人问&#xff0c;如果我学python那么肯定会遇见一些问题和故障bug&#xff0c;那么该怎么办&#xff0c;其实在Python编程中&#xff0c;遇到bug是家常便饭。这里我将列举几种常见的Python错误及其解决方案&#xff1a; 1. SyntaxError: invalid syntax 描述&#xff1a;当…