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 设计。

相关推荐
望江东浪9 小时前
我的 Claude Code 效率工具全套配置分享
大数据·elasticsearch·搜索引擎
Elasticsearch1 天前
如何使用 OpenTelemetry 在 Elastic 上构建搜索分析,无需额外的管道
elasticsearch
Elasticsearch1 天前
用于 Kubernetes 监测的常用 ES|QL 查询
elasticsearch
本旺1 天前
Elasticsearch 前缀匹配性能优化实战,附4种方式即执行计划判别
大数据·elasticsearch·性能优化
Elastic 中国社区官方博客2 天前
Elastic 在 Everest Group 企业搜索产品 PEAK Matrix® 评估 2026 中被评为领导者
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
Java小白笔记2 天前
Codex Skills 分类整理
大数据·人工智能·elasticsearch·搜索引擎·ai·ai编程·ai写作
Elastic 中国社区官方博客2 天前
谁来评判评判者?在 Elasticsearch Workflows 中使用 LLM-as-a-Judge
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
Elastic 中国社区官方博客2 天前
使用 Elasticsearch 作为 Grafana 的直接替代 Prometheus 后端
大数据·数据库·sql·elasticsearch·搜索引擎·grafana·prometheus
阿里云大数据AI技术3 天前
AI Search × ES Agent Builder 最佳实践:企业智能助手落地指南
人工智能·elasticsearch
利威尔·4 天前
常用git命令
大数据·elasticsearch·搜索引擎