julien-c HF staff commited on
Commit
c896608
1 Parent(s): f3afa22

Migrate model card from transformers-repo

Browse files

Read announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/tuner007/t5_abs_qa/README.md

Files changed (1) hide show
  1. README.md +39 -0
README.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # T5 for abstractive question-answering
2
+ This is T5-base model fine-tuned for abstractive QA using text-to-text approach
3
+
4
+ ## Model training
5
+ This model was trained on colab TPU with 35GB RAM for 2 epochs
6
+
7
+ ## Model in Action 🚀
8
+ ```
9
+ from transformers import AutoModelWithLMHead, AutoTokenizer
10
+
11
+ tokenizer = AutoTokenizer.from_pretrained("tuner007/t5_abs_qa")
12
+ model = AutoModelWithLMHead.from_pretrained("tuner007/t5_abs_qa")
13
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
+ model = model.to(device)
15
+
16
+ def get_answer(question, context):
17
+ input_text = "context: %s <question for context: %s </s>" % (context,question)
18
+ features = tokenizer([input_text], return_tensors='pt')
19
+ out = model.generate(input_ids=features['input_ids'].to(device), attention_mask=features['attention_mask'].to(device))
20
+ return tokenizer.decode(out[0])
21
+ ```
22
+ #### Example 1: Answer available
23
+ ```
24
+ context = "In Norse mythology, Valhalla is a majestic, enormous hall located in Asgard, ruled over by the god Odin."
25
+ question = "What is Valhalla?"
26
+ get_answer(question, context)
27
+ # output: 'It is a hall of worship ruled by Odin.'
28
+ ```
29
+ #### Example 2: Answer not available
30
+ ```
31
+ context = "In Norse mythology, Valhalla is a majestic, enormous hall located in Asgard, ruled over by the god Odin."
32
+ question = "What is Asgard?"
33
+ get_answer(question, context)
34
+ # output: 'No answer available in context.'
35
+ ```
36
+
37
+
38
+ > Created by Arpit Rajauria
39
+ [![Twitter icon](https://cdn0.iconfinder.com/data/icons/shift-logotypes/32/Twitter-32.png)](https://twitter.com/arpit_rajauria)