Elasticsearch:创建一个定制的 DeepSeek 嵌入推理端点

今天很高兴阅读了同事写的文章 "Elasticsearch 推理 API 增加了开放的可定制服务"。我马上就想到了如何把它应用到 DeepSeek 中。这是因为截止目前为止,我们还没有为 DeepSeek 做任何的推理端点 API 的创建。

创建 DeepSeek 服务

我们可以仿照之前的文章 "Elasticsearch:在 Elastic 中玩转 DeepSeek R1 来实现 RAG 应用"。我们使用 Ollama 来部署自己的 DeepSeek。等我们部署完毕后,我们可以通过如下的方式来检验我的安装是否成功:

从上面的输出中,我们可以看到我们的 DeepSeek 的部署是成功的。

通过 CURL 命令来测试我们的嵌入输出

我们在 terminal 中打入如下的命令:

arduino 复制代码
`

1.  curl http://localhost:11434/v1/embeddings \
2.    -H "Content-Type: application/json" \
3.    -H "Authorization: Bearer AnyKeyHere" \
4.    -d '{
5.      "model": "deepseek-r1:7b",
6.      "input": "This is a sentence to be embedded."
7.    }'| jq .

`AI写代码

我们可以看到如下的输出:

创建自己的嵌入端点

根据上面的输出,也参考我们的文章 "Elasticsearch 推理 API 增加了开放的可定制服务",我们设计出如下的 endpoint API:

swift 复制代码
`

1.  PUT _inference/text_embedding/inference_deepseek
2.  {
3.      "service": "custom",
4.      "service_settings": {
5.          "secret_parameters": {
6.             "api_key": "AnyKeyHere"
7.          },
8.          "url": "http://localhost:11434/v1/embeddings",
9.          "headers": {
10.              "Authorization": "Bearer ${api_key}",
11.              "Content-Type": "application/json"
12.          },
13.          "request": "{ \"model\": \"deepseek-r1:7b\",\"input\": ${input}}",
14.          "response": {
15.              "json_parser": {
16.                  "text_embeddings": "$.data[*].embedding[*]"
17.              }
18.          },
19.          "input_type": {
20.              "translation": {
21.                  "search": "query",
22.                  "ingest": "passage"
23.              },
24.              "default": "query"
25.          }
26.      }
27.  }

`AI写代码![](https://csdnimg.cn/release/blogv2/dist/pc/img/runCode/icon-arrowwhite.png)

运行完上面命令后,我们可以使用如下的命令来进行检验:

bash 复制代码
`

1.  POST _inference/text_embedding/inference_deepseek
2.  {
3.      "input": ["What is Elastic"]
4.  }

`AI写代码

这样我们就完成了我们的 DeepSeek 嵌入模型的 endpoint 设计。

相关推荐
Elastic 中国社区官方博客8 小时前
Elasticsearch:安装自行管理的 Elastic Stack 集群
大数据·运维·服务器·数据库·elasticsearch·搜索引擎·全文检索
Elastic 中国社区官方博客15 小时前
Observability:当 YAML 遇上 IConfiguration:OpenTelemetry .NET SDK 的声明式配置
大数据·开发语言·elasticsearch·搜索引擎·全文检索·.net
Elasticsearch17 小时前
控制告警如何触发、恢复和发送通知:Elastic 可观测性中的 Kibana 通用告警
elasticsearch
你看我名字18 小时前
ELK 日志分析平台:Filebeat、Logstash、Elasticsearch 与 Kibana 实战
大数据·elk·elasticsearch
大大大大晴天️18 小时前
每天认识一个组件:Elasticsearch
大数据·elasticsearch
墨神谕19 小时前
Elasticsearch 倒排索引底层原理详解:从 Term Dictionary、FST 到海量数据性能优化
大数据·elasticsearch·搜索引擎
jonyleek1 天前
JVS数字底座私有化部署实践:Spring Cloud + K8S 实现文档平台开箱即用
elasticsearch·kubernetes·私有化部署·springcloud·minio·jvs企业文档·文档治理
ClouGence2 天前
开源数据库管理工具 CloudDM 新版本上线,新增 AI SQL 助手,支持 Elasticsearch、崖山数据库
数据库·sql·elasticsearch
csdn2015_2 天前
git 合并分支
大数据·git·elasticsearch