A classic search engine compares characters: if you type «open bakery», it only finds pages containing those exact words. Modern engines —the ones powered by language models— do something quite different: they turn your sentence into a point in a mathematical space and look for the nearest points. That is semantic search, a technology underpinning everything from AI assistants to chatbots that answer questions about documents. Behind it lie two pieces: embeddings and vector databases.
From text to coordinates: the embedding
An embedding is a list of numbers —typically between 384 and 1536 values— that captures the meaning of a piece of text. To produce one, a language model processes the sentence and returns a vector: a set of coordinates inside a space of hundreds or thousands of dimensions.
The process starts with tokenization: the text is split into tokens, word fragments a few dozen characters long. Each token becomes a starting vector that is augmented with positional information, then passes through the model’s attention layers —the transformer architecture popularized by models like GPT—. In every layer, each token “looks at” the other tokens in the sentence to capture context. At the end, the representations are pooled into a single vector that condenses the overall meaning.
The property that makes this space useful is proximity: sentences with similar meaning land close together. «My head hurts» and «I have a headache» produce nearly parallel vectors even though they share no words. That is why a semantic search returns results that do not contain your exact term.
Measuring closeness without measuring real distances
To tell whether two texts “are alike”, the usual approach is not a geometric distance but the cosine of the angle between their vectors (cosine similarity). When the vectors are normalized, that calculation equals the dot product, a very fast operation. To find the documents most similar to a query, you look for the vectors with the highest cosine similarity rather than the closest Euclidean distance.
The problem is scale. Comparing your query vector against billions of documents one by one —brute force— would take too long. This is where vector databases come in: they do not merely store the text, they index the vectors so the answer to “give me the ten most similar” arrives in milliseconds.
Indexes that do not look at everything: approximate search
Most of these engines rely on ANN (approximate nearest neighbor): they accept losing a little precision in exchange for speed. The most widespread technique is HNSW (Hierarchical Navigable Small World), which arranges the vectors in a multi-layer graph. The query enters at the top layer, where nodes are far apart, and works its way down jumping between close neighbors — like reading a general map before zooming into the street map of a neighborhood.
Other common strategies are IVF (inverted file index), which splits the space into regions and only searches the most promising ones, and product quantization, which compresses each vector so millions fit in RAM. Many systems combine vector search with a keyword search (like BM25) in what is called hybrid search, so they do not lose the exact terms a reader is deliberately looking for, and then reorder the results with a more precise reranker model.
Why it matters today
This technology sits behind retrieval-augmented generation (RAG): when a chatbot answers questions about your documents without having “memorized” them, it first retrieves the relevant fragments through vector search and passes them to the model as context. It also powers image search —where the embedding is produced by a multimodal model—, text deduplication, recommendation systems and plagiarism detection.
Choosing how many dimensions to use is a trade-off: longer vectors capture finer nuances but take up more memory and slow down the search. That is why the real engineering lies as much in training or fine-tuning the embedding model as in deciding the right index, metric and compression. The next time a search seems to “understand” what you meant, remember that your words turned into coordinates before finding an answer.






