Question Answering
Transformers
PyTorch
English
t5
text2text-generation
triviaqa
t5-base
lm-head
closed-book
pipeline:question-answering
text-generation-inference
Instructions to use deep-learning-analytics/triviaqa-t5-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deep-learning-analytics/triviaqa-t5-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("question-answering", model="deep-learning-analytics/triviaqa-t5-base")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("deep-learning-analytics/triviaqa-t5-base") model = AutoModelForSeq2SeqLM.from_pretrained("deep-learning-analytics/triviaqa-t5-base") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: "eng"
|
| 3 |
+
tags:
|
| 4 |
+
- triviaqa
|
| 5 |
+
- t5-base
|
| 6 |
+
- pytorch
|
| 7 |
+
- lm-head
|
| 8 |
+
- question-answering
|
| 9 |
+
- closed-book
|
| 10 |
+
- t5
|
| 11 |
+
- pipeline:question-answering
|
| 12 |
+
datasets:
|
| 13 |
+
- triviaqa
|
| 14 |
+
widget:
|
| 15 |
+
- text: "Mount Everest is found in which mountain range?"
|
| 16 |
+
metrics:
|
| 17 |
+
- EM: 17
|
| 18 |
+
- Subset match: 24.5
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Model name
|
| 22 |
+
Closed Book Trivia-QA T5 base
|
| 23 |
+
|
| 24 |
+
## Model description
|
| 25 |
+
|
| 26 |
+
This is a T5-base model trained on No Context Trivia QA data set. The input to the model is a Trivia type question. The model is tuned to search for the answer in its memory to return it. The pretrained model used here was trained on Common Crawl (C4) data set. The model was trained for 135 epochs using a batch size of 32 and learning rate of 1e-3. Max_input_lngth is set as 25 and max_output_length is 10. Model attained an EM score of 17 and a Subset Match score of 24.5
|
| 27 |
+
We have written a blog post that covers the training procedure. Please find it [here](https://medium.com/@priya.dwivedi/fine-tuning-a-t5-transformer-for-any-summarization-task-82334c64c81).
|
| 28 |
+
|
| 29 |
+
Test the model on Trivia Questions from the websites below:
|
| 30 |
+
https://www.triviaquestionss.com/easy-trivia-questions/
|
| 31 |
+
https://laffgaff.com/easy-trivia-questions-and-answers/
|
| 32 |
+
|
| 33 |
+
## Usage
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
| 37 |
+
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained("deep-learning-analytics/triviaqa-t5-base")
|
| 39 |
+
model = AutoModelWithLMHead.from_pretrained("deep-learning-analytics/triviaqa-t5-base")
|
| 40 |
+
|
| 41 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 42 |
+
model = model.to(device)
|
| 43 |
+
|
| 44 |
+
text = "Who directed the movie Jaws?"
|
| 45 |
+
|
| 46 |
+
preprocess_text = text.strip().replace("\n","")
|
| 47 |
+
tokenized_text = tokenizer.encode(preprocess_text, return_tensors="pt").to(device)
|
| 48 |
+
|
| 49 |
+
outs = model.model.generate(
|
| 50 |
+
tokenized_text,
|
| 51 |
+
max_length=10,
|
| 52 |
+
num_beams=2,
|
| 53 |
+
early_stopping=True
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
dec = [tokenizer.decode(ids) for ids in outs]
|
| 57 |
+
print("Predicted Answer: ", dec)
|
| 58 |
+
```
|