Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import time
|
|
8 |
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
|
9 |
import torch
|
10 |
|
11 |
-
retriever = load_the_embedding_retrieve(is_ready=
|
12 |
bm25_retriever = load_the_bm25_retrieve(k=3)
|
13 |
|
14 |
ensemble_retriever = EnsembleRetriever(
|
@@ -20,13 +20,13 @@ model = AutoModelForQuestionAnswering.from_pretrained("ShynBui/vie_qa", token=os
|
|
20 |
|
21 |
headers = {
|
22 |
"Accept": "application/json",
|
23 |
-
"Authorization": "Bearer "+ os.environ.get("HF_TOKEN"),
|
24 |
"Content-Type": "application/json"
|
25 |
}
|
26 |
|
27 |
|
28 |
def query(payload):
|
29 |
-
response = requests.post(API_URL, headers=headers, json=payload)
|
30 |
return response.json()
|
31 |
|
32 |
|
@@ -62,6 +62,7 @@ def greet(quote):
|
|
62 |
answers.append(output['answer'])
|
63 |
return answers
|
64 |
|
|
|
65 |
def greet2(quote):
|
66 |
answers = []
|
67 |
docs = ensemble_retriever.get_relevant_documents(quote)
|
@@ -86,7 +87,7 @@ def greet2(quote):
|
|
86 |
|
87 |
|
88 |
if __name__ == "__main__":
|
89 |
-
|
90 |
|
91 |
iface = gr.Interface(fn=greet2, inputs="text", outputs="text")
|
92 |
iface.launch()
|
|
|
8 |
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
|
9 |
import torch
|
10 |
|
11 |
+
retriever = load_the_embedding_retrieve(is_ready=False, k=3)
|
12 |
bm25_retriever = load_the_bm25_retrieve(k=3)
|
13 |
|
14 |
ensemble_retriever = EnsembleRetriever(
|
|
|
20 |
|
21 |
headers = {
|
22 |
"Accept": "application/json",
|
23 |
+
"Authorization": "Bearer " + os.environ.get("HF_TOKEN"),
|
24 |
"Content-Type": "application/json"
|
25 |
}
|
26 |
|
27 |
|
28 |
def query(payload):
|
29 |
+
response = requests.post(os.environ.get("API_URL"), headers=headers, json=payload)
|
30 |
return response.json()
|
31 |
|
32 |
|
|
|
62 |
answers.append(output['answer'])
|
63 |
return answers
|
64 |
|
65 |
+
|
66 |
def greet2(quote):
|
67 |
answers = []
|
68 |
docs = ensemble_retriever.get_relevant_documents(quote)
|
|
|
87 |
|
88 |
|
89 |
if __name__ == "__main__":
|
90 |
+
quote = "Địa chỉ nhà trường?"
|
91 |
|
92 |
iface = gr.Interface(fn=greet2, inputs="text", outputs="text")
|
93 |
iface.launch()
|