File size: 862 Bytes
2ffda8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 langchain.retrievers.multi_query import MultiQueryRetriever
# from kk 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},
)