DEV Community

Ankush Thakur
Ankush Thakur

Posted on

Making sense of PDFs with AI: Why we need both Sentence-BERT and FAISS

When I first started exploring question-answering on PDFs, one thing confused me:
๐Ÿ‘‰ Why do we use Sentence-BERT and FAISS together?
Canโ€™t FAISS just create embeddings on its own?

Hereโ€™s the simple breakdown ๐Ÿ‘‡

๐Ÿ”น Sentence-BERT

Itโ€™s a neural network model.

Converts text into embeddings (vectors of numbers).

These vectors capture the meaning of the text.

Example: โ€œdogโ€ and โ€œpuppyโ€ โ†’ end up with vectors close to each other.

๐Ÿ”น FAISS (Facebook AI Similarity Search)

It doesnโ€™t create embeddings.

Instead, itโ€™s an efficient search engine for vectors.

Given a query vector, it finds the nearest neighbors (most similar chunks of text) super fast.

๐Ÿ‘‰ Think of it like this:

Sentence-BERT = Translator (text โ†’ coordinates on a โ€œmap of meaningโ€)

FAISS = GPS (finds the closest points on that map in milliseconds)

๐Ÿ’ก Together, they make semantic search possible:

Sentence-BERT gives us the โ€œlanguage of meaningโ€ (embeddings)

FAISS makes searching through thousands or millions of embeddings lightning fast

Without Sentence-BERT โ†’ FAISS has nothing meaningful to compare.
Without FAISS โ†’ you can still compare embeddings, but itโ€™s painfully slow at scale.

Top comments (0)