Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
53496ac5
Unverified
Commit
53496ac5
authored
Jun 14, 2022
by
Patrick von Platen
Committed by
GitHub
Jun 14, 2022
Browse files
[LongT5] Rename checkpoitns (#17700)
parent
3b29c9fd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
26 deletions
+26
-26
src/transformers/models/longt5/configuration_longt5.py
src/transformers/models/longt5/configuration_longt5.py
+5
-5
src/transformers/models/longt5/modeling_flax_longt5.py
src/transformers/models/longt5/modeling_flax_longt5.py
+6
-6
src/transformers/models/longt5/modeling_longt5.py
src/transformers/models/longt5/modeling_longt5.py
+9
-9
tests/models/longt5/test_modeling_longt5.py
tests/models/longt5/test_modeling_longt5.py
+4
-4
tests/onnx/test_onnx_v2.py
tests/onnx/test_onnx_v2.py
+2
-2
No files found.
src/transformers/models/longt5/configuration_longt5.py
View file @
53496ac5
...
@@ -23,10 +23,10 @@ from ...utils import logging
...
@@ -23,10 +23,10 @@ from ...utils import logging
logger
=
logging
.
get_logger
(
__name__
)
logger
=
logging
.
get_logger
(
__name__
)
LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP
=
{
LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP
=
{
"google/
L
ong
T
5-
L
ocal-
B
ase"
:
"https://huggingface.co/google/
L
ong
T
5-
L
ocal-
B
ase/blob/main/config.json"
,
"google/
l
ong
-t
5-
l
ocal-
b
ase"
:
"https://huggingface.co/google/
l
ong
-t
5-
l
ocal-
b
ase/blob/main/config.json"
,
"google/
L
ong
T
5-
L
ocal-
L
arge"
:
"https://huggingface.co/google/
L
ong
T
5-
L
ocal-
L
arge/blob/main/config.json"
,
"google/
l
ong
-t
5-
l
ocal-
l
arge"
:
"https://huggingface.co/google/
l
ong
-t
5-
l
ocal-
l
arge/blob/main/config.json"
,
"google/
L
ong
T5-TG
lobal-
B
ase"
:
"https://huggingface.co/google/
L
ong
T5-TG
lobal-
B
ase/blob/main/config.json"
,
"google/
l
ong
-t5-tg
lobal-
b
ase"
:
"https://huggingface.co/google/
l
ong
-t5-tg
lobal-
b
ase/blob/main/config.json"
,
"google/
L
ong
T5-TG
lobal-
L
arge"
:
"https://huggingface.co/google/
L
ong
T5-TG
lobal-
L
arge/blob/main/config.json"
,
"google/
l
ong
-t5-tg
lobal-
l
arge"
:
"https://huggingface.co/google/
l
ong
-t5-tg
lobal-
l
arge/blob/main/config.json"
,
}
}
...
@@ -35,7 +35,7 @@ class LongT5Config(PretrainedConfig):
...
@@ -35,7 +35,7 @@ class LongT5Config(PretrainedConfig):
This is the configuration class to store the configuration of a [`LongT5Model`] or a [`FlaxLongT5Model`]. It is
This is the configuration class to store the configuration of a [`LongT5Model`] or a [`FlaxLongT5Model`]. It is
used to instantiate a LongT5 model according to the specified arguments, defining the model architecture.
used to instantiate a LongT5 model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the LongT5
Instantiating a configuration with the defaults will yield a similar configuration to that of the LongT5
[google/
L
ong
T
5-
L
ocal-
B
ase](https://huggingface.co/google/
L
ong
T
5-
L
ocal-
B
ase) architecture.
[google/
l
ong
-t
5-
l
ocal-
b
ase](https://huggingface.co/google/
l
ong
-t
5-
l
ocal-
b
ase) architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.
documentation from [`PretrainedConfig`] for more information.
...
...
src/transformers/models/longt5/modeling_flax_longt5.py
View file @
53496ac5
...
@@ -49,7 +49,7 @@ from .configuration_longt5 import LongT5Config
...
@@ -49,7 +49,7 @@ from .configuration_longt5 import LongT5Config
logger
=
logging
.
get_logger
(
__name__
)
logger
=
logging
.
get_logger
(
__name__
)
_CHECKPOINT_FOR_DOC
=
"google/
L
ong
T
5-
L
ocal-
B
ase"
_CHECKPOINT_FOR_DOC
=
"google/
l
ong
-t
5-
l
ocal-
b
ase"
_CONFIG_FOR_DOC
=
"LongT5Config"
_CONFIG_FOR_DOC
=
"LongT5Config"
_TOKENIZER_FOR_DOC
=
"T5Tokenizer"
_TOKENIZER_FOR_DOC
=
"T5Tokenizer"
...
@@ -1799,7 +1799,7 @@ class FlaxLongT5PreTrainedModel(FlaxPreTrainedModel):
...
@@ -1799,7 +1799,7 @@ class FlaxLongT5PreTrainedModel(FlaxPreTrainedModel):
>>> from transformers import T5Tokenizer, FlaxLongT5ForConditionalGeneration
>>> from transformers import T5Tokenizer, FlaxLongT5ForConditionalGeneration
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> text = "My friends are cool but they eat too many carbs."
>>> text = "My friends are cool but they eat too many carbs."
>>> inputs = tokenizer(text, return_tensors="np")
>>> inputs = tokenizer(text, return_tensors="np")
...
@@ -1861,7 +1861,7 @@ class FlaxLongT5PreTrainedModel(FlaxPreTrainedModel):
...
@@ -1861,7 +1861,7 @@ class FlaxLongT5PreTrainedModel(FlaxPreTrainedModel):
>>> import jax.numpy as jnp
>>> import jax.numpy as jnp
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> text = "My friends are cool but they eat too many carbs."
>>> text = "My friends are cool but they eat too many carbs."
>>> inputs = tokenizer(text, return_tensors="np")
>>> inputs = tokenizer(text, return_tensors="np")
...
@@ -2080,7 +2080,7 @@ FLAX_LONGT5_MODEL_DOCSTRING = """
...
@@ -2080,7 +2080,7 @@ FLAX_LONGT5_MODEL_DOCSTRING = """
>>> from transformers import T5Tokenizer, FlaxLongT5Model
>>> from transformers import T5Tokenizer, FlaxLongT5Model
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> model = FlaxLongT5Model.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = FlaxLongT5Model.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> input_ids = tokenizer(
>>> input_ids = tokenizer(
... "Studies have been shown that owning a dog is good for you", return_tensors="np"
... "Studies have been shown that owning a dog is good for you", return_tensors="np"
...
@@ -2233,7 +2233,7 @@ class FlaxLongT5ForConditionalGeneration(FlaxLongT5PreTrainedModel):
...
@@ -2233,7 +2233,7 @@ class FlaxLongT5ForConditionalGeneration(FlaxLongT5PreTrainedModel):
>>> import jax.numpy as jnp
>>> import jax.numpy as jnp
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> text = "summarize: My friends are cool but they eat too many carbs."
>>> text = "summarize: My friends are cool but they eat too many carbs."
>>> inputs = tokenizer(text, return_tensors="np")
>>> inputs = tokenizer(text, return_tensors="np")
...
@@ -2381,7 +2381,7 @@ FLAX_LONGT5_CONDITIONAL_GENERATION_DOCSTRING = """
...
@@ -2381,7 +2381,7 @@ FLAX_LONGT5_CONDITIONAL_GENERATION_DOCSTRING = """
>>> from transformers import T5Tokenizer, FlaxLongT5ForConditionalGeneration
>>> from transformers import T5Tokenizer, FlaxLongT5ForConditionalGeneration
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> tokenizer = T5Tokenizer.from_pretrained("t5-base")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> ARTICLE_TO_SUMMARIZE = "summarize: My friends are cool but they eat too many carbs."
>>> ARTICLE_TO_SUMMARIZE = "summarize: My friends are cool but they eat too many carbs."
>>> inputs = tokenizer([ARTICLE_TO_SUMMARIZE], return_tensors="np")
>>> inputs = tokenizer([ARTICLE_TO_SUMMARIZE], return_tensors="np")
...
...
src/transformers/models/longt5/modeling_longt5.py
View file @
53496ac5
...
@@ -49,14 +49,14 @@ logger = logging.get_logger(__name__)
...
@@ -49,14 +49,14 @@ logger = logging.get_logger(__name__)
_CONFIG_FOR_DOC
=
"LongT5Config"
_CONFIG_FOR_DOC
=
"LongT5Config"
_TOKENIZER_FOR_DOC
=
"T5Tokenizer"
_TOKENIZER_FOR_DOC
=
"T5Tokenizer"
_CHECKPOINT_FOR_DOC
=
"google/
L
ong
T
5-
L
ocal-
B
ase"
_CHECKPOINT_FOR_DOC
=
"google/
l
ong
-t
5-
l
ocal-
b
ase"
# TODO: Update before the merge
# TODO: Update before the merge
LONGT5_PRETRAINED_MODEL_ARCHIVE_LIST
=
[
LONGT5_PRETRAINED_MODEL_ARCHIVE_LIST
=
[
"google/
L
ong
T
5-
L
ocal-
B
ase"
,
"google/
l
ong
-t
5-
l
ocal-
b
ase"
,
"google/
L
ong
T
5-
L
ocal-
L
arge"
,
"google/
l
ong
-t
5-
l
ocal-
l
arge"
,
"google/
L
ong
T5-TG
lobal-
B
ase"
,
"google/
l
ong
-t5-tg
lobal-
b
ase"
,
"google/
L
ong
T5-TG
lobal-
L
arge"
,
"google/
l
ong
-t5-tg
lobal-
l
arge"
,
]
]
...
@@ -1797,8 +1797,8 @@ class LongT5Model(LongT5PreTrainedModel):
...
@@ -1797,8 +1797,8 @@ class LongT5Model(LongT5PreTrainedModel):
```python
```python
>>> from transformers import T5Tokenizer, LongT5Model
>>> from transformers import T5Tokenizer, LongT5Model
>>> tokenizer = T5Tokenizer.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> tokenizer = T5Tokenizer.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> model = LongT5Model.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = LongT5Model.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> # Let's try a very long encoder input.
>>> # Let's try a very long encoder input.
>>> input_ids = tokenizer(
>>> input_ids = tokenizer(
...
@@ -2169,8 +2169,8 @@ class LongT5EncoderModel(LongT5PreTrainedModel):
...
@@ -2169,8 +2169,8 @@ class LongT5EncoderModel(LongT5PreTrainedModel):
```python
```python
>>> from transformers import AutoTokenizer, LongT5ForConditionalGeneration
>>> from transformers import AutoTokenizer, LongT5ForConditionalGeneration
>>> tokenizer = AutoTokenizer.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> tokenizer = AutoTokenizer.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> model = LongT5EncoderModel.from_pretrained("google/
L
ong
T
5-
L
ocal-
B
ase")
>>> model = LongT5EncoderModel.from_pretrained("google/
l
ong
-t
5-
l
ocal-
b
ase")
>>> input_ids = tokenizer(
>>> input_ids = tokenizer(
... 100 * "Studies have been shown that owning a dog is good for you ", return_tensors="pt"
... 100 * "Studies have been shown that owning a dog is good for you ", return_tensors="pt"
... ).input_ids # Batch size 1
... ).input_ids # Batch size 1
...
...
tests/models/longt5/test_modeling_longt5.py
View file @
53496ac5
...
@@ -68,7 +68,7 @@ class LongT5ModelTester:
...
@@ -68,7 +68,7 @@ class LongT5ModelTester:
decoder_start_token_id
=
0
,
decoder_start_token_id
=
0
,
scope
=
None
,
scope
=
None
,
decoder_layers
=
None
,
decoder_layers
=
None
,
large_model_config_path
=
"google/
L
ong
T
5-
L
ocal-
L
arge"
,
large_model_config_path
=
"google/
l
ong
-t
5-
l
ocal-
l
arge"
,
):
):
self
.
parent
=
parent
self
.
parent
=
parent
...
@@ -755,7 +755,7 @@ class LongT5ModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase
...
@@ -755,7 +755,7 @@ class LongT5ModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase
class
LongT5TGlobalModelTest
(
LongT5ModelTest
):
class
LongT5TGlobalModelTest
(
LongT5ModelTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
model_tester
=
LongT5ModelTester
(
self
.
model_tester
=
LongT5ModelTester
(
self
,
encoder_attention_type
=
"transient-global"
,
large_model_config_path
=
"google/
L
ong
T5-TG
lobal-
L
arge"
self
,
encoder_attention_type
=
"transient-global"
,
large_model_config_path
=
"google/
l
ong
-t5-tg
lobal-
l
arge"
)
)
self
.
config_tester
=
ConfigTester
(
self
,
config_class
=
LongT5Config
,
d_model
=
37
)
self
.
config_tester
=
ConfigTester
(
self
,
config_class
=
LongT5Config
,
d_model
=
37
)
...
@@ -912,7 +912,7 @@ class LongT5EncoderOnlyModelTester:
...
@@ -912,7 +912,7 @@ class LongT5EncoderOnlyModelTester:
eos_token_id
=
1
,
eos_token_id
=
1
,
pad_token_id
=
0
,
pad_token_id
=
0
,
scope
=
None
,
scope
=
None
,
large_model_config_path
=
"google/
L
ong
T
5-
L
ocal-
L
arge"
,
large_model_config_path
=
"google/
l
ong
-t
5-
l
ocal-
l
arge"
,
):
):
self
.
parent
=
parent
self
.
parent
=
parent
...
@@ -1095,7 +1095,7 @@ class LongT5EncoderOnlyModelTest(ModelTesterMixin, unittest.TestCase):
...
@@ -1095,7 +1095,7 @@ class LongT5EncoderOnlyModelTest(ModelTesterMixin, unittest.TestCase):
class
LongT5EncoderOnlyTGlobalModelTest
(
LongT5EncoderOnlyModelTest
):
class
LongT5EncoderOnlyTGlobalModelTest
(
LongT5EncoderOnlyModelTest
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
model_tester
=
LongT5EncoderOnlyModelTester
(
self
.
model_tester
=
LongT5EncoderOnlyModelTester
(
self
,
encoder_attention_type
=
"transient-global"
,
large_model_config_path
=
"google/
L
ong
T5-TG
lobal-
L
arge"
self
,
encoder_attention_type
=
"transient-global"
,
large_model_config_path
=
"google/
l
ong
-t5-tg
lobal-
l
arge"
)
)
self
.
config_tester
=
ConfigTester
(
self
,
config_class
=
LongT5Config
,
d_model
=
37
)
self
.
config_tester
=
ConfigTester
(
self
,
config_class
=
LongT5Config
,
d_model
=
37
)
...
...
tests/onnx/test_onnx_v2.py
View file @
53496ac5
...
@@ -213,8 +213,8 @@ PYTORCH_EXPORT_SEQ2SEQ_WITH_PAST_MODELS = {
...
@@ -213,8 +213,8 @@ PYTORCH_EXPORT_SEQ2SEQ_WITH_PAST_MODELS = {
(
"blenderbot-small"
,
"facebook/blenderbot_small-90M"
),
(
"blenderbot-small"
,
"facebook/blenderbot_small-90M"
),
(
"blenderbot"
,
"facebook/blenderbot-400M-distill"
),
(
"blenderbot"
,
"facebook/blenderbot-400M-distill"
),
(
"bigbird-pegasus"
,
"google/bigbird-pegasus-large-arxiv"
),
(
"bigbird-pegasus"
,
"google/bigbird-pegasus-large-arxiv"
),
(
"longt5"
,
"google/
L
ong
T
5-
L
ocal-
B
ase"
),
(
"longt5"
,
"google/
l
ong
-t
5-
l
ocal-
b
ase"
),
(
"longt5"
,
"google/
L
ong
T5-TG
lobal-
B
ase"
),
(
"longt5"
,
"google/
l
ong
-t5-tg
lobal-
b
ase"
),
}
}
# TODO(lewtun): Include the same model types in `PYTORCH_EXPORT_MODELS` once TensorFlow has parity with the PyTorch model implementations.
# TODO(lewtun): Include the same model types in `PYTORCH_EXPORT_MODELS` once TensorFlow has parity with the PyTorch model implementations.
...
...
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