An embedding is a list of numbers (a vector) that represents the meaning of a piece of text. Texts with similar meaning get vectors that point in similar directions, even if they share no words.
“How do I reset my password?” and “I forgot my login” have very similar embeddings. That's what makes embeddings so useful.
Getting an embedding
r = client.embeddings.create(model="bge-m3", input=["How do I reset my password?", "I forgot my login"])
a, b = r.data[0].embedding, r.data[1].embeddingComparing meaning: cosine similarity
import math
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
return dot / (math.sqrt(sum(x * x for x in a)) * math.sqrt(sum(y * y for y in b)))
print(cosine(a, b)) # close to 1 = very similarWhat you can build
- Semantic search: find help articles by meaning, not keywords.
- RAG (retrieval-augmented generation): find the relevant documents, then give them to a chat model so it answers from your data. See RAG with embeddings in Python.
- Deduplication: spot near-duplicate tickets or products.
- Clustering: group feedback into themes automatically.
- Recommendations: “articles similar to this one”.
Practical tips
- Embed once, store forever. Save vectors in a database (pgvector, SQLite with a vector extension, or a vector database) instead of recomputing.
- Chunk long documents into passages of a few hundred words before embedding.
- Use the same model for your documents and your queries; vectors from different models aren't comparable.
- Embeddings are cheap compared with chat; even large document sets usually cost little to index.
Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.