Understanding cosine similarity, Euclidean distance, and how machines find relevant text and images.
1. Why do we need semantic search?
Imagine you're building a search feature for your application.
A user searches:
How do I make my application faster?
Your database contains these articles:
How to optimize database queries
Improving API performance with caching
A beginner's guide to JavaScript arrays
How to bake a chocolate cake
Which articles should appear first?
Traditional keyword search looks for matching words. Since the first two articles don't contain the exact phrase "make my application faster," a basic keyword search might rank them poorly.
Semantic search takes a different approach: it searches for meaning, not just matching words.
It can recognize that "make my application faster," "optimize database queries," and "improve API performance" may describe related ideas.
To understand how semantic search works, we need three concepts:
Embeddings: Representing text or images asβ¦