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

相关推荐
SelectDB技术团队20 分钟前
Agent Trace 数据底座建设:宽表建模、全文检索与成本聚合的配置与验证步骤
大数据·python·clickhouse·elk·elasticsearch·全文检索·复杂查询
Zhu75829 分钟前
快速测试-ZLMediaKit
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客1 小时前
使用 NVIDIA cuVS 在 Elasticsearch 中实现 GPU 加速的向量索引:在 10 分钟内处理 1.38 亿个向量
大数据·数据库·elasticsearch·搜索引擎·全文检索·安全威胁分析
liuhl091013 小时前
【无标题】
大数据·elasticsearch·搜索引擎
xbgRS15 小时前
Elasticsearch的查询
elasticsearch
Elasticsearch18 小时前
使用 Lucene 搜索你的 Bean —— Highlighting
elasticsearch
Elasticsearch18 小时前
使用 Lucene 搜索你的 Bean —— Elasticsearch
elasticsearch
Elasticsearch1 天前
最好的 LLM 只有 59% 的时间能写出正确的 Elasticsearch ES|QL。以下是另外 41% 出错的原因
elasticsearch
垚垚学技术_聚焦云原生1 天前
Ansible Role 生产环境标准目录结构与规范化实践
java·elasticsearch·ansible
小林ixn1 天前
从 MySQL 的 LIKE 到 ES 倒排索引:一次把全文检索和混合检索讲透
sql·elasticsearch·全文检索·agent·关键词