Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,7 +48,7 @@ def get_text_chunks(text:str) ->list:
|
|
48 |
|
49 |
def get_vectorstore(text_chunks : list) -> FAISS:
|
50 |
#model = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
|
51 |
-
model="
|
52 |
encode_kwargs = {
|
53 |
"normalize_embeddings": True
|
54 |
} # set True to compute cosine similarity
|
@@ -59,24 +59,18 @@ def get_vectorstore(text_chunks : list) -> FAISS:
|
|
59 |
return vectorstore
|
60 |
|
61 |
|
62 |
-
def get_conversation_chain(vectorstore):
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
callback_manager=callback_manager,
|
72 |
-
verbose=True,
|
73 |
-
n_ctx=n_ctx)
|
74 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
75 |
conversation_chain = ConversationalRetrievalChain.from_llm(
|
76 |
-
llm=llm,
|
77 |
-
retriever=vectorstore.as_retriever(),
|
78 |
-
memory=memory,
|
79 |
-
# retriever_kwargs={"k": 1},
|
80 |
)
|
81 |
return conversation_chain
|
82 |
|
|
|
48 |
|
49 |
def get_vectorstore(text_chunks : list) -> FAISS:
|
50 |
#model = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
|
51 |
+
model="intfloat/multilingual-e5-large"
|
52 |
encode_kwargs = {
|
53 |
"normalize_embeddings": True
|
54 |
} # set True to compute cosine similarity
|
|
|
59 |
return vectorstore
|
60 |
|
61 |
|
62 |
+
def get_conversation_chain(vectorstore:FAISS) -> ConversationalRetrievalChain:
|
63 |
+
# llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-0613")
|
64 |
+
llm = HuggingFaceHub(
|
65 |
+
#repo_id="mistralai/Mistral-7B-Instruct-v0.2",
|
66 |
+
repo_id="google/gemma-1.1-7b-it",
|
67 |
+
#repo_id="TheBloke/Mixtral-8x7B-Instruct-v0.1-GGUF"
|
68 |
+
model_kwargs={"temperature": 0.5, "max_length": 2048},
|
69 |
+
)
|
70 |
+
|
|
|
|
|
|
|
71 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
72 |
conversation_chain = ConversationalRetrievalChain.from_llm(
|
73 |
+
llm=llm, retriever=vectorstore.as_retriever(), memory=memory
|
|
|
|
|
|
|
74 |
)
|
75 |
return conversation_chain
|
76 |
|