Elasticsearch 开放推理 API 增加了 Azure AI Studio 支持

作者:来自 Elastic Mark Hoy

Elasticsearch 开放推理 API 现已支持 Azure AI Studio。在此博客中了解如何将 Azure AI Studio 功能与 Elasticsearch 结合使用。

作为我们持续致力于为 Microsoft Azure 开发人员提供他们选择的工具的一部分,我们很高兴地宣布,Elasticsearch 现在将 Microsoft Azure AI Studio 上的托管模型目录集成到我们的开放推理 API 中。这补充了开发人员将其 Elasticsearch 向量数据库用于 Azure OpenAI 的能力

开发人员可以使用世界上下载次数最多的向量数据库的功能来存储和利用从 Azure AI Studio 的 OpenAI 模型生成的嵌入,或访问各种聊天完成模型部署,以快速访问 mistral-small 等对话模型。

就在最近,我们增加了对 Azure OpenAI 文本嵌入完成的支持,现在我们又增加了对使用 Azure AI Studio 的支持。Microsoft Azure 开发人员可以完全访问 Azure OpenAI 和 Microsoft Azure AI Studio 服务功能,并可以使用他们的 Elasticsearch 数据彻底改变对话搜索

让我们带你了解如何轻松地在 Elasticsearch 中使用这些功能。

在 Azure AI Studio 中部署模型

首先,你需要订阅 Microsoft Azure 以及访问 Azure AI Studio。设置完成后,你需要从 Azure AI Studio 模型目录中部署文本嵌入模型或聊天完成模型。部署模型后,请在部署概览页面上记下目标 URL 和部署的 API 密钥 - 你稍后需要这些信息在 Elasticsearch 中创建推理端点。

此外,当你部署模型时,Azure 提供两种不同类型的部署选项 - "pay as you go - 随用随付"模型(按代币付费)和 "实时" 部署,后者是按小时计费的专用 VM。并非所有模型都提供这两种部署类型,因此请务必记下所使用的部署类型。

在 Elasticsearch 中创建推理 API 端点

部署模型后,我们现在可以在 Elasticsearch 中为你的推理任务创建一个端点。对于以下示例,我们使用 Cohere Command R 模型来执行聊天完成。

在 Elasticsearch 中,通过提供服务作为 "azureaistudio" 以及服务设置(包括你部署的模型中的 API 密钥和目标)来创建端点。你还需要提供模型提供程序以及之前的端点类型("token" 或 "realtime")。在我们的示例中,我们部署了一个具有 token 类型端点的 Cohere 模型。

PUT _inference/completion/test_cohere_chat_completion
{
  "service": "azureaistudio",
  "service_settings": {
    "api_key": "<<API_KEY>>",
    "target": "<<TARGET_URL>>",
    "provider": "cohere",
    "endpoint_type": "token"
  }
}

当你向 Elasticsearch 发送命令时,它应该返回创建的模型以确认命令已成功。请注意,API 密钥永远不会返回,并且存储在 Elasticsearch 的安全设置中。

{
    "model_id": "test_cohere_chat_completion",
    "task_type": "completion",
    "service": "azureaistudio",
    "service_settings": {
        "target": "<<TARGET_URL>>",
        "provider": "cohere",
        "endpoint_type": "token"
    },
    "task_settings": {}
}

添加使用文本嵌入的模型同样简单。作为参考,如果我们已经部署了 Cohere-embed-v3-english 模型,我们可以通过从该部署的概述页面提供适当的 API 密钥和目标 URL,使用 "text_embeddings" 任务类型在 Elasticsearch 中创建我们的推理模型:

PUT _inference/text_embeddings/test_cohere_embeddings
{
  "service": "azureaistudio",
  "service_settings": {
    "api_key": "<<API_KEY>>",
    "target": "<<TARGET_URL>>",
    "provider": "cohere",
    "endpoint_type": "token"
  }
}

让我们进行一些推理

这就是设置模型的全部内容。现在一切都已完成,我们可以使用该模型了。首先,让我们通过要求模型在给出简单提示的情况下提供一些文本来测试该模型。为此,我们将使用输入文本调用 _inference API:

POST _inference/completion/test_cohere_chat_completion
{
  "input": "The answer to the universe is"
}

我们应该看到 Elasticsearch 提供响应。在后台,Elasticsearch 使用输入文本调用 Azure AI Studio 并处理推理结果。在本例中,我们收到了响应:

{
    "completion": [
        {
            "result": "42. \n\nIn Douglas Adams' *The Hitchhiker's Guide to the Galaxy*, a super-computer named Deep Thought is asked what the answer to the ultimate question of life, the universe, and everything is. After calculating for 7.5-million years, Deep Thought announces that the answer is 42. \n\nThe number 42 has since become a reference to the novel, and many fans of the book series speculate as to what the actual question might be."
        }
    ]
}

我们试图让最终用户轻松地不必处理幕后的所有技术细节,但我们也可以通过提供额外的参数来控制处理,例如采样温度和请求生成的最大令牌数,从而更好地控制我们的推理:

POST _inference/completion/test_cohere_chat_completion
{
  "input": "The answer to the universe is",
  "task_settings": {
    "temperature": 1.0,
    "do_sample": true,
    "max_new_tokens": 50
  }
}

这很简单。我们还能做什么?

当我们能够以其他方式使用我们的新模型时,这会变得更加强大,例如在 Elasticsearch 提取管道中使用时向文档添加其他文本。例如,以下管道定义将使用我们的模型,并且每当提取使用此管道的文档时,字段 "question_field" 中的任何文本都将通过 inference API 发送,并且响应将写入文档中的 "completed_text_answer" 字段。这允许扩充大量文档。

PUT _ingest/pipeline/azure_ai_studio_cohere_completions
{
  "processors": [
    {
      "inference": {
        "model_id": "test_cohere_chat_completion", 
        "input_output": { 
          "input_field": "question_field",
          "output_field": "completed_text_answer"
        }
      }
    }
  ]
}

无限可能

通过在 Elasticsearch 推理管道中利用 Azure AI Studio 部署模型的强大功能,你可以增强搜索体验的自然语言处理和预测分析功能。

在即将推出的 Elasticsearch 版本中,用户可以利用新的字段映射类型,进一步简化流程,不再需要设计提取管道。此外,正如我们在语义搜索加速路线图中提到的那样,未来将在查询时使用 Elasticsearch 检索器为推理任务提供显着简化的支持。

这些功能可通过 Elastic Cloud 上serverless 产品中的开放 inference API 获得。它还将在即将发布的 Elasticsearch 版本中向所有人提供。

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

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

原文:Elasticsearch open inference API adds Azure AI Studio support - Elasticsearch Labs

相关推荐
Quz5 分钟前
OpenCV:特征检测总结
图像处理·人工智能·opencv·计算机视觉
用心把天空锁住12 分钟前
从零开始:OpenCV 图像处理快速入门教程
图像处理·人工智能·opencv·计算机视觉
J不A秃V头A15 分钟前
SQL精度丢失:CAST(ce.fund / 100 AS DECIMAL(10, 2)) 得到 99999999.99
数据库·sql·oracle
SeaTunnel27 分钟前
Apache SeaTunnel 整体架构运行原理
大数据
工业甲酰苯胺38 分钟前
Redis 事务和 “锁机制”——> 并发秒杀处理的详细说明
数据库·redis·bootstrap
WHYBIGDATA1 小时前
Hive之数据操作DML
大数据·hive·hadoop
wybshyy1 小时前
WebApi使用 (.Net Framework版)
数据库·.net
菠萝咕噜肉i1 小时前
Maven
java·数据库·maven
Snow_Dragon_L1 小时前
【MySQL】语言连接
android·数据库·后端·sql·mysql·ubuntu·adb
云上的阿七1 小时前
Elasticsearch集群模式保姆级教程
大数据·elasticsearch