ThomasFfefefef commited on
Commit
7bf1aae
1 Parent(s): bdde52f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +40 -0
README.md CHANGED
@@ -25,6 +25,46 @@ This model is a fine-tuned version of [t5-base](https://huggingface.co/t5-base)
25
  It achieves the following results on the evaluation set:
26
  - Loss: 1.5691
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ## Model description
29
 
30
  More information needed
 
25
  It achieves the following results on the evaluation set:
26
  - Loss: 1.5691
27
 
28
+ ## Use the Model
29
+ ```
30
+ from transformers import T5ForConditionalGeneration, T5TokenizerFast
31
+
32
+ hfmodel = T5ForConditionalGeneration.from_pretrained("ThomasSimonini/t5-end2end-question-generation")
33
+
34
+ text= "The abolition of feudal privileges by the National Constituent Assembly on 4 August 1789 and the Declaration \
35
+ of the Rights of Man and of the Citizen (La Déclaration des Droits de l'Homme et du Citoyen), drafted by Lafayette \
36
+ with the help of Thomas Jefferson and adopted on 26 August, paved the way to a Constitutional Monarchy \
37
+ (4 September 1791 – 21 September 1792). Despite these dramatic changes, life at the court continued, while the situation \
38
+ in Paris was becoming critical because of bread shortages in September. On 5 October 1789, a crowd from Paris descended upon Versailles \
39
+ and forced the royal family to move to the Tuileries Palace in Paris, where they lived under a form of house arrest under \
40
+ the watch of Lafayette's Garde Nationale, while the Comte de Provence and his wife were allowed to reside in the \
41
+ Petit Luxembourg, where they remained until they went into exile on 20 June 1791."
42
+
43
+ def run_model(input_string, **generator_args):
44
+ generator_args = {
45
+ "max_length": 256,
46
+ "num_beams": 4,
47
+ "length_penalty": 1.5,
48
+ "no_repeat_ngram_size": 3,
49
+ "early_stopping": True,
50
+ }
51
+ input_string = "generate questions: " + input_string + " </s>"
52
+ input_ids = tokenizer.encode(input_string, return_tensors="pt")
53
+ res = hfmodel.generate(input_ids, **generator_args)
54
+ output = tokenizer.batch_decode(res, skip_special_tokens=True)
55
+ output = [item.split("<sep>") for item in output]
56
+ return output
57
+
58
+ run_model(text)
59
+
60
+ => [['When did the National Constituent Assembly abolish feudal privileges?',
61
+ ' Who drafted the Declaration of the Rights of Man and of the Citizen?',
62
+ ' When was the Constitutional Monarchy established?',
63
+ ' What was the name of the Declaration that paved the way to a constitutional monarchy?',
64
+ '']]
65
+
66
+ ```
67
+
68
  ## Model description
69
 
70
  More information needed