Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3bd7a70
initial commit
ArthurZucker May 24, 2022
b4e03b7
add init file
ArthurZucker May 24, 2022
5f4ad0a
update globakl init
ArthurZucker May 24, 2022
9bf9b95
update index and dummy objects
ArthurZucker May 24, 2022
7e53484
style
ArthurZucker May 24, 2022
b3a74bd
update modelling auto
ArthurZucker May 24, 2022
a8e76bc
fix initi typo in src/transformers
ArthurZucker May 24, 2022
9641709
fix typo in modeling tf auto, opt was in wrong mapping name
ArthurZucker May 24, 2022
18bc191
fixed a slow test : saved_model
ArthurZucker May 24, 2022
1257768
style
ArthurZucker May 24, 2022
6355a10
fix positionnal embedding if no position id is provided
ArthurZucker May 24, 2022
89d4dc9
update tf test
ArthurZucker May 24, 2022
da57713
update test flax requirements
ArthurZucker May 24, 2022
4fea708
fixed serialization
ArthurZucker May 24, 2022
d6b4fd5
update
ArthurZucker May 24, 2022
2215d1c
update tf name to allow smooth convertion
ArthurZucker May 25, 2022
fd18014
update flax tests
ArthurZucker May 25, 2022
156b983
style
ArthurZucker May 25, 2022
9597454
fix test typo
ArthurZucker May 25, 2022
72510ea
fix tf typo test
ArthurZucker May 25, 2022
353f62f
add xla for generate support in causal LM
ArthurZucker May 25, 2022
5b2bcec
fixed bug
ArthurZucker May 25, 2022
d8c3c24
cleaned tf tests
ArthurZucker May 25, 2022
b7aa9d2
style
ArthurZucker May 25, 2022
1894095
removed from PT for slow tests
ArthurZucker May 25, 2022
9431c2c
fix typp
ArthurZucker May 25, 2022
55772ad
opt test as slow
ArthurZucker May 25, 2022
159b606
trying to fix GPT2 undefined
ArthurZucker May 25, 2022
79f005c
correct documentation and add to test doc
ArthurZucker May 26, 2022
875a75c
update tf doc
ArthurZucker May 26, 2022
a1bf76c
fix doc
ArthurZucker May 26, 2022
1a0389b
fake commit
ArthurZucker May 26, 2022
0ba0740
Apply suggestions from code review
ArthurZucker May 27, 2022
9352406
update test based on review
ArthurZucker May 27, 2022
3ba2bbe
Merge branch 'opt-flax-tf' of https://github.com/ArthurZucker/transfo…
ArthurZucker May 27, 2022
c9ef765
Merge branch 'main' of https://github.com/huggingface/transformers in…
ArthurZucker May 27, 2022
8b3cbd3
merged main layer for functionning test
ArthurZucker May 27, 2022
d054906
fixup + quality
ArthurZucker May 27, 2022
5f1bb05
Apply suggestions from code review
ArthurZucker May 31, 2022
f9a2202
update long comment
ArthurZucker May 31, 2022
a6f9537
make fix copies
ArthurZucker May 31, 2022
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
2 changes: 1 addition & 1 deletion docs/source/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Flax), PyTorch, and/or TensorFlow.
| Nystromformer | ❌ | ❌ | ✅ | ❌ | ❌ |
| OpenAI GPT | ✅ | ✅ | ✅ | ✅ | ❌ |
| OpenAI GPT-2 | ✅ | ✅ | ✅ | ✅ | ✅ |
| OPT | ❌ | ❌ | ✅ | | |
| OPT | ❌ | ❌ | ✅ | | |
| Pegasus | ✅ | ✅ | ✅ | ✅ | ✅ |
| Perceiver | ✅ | ❌ | ✅ | ❌ | ❌ |
| PLBart | ✅ | ❌ | ✅ | ❌ | ❌ |
Expand Down
21 changes: 20 additions & 1 deletion docs/source/en/model_doc/opt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,28 @@ The original code can be found [here](https://github.com/facebookresearch/metase
[[autodoc]] OPTModel
- forward


## OPTForCausalLM

[[autodoc]] OPTForCausalLM
- forward

## TFOPTModel

[[autodoc]] TFOPTModel
- call

## TFOPTForCausalLM

[[autodoc]] TFOPTForCausalLM
- call

## FlaxOPTModel

[[autodoc]] FlaxOPTModel
- __call__


## FlaxOPTForCausalLM

[[autodoc]] FlaxOPTForCausalLM
- __call__
16 changes: 16 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,13 @@
"TFOpenAIGPTPreTrainedModel",
]
)
_import_structure["models.opt"].extend(
[
"TFOPTForCausalLM",
"TFOPTModel",
"TFOPTPreTrainedModel",
]
)
_import_structure["models.pegasus"].extend(
["TFPegasusForConditionalGeneration", "TFPegasusModel", "TFPegasusPreTrainedModel"]
)
Expand Down Expand Up @@ -2560,6 +2567,13 @@
]
)
_import_structure["models.mt5"].extend(["FlaxMT5ForConditionalGeneration", "FlaxMT5Model"])
_import_structure["models.opt"].extend(
[
"FlaxOPTForCausalLM",
"FlaxOPTModel",
"FlaxOPTPreTrainedModel",
]
)
_import_structure["models.pegasus"].extend(
[
"FlaxPegasusForConditionalGeneration",
Expand Down Expand Up @@ -4448,6 +4462,7 @@
TFOpenAIGPTModel,
TFOpenAIGPTPreTrainedModel,
)
from .models.opt import TFOPTForCausalLM, TFOPTModel, TFOPTPreTrainedModel
from .models.pegasus import TFPegasusForConditionalGeneration, TFPegasusModel, TFPegasusPreTrainedModel
from .models.rag import TFRagModel, TFRagPreTrainedModel, TFRagSequenceForGeneration, TFRagTokenForGeneration
from .models.rembert import (
Expand Down Expand Up @@ -4717,6 +4732,7 @@
FlaxMBartPreTrainedModel,
)
from .models.mt5 import FlaxMT5ForConditionalGeneration, FlaxMT5Model
from .models.opt import FlaxOPTForCausalLM, FlaxOPTModel, FlaxOPTPreTrainedModel
from .models.pegasus import FlaxPegasusForConditionalGeneration, FlaxPegasusModel, FlaxPegasusPreTrainedModel
from .models.roberta import (
FlaxRobertaForCausalLM,
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/modeling_flax_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
("marian", "FlaxMarianModel"),
("mbart", "FlaxMBartModel"),
("mt5", "FlaxMT5Model"),
("opt", "FlaxOPTModel"),
("pegasus", "FlaxPegasusModel"),
("roberta", "FlaxRobertaModel"),
("roformer", "FlaxRoFormerModel"),
Expand Down Expand Up @@ -129,6 +130,7 @@
("gpt2", "FlaxGPT2LMHeadModel"),
("gpt_neo", "FlaxGPTNeoForCausalLM"),
("gptj", "FlaxGPTJForCausalLM"),
("opt", "FlaxOPTForCausalLM"),
("roberta", "FlaxRobertaForCausalLM"),
("xglm", "FlaxXGLMForCausalLM"),
]
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/modeling_tf_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
("mpnet", "TFMPNetModel"),
("mt5", "TFMT5Model"),
("openai-gpt", "TFOpenAIGPTModel"),
("opt", "TFOPTModel"),
("pegasus", "TFPegasusModel"),
("rembert", "TFRemBertModel"),
("roberta", "TFRobertaModel"),
Expand Down Expand Up @@ -151,6 +152,7 @@
("gpt2", "TFGPT2LMHeadModel"),
("gptj", "TFGPTJForCausalLM"),
("openai-gpt", "TFOpenAIGPTLMHeadModel"),
("opt", "TFOPTForCausalLM"),
("rembert", "TFRemBertForCausalLM"),
("roberta", "TFRobertaForCausalLM"),
("roformer", "TFRoFormerForCausalLM"),
Expand Down
60 changes: 56 additions & 4 deletions src/transformers/models/opt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,79 @@
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import _LazyModule, is_tokenizers_available, is_torch_available
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_flax_available,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)


_import_structure = {"configuration_opt": ["OPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "OPTConfig"]}


if is_torch_available():
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_opt"] = [
"OPT_PRETRAINED_MODEL_ARCHIVE_LIST",
"OPTForCausalLM",
"OPTModel",
"OPTPreTrainedModel",
]

try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_opt"] = ["TFOPTForCausalLM", "TFOPTModel", "TFOPTPreTrainedModel"]

try:
if not is_flax_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_flax_opt"] = [
"FlaxOPTForCausalLM",
"FlaxOPTModel",
"FlaxOPTPreTrainedModel",
]


if TYPE_CHECKING:
from .configuration_opt import OPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OPTConfig

if is_torch_available():
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_opt import OPT_PRETRAINED_MODEL_ARCHIVE_LIST, OPTForCausalLM, OPTModel, OPTPreTrainedModel

try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_opt import TFOPTForCausalLM, TFOPTModel, TFOPTPreTrainedModel

try:
if not is_flax_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_flax_opt import FlaxOPTForCausalLM, FlaxOPTModel, FlaxOPTPreTrainedModel

else:
import sys

Expand Down
Loading