Spaces:
Runtime error
Runtime error
Christian Koch
commited on
Commit
·
3b42afc
1
Parent(s):
cd3659c
delete old file
Browse files- question_generator.py +0 -76
question_generator.py
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
import gdown as gdown
|
4 |
-
import nltk
|
5 |
-
import streamlit as st
|
6 |
-
import torch
|
7 |
-
from transformers import AutoTokenizer
|
8 |
-
|
9 |
-
from mt5 import MT5
|
10 |
-
|
11 |
-
|
12 |
-
# elif task == 'Question Answering':
|
13 |
-
#
|
14 |
-
# # Input area
|
15 |
-
# inputs = st.text_area('Context:', value="A few years after the First Crusade, in 1107, the Normans under "
|
16 |
-
# "the command of Bohemond, Robert\'s son, landed in Valona and "
|
17 |
-
# "besieged Dyrrachium using the most sophisticated military "
|
18 |
-
# "equipment of the time, but to no avail. Meanwhile, they occupied "
|
19 |
-
# "Petrela, the citadel of Mili at the banks of the river Deabolis, "
|
20 |
-
# "Gllavenica (Ballsh), Kanina and Jericho. This time, "
|
21 |
-
# "the Albanians sided with the Normans, dissatisfied by the heavy "
|
22 |
-
# "taxes the Byzantines had imposed upon them. With their help, "
|
23 |
-
# "the Normans secured the Arbanon passes and opened their way to "
|
24 |
-
# "Dibra. The lack of supplies, disease and Byzantine resistance "
|
25 |
-
# "forced Bohemond to retreat from his campaign and sign a peace "
|
26 |
-
# "treaty with the Byzantines in the city of Deabolis. ", max_chars=2048,
|
27 |
-
# height=250)
|
28 |
-
# question = st.text_input('Question:', value="What forced Bohemond to retreat from his campaign? ")
|
29 |
-
#
|
30 |
-
# # Prediction
|
31 |
-
# with st.spinner('Please wait while the inputs are being processed...'):
|
32 |
-
# predictions = model.qa([{'question': question, 'context': inputs}], max_length=512)
|
33 |
-
# answer = {question: predictions[0]}
|
34 |
-
#
|
35 |
-
# # Answer area
|
36 |
-
# st.write(answer)
|
37 |
-
#
|
38 |
-
# elif task == 'Question Generation':
|
39 |
-
#
|
40 |
-
# # Input area
|
41 |
-
# inputs = st.text_area('Context (highlight answers with <hl> tokens): ',
|
42 |
-
# value="A few years after the First Crusade, in <hl> 1107 <hl>, the <hl> Normans <hl> under "
|
43 |
-
# "the command of <hl> Bohemond <hl>, Robert\'s son, landed in Valona and "
|
44 |
-
# "besieged Dyrrachium using the most sophisticated military "
|
45 |
-
# "equipment of the time, but to no avail. Meanwhile, they occupied "
|
46 |
-
# "Petrela, <hl> the citadel of Mili <hl> at the banks of the river Deabolis, "
|
47 |
-
# "Gllavenica (Ballsh), Kanina and Jericho. This time, "
|
48 |
-
# "the Albanians sided with the Normans, dissatisfied by the heavy "
|
49 |
-
# "taxes the Byzantines had imposed upon them. With their help, "
|
50 |
-
# "the Normans secured the Arbanon passes and opened their way to "
|
51 |
-
# "Dibra. The <hl> lack of supplies, disease and Byzantine resistance <hl> "
|
52 |
-
# "forced Bohemond to retreat from his campaign and sign a peace "
|
53 |
-
# "treaty with the Byzantines in the city of Deabolis. ", max_chars=2048,
|
54 |
-
# height=250)
|
55 |
-
#
|
56 |
-
# # Split by highlights
|
57 |
-
# hl_index = [i for i in range(len(inputs)) if inputs.startswith('<hl>', i)]
|
58 |
-
# contexts = []
|
59 |
-
# answers = []
|
60 |
-
#
|
61 |
-
# # Build a context for each highlight pair
|
62 |
-
# for i in range(0, len(hl_index), 2):
|
63 |
-
# contexts.append(inputs[:hl_index[i]].replace('<hl>', '') +
|
64 |
-
# inputs[hl_index[i]: hl_index[i + 1] + 4] +
|
65 |
-
# inputs[hl_index[i + 1] + 4:].replace('<hl>', ''))
|
66 |
-
# answers.append(inputs[hl_index[i]: hl_index[i + 1] + 4].replace('<hl>', '').strip())
|
67 |
-
#
|
68 |
-
# # Prediction
|
69 |
-
# with st.spinner('Please wait while the inputs are being processed...'):
|
70 |
-
# predictions = model.qg(contexts, max_length=512)
|
71 |
-
#
|
72 |
-
# # Answer area
|
73 |
-
# content = {}
|
74 |
-
# for pred, ans in zip(predictions, answers):
|
75 |
-
# content[pred] = ans
|
76 |
-
# st.write(content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|