AI / A CONCEPT NOTE

Embeddings

converting text into numerical vectors for semantic search

~75 sec read

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

  1. Input text

    'What is Kubernetes?' is sent to an embedding model API.

  2. Embedding model

    processes the text through its transformer layers and outputs a 1536-dimensional vector.

  3. Vector index

    the vector is stored in a vector DB (pgvector, Pinecone, Qdrant) alongside the original text.

  4. 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.

EXAMPLE 01 · REFERENCE

generate an embedding

curl -X POST -d '{"input":"What is Kubernetes?","model":"text-embedding-3-small"}' https://api.openai.com/v1/embeddings

EXAMPLE 02 · REFERENCE

generate embeddings locally

python -c "from sentence_transformers import SentenceTransformer; model = SentenceTransformer('all-MiniLM-L6-v2'); emb = model.encode('Hello world')"

Explore command anatomy in the CLI lab