nielsr HF staff commited on
Commit
437e415
1 Parent(s): 1915e0e

First draft of model card

Browse files
Files changed (1) hide show
  1. README.md +104 -0
README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ datasets:
5
+ - drop
6
+ ---
7
+
8
+ # NT5, a T5 model trained to perform numerical reasoning
9
+
10
+ T5-small model pre-trained on and fine-tuned on DROP. It was introduced in the paper [NT5?! Training T5 to Perform Numerical Reasoning](https://arxiv.org/abs/2104.07307) by Yang et al. and first released in [this repository](https://github.com/lesterpjy/numeric-t5). As the original implementation was in Tensorflow 2, I've converted the weigths to PyTorch. This model corresponds to RC Experiment 1 (see the paper), their best performing model.
11
+
12
+ Disclaimer: The team releasing NT5 did not write a model card for this model so this model card has been written by me.
13
+
14
+ ## Model description
15
+
16
+ The NT5 model is a T5 model, in other words, an encoder-decoder Transformer. In order to encourage numerical reasoning, the model was further pre-trained on three datasets designed to strengthen skills necessary for numerical reasoning over text (NRoT) and general reading comprehension before being fine-tuned on Discrete Reasoning over Text (DROP) dataset.
17
+
18
+ ## Intended uses & limitations
19
+
20
+ You can use the model for numerical reasoning over text.
21
+
22
+ ### How to use
23
+
24
+ Here is how to use this model:
25
+
26
+ ```python
27
+ from transformers import T5Tokenizer, T5ForConditionalGeneration
28
+
29
+ context = """Saint Jean de Brébeuf was a French Jesuit missionary who
30
+ travelled to New France in 1625. There he worked primarily with the Huron
31
+ for the rest of his life, except for a few years in France from 1629 to
32
+ 1633. He learned their language and culture, writing extensively about
33
+ each to aid other missionaries. In 1649, Br´ebeuf and another missionary
34
+ were captured when an Iroquois raid took over a Huron village . Together
35
+ with Huron captives, the missionaries were ritually tortured and killed
36
+ on March 16, 1649. Br´ebeuf was beatified in 1925 and among eight Jesuit
37
+ missionaries canonized as saints in the Roman Catholic Church in 1930."""
38
+
39
+ question = "How many years did Saint Jean de Brébeuf stay in New France
40
+ before he went back to France for a few years?"
41
+
42
+ tokenizer = T5Tokenizer.from_pretrained("nielsr/nt5-small-finetuned-drop")
43
+ model = T5ForConditionalGeneration.from_pretrained("nielsr/nt5-small-finetuned-drop")
44
+
45
+ # encode context & question
46
+ input_text = f"answer_me: {question} context: {context}"
47
+ encoded_query = tokenizer(
48
+ input_text,
49
+ return_tensors='pt',
50
+ padding='max_length',
51
+ truncation=True,
52
+ max_length=512)
53
+
54
+ # generate answer
55
+ generated_answer = model.generate(input_ids=encoded_query["input_ids"],
56
+ attention_mask=encoded_query["attention_mask"],
57
+ max_length=54)
58
+
59
+ decoded_answer = tokenizer.decode(generated_answer.numpy()[0])
60
+ print("T5 Answer: ", decoded_answer)
61
+ T5 Answer: 4
62
+ ```
63
+
64
+ ## Evaluation results
65
+
66
+ This model achieves an F1 score of 0.7031 and exact match of 0.6687 on the development set of DROP.
67
+
68
+
69
+ ### BibTeX entry and citation info
70
+
71
+ ```bibtex
72
+ @misc{yang2021nt5,
73
+ title={NT5?! Training T5 to Perform Numerical Reasoning},
74
+ author={Peng-Jian Yang and Ying Ting Chen and Yuechan Chen and Daniel Cer},
75
+ year={2021},
76
+ eprint={2104.07307},
77
+ archivePrefix={arXiv},
78
+ primaryClass={cs.CL}
79
+ }
80
+ ```
81
+
82
+ ```bibtex
83
+ @article{DBLP:journals/corr/abs-1903-00161,
84
+ author = {Dheeru Dua and
85
+ Yizhong Wang and
86
+ Pradeep Dasigi and
87
+ Gabriel Stanovsky and
88
+ Sameer Singh and
89
+ Matt Gardner},
90
+ title = {{DROP:} {A} Reading Comprehension Benchmark Requiring Discrete Reasoning
91
+ Over Paragraphs},
92
+ journal = {CoRR},
93
+ volume = {abs/1903.00161},
94
+ year = {2019},
95
+ url = {http://arxiv.org/abs/1903.00161},
96
+ archivePrefix = {arXiv},
97
+ eprint = {1903.00161},
98
+ timestamp = {Wed, 03 Jul 2019 07:17:04 +0200},
99
+ biburl = {https://dblp.org/rec/journals/corr/abs-1903-00161.bib},
100
+ bibsource = {dblp computer science bibliography, https://dblp.org}
101
+ }
102
+ a service of Schloss Dagstuhl - Leibniz Center for Informatics homebrowsesearchabout
103
+
104
+ ```