Spaces:
Running
Running
First attempt at asking questions
Browse files
app.py
CHANGED
@@ -10,5 +10,19 @@ doc_dir = './article_txt_got'
|
|
10 |
document_store = InMemoryDocumentStore()
|
11 |
docs = convert_files_to_docs(dir_path=doc_dir, clean_func=clean_wiki_text, split_paragraphs=True)
|
12 |
|
|
|
|
|
|
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
document_store = InMemoryDocumentStore()
|
11 |
docs = convert_files_to_docs(dir_path=doc_dir, clean_func=clean_wiki_text, split_paragraphs=True)
|
12 |
|
13 |
+
document_store.write_documents(docs)
|
14 |
+
retriever = TfidfRetriever(document_store=document_store)
|
15 |
+
reader = FARMReader(model_name_or_path="deepset/roberta-base-squad2", use_gpu=True)
|
16 |
|
17 |
+
pipeline = ExtractiveQAPipeline(reader, retriever)
|
18 |
+
|
19 |
+
def ask_question(question):
|
20 |
+
prediction = pipeline.run(query=question, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}})
|
21 |
+
st.write(prediction)
|
22 |
+
|
23 |
+
st.write(docs[1])
|
24 |
+
|
25 |
+
question = st.text_input(label="Ask a Question about Game of Thromes", value="Who is Arya's father?")
|
26 |
+
|
27 |
+
if question:
|
28 |
+
ask_question(question)
|