From keywords to meaning
Traditional search matches words. Query "PLC programming" and a keyword index returns documents containing those exact terms — but misses a document about "programmable logic controller software" even though it is exactly what you wanted. Semantic search matches *meaning*: it represents both the query and the documents as vectors in a shared space and looks for the closest neighbours.
What an embedding is
An embedding is a fixed-length vector of numbers — typically 128 to 1536 dimensions — produced by a neural model that has learned that words and phrases with similar meanings sit close together. "PLC" and "programmable logic controller" are embedded near each other; "PLC" and "pizza" are far apart.
Modern embedding models are trained on enormous text corpora and can be run locally in the browser (via TensorFlow.js and similar) or on a server. Once documents are embedded, searching is pure linear algebra: embed the query, then compute similarity against every document vector.
Similarity and ranking
The most common similarity measure is cosine similarity: the cosine of the angle between two vectors, ranging from 1 (identical direction) to -1 (opposite). It ignores vector length, which makes it robust to document length differences.
Ranking by pure vector similarity has failure modes: rare technical abbreviations, numbers, and exact identifiers (register addresses, part numbers) embed poorly. "Port 502" or "0x40001" are strings a model may not have seen in context, and exact-match is what matters for them.
Hybrid retrieval in practice
Production systems therefore combine both signals:
- Keyword scoring catches exact terms, abbreviations, and identifiers with high precision.
- Vector scoring catches synonyms, paraphrases, and conceptual matches with high recall.
- A weighted blend ranks results, with the blend tuned per domain.
This hybrid pattern is what makes domain search robust: an engineer can search "Modbus TCP" and get both the exact-protocol entries and the conceptual "industrial Ethernet" context, while a search for a specific register address still finds the exact document.