benjleite commited on
Commit
239f0f8
1 Parent(s): 85dde41

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +163 -3
README.md CHANGED
@@ -1,3 +1,163 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - t5
6
+ - english
7
+ - text-generation
8
+ - question-generation
9
+ datasets:
10
+ - GEM/FairytaleQA
11
+ license: apache-2.0
12
+ pipeline_tag: text-generation
13
+ ---
14
+
15
+ # Model Card for t5-english-qg
16
+
17
+ ## Model Description
18
+
19
+ **t5-english-qg** is a T5 model, fine-tuned from [T5-base](https://huggingface.co/google-t5/t5-base) in English using the [original English FairytaleQA dataset](https://huggingface.co/datasets/GEM/FairytaleQA).
20
+ The task of fine-tuning is Question Generation. You can check our [paper](https://arxiv.org/abs/2406.04233), accepted in ECTEL 2024.
21
+
22
+ ## Training Data
23
+ **FairytaleQA** is an open-source dataset designed to enhance comprehension of narratives, aimed at students from kindergarten to eighth grade. The dataset is meticulously annotated by education experts following an evidence-based theoretical framework. It comprises 10,580 explicit and implicit questions derived from 278 child-friendly stories, covering seven types of narrative elements or relations.
24
+
25
+ ## Implementation Details
26
+
27
+ The encoder concatenates the answer and text, and the decoder generates the question. We use special labels to differentiate the components. Our maximum token input is set to 512, while the maximum token output is set to 128. During training, the models undergo a maximum of 20 epochs and incorporate early stopping with a patience of 2. A batch size of 16 is employed. During inference, we utilize beam search with a beam width of 5.
28
+
29
+ ## Evaluation - Question Generation
30
+
31
+ | Model | ROUGEL-F1 |
32
+ | ---------------- | ---------- |
33
+ | BART (baseline from FairytaleQA authors) | 0.527 |
34
+ | T5 (ours) | 0.530 |
35
+
36
+ ## Load Model and Tokenizer
37
+
38
+ ```py
39
+ >>> from transformers import T5ForConditionalGeneration, T5Tokenizer
40
+ >>> model = T5ForConditionalGeneration.from_pretrained("benjleite/t5-english-qg")
41
+ >>> tokenizer = T5Tokenizer.from_pretrained("t5-base", model_max_length=512)
42
+ ```
43
+ **Important Note**: Special tokens need to be added and model tokens must be resized:
44
+
45
+ ```py
46
+ >>> tokenizer.add_tokens(['<attribute>', '<question>','<answer>','<answertype>','<text>'], special_tokens=True)
47
+ >>> model.resize_token_embeddings(len(tokenizer))
48
+ ```
49
+
50
+ ## Inference Example (same parameters as used in paper experiments)
51
+
52
+ Note: See our [repository](https://github.com/bernardoleite/fairytaleqa-translated) for additional code details.
53
+
54
+ ```py
55
+ input_text = '<answer>' + 'A Bear.' + '<text>' + 'Once upon a time, a bear was walking in the forest....'
56
+
57
+ source_encoding = tokenizer(
58
+ input_text,
59
+ max_length=512,
60
+ padding='max_length',
61
+ truncation = 'only_second',
62
+ return_attention_mask=True,
63
+ add_special_tokens=True,
64
+ return_tensors='pt'
65
+ )
66
+
67
+ input_ids = source_encoding['input_ids']
68
+ attention_mask = source_encoding['attention_mask']
69
+
70
+ generated_ids = model.generate(
71
+ input_ids=input_ids,
72
+ attention_mask=attention_mask,
73
+ num_return_sequences=1,
74
+ num_beams=5,
75
+ max_length=512,
76
+ repetition_penalty=1.0,
77
+ length_penalty=1.0,
78
+ early_stopping=True,
79
+ use_cache=True
80
+ )
81
+
82
+ prediction = {
83
+ tokenizer.decode(generated_id, skip_special_tokens=False, clean_up_tokenization_spaces=True)
84
+ for generated_id in generated_ids
85
+ }
86
+
87
+ generated_str = ''.join(preds)
88
+
89
+ print(generated_str)
90
+ ```
91
+
92
+ ## Licensing Information
93
+
94
+ This fine-tuned model is released under the [Apache-2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
95
+
96
+ ## Citation Information
97
+
98
+ Our paper (preprint - accepted for publication at ECTEL 2024):
99
+
100
+ ```
101
+ @article{leite_fairytaleqa_translated_2024,
102
+ title={FairytaleQA Translated: Enabling Educational Question and Answer Generation in Less-Resourced Languages},
103
+ author={Bernardo Leite and Tomás Freitas Osório and Henrique Lopes Cardoso},
104
+ year={2024},
105
+ eprint={2406.04233},
106
+ archivePrefix={arXiv},
107
+ primaryClass={cs.CL}
108
+ }
109
+ ```
110
+
111
+ Original FairytaleQA paper:
112
+
113
+ ```
114
+ @inproceedings{xu-etal-2022-fantastic,
115
+ title = "Fantastic Questions and Where to Find Them: {F}airytale{QA} {--} An Authentic Dataset for Narrative Comprehension",
116
+ author = "Xu, Ying and
117
+ Wang, Dakuo and
118
+ Yu, Mo and
119
+ Ritchie, Daniel and
120
+ Yao, Bingsheng and
121
+ Wu, Tongshuang and
122
+ Zhang, Zheng and
123
+ Li, Toby and
124
+ Bradford, Nora and
125
+ Sun, Branda and
126
+ Hoang, Tran and
127
+ Sang, Yisi and
128
+ Hou, Yufang and
129
+ Ma, Xiaojuan and
130
+ Yang, Diyi and
131
+ Peng, Nanyun and
132
+ Yu, Zhou and
133
+ Warschauer, Mark",
134
+ editor = "Muresan, Smaranda and
135
+ Nakov, Preslav and
136
+ Villavicencio, Aline",
137
+ booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
138
+ month = may,
139
+ year = "2022",
140
+ address = "Dublin, Ireland",
141
+ publisher = "Association for Computational Linguistics",
142
+ url = "https://aclanthology.org/2022.acl-long.34",
143
+ doi = "10.18653/v1/2022.acl-long.34",
144
+ pages = "447--460",
145
+ abstract = "Question answering (QA) is a fundamental means to facilitate assessment and training of narrative comprehension skills for both machines and young children, yet there is scarcity of high-quality QA datasets carefully designed to serve this purpose. In particular, existing datasets rarely distinguish fine-grained reading skills, such as the understanding of varying narrative elements. Drawing on the reading education research, we introduce FairytaleQA, a dataset focusing on narrative comprehension of kindergarten to eighth-grade students. Generated by educational experts based on an evidence-based theoretical framework, FairytaleQA consists of 10,580 explicit and implicit questions derived from 278 children-friendly stories, covering seven types of narrative elements or relations. Our dataset is valuable in two folds: First, we ran existing QA models on our dataset and confirmed that this annotation helps assess models{'} fine-grained learning skills. Second, the dataset supports question generation (QG) task in the education domain. Through benchmarking with QG models, we show that the QG model trained on FairytaleQA is capable of asking high-quality and more diverse questions.",
146
+ }
147
+ ```
148
+
149
+ T5 model:
150
+
151
+ ```
152
+ @article{raffel_2020_t5,
153
+ author = {Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu},
154
+ title = {Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
155
+ journal = {Journal of Machine Learning Research},
156
+ year = {2020},
157
+ volume = {21},
158
+ number = {140},
159
+ pages = {1-67},
160
+ url = {http://jmlr.org/papers/v21/20-074.html},
161
+ note={Model URL: \url{huggingface.co/google-t5/t5-base}}
162
+ }
163
+ ```