Text to Vectors
To use text with math, you first have to turn it into numbers. Converting text into a vector — an embedding — is the essential first step for semantic search, RAG, and similarity comparisons. This is how a sentence becomes a fixed list of numbers that captures its meaning, ready to be compared with any other text.
💡 In one line: Text-to-vector conversion runs text through an embedding model to produce a single fixed-length vector that represents its meaning.
The Goal
Take a piece of text — a word, sentence, or paragraph — and produce one fixed-length vector of numbers that represents its meaning. That single vector is what everything downstream (search, clustering, RAG) works with.
How Text Becomes a Vector
The conversion runs through a short pipeline.
The model produces a representation for each token, then pools them (e.g. averaging, or using a special summary token) into a single vector for the whole text.
What the Vector Looks Like
The result is a list of floating-point numbers of fixed length — for example a 384-dimensional vector:
[0.021, -0.187, 0.043, 0.256, -0.099, ... ]Each dimension is a learned feature. The individual numbers aren't human-readable, but the whole vector encodes the text's meaning.
Fixed Length, Regardless of Input
A single word and a whole paragraph both map to a vector of the same dimension. This uniformity is what lets you compare any two texts directly.
Token Embeddings vs. Text Embeddings
- Token embeddings — one vector per token (the input layer inside an LLM).
- Text embeddings — those token vectors pooled into one vector for the whole text.
For search and similarity, we use the text embedding — the single pooled vector.
Use the Same Model for Everything
Vectors are only comparable if they come from the same embedding model. Different models produce different, incompatible spaces — so embed everything you plan to compare with one model.
Code Example
Practical Notes
- Batch-encode many texts at once for speed.
- Normalise vectors if you'll compare them with cosine similarity.
- Store vectors in a vector database for fast search at scale.
Summary
- Text-to-vector conversion produces a single fixed-length embedding for a piece of text.
- The pipeline is tokenize → embedding model → pool → vector.
- The vector is a list of floats where each dimension is a learned feature.
- Any text — word or paragraph — maps to the same dimension, enabling direct comparison.
- Always use the same model, and store vectors in a vector database for search. EOF echo created