GENERATIVE AI • LESSON 7

Keyword Search vs Semantic Search

This is an important concept because it explains why embeddings are useful.

The simplest difference is:

Keyword Search looks for matching words. Semantic Search looks for matching meaning.
01

Keyword Search

Keyword search tries to find documents containing the same words as the user's search.

For example, the user searches:

"How to learn Python?"

A keyword search looks for words like:

  • learn
  • Python

If a document says:

"Learn Python programming from beginner to advanced."

That's a strong keyword match.

02

Semantic Search

Semantic search focuses on meaning rather than exact words.

User: "How can I start coding with Python?" ↓ Embedding ↓ Query Vector ↓ Similarity Search ↓ "Beginner's guide to programming using Python."

The wording is different, but the meaning is similar.

03

Side-by-Side Example

Let's say your database contains:

Document A:
"How to reset your password"

Document B:
"How to update your email address"

Document C:
"Recover access to your account after forgetting credentials"

User searches:

"I forgot my password. How can I get back into my account?"

Keyword Search

It looks for:

  • forgot
  • password
  • account

It may rank Document A highly because of "password".

Semantic Search

It looks at the meaning:

"I forgot my password" ↓ "Recover access to your account"

Document C may be highly relevant even though it doesn't use the exact phrase "forgot my password".

WHOLE IDEA

Keyword Search looks for matching words. Semantic Search looks for matching meaning.