Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BigBirdPegasus #10991

Merged
Merged
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
84b8ab3
init bigbird pegasus
thevasudevgupta Mar 30, 2021
5c0307b
add debugging nb ; update config
thevasudevgupta Apr 2, 2021
ee47797
init conversion
thevasudevgupta Apr 2, 2021
677b72a
update conversion script
thevasudevgupta Apr 4, 2021
94861d6
complete conversion script
thevasudevgupta Apr 5, 2021
7529516
init forward()
thevasudevgupta Apr 7, 2021
2ce502b
complete forward()
thevasudevgupta Apr 10, 2021
72807a7
add tokenizer
thevasudevgupta Apr 10, 2021
0f00e43
add some slow tests
thevasudevgupta Apr 12, 2021
3bee313
commit current
thevasudevgupta Apr 13, 2021
2f72512
fix copies
thevasudevgupta Apr 13, 2021
af47e3c
add docs
thevasudevgupta Apr 13, 2021
bbe710f
add conversion script for bigbird-roberta-summarization
thevasudevgupta Apr 13, 2021
7b1ecce
remove TODO
thevasudevgupta Apr 16, 2021
1de6954
small fixups
thevasudevgupta Apr 17, 2021
fb10be0
correct tokenizer
patrickvonplaten Apr 19, 2021
c78bf6f
add bigbird core for now
thevasudevgupta Apr 22, 2021
38c7638
fix config
thevasudevgupta Apr 23, 2021
0b87a70
fix more
thevasudevgupta Apr 30, 2021
c403796
revert pegasus-tokenizer back
thevasudevgupta Apr 30, 2021
30a586a
make style
thevasudevgupta Apr 30, 2021
9618f8b
everything working for pubmed; yayygit status
thevasudevgupta Apr 30, 2021
53d99b5
complete tests finally
thevasudevgupta Apr 30, 2021
a83e681
remove bigbird pegasus tok
patrickvonplaten May 4, 2021
789d170
correct tokenizer
patrickvonplaten May 4, 2021
324cb89
correct tests
patrickvonplaten May 4, 2021
24f7931
add tokenizer files
patrickvonplaten May 4, 2021
94326e1
merge conflicts
patrickvonplaten May 4, 2021
0657b81
finish make style
patrickvonplaten May 4, 2021
0aaddf4
fix test
patrickvonplaten May 4, 2021
0c11023
update
patrickvonplaten May 4, 2021
2b23619
make style
patrickvonplaten May 4, 2021
53d3a45
fix tok utils base file
patrickvonplaten May 4, 2021
2d64dda
make fix-copies
patrickvonplaten May 4, 2021
5157815
clean a bit
thevasudevgupta May 4, 2021
cd2a5b6
small update
thevasudevgupta May 4, 2021
237c118
fix some suggestions
thevasudevgupta May 4, 2021
2d217e3
add to readme
thevasudevgupta May 4, 2021
11d9c2e
fix a bit, clean tests
thevasudevgupta May 5, 2021
b556fc9
fix more tests
thevasudevgupta May 5, 2021
a066db7
Update src/transformers/__init__.py
patrickvonplaten May 6, 2021
9c0b312
Update src/transformers/__init__.py
patrickvonplaten May 6, 2021
4d706f7
make fix-copies
patrickvonplaten May 6, 2021
9a52751
complete attn switching, auto-padding left
thevasudevgupta May 6, 2021
b13e76a
make style
patrickvonplaten May 6, 2021
97e1f71
fix auto-padding test
thevasudevgupta May 6, 2021
0ba203a
make style
thevasudevgupta May 6, 2021
0a85bb2
fix batched attention tests
patrickvonplaten May 6, 2021
89e9d5c
Merge branch 'add_bigbird_pegasus' of https://github.com/vasudevgupta…
patrickvonplaten May 6, 2021
7d2cae9
put tolerance at 1e-1 for stand-alone decoder test
patrickvonplaten May 6, 2021
34c3a63
fix docs
patrickvonplaten May 6, 2021
c229de1
fix tests
patrickvonplaten May 6, 2021
1d8d60d
correct slow tokenizer conversion
patrickvonplaten May 6, 2021
dfb74ea
Apply suggestions from code review
thevasudevgupta May 6, 2021
ca77ad3
complete remaining suggestions
thevasudevgupta May 6, 2021
2eb7563
fix test
patrickvonplaten May 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert pegasus-tokenizer back
  • Loading branch information
thevasudevgupta committed Apr 30, 2021
commit c403796204293bcef9450cc0dd56b038af60365b
17 changes: 4 additions & 13 deletions src/transformers/models/pegasus/tokenization_pegasus.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
class PegasusTokenizer(PreTrainedTokenizer):
r"""
Construct a PEGASUS tokenizer. Based on `SentencePiece <https://github.com/google/sentencepiece>`__.

This tokenizer inherits from :class:`~transformers.PreTrainedTokenizer` which contains most of the main methods.
Users should refer to this superclass for more information regarding those methods.

Args:
vocab_file (:obj:`str`):
`SentencePiece <https://github.com/google/sentencepiece>`__ file (generally has a `.spm` extension) that
Expand All @@ -53,9 +51,7 @@ class PegasusTokenizer(PreTrainedTokenizer):
The token used for padding, for example when batching sequences of different lengths.
eos_token (:obj:`str`, `optional`, defaults to :obj:`"</s>"`):
The end of sequence token.

.. note::

When building a sequence using special tokens, this is not the token that is used for the end of
sequence. The token used is the :obj:`sep_token`.
unk_token (:obj:`str`, `optional`, defaults to :obj:`"<unk>"`):
Expand All @@ -79,6 +75,9 @@ class PegasusTokenizer(PreTrainedTokenizer):
that uses the tokens 2 - 104 only for pretraining
"""
vocab_files_names = VOCAB_FILES_NAMES

offset = 103 # entries 2 - 104 are only used for pretraining
vocab_files_names = VOCAB_FILES_NAMES
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
max_model_input_sizes = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
model_input_names = ["input_ids", "attention_mask"]
Expand All @@ -92,11 +91,8 @@ def __init__(
mask_token="<mask_2>",
mask_token_sent="<mask_1>",
additional_special_tokens=None,
offset=103,
**kwargs
):
self.offset = offset # entries 2 - 104 are only used for pretraining by default

if additional_special_tokens is not None:
assert isinstance(
additional_special_tokens, list
Expand Down Expand Up @@ -128,7 +124,6 @@ def __init__(
pad_token=pad_token,
mask_token_sent=mask_token_sent,
additional_special_tokens=additional_special_tokens,
offset=self.offset,
**kwargs,
)
self.vocab_file = vocab_file
Expand Down Expand Up @@ -228,19 +223,15 @@ def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None) -> Lis
"""
Build model inputs from a sequence or a pair of sequences for sequence classification tasks by concatenating
and adding special tokens. A PEGASUS sequence has the following format, where ``X`` represents the sequence:

- single sequence: ``X </s>``
- pair of sequences: ``A B </s>`` (not intended use)

BOS is never used. Pairs of sequences are not the expected use case, but they will be handled without a
separator.

Args:
token_ids_0 (:obj:`List[int]`):
List of IDs to which the special tokens will be added.
token_ids_1 (:obj:`List[int]`, `optional`):
Optional second list of IDs for sequence pairs.

Returns:
:obj:`List[int]`: List of `input IDs <../glossary.html#input-ids>`__ with the appropriate special tokens.
"""
Expand All @@ -260,4 +251,4 @@ def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] =
if os.path.abspath(self.vocab_file) != os.path.abspath(out_vocab_file):
copyfile(self.vocab_file, out_vocab_file)

return (out_vocab_file,)
return (out_vocab_file,)