An embedding is a vector, a list of numbers that a model produces from a piece of content. The model places similar meanings close together in that space, so the distance between two vectors stands in for similarity of meaning. A typical text model returns a few hundred to a few thousand numbers per input.
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "How do I reset my password?"}'
# -> {"data": [{"embedding": [0.021, -0.043, 0.017, ...]}]}
For search, you embed each document once at write time and store the vector. You embed the query the same way, then return the closest document vectors. Wording no longer has to match, so a query about resetting a password can retrieve "recover account access". Keep the original text beside each vector, because the search hands back ids and scores, and your app needs the text itself.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓