Carlosito16 commited on
Commit
9359dde
1 Parent(s): 5852e4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
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 Chroma
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
- db_chunk_500 = Chroma.from_documents(documents= chunked_text,
48
- embedding= embedding_model)
 
 
 
 
 
 
 
 
49
 
50
- print("load done")
 
 
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))