Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
b1ee6976
Unverified
Commit
b1ee6976
authored
Jul 21, 2020
by
tuner007
Committed by
GitHub
Jul 21, 2020
Browse files
Create README.md (#5864)
parent
5f809e49
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
model_cards/tuner007/t5_abs_qa/README.md
model_cards/tuner007/t5_abs_qa/README.md
+39
-0
No files found.
model_cards/tuner007/t5_abs_qa/README.md
0 → 100644
View file @
b1ee6976
# T5 for abstractive question-answering
This is T5-base model fine-tuned for abstractive QA using text-to-text approach
## Model training
This model was trained on colab TPU with 35GB RAM for 2 epochs
## Model in Action 🚀
```
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
])
```
#### Example 1: Answer available
```
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.'
```
#### Example 2: Answer not available
```
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.'
```
> Created by Arpit Rajauria
[

](https://twitter.com/arpit_rajauria)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment