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 中国社区官方博客19 小时前
更少的位数,相同的召回率:DiskBBQ 更保守的自动校准扫描
大数据·运维·开发语言·人工智能·elasticsearch·搜索引擎
Elasticsearch21 小时前
Kibana 中的人工智能连接器:你的 agent 可调用的 90 多个数据源
elasticsearch
Elasticsearch2 天前
更少的位数,相同的召回率:DiskBBQ 更保守的自动校准扫描
elasticsearch
瑞克-桑切斯3 天前
docker Harbor 单机部署手册
大数据·运维·elasticsearch·docker·容器
Elasticsearch5 天前
对 OpenTelemetry Kafka 接收器的两项改动,避免一个缓慢的租户拖住其他租户
elasticsearch
全栈陈序员6 天前
Git】从入门到精通(八)—— git log:查看提交历史
大数据·git·elasticsearch
Percep_gan6 天前
Linux中安装gitea,很详细
linux·elasticsearch·gitea
木棉软糖7 天前
5 步确认 TiDB 历史抽数的 Logstash 有没有真的写进 ES
elasticsearch·oracle·tidb
全栈陈序员7 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
Elasticsearch7 天前
Elasticsearch:稠密向量字段类型
elasticsearch