What is cosine similarity in AI search?
Quick answer
Cosine similarity is a score for how alike two pieces of text are in meaning, worked out from their embeddings. It measures the angle between two lists of numbers: the closer they point the same way, the higher the score. Vector databases use it to rank which stored chunks best match a question.
Last updated
Take the free module →Module 15 of the free AI for Customer Support course, about 14 minutes. No account needed.
Updated · By Robert Breen
Why it matters for a small business
When an AI helpdesk answers from your handbook, it first turns the question into an embedding, a long list of numbers, and compares it with the embedding of every stored chunk. Cosine similarity is one common way to do that comparison. A score near 1 means the two texts point in almost the same direction, which in practice means they talk about the same thing, even when the words differ.
You rarely calculate it yourself, but you do meet it as a setting. Pinecone asks you to pick a metric when you create an index, and cosine is the usual choice for text. OpenAI's documentation recommends cosine similarity for its embedding models. Knowing what the score means also helps you read match scores in a bot's logs: high scores are strong matches, low ones are noise the bot should leave out.
In a real lesson: Make Your Handbook Searchable for an AI Helpdesk using Pinecone + n8n
In Make Your Handbook Searchable, you create a Pinecone index called stepthrough-tests and pick OpenAI's text-embedding-3-small. The lesson points out that Metric is already set to cosine, which is right, and then fixes the real trap: Dimension says 512, but n8n sends 1536 numbers per chunk, so you change it to 1536.
That metric is what the chatbot in the next lesson relies on. When a Cedar Ridge employee asks about vacation days, Pinecone compares the question's embedding with all 38 handbook chunks using cosine similarity and hands back the closest ones. The explainer How AI Answers from Your Documents shows the same idea as match scores: a 0.89 chunk with the price goes to the AI, a 0.38 chunk about office hours stays out. That lesson doesn't name the metric, but the score plays the same role.

Try this lesson free or read the step-by-step guide.
Common confusions
Cosine similarity vs keyword match
A keyword match needs the same words. Cosine similarity compares meaning, so "time off" can match a chunk about "paid leave".
Cosine similarity vs confidence
A high score means the chunk is close to the question, not that the final answer is correct. The AI can still misread a good chunk.
Tips
- Leave the metric on cosine for text unless your embedding model's documentation says otherwise.
- Check that the index dimension matches the embedding model, or searches fail or return nothing useful.
- Look at match scores in the logs when a bot answers badly: weak scores usually mean the answer isn't in your files.
Related terms
More AI basics terms
Where you use it: free lessons
- Make Your Handbook Searchable for an AI Helpdesk using Pinecone + n8n (n8n, 14 min)
- How AI Answers from Your Documents: Retrieval (RAG) Explained (Stepthrough, 7 min)
Frequently asked questions
- What is a good cosine similarity score?
- There is no fixed cut-off. Scores depend on the embedding model and your documents, so compare strong and weak matches on your own data before you set a threshold.
- Can I change the metric after creating a Pinecone index?
- Plan on creating a new index if you need a different metric, then loading your documents into it again. Pick it carefully at the start.
- Is cosine distance the same thing?
- They are two sides of one idea. Cosine distance is usually 1 minus cosine similarity, so a smaller distance means a closer match.