Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,38 +7,30 @@ from langchain.vectorstores import Chroma
|
|
7 |
#from langchain.embeddings import OpenAIEmbeddings
|
8 |
#from langchain.llms import OpenAI
|
9 |
from langchain.chains import VectorDBQA
|
10 |
-
|
|
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
tokenizer_nlp = AutoTokenizer.from_pretrained("FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model")
|
16 |
model_nlp = AutoModelForQuestionAnswering.from_pretrained("FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model")
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
#url='https://huggingface.co/FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model/commit/1a9570af077d83fc8a728b0addf8a8bd276e2492'
|
21 |
# Load model directly
|
22 |
#model_name2 = "FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model"
|
23 |
#nlp = pipeline("question-answering", model=model_nlp, tokenizer=tokenizer2)
|
24 |
#nlp = pipeline("fill-mask", model="FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model")
|
25 |
|
26 |
-
|
27 |
-
persist_directory = 'https://drive.google.com/file/d/1U-isHky75OdYwt0UFjYsDAh4idVyixxM/view?usp=sharing'
|
28 |
|
29 |
embedding = HuggingFaceEmbeddings()
|
30 |
vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding)
|
31 |
-
|
32 |
# Now we can load the persisted database from disk, and use it as normal.
|
33 |
#vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding)
|
34 |
-
qa = VectorDBQA.from_chain_type(llm=OpenAI(temperature=0, model_name="gpt-3.5-turbo", openai_api_base=base_path), chain_type="stuff", vectorstore=vectordb)
|
35 |
|
36 |
context=qa.run(query)
|
37 |
-
|
38 |
-
context = ""
|
39 |
-
question = ""
|
40 |
-
|
41 |
-
|
42 |
#vectordb = Chroma.from_documents(documents=all_splits, embedding=embeddings, persist_directory="chroma_db")
|
43 |
|
44 |
retriever = vectordb.as_retriever()
|
|
|
7 |
#from langchain.embeddings import OpenAIEmbeddings
|
8 |
#from langchain.llms import OpenAI
|
9 |
from langchain.chains import VectorDBQA
|
10 |
+
from langchain.vectorstores import FAISS
|
11 |
+
from langchain.embeddings import HuggingFaceEmbeddings
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
tokenizer_nlp = AutoTokenizer.from_pretrained("FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model")
|
17 |
model_nlp = AutoModelForQuestionAnswering.from_pretrained("FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model")
|
|
|
|
|
|
|
18 |
#url='https://huggingface.co/FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model/commit/1a9570af077d83fc8a728b0addf8a8bd276e2492'
|
19 |
# Load model directly
|
20 |
#model_name2 = "FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model"
|
21 |
#nlp = pipeline("question-answering", model=model_nlp, tokenizer=tokenizer2)
|
22 |
#nlp = pipeline("fill-mask", model="FlavioBF/multi-qa-mpnet-base-dot-v1_fine_tuned_model")
|
23 |
|
24 |
+
persist_directory = 'https://drive.google.com/drive/folders/1jRoIBEzgT3-5Pk9eu9oWkbaUq7GxBAiV?usp=sharing'
|
25 |
+
#persist_directory = 'https://drive.google.com/file/d/1U-isHky75OdYwt0UFjYsDAh4idVyixxM/view?usp=sharing'
|
26 |
|
27 |
embedding = HuggingFaceEmbeddings()
|
28 |
vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding)
|
|
|
29 |
# Now we can load the persisted database from disk, and use it as normal.
|
30 |
#vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedding)
|
31 |
+
#qa = VectorDBQA.from_chain_type(llm=OpenAI(temperature=0, model_name="gpt-3.5-turbo", openai_api_base=base_path), chain_type="stuff", vectorstore=vectordb)
|
32 |
|
33 |
context=qa.run(query)
|
|
|
|
|
|
|
|
|
|
|
34 |
#vectordb = Chroma.from_documents(documents=all_splits, embedding=embeddings, persist_directory="chroma_db")
|
35 |
|
36 |
retriever = vectordb.as_retriever()
|