Spaces:
Runtime error
Runtime error
LTW-1181203031
commited on
Commit
·
ddb7963
1
Parent(s):
ca01b05
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,14 @@
|
|
1 |
from haystack.document_stores.memory import InMemoryDocumentStore
|
2 |
from haystack.nodes import TfidfRetriever, FARMReader
|
3 |
-
import google.colab
|
4 |
-
google.colab.drive.mount('/content/drive')
|
5 |
|
6 |
import pickle
|
7 |
|
8 |
-
pickle_file = '
|
9 |
|
10 |
# Load the knowledge graph from the pickle file
|
11 |
with open(pickle_file, 'rb') as f:
|
12 |
knowledge_graph = pickle.load(f)
|
13 |
|
14 |
-
print("Knowledge graph loaded from ", pickle_file)
|
15 |
-
|
16 |
document_store = InMemoryDocumentStore()
|
17 |
node_sentences = {}
|
18 |
documents = []
|
@@ -47,9 +43,11 @@ document_store.write_documents(documents)
|
|
47 |
|
48 |
#Initialize the retriever
|
49 |
retriever = TfidfRetriever(document_store=document_store)
|
|
|
50 |
#Initialize the reader
|
51 |
model_name = "primasr/multilingualbert-for-eqa-finetuned"
|
52 |
reader = FARMReader(model_name_or_path=model_name, use_gpu=False)
|
|
|
53 |
#Create pipeline with the component of retriever and reader
|
54 |
from haystack.pipelines import Pipeline
|
55 |
pipeline = Pipeline()
|
@@ -96,11 +94,8 @@ def checkReiterateQuery(query,lang):
|
|
96 |
|
97 |
import gradio as gr
|
98 |
from langdetect import detect
|
99 |
-
import warnings
|
100 |
-
warnings.filterwarnings('ignore')
|
101 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
102 |
|
103 |
-
|
104 |
chat_history = []
|
105 |
answer_counter = 0
|
106 |
def chatbot_interface(message):
|
|
|
1 |
from haystack.document_stores.memory import InMemoryDocumentStore
|
2 |
from haystack.nodes import TfidfRetriever, FARMReader
|
|
|
|
|
3 |
|
4 |
import pickle
|
5 |
|
6 |
+
pickle_file = 'knowledge_graph.pickle'
|
7 |
|
8 |
# Load the knowledge graph from the pickle file
|
9 |
with open(pickle_file, 'rb') as f:
|
10 |
knowledge_graph = pickle.load(f)
|
11 |
|
|
|
|
|
12 |
document_store = InMemoryDocumentStore()
|
13 |
node_sentences = {}
|
14 |
documents = []
|
|
|
43 |
|
44 |
#Initialize the retriever
|
45 |
retriever = TfidfRetriever(document_store=document_store)
|
46 |
+
|
47 |
#Initialize the reader
|
48 |
model_name = "primasr/multilingualbert-for-eqa-finetuned"
|
49 |
reader = FARMReader(model_name_or_path=model_name, use_gpu=False)
|
50 |
+
|
51 |
#Create pipeline with the component of retriever and reader
|
52 |
from haystack.pipelines import Pipeline
|
53 |
pipeline = Pipeline()
|
|
|
94 |
|
95 |
import gradio as gr
|
96 |
from langdetect import detect
|
|
|
|
|
97 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
98 |
|
|
|
99 |
chat_history = []
|
100 |
answer_counter = 0
|
101 |
def chatbot_interface(message):
|