app1 / Retrieval.py
Sandaruth
multi query
fb208af
raw
history blame
812 Bytes
import logging
from model import llm, vectorstore, splitter, embedding, QA_PROMPT
# Chain for Web
from langchain.chains import RetrievalQA
bsic_chain = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever = vectorstore.as_retriever(search_kwargs={"k": 4}),
return_source_documents= True,
input_key="question",
chain_type_kwargs={"prompt": QA_PROMPT},
)
from MultiQueryRetriever import MultiQueryRetriever
retriever_from_llm = MultiQueryRetriever.from_llm(
retriever=vectorstore.as_retriever(search_kwargs={"k": 3}),
llm=llm,
)
multiQuery_chain = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever = retriever_from_llm,
return_source_documents= True,
input_key="question",
chain_type_kwargs={"prompt": QA_PROMPT},
)