Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

How to calculate embedding vectors using the OpenAI API for MongoDB vector search?

$
0
0

I am trying to follow the example from the official MongoDB documentation.

It mentioned that the search vector was based on the string "historical heist" using the OpenAI text-embedding-ada-002 model. However, when I tried to validate this with my own OpenAI API key, I got different results.

Why?

curl https://api.openai.com/v1/embeddings \  -H "Content-Type: application/json" \  -H "Authorization: Bearer sk-xxxxx" \  -d '{"input": "historical heist","model": "text-embedding-ada-002","encoding_format": "float"  }'

My results are the following:

"data": [     {108      "object": "embedding","index": 0,19      "embedding": [8        -0.02273331,97         -0.027646419,          0.0030520316, 3        -0.033631727,1        -0.026207773,4  0:00:01 --:-        0.0016854883,-:--  0:0        -0.017983066,0:0        0.006311038,1         -0.0013012275,201        -0.024823416,54        0.015227924,        0.005751188,        0.0004003777,        -0.008095773,

The example results are the following:

'queryVector': [-0.020156775, -0.024996493, 0.010778184, ....

Viewing all articles
Browse latest Browse all 271

Trending Articles