Vector Databases 1/5: Turning Data into Meaning
Learn the foundations of vectors, embeddings, similarity and semantic search through mathematics, everyday examples and comparisons with SQL.
Why data is more than rows and columns
A hotel catalogue can keep room counts, location and price in structured columns. But a traveller asking for a quiet weekend away from crowds may be interested in a property described as a secluded woodland retreat, even when none of the exact words match. A vector representation makes this type of relationship searchable through numerical similarity. It complements rather than replaces reliable structured records such as availability, price and location.
What a vector means mathematically
A vector is an ordered list of numbers. The two-dimensional vector (3, 4) has length 5. A text encoder may output hundreds of coordinates. These typically do not have individual labels such as peaceful or romantic: the representation distributes features across many coordinates. A two-dimensional illustration is a conceptual simplification. Store model identity, dimension and version; equal dimensions alone do not make vectors from different models compatible.
Embeddings encode context
An embedding model maps a raw input into numerical coordinates. Text is tokenized, contextualized and reduced to a fixed-size representation. A model trained for sentence similarity may put pet-friendly hotel and a place where I can stay with my dog near each other. Multilingual encoders can share a representation space across languages, but Turkish performance still needs evaluation. Similarity does not prove that a statement is factually true.
How similarity is calculated
Cosine similarity divides the dot product by the product of vector norms. For (1,0) and (0.8,0.6) it is 0.8; for orthogonal vectors it is zero. Euclidean distance measures straight-line separation, while dot product is sensitive to magnitude. On unit-normalized vectors cosine and dot product rank results identically. Check whether a database returns distance or similarity. A score of 0.8 is not an 80% probability of correctness.
SQL and vector search work together
SQL is excellent for exact constraints such as city, swimming pool availability and price. Vector retrieval ranks eligible candidates against a flexible intention such as a fun family holiday. The filter determines eligibility; the vector score determines semantic ordering within that scope. Keep authoritative price, access rights and availability in structured records. Join returned IDs back to that source and enforce permissions before presenting data.
Applications and misplaced expectations
Semantic product discovery, similar support tickets, skill discovery, article recommendations, image retrieval and internal knowledge search are promising uses. Anomaly detection may use neighbourhoods as one signal, not an automatic verdict. A vector database does not train neural networks, discover the internet or make unverified text true. Exact identifiers may be better served by a conventional index. Define which real queries fail today and why that failure matters.
A practical thought experiment
Consider three fictional properties: a quiet mountainside bungalow, a family water-park hotel and a city business hotel. For a secluded nature break we expect the first to rank highly, but that is a hypothesis, not a measured result. Test paraphrases, Turkish and English, then add structured filters. Label expected relevant records independently and compare the top three keyword and embedding results. Include misleading and incomplete descriptions to reveal failure modes.
Sources and all five chapters
This is part 1 of a five-part series. Start with the foundations or jump directly to another chapter. The links below lead to the other articles in the same series, followed by primary technical references. Code listings are educational examples; evaluate performance and model relevance in your own environment.
Reader discussion
Bu gelişmeyi kendi alanınızda uygulamadan önce hangi veriyi doğrulamak isterdiniz?
No comments yet. Be the first to contribute.
Write a comment