AI / A CONCEPT NOTE
Embeddings
converting text into numerical vectors for semantic search
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
An embedding model converts text — a word, sentence, or document — into a fixed-length array of floating-point numbers (e.g., 1536 dimensions for text-embedding-3-small). The key property: semantically similar texts produce vectors that are close together in vector space (high cosine similarity). This is the foundation of RAG, semantic search, and clustering.
02 / FOLLOW THE MECHANISM
How embeddings are created and used
Input text
'What is Kubernetes?' is sent to an embedding model API.
Embedding model
processes the text through its transformer layers and outputs a 1536-dimensional vector.
Vector index
the vector is stored in a vector DB (pgvector, Pinecone, Qdrant) alongside the original text.
Semantic search
a query is embedded with the same model. The vector DB returns the nearest neighbors by cosine distance.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
generate an embedding
curl -X POST -d '{"input":"What is Kubernetes?","model":"text-embedding-3-small"}' https://api.openai.com/v1/embeddingsgenerate embeddings locally
python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('all-MiniLM-L6-v2'); emb = model.encode('Hello world')"05 / CHECK YOURSELF
Could you explain Embeddings to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in AI engineeringGuardrailspreventing LLMs from producing harmful, unsafe, or off-brand output