openai 嵌入相同的文本但返回不同的向量

问题描述 投票:0回答:2

我现在正在尝试 OpenAI Embedding API。但我发现了一个问题。当我一次又一次嵌入相同的文本时,我得到了不同的向量数组。

文字内容为

baby is crying
,型号为
text-embedding-ada-002(MODEL GENERATION: V2)
。我在
for
循环中运行代码 5 次,得到了不同的向量值。例如,第一个向量值为

"-0.017496677", "-0.017429505", "-0.017429505", "-0.017429505" and "-0.017496677"

我认为对于相同的文本内容,嵌入后应该返回相同的向量。是吗?

embedding openai-api
2个回答
0
投票
  • 相同输入(句子)的向量应该彼此相同(非常相似)

  • 如果不是,那么在从向量数据库中搜索相似上下文时,结果将不准确(正确)。

  • 我发现这非常有帮助,请阅读:Openai 讨论

  • 引自论坛:

Embeddings only return vectors. The vector is the same for the same input, same model, and the same API endpoint. But we have seen differences between the OpenAI endpoint and the Azure endpoint for the same model. So a pick an endpoint and stick with it to avoid any differences.

There could be very slight roundoff errors in the embedding when calling it over and over for the same (above) configuration, but this is in the noise and won’t effect your search result

0
投票

从这里开始

我们刚刚在使用时第一次遇到同样的问题 openai-python 包。

我们做了一些测试,其中大约 11% 有很大不同, 甚至在向量空间附近。

更新:对于面临此问题的任何人,嵌入的端点是 确定性的。造成这种差异的原因是 OpenAI 造成的 Python包,因为它使用base64作为默认编码格式, 而其他人则不然。

© www.soinside.com 2019 - 2024. All rights reserved.