Model Card for t5-english-qg
Model Description
t5-english-qg is a T5 model, fine-tuned from T5-base in English using the original English FairytaleQA dataset. The task of fine-tuning is Question Generation. You can check our paper, accepted in ECTEL 2024.
Training Data
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.
Implementation Details
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.
Evaluation - Question Generation
Model | ROUGEL-F1 |
---|---|
BART (baseline from FairytaleQA authors) | 0.527 |
T5 (ours) | 0.530 |
Load Model and Tokenizer
>>> from transformers import T5ForConditionalGeneration, T5Tokenizer
>>> model = T5ForConditionalGeneration.from_pretrained("benjleite/t5-english-qg")
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base", model_max_length=512)
Important Note: Special tokens need to be added and model tokens must be resized:
>>> tokenizer.add_tokens(['<attribute>', '<question>','<answer>','<answertype>','<text>'], special_tokens=True)
>>> model.resize_token_embeddings(len(tokenizer))
Inference Example (same parameters as used in paper experiments)
Note: See our repository for additional code details.
input_text = '<answer>' + 'A Bear.' + '<text>' + 'Once upon a time, a bear was walking in the forest....'
source_encoding = tokenizer(
input_text,
max_length=512,
padding='max_length',
truncation = 'only_second',
return_attention_mask=True,
add_special_tokens=True,
return_tensors='pt'
)
input_ids = source_encoding['input_ids']
attention_mask = source_encoding['attention_mask']
generated_ids = model.generate(
input_ids=input_ids,
attention_mask=attention_mask,
num_return_sequences=1,
num_beams=5,
max_length=512,
repetition_penalty=1.0,
length_penalty=1.0,
early_stopping=True,
use_cache=True
)
prediction = {
tokenizer.decode(generated_id, skip_special_tokens=False, clean_up_tokenization_spaces=True)
for generated_id in generated_ids
}
generated_str = ''.join(preds)
print(generated_str)
Licensing Information
This fine-tuned model is released under the Apache-2.0 License.
Citation Information
Our paper (preprint - accepted for publication at ECTEL 2024):
@article{leite_fairytaleqa_translated_2024,
title={FairytaleQA Translated: Enabling Educational Question and Answer Generation in Less-Resourced Languages},
author={Bernardo Leite and Tomás Freitas Osório and Henrique Lopes Cardoso},
year={2024},
eprint={2406.04233},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Original FairytaleQA paper:
@inproceedings{xu-etal-2022-fantastic,
title = "Fantastic Questions and Where to Find Them: {F}airytale{QA} {--} An Authentic Dataset for Narrative Comprehension",
author = "Xu, Ying and
Wang, Dakuo and
Yu, Mo and
Ritchie, Daniel and
Yao, Bingsheng and
Wu, Tongshuang and
Zhang, Zheng and
Li, Toby and
Bradford, Nora and
Sun, Branda and
Hoang, Tran and
Sang, Yisi and
Hou, Yufang and
Ma, Xiaojuan and
Yang, Diyi and
Peng, Nanyun and
Yu, Zhou and
Warschauer, Mark",
editor = "Muresan, Smaranda and
Nakov, Preslav and
Villavicencio, Aline",
booktitle = "Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
month = may,
year = "2022",
address = "Dublin, Ireland",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2022.acl-long.34",
doi = "10.18653/v1/2022.acl-long.34",
pages = "447--460",
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.",
}
T5 model:
@article{raffel_2020_t5,
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},
title = {Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
journal = {Journal of Machine Learning Research},
year = {2020},
volume = {21},
number = {140},
pages = {1-67},
url = {http://jmlr.org/papers/v21/20-074.html},
note={Model URL: \url{huggingface.co/google-t5/t5-base}}
}
- Downloads last month
- 37