AI Hints
Home›Generative AI Tutorial›Search by Meaning and RAG
Generative AI · Lesson 34 of 77

Search by Meaning

Embeddings in action.

⏱ 2 min read▶ Video at 1:19:38🎓 Free
Watch this lesson in the Generative AI courseWatch on YouTube ↗Full Generative AI course

Ordinary search matches words. Search by meaning matches ideas. If you type, how do I get my money back, a smart system should find the page titled, refund policy, even though they share no words. In this lesson, you will see how embeddings make that possible.

Search by Meaning
From the video: Search by Meaning
  • Keyword search matches words
  • Semantic search matches ideas
  • Embeddings make it possible

How semantic search works

Here is the method. First, turn every document into an embedding, a list of numbers that captures its meaning, and store them. Second, when a question arrives, turn the question into an embedding too. Third, find the stored embeddings that are closest to it. Fourth, return those documents. Closeness is measured with a simple score, called cosine similarity, where one means very similar, and zero means unrelated.

  1. Embed the documentsmeaning as numbers, stored once
  2. Embed the questionthe same way
  3. Find the closesthighest similarity score
  4. Return the matchesthe most relevant documents
Closest in meaning wins
How semantic search works
From the video: How semantic search works

Finding the nearest meaning

Picture the documents as points on the map of meaning. Your question lands somewhere on that map too. The system simply looks for the nearest points. Here, the question about getting money back, lands right next to the refund policy, and far away from the opening hours, and the shipping times. No shared words were needed. Only shared meaning.

Refund policy, Returns and exchangesclose together in meaning
Opening hoursclose together in meaning
Shipping timesclose together in meaning
Gift cardsclose together in meaning
Get my money back?close together in meaning
Finding the nearest meaning
From the video: Finding the nearest meaning

This technique appears everywhere. Company help centres, that find the right article. Online shops, that understand what you mean, not only what you type. Internal tools, that search thousands of documents. Customer support, that finds similar past tickets. And chatbots, that need to find facts, before answering. That last use is called retrieval augmented generation, and it is our next topic.

Help centresfind the right article
Online shopsunderstand intent
Internal searchacross thousands of documents
Similar ticketsreuse past solutions
Chatbotsfind facts before answering

Summary

Good. Semantic search turns documents and questions into embeddings, and finds the closest matches by meaning. It works even when the words are different. Next, we store those embeddings properly, with vector databases, and learn the art of cutting documents into chunks.

Key takeaways
  • Embed documents and questions
  • Closest embeddings = most relevant
  • Works without shared words
Next up: Vector Databases and Chunking — storing and cutting documents