Skip to content

Commit

Permalink
refactor superclass of MaskedLMModel (#2170)
Browse files Browse the repository at this point in the history
Summary:
masked_lm is actually encoder-only model

# Before submitting

- [ ] Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
- [x] Did you read the [contributor guideline](https://github.com/pytorch/fairseq/blob/master/CONTRIBUTING.md)?
- [x] Did you make sure to update the docs?
- [ ] Did you write any new necessary tests?

## What does this PR do?
Class Refactor

## Did you have fun?
Make sure you had fun coding �
Pull Request resolved: #2170

Reviewed By: ngoyal2707

Differential Revision: D21725071

Pulled By: myleott

fbshipit-source-id: 75fd36008f3e3425f8f5180472734394046dfb77
  • Loading branch information
xu-song authored and facebook-github-bot committed May 27, 2020
1 parent 145bc9d commit 95294bf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fairseq/models/masked_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from fairseq import utils
from fairseq.models import (
BaseFairseqModel,
FairseqEncoderModel,
FairseqEncoder,
register_model,
register_model_architecture,
Expand All @@ -28,15 +28,14 @@


@register_model('masked_lm')
class MaskedLMModel(BaseFairseqModel):
class MaskedLMModel(FairseqEncoderModel):
"""
Class for training a Masked Language Model. It also supports an
additional sentence level prediction if the sent-loss argument is set.
"""
def __init__(self, args, encoder):
super().__init__()
super().__init__(encoder)
self.args = args
self.encoder = encoder

# if specified then apply bert initialization on the model. We need
# to explictly call this to make sure that the output embeddings
Expand Down

0 comments on commit 95294bf

Please # to comment.