How you can Use Hybrid Seek for Higher LLM RAG Retrieval | by Dr. Leon Eversberg | Aug, 2024


Constructing a sophisticated native LLM RAG pipeline by combining dense embeddings with BM25

Code snippet from the hybrid search we’re going to implement on this article. Picture by writer

The essential Retrieval-Augmented Technology (RAG) pipeline makes use of an encoder mannequin to seek for comparable paperwork when given a question.

That is additionally referred to as semantic search as a result of the encoder transforms textual content right into a high-dimensional vector illustration (referred to as an embedding) during which semantically comparable texts are shut collectively.

Earlier than we had Massive Language Fashions (LLMs) to create these vector embeddings, the BM25 algorithm was a extremely popular search algorithm. BM25 focuses on necessary key phrases and appears for actual matches within the obtainable paperwork. This method is named key phrase search.

If you wish to take your RAG pipeline to the subsequent degree, you may wish to attempt hybrid search. Hybrid search combines the advantages of key phrase search and semantic search to enhance search high quality.

On this article, we’ll cowl the speculation and implement all three search approaches in Python.

Desk of Contents

· RAG Retrieval
Keyword Search With BM25
Semantic Search With Dense Embeddings
Semantic Search or Hybrid Search?
Hybrid Search
Putting It All Together
·…

Leave a Reply

Your email address will not be published. Required fields are marked *