Downloads · 30 days
14
0% of all-time downloads
tuner007/t5_abs_qa
t5_abs_qa is a machine learning model from tuner007. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
This is T5-base model fine-tuned for abstractive QA using text-to-text approach
Downloads · 30 days
14
0% of all-time downloads
All-time downloads
38.4K
Public
Repo size
2.4 GB
Likes
8
Public
Click a slice to open those files.
.bin1.2 GB · 100%
From the Hugging Face model README
This is T5-base model fine-tuned for abstractive QA using text-to-text approach
This model was trained on colab TPU with 35GB RAM for 2 epochs
from transformers import AutoModelWithLMHead, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("tuner007/t5_abs_qa")
model = AutoModelWithLMHead.from_pretrained("tuner007/t5_abs_qa")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
def get_answer(question, context):
input_text = "context: %s <question for context: %s </s>" % (context,question)
features = tokenizer([input_text], return_tensors='pt')
out = model.generate(input_ids=features['input_ids'].to(device), attention_mask=features['attention_mask'].to(device))
return tokenizer.decode(out[0])
context = "In Norse mythology, Valhalla is a majestic, enormous hall located in Asgard, ruled over by the god Odin."
question = "What is Valhalla?"
get_answer(question, context)
# output: 'It is a hall of worship ruled by Odin.'
context = "In Norse mythology, Valhalla is a majestic, enormous hall located in Asgard, ruled over by the god Odin."
question = "What is Asgard?"
get_answer(question, context)
# output: 'No answer available in context.'