Spaces:
Paused
Paused
Carlosito16
commited on
Commit
•
9359dde
1
Parent(s):
5852e4a
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,8 @@ import torch
|
|
5 |
from tqdm.auto import tqdm
|
6 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
7 |
|
8 |
-
|
9 |
-
from langchain.vectorstores import
|
10 |
from langchain.embeddings import HuggingFaceInstructEmbeddings
|
11 |
|
12 |
|
@@ -44,7 +44,16 @@ st.markdown(f"Number of chunked texts: {len(chunked_text)}")
|
|
44 |
embedding_model = HuggingFaceInstructEmbeddings(model_name='hkunlp/instructor-base',
|
45 |
model_kwargs = {'device': torch.device('cuda' if torch.cuda.is_available() else 'cpu')})
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
|
|
|
|
5 |
from tqdm.auto import tqdm
|
6 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
7 |
|
8 |
+
# from langchain.vectorstores import Chroma
|
9 |
+
from langchain.vectorstores import FAISS
|
10 |
from langchain.embeddings import HuggingFaceInstructEmbeddings
|
11 |
|
12 |
|
|
|
44 |
embedding_model = HuggingFaceInstructEmbeddings(model_name='hkunlp/instructor-base',
|
45 |
model_kwargs = {'device': torch.device('cuda' if torch.cuda.is_available() else 'cpu')})
|
46 |
|
47 |
+
vector_database = FAISS.load_local("faiss_index", embedding_model)
|
48 |
+
print("load done")
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
query_input = st.text_input(label= 'your question')
|
54 |
+
def retrieve_document(query_input):
|
55 |
+
related_doc = vector_database.similarity_search(query_input)
|
56 |
+
return related_doc
|
57 |
|
58 |
+
output = st.text_area(label = "Here is the relevant documents",
|
59 |
+
value = retrieve_document(query_input))
|