1
---
2
language: multilingual
3
datasets:
4
- tydiqa
5
widget:
6
- text: "question: What won HuggingFace? context: HuggingFace won the best Demo paper at EMNLP2020."
7
---
8
9
# mT5-small fine-tuned on TyDiQA for multilingual QA 🗺📖❓
10
[Google's mT5-small](https://huggingface.co/google/mt5-small) fine-tuned on [TyDi QA](https://huggingface.co/nlp/viewer/?dataset=tydiqa&config=secondary_task) (secondary task) for **multingual Q&A** downstream task.
11
12
## Details of mT5
13
14
[Google's mT5](https://github.com/google-research/multilingual-t5)
15
16
mT5 is pretrained on the [mC4](https://www.tensorflow.org/datasets/catalog/c4#c4multilingual) corpus, covering 101 languages:
17
18
Afrikaans, Albanian, Amharic, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bulgarian, Burmese, Catalan, Cebuano, Chichewa, Chinese, Corsican, Czech, Danish, Dutch, English, Esperanto, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Haitian Creole, Hausa, Hawaiian, Hebrew, Hindi, Hmong, Hungarian, Icelandic, Igbo, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kazakh, Khmer, Korean, Kurdish, Kyrgyz, Lao, Latin, Latvian, Lithuanian, Luxembourgish, Macedonian, Malagasy, Malay, Malayalam, Maltese, Maori, Marathi, Mongolian, Nepali, Norwegian, Pashto, Persian, Polish, Portuguese, Punjabi, Romanian, Russian, Samoan, Scottish Gaelic, Serbian, Shona, Sindhi, Sinhala, Slovak, Slovenian, Somali, Sotho, Spanish, Sundanese, Swahili, Swedish, Tajik, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Uzbek, Vietnamese, Welsh, West Frisian, Xhosa, Yiddish, Yoruba, Zulu.
19
20
**Note**: mT5 was only pre-trained on mC4 excluding any supervised training. Therefore, this model has to be fine-tuned before it is useable on a downstream task.
21
22
Pretraining Dataset: [mC4](https://www.tensorflow.org/datasets/catalog/c4#c4multilingual)
23
24
Other Community Checkpoints: [here](https://huggingface.co/models?search=mt5)
25
26
Paper: [mT5: A massively multilingual pre-trained text-to-text transformer](https://arxiv.org/abs/2010.11934)
27
28
Authors: *Linting Xue, Noah Constant, Adam Roberts, Mihir Kale, Rami Al-Rfou, Aditya Siddhant, Aditya Barua, Colin Raffel* 
29
30
31
## Details of the dataset 📚 
32
33
**TyDi QA** is a question answering dataset covering 11 typologically diverse languages with 204K question-answer pairs. The languages of TyDi QA are diverse with regard to their typology -- the set of linguistic features that each language expresses -- such that we expect models performing well on this set to generalize across a large number of the languages in the world. It contains language phenomena that would not be found in English-only corpora. To provide a realistic information-seeking task and avoid priming effects, questions are written by people who want to know the answer, but don’t know the answer yet, (unlike SQuAD and its descendents) and the data is collected directly in each language without the use of translation (unlike MLQA and XQuAD).
34
35
| Dataset  | Task | Split | # samples |
36
| -------- | ----- |------| --------- |
37
| TyDi QA | GoldP  | train| 49881     |
38
| TyDi QA | GoldP  | valid| 5077      | 
39
40
41
42
## Results on validation dataset 📝
43
44
| Metric | # Value   |
45
| ------ | --------- |
46
| **EM** | **41.65** |
47
48
49
50
## Model in Action 🚀
51
52
```python
53
from transformers import AutoModelForCausalLM, AutoTokenizer
54
import torch
55
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
56
tokenizer = AutoTokenizer.from_pretrained("mrm8488/mT5-small-finetuned-tydiqa-for-xqa")
57
model = AutoModelForCausalLM.from_pretrained("mrm8488/mT5-small-finetuned-tydiqa-for-xqa").to(device)
58
59
def get_response(question, context, max_length=32):
60
  input_text = 'question: %s  context: %s' % (question, context)
61
  features = tokenizer([input_text], return_tensors='pt')
62
63
  output = model.generate(input_ids=features['input_ids'].to(device), 
64
               attention_mask=features['attention_mask'].to(device),
65
               max_length=max_length)
66
67
  return tokenizer.decode(output[0], skip_special_tokens=True)
68
  
69
# Some examples in different languages
70
71
context = 'HuggingFace won the best Demo paper at EMNLP2020.'
72
question = 'What won HuggingFace?'
73
get_response(question, context)
74
75
context = 'HuggingFace ganó la mejor demostración con su paper en la EMNLP2020.'
76
question = 'Qué ganó HuggingFace?'
77
get_response(question, context)
78
79
context = 'HuggingFace выиграл лучшую демонстрационную работу на EMNLP2020.'
80
question = 'Что победило в HuggingFace?'
81
get_response(question, context)
82
```
83
84
> Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488) | [LinkedIn](https://www.linkedin.com/in/manuel-romero-cs/)
85
86
> Made with <span style="color: #e25555;">&hearts;</span> in Spain
87