Join the conversation

Join the community of Machine Learners and AI enthusiasts.

Sign Up
lucifertrj 
posted an update Jun 12
Post
2243
Advanced RAG - Hybrid Search using HuggingFace Models

Chat with PDF in 10 lines of code:

# pip install beyondllm
# pip install llama-index-embeddings-fastembed

from beyondllm import source,retrieve,embeddings,llms,generator
import os
from getpass import getpass
os.environ['HUGGINGFACE_ACCESS_TOKEN'] = getpass("Enter your HF API token:")

data = source.fit("sample.pdf", dtype="pdf")
embed_model = embeddings.FastEmbedEmbeddings()

retriever = auto_retriever(
    data=data, embed_model=embed_model,
    type="hybrid", top_k=5, mode="OR"
)

llm = HuggingFaceHubModel(model="mistralai/Mistral-7B-Instruct-v0.2")
pipeline = generator.Generate(question="<replace-with-your-query>",llm=llm,retriever=retriever)
print(pipeline.call())


Cookbook: https://github.com/aiplanethub/beyondllm/blob/main/cookbook/Implementing_Hybrid_Search.ipynb

Support the project by giving a ⭐️ to the repo
In this post