Why does it find "car" when I searched "automobile"?
Semantic search: embeddings and cosine similarity · Beginner · 5 min · embeddings, rag · after Embeddings
Semantic search turns the query and every document into embeddings, lists of numbers whose direction follows meaning, and returns the documents pointing closest to the query (cosine similarity), even when they share no word with it.
1 Guess first
2 Look
Search by meaning
1 / 4keyword search: notes that contain a word of “automobile”
No note contains that word.
search by meaning: the three closest notes
- My car won’t start in the cold.0.29
- Automatic door repair service0.23
- Best tyres for a family hatchback0.16
measured with all-MiniLM-L6-v2 (384 numbers per text) · cosine similarity · 2026-10-23
No note says “automobile”. Keywords find nothing; meaning finds the car.
Turn the query and every note into a point; the search returns the nearest points, whatever words they use.
This is semantic search. An embedding model turns each note into 384 numbers once, ahead of time. Your query gets its own 384 numbers, and the search compares directions: cosine similarity, 1 for the same direction, near 0 for unrelated. “Automobile” and “car” appear in the same company in text, so their directions agree.
4 You are the model
You are the search. For four queries, pick the note that points closest to the query: the one all-MiniLM-L6-v2 ranks first.
you are the search · pick the note that points closest to the query
Search: “feline”
measured with all-MiniLM-L6-v2 (384 numbers per text) · cosine similarity · 2026-10-23
You are the search. Which note points closest?5 Check
Two habits for real apps. Set a minimum score, so “nothing close” can be an answer. And keep a keyword search too: embeddings blur exact things like error codes, names and “not”. Many search tools mix both (hybrid search). In RAG, the nearest passages are what gets pasted into the prompt.
7 Say it back
8 Mission · 5 min
Copy the free key on Jina’s embeddings page (no card) and embed four texts in one request with "normalized": true: “automobile”, “My car won’t start”, “Automatic door repair”, “Mobile phone deals”. With normalized vectors, cosine is a plain dot product (SUMPRODUCT in a spreadsheet). Does the car note win without sharing a word?
Three quick ones
Drawn at random from this lesson's pool; different next time.
Done?
Go deeper
Sources
- Cosine similarities measured with sentence-transformers/all-MiniLM-L6-v2 (https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2: 384 dimensions, mean pooling, normalised) on 2026-10-23 by scripts/explain-data/semantic-search.ts (plain forward pass, no torch), which reproduces the published example below exactly
- https://sbert.net/docs/sentence_transformer/usage/semantic_textual_similarity.html (checked 2026-10-23): all-MiniLM-L6-v2 on “The weather is lovely today.”, “It’s so sunny outside!”, “He drove to the stadium.” gives 0.6660, 0.1046, 0.1411
- Scores used (query → note): automobile → car 0.288, automatic door 0.233, tyres 0.162, phone deals 0.116, cat on the sofa −0.080; feline → kitten 0.312, cat 0.271; my vehicle broke down → car 0.387, door 0.256, bicycle 0.217; airplane tickets → flights 0.343, phone deals 0.303; quantum physics homework → pasta 0.132 (best of nine)
- Pairs: “I love this car.” / “I do not love this car.” 0.775; “Flights from London to Paris” / “Flights from Paris to London” 0.997; “Error code E-4012” / “Error code E-4013” 0.908
- The nine notes and five queries were written for the lesson. The 2-D map is the first two principal components of their 14 embeddings, scaled to 5–95; nearest notes and scores use all 384 numbers
- https://jina.ai/embeddings/ (checked 2026-10-23): new users get an auto-generated API key with free tokens; free keys 100 RPM and 100K TPM; endpoint https://api.jina.ai/v1/embeddings, jina-embeddings-v5-text-small recommended for text; aifree.dev catalog jina-ai-free-api-tokens (verified 2026-10-12): 10M tokens per new API key, no card
Published Oct 23, 2026 · updated Oct 23, 2026