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

embedded/2024/11/26 11:23:11/
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/embedded/140606.html

相关文章

MySql:库和表的操作

✨✨作者主页&#xff1a;嶔某✨✨ ✨✨所属专栏&#xff1a;MySql✨✨ 库的操作 创建数据库 CREATE DATABASE [IF NOT EXISTS] db_name [create_specification [, create_specification] ...] create_specification: [DEFAULT] CHARACTER SET charset_name [DEFAULT] COLLA…

GCN分类预测 | 基于图卷积神经网络GCN多特征分类预测(多输入单输出) Matlab代码

基于图卷积神经网络GCN多特征分类预测(多输入单输出) Matlab代码 目录 基于图卷积神经网络GCN多特征分类预测(多输入单输出) Matlab代码分类效果基本描述程序设计参考资料 分类效果 基本描述 基于图卷积神经网络GCN多特征分类预测(多输入单输出) Matlab代码 图卷积神经网络可以…

优选算法:长度最小的子数组(滑动窗口)

题目详情&#xff1a;. - 力扣&#xff08;LeetCode&#xff09; 一. 题目解析 题意为&#xff1a;给一个数组&#xff0c;找其中元素相加>目标值的最小子数组&#xff08;子数组是连续的&#xff09; 二. 算法分析 首先我们第一次看到这个题&#xff0c;第一想法肯定是暴…

Unity3D 截图

使用 Unity3D 自带的截图接口&#xff0c;制作截图工具。 截图 有时候我们想对 Unity 的窗口进行截图&#xff0c;如果直接使用一些截图工具&#xff0c;很难截取到一张完整分辨率的图片&#xff08;例如&#xff0c;我们想要截取一张 1920 * 1080 的图片&#xff09;。 其实…

Spring 框架七大模块(Java EE 学习笔记03)

​ ​核心容器模块&#xff08;Core Container&#xff09; 核心容器模块在Spring的功能体系中起着支撑性作用&#xff0c;是其他模块的基石。核心容器层主要由Beans模块、Core模块、Contex模块和SpEL模块组成。 &#xff08;1&#xff09;Beans模块。它提供了BeanFactory类&…

微信小程序点击跳转打电话功能

wx.makePhoneCall 属性类型默认值必填说明phoneNumberstring是需要拨打的电话号码successfunction否接口调用成功的回调函数failfunction否接口调用失败的回调函数completefunction否接口调用结束的回调函数&#xff08;调用成功、失败都会执行&#xff09; <view class&q…

【C++11】尽显锋芒

(续) 一、可变参数模板 C11支持可变参数模板&#xff0c;也就是说支持可变数量参数的函数模板和类模板&#xff0c;可变数目的参数被称 为参数包&#xff0c;存在两种参数包&#xff1a;模板参数包&#xff0c;表示零或多个模板参数&#xff1b;函数参数包&#xff1a;表示零…

HTML5和CSS3新增特性

HTML5的新特性 HTML5新增的语义化标签 HTML5 的新增特性主要是针对于以前的不足&#xff0c;增加了一些新的标签、新的表单和新的表单属性等。 这些新特性都有兼容性问题&#xff0c;基本是 IE9 以上版本的浏览器才支持&#xff0c;如果不考虑兼容性问题&#xff0c;可以大量…