danyaljj commited on
Commit
b7b4b63
1 Parent(s): 95c84ae

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Next word generator trained on questions. Receives partial questions and tries to predict the next word.
2
+ Example use:
3
+
4
+ ```python
5
+ from transformers import T5Config, T5ForConditionalGeneration, T5Tokenizer
6
+
7
+ model_name = "allenai/t5-small-next-word-generator-qoogle"
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("Which")
20
+ run_model("Which two")
21
+ run_model("Which two counties")
22
+ run_model("Which two counties are")
23
+ run_model("Which two counties are the")
24
+ run_model("Which two counties are the biggest")
25
+ run_model("Which two counties are the biggest economic")
26
+ run_model("Which two counties are the biggest economic powers")
27
+
28
+ ```
29
+ which should result in the following:
30
+ ```
31
+ ['one']
32
+ ['statements']
33
+ ['are']
34
+ ['in']
35
+ ['most']
36
+ ['in']
37
+ ['zones']
38
+ ['of']
39
+ ```
40
+