Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
A simple question-generation model, built based on SQuAD 2.0 dataset.
|
2 |
+
Example use:
|
3 |
+
|
4 |
+
```
|
5 |
+
from transformers import T5Config, T5ForConditionalGeneration, T5Tokenizer
|
6 |
+
|
7 |
+
model_name = "allenai/t5-small-squad2-question-generation"
|
8 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
9 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
10 |
+
|
11 |
+
def run_model(input_string, **generator_args):
|
12 |
+
input_ids = tokenizer.encode(input_string, return_tensors="pt")
|
13 |
+
res = model.generate(input_ids, **generator_args)
|
14 |
+
output = tokenizer.batch_decode(res, skip_special_tokens=True)
|
15 |
+
print(output)
|
16 |
+
return output
|
17 |
+
|
18 |
+
|
19 |
+
run_model("shrouds herself in white and walks penitentially disguised as brotherly love through factories and parliaments; offers help, but desires power;")
|
20 |
+
run_model("He thanked all fellow bloggers and organizations that showed support.")
|
21 |
+
run_model("Races are held between April and December at the Veliefendi Hippodrome near Bakerky, 15 km (9 miles) west of Istanbul.")
|
22 |
+
```
|
23 |
+
which should result in the following:
|
24 |
+
```
|
25 |
+
['What is the name of the man who is a brotherly love?']
|
26 |
+
['What did He thank all fellow bloggers and organizations that showed support?']
|
27 |
+
['Where is the Veliefendi Hippodrome located?']
|
28 |
+
```
|
29 |
+
|