You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the research paper, the authors tackle many different problems using the same base architecture, it is one the main strength of this article. Unfortunately, the actual version of the code only allows to work with multiple choices tasks such as ROCStories.
This is what I would like to fix in a future patch. By providing multiple model heads dedicated to other tasks that multiple choices problems, we can allow a lot more people to use this code.
I have already started working on this and I would like to get your opinions on a few design choices.
This is the new version of the DoubleHeadModel class:
classDoubleHeadModel(nn.Module):
""" Transformer with language model and task specific heads """def__init__(self, cfg, clf_token, task_head_type, vocab=40990, n_ctx=512):
super(DoubleHeadModel, self).__init__()
self.transformer=TransformerModel(cfg, vocab=vocab, n_ctx=n_ctx)
self.lm_head=LMHead(self.transformer, cfg)
ifisinstance(task_head_type, str):
iftask_head_type=='multiple_choice':
self.task_head=MultipleChoiceHead(clf_token, cfg)
eliftask_head_type=='similarity':
self.task_head=SimilarityHead(clf_token, cfg)
eliftask_head_type=='inference':
# the three classes correspond to entailment, contradiction and neutral.self.task_head=ClfHead(clf_token, cfg, 3)
else:
raiseValueError("task_head_type is expected to be 'multiple_choice' ""'similarity', 'inference' or ('classification', n_class) "f"got {task_head_type}.")
elifisinstance(task_head_type, collections.abc.Sequence) andlen(task_head_type) ==2and \
task_head_type[0] =='classification':
n_class=task_head_type[1]
self.task_head=ClfHead(clf_token, cfg, n_class)
else:
raiseValueError("task_head_type is expected to be 'multiple_choice' ""'similarity', 'inference' or ('classification', n_class) "f"got {task_head_type}.")
defforward(self, x):
h=self.transformer(x)
lm_logits=self.lm_head(h)
task_logits=self.task_head(h, x)
returnlm_logits, task_logits
The __init__ method takes a new argument task_head_type which can be one of the following things:
"multiple_choice" for multiple choice problems (corresponds to current ClfHead) such as ROCStories.
"similarity" for similarity tasks such Quora Question Pairs (QQP) and the Semantic Textual Similarity benchmark (STS-B).
"inference" for Natural Language Inference (NLI) tasks such as SNLI, QNLI and MNLI. Inference problems are treated as classification problems with 3 classes: entailment, contradiction and neutral.
("classification", n_class) for classification tasks such as the Corpus of Linguistic Acceptability (CoLA) and the Stanford Sentiment Treebank (SST-2).
If this code seems ok, I would like to test it before creating a pull request. Unfortunately I will not have the time to test SimilarityHead. Would anyone like to work with me on this ?
The text was updated successfully, but these errors were encountered:
Hi!
In the research paper, the authors tackle many different problems using the same base architecture, it is one the main strength of this article. Unfortunately, the actual version of the code only allows to work with multiple choices tasks such as ROCStories.
This is what I would like to fix in a future patch. By providing multiple model heads dedicated to other tasks that multiple choices problems, we can allow a lot more people to use this code.
I have already started working on this and I would like to get your opinions on a few design choices.
This is the new version of the
DoubleHeadModel
class:The
__init__
method takes a new argumenttask_head_type
which can be one of the following things:"multiple_choice"
for multiple choice problems (corresponds to currentClfHead
) such as ROCStories."similarity"
for similarity tasks such Quora Question Pairs (QQP) and the Semantic Textual Similarity benchmark (STS-B)."inference"
for Natural Language Inference (NLI) tasks such as SNLI, QNLI and MNLI. Inference problems are treated as classification problems with 3 classes: entailment, contradiction and neutral.("classification", n_class)
for classification tasks such as the Corpus of Linguistic Acceptability (CoLA) and the Stanford Sentiment Treebank (SST-2).The code for the various heads is the following:
Do you think that this new design is reasonable?
If this code seems ok, I would like to test it before creating a pull request. Unfortunately I will not have the time to test
SimilarityHead
. Would anyone like to work with me on this ?The text was updated successfully, but these errors were encountered: