mirror of
https://github.com/huggingface/transformers.git
synced 2025-10-20 17:13:56 +08:00
Compare commits
11 Commits
v4.51.3-Bi
...
simplify-c
Author | SHA1 | Date | |
---|---|---|---|
e3665de463 | |||
3967eaa39e | |||
f92d17c9e6 | |||
c07e817452 | |||
818b572acc | |||
2a727f6604 | |||
226c8ec143 | |||
1f528f9c7e | |||
5a293ea34d | |||
af3b2251d1 | |||
5962d6f7cb |
@ -116,7 +116,7 @@ jobs:
|
||||
command: pip freeze | tee installed.txt
|
||||
- store_artifacts:
|
||||
path: ~/transformers/installed.txt
|
||||
- run: python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
|
||||
- run: python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! Have you added this object to the __all__ object of the module? 🚨'; exit 1)
|
||||
- run: ruff check examples tests src utils
|
||||
- run: ruff format tests src utils --check
|
||||
- run: python utils/custom_init_isort.py --check_only
|
||||
|
4
Makefile
4
Makefile
@ -50,10 +50,9 @@ repo-consistency:
|
||||
# this target runs checks on all files
|
||||
|
||||
quality:
|
||||
@python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
|
||||
@python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! Have you added this object to the __all__ object of the module? 🚨'; exit 1)
|
||||
ruff check $(check_dirs) setup.py conftest.py
|
||||
ruff format --check $(check_dirs) setup.py conftest.py
|
||||
python utils/custom_init_isort.py --check_only
|
||||
python utils/sort_auto_mappings.py --check_only
|
||||
python utils/check_doc_toc.py
|
||||
python utils/check_docstrings.py --check_all
|
||||
@ -62,7 +61,6 @@ quality:
|
||||
# Format source code automatically and check is there are any problems left that need manual fixing
|
||||
|
||||
extra_style_checks:
|
||||
python utils/custom_init_isort.py
|
||||
python utils/sort_auto_mappings.py
|
||||
python utils/check_doc_toc.py --fix_and_overwrite
|
||||
|
||||
|
@ -1499,7 +1499,6 @@ else:
|
||||
"BertForQuestionAnswering",
|
||||
"BertForSequenceClassification",
|
||||
"BertForTokenClassification",
|
||||
"BertLayer",
|
||||
"BertLMHeadModel",
|
||||
"BertModel",
|
||||
"BertPreTrainedModel",
|
||||
@ -1523,7 +1522,6 @@ else:
|
||||
"BigBirdForQuestionAnswering",
|
||||
"BigBirdForSequenceClassification",
|
||||
"BigBirdForTokenClassification",
|
||||
"BigBirdLayer",
|
||||
"BigBirdModel",
|
||||
"BigBirdPreTrainedModel",
|
||||
"load_tf_weights_in_big_bird",
|
||||
@ -1642,7 +1640,6 @@ else:
|
||||
"CanineForQuestionAnswering",
|
||||
"CanineForSequenceClassification",
|
||||
"CanineForTokenClassification",
|
||||
"CanineLayer",
|
||||
"CanineModel",
|
||||
"CaninePreTrainedModel",
|
||||
"load_tf_weights_in_canine",
|
||||
@ -1729,7 +1726,6 @@ else:
|
||||
"ConvBertForQuestionAnswering",
|
||||
"ConvBertForSequenceClassification",
|
||||
"ConvBertForTokenClassification",
|
||||
"ConvBertLayer",
|
||||
"ConvBertModel",
|
||||
"ConvBertPreTrainedModel",
|
||||
"load_tf_weights_in_convbert",
|
||||
@ -1958,7 +1954,6 @@ else:
|
||||
"QDQBertForQuestionAnswering",
|
||||
"QDQBertForSequenceClassification",
|
||||
"QDQBertForTokenClassification",
|
||||
"QDQBertLayer",
|
||||
"QDQBertLMHeadModel",
|
||||
"QDQBertModel",
|
||||
"QDQBertPreTrainedModel",
|
||||
@ -2210,7 +2205,6 @@ else:
|
||||
"FNetForQuestionAnswering",
|
||||
"FNetForSequenceClassification",
|
||||
"FNetForTokenClassification",
|
||||
"FNetLayer",
|
||||
"FNetModel",
|
||||
"FNetPreTrainedModel",
|
||||
]
|
||||
@ -2311,7 +2305,6 @@ else:
|
||||
"GPTNeoXForQuestionAnswering",
|
||||
"GPTNeoXForSequenceClassification",
|
||||
"GPTNeoXForTokenClassification",
|
||||
"GPTNeoXLayer",
|
||||
"GPTNeoXModel",
|
||||
"GPTNeoXPreTrainedModel",
|
||||
]
|
||||
@ -2319,7 +2312,6 @@ else:
|
||||
_import_structure["models.gpt_neox_japanese"].extend(
|
||||
[
|
||||
"GPTNeoXJapaneseForCausalLM",
|
||||
"GPTNeoXJapaneseLayer",
|
||||
"GPTNeoXJapaneseModel",
|
||||
"GPTNeoXJapanesePreTrainedModel",
|
||||
]
|
||||
@ -2551,7 +2543,6 @@ else:
|
||||
"LongformerForTokenClassification",
|
||||
"LongformerModel",
|
||||
"LongformerPreTrainedModel",
|
||||
"LongformerSelfAttention",
|
||||
]
|
||||
)
|
||||
_import_structure["models.longt5"].extend(
|
||||
@ -2584,7 +2575,6 @@ else:
|
||||
"LxmertModel",
|
||||
"LxmertPreTrainedModel",
|
||||
"LxmertVisualFeatureEncoder",
|
||||
"LxmertXLayer",
|
||||
]
|
||||
)
|
||||
_import_structure["models.m2m_100"].extend(
|
||||
@ -2608,7 +2598,9 @@ else:
|
||||
"Mamba2PreTrainedModel",
|
||||
]
|
||||
)
|
||||
_import_structure["models.marian"].extend(["MarianForCausalLM", "MarianModel", "MarianMTModel"])
|
||||
_import_structure["models.marian"].extend(
|
||||
["MarianForCausalLM", "MarianModel", "MarianMTModel", "MarianPreTrainedModel"]
|
||||
)
|
||||
_import_structure["models.markuplm"].extend(
|
||||
[
|
||||
"MarkupLMForQuestionAnswering",
|
||||
@ -2691,7 +2683,6 @@ else:
|
||||
"MobileBertForQuestionAnswering",
|
||||
"MobileBertForSequenceClassification",
|
||||
"MobileBertForTokenClassification",
|
||||
"MobileBertLayer",
|
||||
"MobileBertModel",
|
||||
"MobileBertPreTrainedModel",
|
||||
"load_tf_weights_in_mobilebert",
|
||||
@ -2737,7 +2728,6 @@ else:
|
||||
"MPNetForQuestionAnswering",
|
||||
"MPNetForSequenceClassification",
|
||||
"MPNetForTokenClassification",
|
||||
"MPNetLayer",
|
||||
"MPNetModel",
|
||||
"MPNetPreTrainedModel",
|
||||
]
|
||||
@ -2827,7 +2817,6 @@ else:
|
||||
"NystromformerForQuestionAnswering",
|
||||
"NystromformerForSequenceClassification",
|
||||
"NystromformerForTokenClassification",
|
||||
"NystromformerLayer",
|
||||
"NystromformerModel",
|
||||
"NystromformerPreTrainedModel",
|
||||
]
|
||||
@ -2941,7 +2930,6 @@ else:
|
||||
"PerceiverForMultimodalAutoencoding",
|
||||
"PerceiverForOpticalFlow",
|
||||
"PerceiverForSequenceClassification",
|
||||
"PerceiverLayer",
|
||||
"PerceiverModel",
|
||||
"PerceiverPreTrainedModel",
|
||||
]
|
||||
@ -3077,11 +3065,9 @@ else:
|
||||
)
|
||||
_import_structure["models.reformer"].extend(
|
||||
[
|
||||
"ReformerAttention",
|
||||
"ReformerForMaskedLM",
|
||||
"ReformerForQuestionAnswering",
|
||||
"ReformerForSequenceClassification",
|
||||
"ReformerLayer",
|
||||
"ReformerModel",
|
||||
"ReformerModelWithLMHead",
|
||||
"ReformerPreTrainedModel",
|
||||
@ -3102,7 +3088,6 @@ else:
|
||||
"RemBertForQuestionAnswering",
|
||||
"RemBertForSequenceClassification",
|
||||
"RemBertForTokenClassification",
|
||||
"RemBertLayer",
|
||||
"RemBertModel",
|
||||
"RemBertPreTrainedModel",
|
||||
"load_tf_weights_in_rembert",
|
||||
@ -3149,7 +3134,6 @@ else:
|
||||
"RoCBertForQuestionAnswering",
|
||||
"RoCBertForSequenceClassification",
|
||||
"RoCBertForTokenClassification",
|
||||
"RoCBertLayer",
|
||||
"RoCBertModel",
|
||||
"RoCBertPreTrainedModel",
|
||||
"load_tf_weights_in_roc_bert",
|
||||
@ -3163,7 +3147,6 @@ else:
|
||||
"RoFormerForQuestionAnswering",
|
||||
"RoFormerForSequenceClassification",
|
||||
"RoFormerForTokenClassification",
|
||||
"RoFormerLayer",
|
||||
"RoFormerModel",
|
||||
"RoFormerPreTrainedModel",
|
||||
"load_tf_weights_in_roformer",
|
||||
@ -3220,7 +3203,6 @@ else:
|
||||
"SegformerDecodeHead",
|
||||
"SegformerForImageClassification",
|
||||
"SegformerForSemanticSegmentation",
|
||||
"SegformerLayer",
|
||||
"SegformerModel",
|
||||
"SegformerPreTrainedModel",
|
||||
]
|
||||
@ -3279,7 +3261,6 @@ else:
|
||||
[
|
||||
"SplinterForPreTraining",
|
||||
"SplinterForQuestionAnswering",
|
||||
"SplinterLayer",
|
||||
"SplinterModel",
|
||||
"SplinterPreTrainedModel",
|
||||
]
|
||||
@ -3292,7 +3273,6 @@ else:
|
||||
"SqueezeBertForSequenceClassification",
|
||||
"SqueezeBertForTokenClassification",
|
||||
"SqueezeBertModel",
|
||||
"SqueezeBertModule",
|
||||
"SqueezeBertPreTrainedModel",
|
||||
]
|
||||
)
|
||||
@ -3491,7 +3471,6 @@ else:
|
||||
"ViltForMaskedLM",
|
||||
"ViltForQuestionAnswering",
|
||||
"ViltForTokenClassification",
|
||||
"ViltLayer",
|
||||
"ViltModel",
|
||||
"ViltPreTrainedModel",
|
||||
]
|
||||
@ -3511,7 +3490,6 @@ else:
|
||||
"VisualBertForQuestionAnswering",
|
||||
"VisualBertForRegionToPhraseAlignment",
|
||||
"VisualBertForVisualReasoning",
|
||||
"VisualBertLayer",
|
||||
"VisualBertModel",
|
||||
"VisualBertPreTrainedModel",
|
||||
]
|
||||
@ -3527,7 +3505,6 @@ else:
|
||||
_import_structure["models.vit_mae"].extend(
|
||||
[
|
||||
"ViTMAEForPreTraining",
|
||||
"ViTMAELayer",
|
||||
"ViTMAEModel",
|
||||
"ViTMAEPreTrainedModel",
|
||||
]
|
||||
@ -3707,7 +3684,6 @@ else:
|
||||
"YosoForQuestionAnswering",
|
||||
"YosoForSequenceClassification",
|
||||
"YosoForTokenClassification",
|
||||
"YosoLayer",
|
||||
"YosoModel",
|
||||
"YosoPreTrainedModel",
|
||||
]
|
||||
@ -3854,7 +3830,6 @@ else:
|
||||
)
|
||||
_import_structure["models.bert"].extend(
|
||||
[
|
||||
"TFBertEmbeddings",
|
||||
"TFBertForMaskedLM",
|
||||
"TFBertForMultipleChoice",
|
||||
"TFBertForNextSentencePrediction",
|
||||
@ -3920,7 +3895,6 @@ else:
|
||||
"TFConvBertForQuestionAnswering",
|
||||
"TFConvBertForSequenceClassification",
|
||||
"TFConvBertForTokenClassification",
|
||||
"TFConvBertLayer",
|
||||
"TFConvBertModel",
|
||||
"TFConvBertPreTrainedModel",
|
||||
]
|
||||
@ -4151,7 +4125,6 @@ else:
|
||||
"TFLongformerForTokenClassification",
|
||||
"TFLongformerModel",
|
||||
"TFLongformerPreTrainedModel",
|
||||
"TFLongformerSelfAttention",
|
||||
]
|
||||
)
|
||||
_import_structure["models.lxmert"].extend(
|
||||
@ -4252,7 +4225,6 @@ else:
|
||||
"TFRemBertForQuestionAnswering",
|
||||
"TFRemBertForSequenceClassification",
|
||||
"TFRemBertForTokenClassification",
|
||||
"TFRemBertLayer",
|
||||
"TFRemBertModel",
|
||||
"TFRemBertPreTrainedModel",
|
||||
]
|
||||
@ -4298,7 +4270,6 @@ else:
|
||||
"TFRoFormerForQuestionAnswering",
|
||||
"TFRoFormerForSequenceClassification",
|
||||
"TFRoFormerForTokenClassification",
|
||||
"TFRoFormerLayer",
|
||||
"TFRoFormerModel",
|
||||
"TFRoFormerPreTrainedModel",
|
||||
]
|
||||
@ -5827,7 +5798,8 @@ if TYPE_CHECKING:
|
||||
from .models.llama import LlamaTokenizer
|
||||
from .models.m2m_100 import M2M100Tokenizer
|
||||
from .models.marian import MarianTokenizer
|
||||
from .models.mbart import MBart50Tokenizer, MBartTokenizer
|
||||
from .models.mbart import MBartTokenizer
|
||||
from .models.mbart50 import MBart50Tokenizer
|
||||
from .models.mluke import MLukeTokenizer
|
||||
from .models.mt5 import MT5Tokenizer
|
||||
from .models.nllb import NllbTokenizer
|
||||
@ -6298,7 +6270,6 @@ if TYPE_CHECKING:
|
||||
BertForQuestionAnswering,
|
||||
BertForSequenceClassification,
|
||||
BertForTokenClassification,
|
||||
BertLayer,
|
||||
BertLMHeadModel,
|
||||
BertModel,
|
||||
BertPreTrainedModel,
|
||||
@ -6318,7 +6289,6 @@ if TYPE_CHECKING:
|
||||
BigBirdForQuestionAnswering,
|
||||
BigBirdForSequenceClassification,
|
||||
BigBirdForTokenClassification,
|
||||
BigBirdLayer,
|
||||
BigBirdModel,
|
||||
BigBirdPreTrainedModel,
|
||||
load_tf_weights_in_big_bird,
|
||||
@ -6413,7 +6383,6 @@ if TYPE_CHECKING:
|
||||
CanineForQuestionAnswering,
|
||||
CanineForSequenceClassification,
|
||||
CanineForTokenClassification,
|
||||
CanineLayer,
|
||||
CanineModel,
|
||||
CaninePreTrainedModel,
|
||||
load_tf_weights_in_canine,
|
||||
@ -6486,7 +6455,6 @@ if TYPE_CHECKING:
|
||||
ConvBertForQuestionAnswering,
|
||||
ConvBertForSequenceClassification,
|
||||
ConvBertForTokenClassification,
|
||||
ConvBertLayer,
|
||||
ConvBertModel,
|
||||
ConvBertPreTrainedModel,
|
||||
load_tf_weights_in_convbert,
|
||||
@ -6671,7 +6639,6 @@ if TYPE_CHECKING:
|
||||
QDQBertForQuestionAnswering,
|
||||
QDQBertForSequenceClassification,
|
||||
QDQBertForTokenClassification,
|
||||
QDQBertLayer,
|
||||
QDQBertLMHeadModel,
|
||||
QDQBertModel,
|
||||
QDQBertPreTrainedModel,
|
||||
@ -6870,7 +6837,6 @@ if TYPE_CHECKING:
|
||||
FNetForQuestionAnswering,
|
||||
FNetForSequenceClassification,
|
||||
FNetForTokenClassification,
|
||||
FNetLayer,
|
||||
FNetModel,
|
||||
FNetPreTrainedModel,
|
||||
)
|
||||
@ -6958,13 +6924,11 @@ if TYPE_CHECKING:
|
||||
GPTNeoXForQuestionAnswering,
|
||||
GPTNeoXForSequenceClassification,
|
||||
GPTNeoXForTokenClassification,
|
||||
GPTNeoXLayer,
|
||||
GPTNeoXModel,
|
||||
GPTNeoXPreTrainedModel,
|
||||
)
|
||||
from .models.gpt_neox_japanese import (
|
||||
GPTNeoXJapaneseForCausalLM,
|
||||
GPTNeoXJapaneseLayer,
|
||||
GPTNeoXJapaneseModel,
|
||||
GPTNeoXJapanesePreTrainedModel,
|
||||
)
|
||||
@ -7140,7 +7104,6 @@ if TYPE_CHECKING:
|
||||
LongformerForTokenClassification,
|
||||
LongformerModel,
|
||||
LongformerPreTrainedModel,
|
||||
LongformerSelfAttention,
|
||||
)
|
||||
from .models.longt5 import (
|
||||
LongT5EncoderModel,
|
||||
@ -7167,7 +7130,6 @@ if TYPE_CHECKING:
|
||||
LxmertModel,
|
||||
LxmertPreTrainedModel,
|
||||
LxmertVisualFeatureEncoder,
|
||||
LxmertXLayer,
|
||||
)
|
||||
from .models.m2m_100 import (
|
||||
M2M100ForConditionalGeneration,
|
||||
@ -7184,7 +7146,7 @@ if TYPE_CHECKING:
|
||||
Mamba2Model,
|
||||
Mamba2PreTrainedModel,
|
||||
)
|
||||
from .models.marian import MarianForCausalLM, MarianModel, MarianMTModel
|
||||
from .models.marian import MarianForCausalLM, MarianModel, MarianMTModel, MarianPreTrainedModel
|
||||
from .models.markuplm import (
|
||||
MarkupLMForQuestionAnswering,
|
||||
MarkupLMForSequenceClassification,
|
||||
@ -7250,7 +7212,6 @@ if TYPE_CHECKING:
|
||||
MobileBertForQuestionAnswering,
|
||||
MobileBertForSequenceClassification,
|
||||
MobileBertForTokenClassification,
|
||||
MobileBertLayer,
|
||||
MobileBertModel,
|
||||
MobileBertPreTrainedModel,
|
||||
load_tf_weights_in_mobilebert,
|
||||
@ -7286,7 +7247,6 @@ if TYPE_CHECKING:
|
||||
MPNetForQuestionAnswering,
|
||||
MPNetForSequenceClassification,
|
||||
MPNetForTokenClassification,
|
||||
MPNetLayer,
|
||||
MPNetModel,
|
||||
MPNetPreTrainedModel,
|
||||
)
|
||||
@ -7358,7 +7318,6 @@ if TYPE_CHECKING:
|
||||
NystromformerForQuestionAnswering,
|
||||
NystromformerForSequenceClassification,
|
||||
NystromformerForTokenClassification,
|
||||
NystromformerLayer,
|
||||
NystromformerModel,
|
||||
NystromformerPreTrainedModel,
|
||||
)
|
||||
@ -7446,7 +7405,6 @@ if TYPE_CHECKING:
|
||||
PerceiverForMultimodalAutoencoding,
|
||||
PerceiverForOpticalFlow,
|
||||
PerceiverForSequenceClassification,
|
||||
PerceiverLayer,
|
||||
PerceiverModel,
|
||||
PerceiverPreTrainedModel,
|
||||
)
|
||||
@ -7548,11 +7506,9 @@ if TYPE_CHECKING:
|
||||
RecurrentGemmaPreTrainedModel,
|
||||
)
|
||||
from .models.reformer import (
|
||||
ReformerAttention,
|
||||
ReformerForMaskedLM,
|
||||
ReformerForQuestionAnswering,
|
||||
ReformerForSequenceClassification,
|
||||
ReformerLayer,
|
||||
ReformerModel,
|
||||
ReformerModelWithLMHead,
|
||||
ReformerPreTrainedModel,
|
||||
@ -7569,7 +7525,6 @@ if TYPE_CHECKING:
|
||||
RemBertForQuestionAnswering,
|
||||
RemBertForSequenceClassification,
|
||||
RemBertForTokenClassification,
|
||||
RemBertLayer,
|
||||
RemBertModel,
|
||||
RemBertPreTrainedModel,
|
||||
load_tf_weights_in_rembert,
|
||||
@ -7608,7 +7563,6 @@ if TYPE_CHECKING:
|
||||
RoCBertForQuestionAnswering,
|
||||
RoCBertForSequenceClassification,
|
||||
RoCBertForTokenClassification,
|
||||
RoCBertLayer,
|
||||
RoCBertModel,
|
||||
RoCBertPreTrainedModel,
|
||||
load_tf_weights_in_roc_bert,
|
||||
@ -7620,7 +7574,6 @@ if TYPE_CHECKING:
|
||||
RoFormerForQuestionAnswering,
|
||||
RoFormerForSequenceClassification,
|
||||
RoFormerForTokenClassification,
|
||||
RoFormerLayer,
|
||||
RoFormerModel,
|
||||
RoFormerPreTrainedModel,
|
||||
load_tf_weights_in_roformer,
|
||||
@ -7665,7 +7618,6 @@ if TYPE_CHECKING:
|
||||
SegformerDecodeHead,
|
||||
SegformerForImageClassification,
|
||||
SegformerForSemanticSegmentation,
|
||||
SegformerLayer,
|
||||
SegformerModel,
|
||||
SegformerPreTrainedModel,
|
||||
)
|
||||
@ -7710,7 +7662,6 @@ if TYPE_CHECKING:
|
||||
from .models.splinter import (
|
||||
SplinterForPreTraining,
|
||||
SplinterForQuestionAnswering,
|
||||
SplinterLayer,
|
||||
SplinterModel,
|
||||
SplinterPreTrainedModel,
|
||||
)
|
||||
@ -7721,7 +7672,6 @@ if TYPE_CHECKING:
|
||||
SqueezeBertForSequenceClassification,
|
||||
SqueezeBertForTokenClassification,
|
||||
SqueezeBertModel,
|
||||
SqueezeBertModule,
|
||||
SqueezeBertPreTrainedModel,
|
||||
)
|
||||
from .models.stablelm import (
|
||||
@ -7870,7 +7820,6 @@ if TYPE_CHECKING:
|
||||
ViltForMaskedLM,
|
||||
ViltForQuestionAnswering,
|
||||
ViltForTokenClassification,
|
||||
ViltLayer,
|
||||
ViltModel,
|
||||
ViltPreTrainedModel,
|
||||
)
|
||||
@ -7886,7 +7835,6 @@ if TYPE_CHECKING:
|
||||
VisualBertForQuestionAnswering,
|
||||
VisualBertForRegionToPhraseAlignment,
|
||||
VisualBertForVisualReasoning,
|
||||
VisualBertLayer,
|
||||
VisualBertModel,
|
||||
VisualBertPreTrainedModel,
|
||||
)
|
||||
@ -7898,7 +7846,6 @@ if TYPE_CHECKING:
|
||||
)
|
||||
from .models.vit_mae import (
|
||||
ViTMAEForPreTraining,
|
||||
ViTMAELayer,
|
||||
ViTMAEModel,
|
||||
ViTMAEPreTrainedModel,
|
||||
)
|
||||
@ -8040,7 +7987,6 @@ if TYPE_CHECKING:
|
||||
YosoForQuestionAnswering,
|
||||
YosoForSequenceClassification,
|
||||
YosoForTokenClassification,
|
||||
YosoLayer,
|
||||
YosoModel,
|
||||
YosoPreTrainedModel,
|
||||
)
|
||||
@ -8174,7 +8120,6 @@ if TYPE_CHECKING:
|
||||
TFBartPretrainedModel,
|
||||
)
|
||||
from .models.bert import (
|
||||
TFBertEmbeddings,
|
||||
TFBertForMaskedLM,
|
||||
TFBertForMultipleChoice,
|
||||
TFBertForNextSentencePrediction,
|
||||
@ -8228,7 +8173,6 @@ if TYPE_CHECKING:
|
||||
TFConvBertForQuestionAnswering,
|
||||
TFConvBertForSequenceClassification,
|
||||
TFConvBertForTokenClassification,
|
||||
TFConvBertLayer,
|
||||
TFConvBertModel,
|
||||
TFConvBertPreTrainedModel,
|
||||
)
|
||||
@ -8413,7 +8357,6 @@ if TYPE_CHECKING:
|
||||
TFLongformerForTokenClassification,
|
||||
TFLongformerModel,
|
||||
TFLongformerPreTrainedModel,
|
||||
TFLongformerSelfAttention,
|
||||
)
|
||||
from .models.lxmert import (
|
||||
TFLxmertForPreTraining,
|
||||
@ -8503,7 +8446,6 @@ if TYPE_CHECKING:
|
||||
TFRemBertForQuestionAnswering,
|
||||
TFRemBertForSequenceClassification,
|
||||
TFRemBertForTokenClassification,
|
||||
TFRemBertLayer,
|
||||
TFRemBertModel,
|
||||
TFRemBertPreTrainedModel,
|
||||
)
|
||||
@ -8541,7 +8483,6 @@ if TYPE_CHECKING:
|
||||
TFRoFormerForQuestionAnswering,
|
||||
TFRoFormerForSequenceClassification,
|
||||
TFRoFormerForTokenClassification,
|
||||
TFRoFormerLayer,
|
||||
TFRoFormerModel,
|
||||
TFRoFormerPreTrainedModel,
|
||||
)
|
||||
|
@ -11,165 +11,21 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_sentencepiece_available,
|
||||
is_tf_available,
|
||||
is_tokenizers_available,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_albert": ["AlbertConfig", "AlbertOnnxConfig"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_albert"] = ["AlbertTokenizer"]
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_albert_fast"] = ["AlbertTokenizerFast"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_albert"] = [
|
||||
"AlbertForMaskedLM",
|
||||
"AlbertForMultipleChoice",
|
||||
"AlbertForPreTraining",
|
||||
"AlbertForQuestionAnswering",
|
||||
"AlbertForSequenceClassification",
|
||||
"AlbertForTokenClassification",
|
||||
"AlbertModel",
|
||||
"AlbertPreTrainedModel",
|
||||
"load_tf_weights_in_albert",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_albert"] = [
|
||||
"TFAlbertForMaskedLM",
|
||||
"TFAlbertForMultipleChoice",
|
||||
"TFAlbertForPreTraining",
|
||||
"TFAlbertForQuestionAnswering",
|
||||
"TFAlbertForSequenceClassification",
|
||||
"TFAlbertForTokenClassification",
|
||||
"TFAlbertMainLayer",
|
||||
"TFAlbertModel",
|
||||
"TFAlbertPreTrainedModel",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_albert"] = [
|
||||
"FlaxAlbertForMaskedLM",
|
||||
"FlaxAlbertForMultipleChoice",
|
||||
"FlaxAlbertForPreTraining",
|
||||
"FlaxAlbertForQuestionAnswering",
|
||||
"FlaxAlbertForSequenceClassification",
|
||||
"FlaxAlbertForTokenClassification",
|
||||
"FlaxAlbertModel",
|
||||
"FlaxAlbertPreTrainedModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_albert import AlbertConfig, AlbertOnnxConfig
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_albert import AlbertTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_albert_fast import AlbertTokenizerFast
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_albert import (
|
||||
AlbertForMaskedLM,
|
||||
AlbertForMultipleChoice,
|
||||
AlbertForPreTraining,
|
||||
AlbertForQuestionAnswering,
|
||||
AlbertForSequenceClassification,
|
||||
AlbertForTokenClassification,
|
||||
AlbertModel,
|
||||
AlbertPreTrainedModel,
|
||||
load_tf_weights_in_albert,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_albert import (
|
||||
TFAlbertForMaskedLM,
|
||||
TFAlbertForMultipleChoice,
|
||||
TFAlbertForPreTraining,
|
||||
TFAlbertForQuestionAnswering,
|
||||
TFAlbertForSequenceClassification,
|
||||
TFAlbertForTokenClassification,
|
||||
TFAlbertMainLayer,
|
||||
TFAlbertModel,
|
||||
TFAlbertPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_albert import (
|
||||
FlaxAlbertForMaskedLM,
|
||||
FlaxAlbertForMultipleChoice,
|
||||
FlaxAlbertForPreTraining,
|
||||
FlaxAlbertForQuestionAnswering,
|
||||
FlaxAlbertForSequenceClassification,
|
||||
FlaxAlbertForTokenClassification,
|
||||
FlaxAlbertModel,
|
||||
FlaxAlbertPreTrainedModel,
|
||||
)
|
||||
from .configuration_albert import *
|
||||
from .modeling_albert import *
|
||||
from .modeling_flax_albert import *
|
||||
from .modeling_tf_albert import *
|
||||
from .tokenization_albert import *
|
||||
from .tokenization_albert_fast import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -165,3 +165,6 @@ class AlbertOnnxConfig(OnnxConfig):
|
||||
("token_type_ids", dynamic_axis),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["AlbertConfig", "AlbertOnnxConfig"]
|
||||
|
@ -1466,3 +1466,16 @@ class AlbertForMultipleChoice(AlbertPreTrainedModel):
|
||||
hidden_states=outputs.hidden_states,
|
||||
attentions=outputs.attentions,
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"load_tf_weights_in_albert",
|
||||
"AlbertPreTrainedModel",
|
||||
"AlbertModel",
|
||||
"AlbertForPreTraining",
|
||||
"AlbertForMaskedLM",
|
||||
"AlbertForSequenceClassification",
|
||||
"AlbertForTokenClassification",
|
||||
"AlbertForQuestionAnswering",
|
||||
"AlbertForMultipleChoice",
|
||||
]
|
||||
|
@ -1119,3 +1119,14 @@ append_call_sample_docstring(
|
||||
FlaxQuestionAnsweringModelOutput,
|
||||
_CONFIG_FOR_DOC,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FlaxAlbertPreTrainedModel",
|
||||
"FlaxAlbertModel",
|
||||
"FlaxAlbertForPreTraining",
|
||||
"FlaxAlbertForMaskedLM",
|
||||
"FlaxAlbertForSequenceClassification",
|
||||
"FlaxAlbertForMultipleChoice",
|
||||
"FlaxAlbertForTokenClassification",
|
||||
"FlaxAlbertForQuestionAnswering",
|
||||
]
|
||||
|
@ -1558,3 +1558,16 @@ class TFAlbertForMultipleChoice(TFAlbertPreTrainedModel, TFMultipleChoiceLoss):
|
||||
if getattr(self, "classifier", None) is not None:
|
||||
with tf.name_scope(self.classifier.name):
|
||||
self.classifier.build([None, None, self.config.hidden_size])
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TFAlbertPreTrainedModel",
|
||||
"TFAlbertModel",
|
||||
"TFAlbertForPreTraining",
|
||||
"TFAlbertForMaskedLM",
|
||||
"TFAlbertForSequenceClassification",
|
||||
"TFAlbertForTokenClassification",
|
||||
"TFAlbertForQuestionAnswering",
|
||||
"TFAlbertForMultipleChoice",
|
||||
"TFAlbertMainLayer",
|
||||
]
|
||||
|
@ -23,6 +23,7 @@ import sentencepiece as spm
|
||||
|
||||
from ...tokenization_utils import AddedToken, PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
@ -32,6 +33,7 @@ VOCAB_FILES_NAMES = {"vocab_file": "spiece.model"}
|
||||
SPIECE_UNDERLINE = "▁"
|
||||
|
||||
|
||||
@export(backends=("sentencepiece",))
|
||||
class AlbertTokenizer(PreTrainedTokenizer):
|
||||
"""
|
||||
Construct an ALBERT tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
|
||||
@ -343,3 +345,6 @@ class AlbertTokenizer(PreTrainedTokenizer):
|
||||
fi.write(content_spiece_model)
|
||||
|
||||
return (out_vocab_file,)
|
||||
|
||||
|
||||
__all__ = ["AlbertTokenizer"]
|
||||
|
@ -207,3 +207,6 @@ class AlbertTokenizerFast(PreTrainedTokenizerFast):
|
||||
copyfile(self.vocab_file, out_vocab_file)
|
||||
|
||||
return (out_vocab_file,)
|
||||
|
||||
|
||||
__all__ = ["AlbertTokenizerFast"]
|
||||
|
@ -13,57 +13,16 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_align": [
|
||||
"AlignConfig",
|
||||
"AlignTextConfig",
|
||||
"AlignVisionConfig",
|
||||
],
|
||||
"processing_align": ["AlignProcessor"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_align"] = [
|
||||
"AlignModel",
|
||||
"AlignPreTrainedModel",
|
||||
"AlignTextModel",
|
||||
"AlignVisionModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_align import (
|
||||
AlignConfig,
|
||||
AlignTextConfig,
|
||||
AlignVisionConfig,
|
||||
)
|
||||
from .processing_align import AlignProcessor
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_align import (
|
||||
AlignModel,
|
||||
AlignPreTrainedModel,
|
||||
AlignTextModel,
|
||||
AlignVisionModel,
|
||||
)
|
||||
|
||||
from .configuration_align import *
|
||||
from .modeling_align import *
|
||||
from .processing_align import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -378,3 +378,6 @@ class AlignConfig(PretrainedConfig):
|
||||
"""
|
||||
|
||||
return cls(text_config=text_config.to_dict(), vision_config=vision_config.to_dict(), **kwargs)
|
||||
|
||||
|
||||
__all__ = ["AlignTextConfig", "AlignVisionConfig", "AlignConfig"]
|
||||
|
@ -1636,3 +1636,6 @@ class AlignModel(AlignPreTrainedModel):
|
||||
text_model_output=text_outputs,
|
||||
vision_model_output=vision_outputs,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["AlignPreTrainedModel", "AlignTextModel", "AlignVisionModel", "AlignModel"]
|
||||
|
@ -162,3 +162,6 @@ class AlignProcessor(ProcessorMixin):
|
||||
tokenizer_input_names = self.tokenizer.model_input_names
|
||||
image_processor_input_names = self.image_processor.model_input_names
|
||||
return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
|
||||
|
||||
|
||||
__all__ = ["AlignProcessor"]
|
||||
|
@ -13,55 +13,16 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_altclip": [
|
||||
"AltCLIPConfig",
|
||||
"AltCLIPTextConfig",
|
||||
"AltCLIPVisionConfig",
|
||||
],
|
||||
"processing_altclip": ["AltCLIPProcessor"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_altclip"] = [
|
||||
"AltCLIPPreTrainedModel",
|
||||
"AltCLIPModel",
|
||||
"AltCLIPTextModel",
|
||||
"AltCLIPVisionModel",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_altclip import (
|
||||
AltCLIPConfig,
|
||||
AltCLIPTextConfig,
|
||||
AltCLIPVisionConfig,
|
||||
)
|
||||
from .processing_altclip import AltCLIPProcessor
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_altclip import (
|
||||
AltCLIPModel,
|
||||
AltCLIPPreTrainedModel,
|
||||
AltCLIPTextModel,
|
||||
AltCLIPVisionModel,
|
||||
)
|
||||
|
||||
|
||||
from .configuration_altclip import *
|
||||
from .modeling_altclip import *
|
||||
from .processing_altclip import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -398,3 +398,6 @@ class AltCLIPConfig(PretrainedConfig):
|
||||
"""
|
||||
|
||||
return cls(text_config=text_config.to_dict(), vision_config=vision_config.to_dict(), **kwargs)
|
||||
|
||||
|
||||
__all__ = ["AltCLIPTextConfig", "AltCLIPVisionConfig", "AltCLIPConfig"]
|
||||
|
@ -1694,3 +1694,6 @@ def create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_l
|
||||
mask = input_ids.ne(padding_idx).int()
|
||||
incremental_indices = (torch.cumsum(mask, dim=1).type_as(mask) + past_key_values_length) * mask
|
||||
return incremental_indices.long() + padding_idx
|
||||
|
||||
|
||||
__all__ = ["AltCLIPPreTrainedModel", "AltCLIPVisionModel", "AltCLIPTextModel", "AltCLIPModel"]
|
||||
|
@ -130,3 +130,6 @@ class AltCLIPProcessor(ProcessorMixin):
|
||||
tokenizer_input_names = self.tokenizer.model_input_names
|
||||
image_processor_input_names = self.image_processor.model_input_names
|
||||
return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names))
|
||||
|
||||
|
||||
__all__ = ["AltCLIPProcessor"]
|
||||
|
@ -13,47 +13,16 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_audio_spectrogram_transformer": ["ASTConfig"],
|
||||
"feature_extraction_audio_spectrogram_transformer": ["ASTFeatureExtractor"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_audio_spectrogram_transformer"] = [
|
||||
"ASTForAudioClassification",
|
||||
"ASTModel",
|
||||
"ASTPreTrainedModel",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_audio_spectrogram_transformer import (
|
||||
ASTConfig,
|
||||
)
|
||||
from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_audio_spectrogram_transformer import (
|
||||
ASTForAudioClassification,
|
||||
ASTModel,
|
||||
ASTPreTrainedModel,
|
||||
)
|
||||
|
||||
|
||||
from .configuration_audio_spectrogram_transformer import *
|
||||
from .feature_extraction_audio_spectrogram_transformer import *
|
||||
from .modeling_audio_spectrogram_transformer import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -126,3 +126,6 @@ class ASTConfig(PretrainedConfig):
|
||||
# generative parameters deprecation cycle, overwriting this function prevents this from happening.
|
||||
def _get_non_default_generation_parameters(self) -> Dict[str, Any]:
|
||||
return {}
|
||||
|
||||
|
||||
__all__ = ["ASTConfig"]
|
||||
|
@ -234,3 +234,6 @@ class ASTFeatureExtractor(SequenceFeatureExtractor):
|
||||
padded_inputs = padded_inputs.convert_to_tensors(return_tensors)
|
||||
|
||||
return padded_inputs
|
||||
|
||||
|
||||
__all__ = ["ASTFeatureExtractor"]
|
||||
|
@ -654,3 +654,6 @@ class ASTForAudioClassification(ASTPreTrainedModel):
|
||||
hidden_states=outputs.hidden_states,
|
||||
attentions=outputs.attentions,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["ASTPreTrainedModel", "ASTModel", "ASTForAudioClassification"]
|
||||
|
@ -13,45 +13,15 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
# rely on isort to merge the imports
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_autoformer": ["AutoformerConfig"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_autoformer"] = [
|
||||
"AutoformerForPrediction",
|
||||
"AutoformerModel",
|
||||
"AutoformerPreTrainedModel",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_autoformer import (
|
||||
AutoformerConfig,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_autoformer import (
|
||||
AutoformerForPrediction,
|
||||
AutoformerModel,
|
||||
AutoformerPreTrainedModel,
|
||||
)
|
||||
|
||||
from .configuration_autoformer import *
|
||||
from .modeling_autoformer import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -240,3 +240,6 @@ class AutoformerConfig(PretrainedConfig):
|
||||
+ self.num_static_real_features
|
||||
+ self.input_size * 2 # the log1p(abs(loc)) and log(scale) features
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["AutoformerConfig"]
|
||||
|
@ -2150,3 +2150,6 @@ class AutoformerForPrediction(AutoformerPreTrainedModel):
|
||||
(-1, num_parallel_samples, self.config.prediction_length) + self.target_shape,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["AutoformerPreTrainedModel", "AutoformerModel", "AutoformerForPrediction"]
|
||||
|
@ -13,63 +13,16 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_bark": [
|
||||
"BarkCoarseConfig",
|
||||
"BarkConfig",
|
||||
"BarkFineConfig",
|
||||
"BarkSemanticConfig",
|
||||
],
|
||||
"processing_bark": ["BarkProcessor"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_bark"] = [
|
||||
"BarkFineModel",
|
||||
"BarkSemanticModel",
|
||||
"BarkCoarseModel",
|
||||
"BarkModel",
|
||||
"BarkPreTrainedModel",
|
||||
"BarkCausalModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_bark import (
|
||||
BarkCoarseConfig,
|
||||
BarkConfig,
|
||||
BarkFineConfig,
|
||||
BarkSemanticConfig,
|
||||
)
|
||||
from .processing_bark import BarkProcessor
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_bark import (
|
||||
BarkCausalModel,
|
||||
BarkCoarseModel,
|
||||
BarkFineModel,
|
||||
BarkModel,
|
||||
BarkPreTrainedModel,
|
||||
BarkSemanticModel,
|
||||
)
|
||||
|
||||
from .configuration_bark import *
|
||||
from .modeling_bark import *
|
||||
from .processing_bark import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -323,3 +323,6 @@ class BarkConfig(PretrainedConfig):
|
||||
codec_config=codec_config.to_dict(),
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BarkSemanticConfig", "BarkCoarseConfig", "BarkFineConfig", "BarkConfig"]
|
||||
|
@ -546,6 +546,8 @@ BARK_CAUSAL_MODEL_INPUTS_DOCSTRING = r"""
|
||||
|
||||
|
||||
# GPT2-like autoregressive model
|
||||
|
||||
|
||||
class BarkCausalModel(BarkPreTrainedModel):
|
||||
config_class = BarkSubModelConfig
|
||||
|
||||
@ -1811,3 +1813,13 @@ class BarkModel(BarkPreTrainedModel):
|
||||
config.coarse_acoustics_config._attn_implementation = config._attn_implementation
|
||||
config.fine_acoustics_config._attn_implementation = config._attn_implementation
|
||||
return config
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BarkPreTrainedModel",
|
||||
"BarkCausalModel",
|
||||
"BarkFineModel",
|
||||
"BarkCoarseModel",
|
||||
"BarkSemanticModel",
|
||||
"BarkModel",
|
||||
]
|
||||
|
@ -285,3 +285,6 @@ class BarkProcessor(ProcessorMixin):
|
||||
encoded_text["history_prompt"] = voice_preset
|
||||
|
||||
return encoded_text
|
||||
|
||||
|
||||
__all__ = ["BarkProcessor"]
|
||||
|
@ -13,134 +13,19 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_tf_available,
|
||||
is_tokenizers_available,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_bart": ["BartConfig", "BartOnnxConfig"],
|
||||
"tokenization_bart": ["BartTokenizer"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_bart_fast"] = ["BartTokenizerFast"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_bart"] = [
|
||||
"BartForCausalLM",
|
||||
"BartForConditionalGeneration",
|
||||
"BartForQuestionAnswering",
|
||||
"BartForSequenceClassification",
|
||||
"BartModel",
|
||||
"BartPreTrainedModel",
|
||||
"BartPretrainedModel",
|
||||
"PretrainedBartModel",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_bart"] = [
|
||||
"TFBartForConditionalGeneration",
|
||||
"TFBartForSequenceClassification",
|
||||
"TFBartModel",
|
||||
"TFBartPretrainedModel",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_bart"] = [
|
||||
"FlaxBartDecoderPreTrainedModel",
|
||||
"FlaxBartForCausalLM",
|
||||
"FlaxBartForConditionalGeneration",
|
||||
"FlaxBartForQuestionAnswering",
|
||||
"FlaxBartForSequenceClassification",
|
||||
"FlaxBartModel",
|
||||
"FlaxBartPreTrainedModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_bart import BartConfig, BartOnnxConfig
|
||||
from .tokenization_bart import BartTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_bart_fast import BartTokenizerFast
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_bart import (
|
||||
BartForCausalLM,
|
||||
BartForConditionalGeneration,
|
||||
BartForQuestionAnswering,
|
||||
BartForSequenceClassification,
|
||||
BartModel,
|
||||
BartPreTrainedModel,
|
||||
BartPretrainedModel,
|
||||
PretrainedBartModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_bart import (
|
||||
TFBartForConditionalGeneration,
|
||||
TFBartForSequenceClassification,
|
||||
TFBartModel,
|
||||
TFBartPretrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_bart import (
|
||||
FlaxBartDecoderPreTrainedModel,
|
||||
FlaxBartForCausalLM,
|
||||
FlaxBartForConditionalGeneration,
|
||||
FlaxBartForQuestionAnswering,
|
||||
FlaxBartForSequenceClassification,
|
||||
FlaxBartModel,
|
||||
FlaxBartPreTrainedModel,
|
||||
)
|
||||
|
||||
from .configuration_bart import *
|
||||
from .modeling_bart import *
|
||||
from .modeling_flax_bart import *
|
||||
from .modeling_tf_bart import *
|
||||
from .tokenization_bart import *
|
||||
from .tokenization_bart_fast import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -18,10 +18,10 @@ import warnings
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Mapping, Optional
|
||||
|
||||
from ... import PreTrainedTokenizer
|
||||
from ...configuration_utils import PretrainedConfig
|
||||
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeq2SeqConfigWithPast
|
||||
from ...onnx.utils import compute_effective_axis_dimension
|
||||
from ...tokenization_utils import PreTrainedTokenizer
|
||||
from ...utils import TensorType, is_torch_available, logging
|
||||
|
||||
|
||||
@ -400,3 +400,6 @@ class BartOnnxConfig(OnnxSeq2SeqConfigWithPast):
|
||||
flattened_output = super(OnnxSeq2SeqConfigWithPast, self)._flatten_past_key_values_(
|
||||
flattened_output, name, idx, t
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BartConfig", "BartOnnxConfig"]
|
||||
|
@ -2222,3 +2222,16 @@ class BartForCausalLM(BartPreTrainedModel):
|
||||
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
||||
)
|
||||
return reordered_past
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BartPreTrainedModel",
|
||||
"PretrainedBartModel",
|
||||
"BartPretrainedModel",
|
||||
"BartDecoder",
|
||||
"BartModel",
|
||||
"BartForConditionalGeneration",
|
||||
"BartForSequenceClassification",
|
||||
"BartForQuestionAnswering",
|
||||
"BartForCausalLM",
|
||||
]
|
||||
|
@ -1993,3 +1993,13 @@ append_call_sample_docstring(
|
||||
FlaxCausalLMOutputWithCrossAttentions,
|
||||
_CONFIG_FOR_DOC,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FlaxBartPreTrainedModel",
|
||||
"FlaxBartModel",
|
||||
"FlaxBartForConditionalGeneration",
|
||||
"FlaxBartForSequenceClassification",
|
||||
"FlaxBartForQuestionAnswering",
|
||||
"FlaxBartDecoderPreTrainedModel",
|
||||
"FlaxBartForCausalLM",
|
||||
]
|
||||
|
@ -1709,3 +1709,12 @@ class TFBartForSequenceClassification(TFBartPretrainedModel, TFSequenceClassific
|
||||
if getattr(self, "classification_head", None) is not None:
|
||||
with tf.name_scope(self.classification_head.name):
|
||||
self.classification_head.build(None)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TFBartPretrainedModel",
|
||||
"TFBartModel",
|
||||
"TFBartForConditionalGeneration",
|
||||
"TFBartForSequenceClassification",
|
||||
"TFBartMainLayer",
|
||||
]
|
||||
|
@ -388,3 +388,6 @@ class BartTokenizer(PreTrainedTokenizer):
|
||||
if (is_split_into_words or add_prefix_space) and (len(text) > 0 and not text[0].isspace()):
|
||||
text = " " + text
|
||||
return (text, kwargs)
|
||||
|
||||
|
||||
__all__ = ["BartTokenizer"]
|
||||
|
@ -274,3 +274,6 @@ class BartTokenizerFast(PreTrainedTokenizerFast):
|
||||
if token_ids_1 is None:
|
||||
return len(cls + token_ids_0 + sep) * [0]
|
||||
return len(cls + token_ids_0 + sep + sep + token_ids_1 + sep) * [0]
|
||||
|
||||
|
||||
__all__ = ["BartTokenizerFast"]
|
||||
|
@ -11,49 +11,17 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available
|
||||
|
||||
|
||||
_import_structure = {}
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_barthez"] = ["BarthezTokenizer"]
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_barthez_fast"] = ["BarthezTokenizerFast"]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_barthez import BarthezTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_barthez_fast import BarthezTokenizerFast
|
||||
|
||||
from .tokenization_barthez import *
|
||||
from .tokenization_barthez_fast import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -22,6 +22,7 @@ import sentencepiece as spm
|
||||
|
||||
from ...tokenization_utils import AddedToken, PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
@ -34,6 +35,7 @@ SPIECE_UNDERLINE = "▁"
|
||||
# TODO this class is useless. This is the most standard sentencpiece model. Let's find which one is closest and nuke this.
|
||||
|
||||
|
||||
@export(backends=("sentencepiece",))
|
||||
class BarthezTokenizer(PreTrainedTokenizer):
|
||||
"""
|
||||
Adapted from [`CamembertTokenizer`] and [`BartTokenizer`]. Construct a BARThez tokenizer. Based on
|
||||
@ -284,3 +286,6 @@ class BarthezTokenizer(PreTrainedTokenizer):
|
||||
fi.write(content_spiece_model)
|
||||
|
||||
return (out_vocab_file,)
|
||||
|
||||
|
||||
__all__ = ["BarthezTokenizer"]
|
||||
|
@ -192,3 +192,6 @@ class BarthezTokenizerFast(PreTrainedTokenizerFast):
|
||||
copyfile(self.vocab_file, out_vocab_file)
|
||||
|
||||
return (out_vocab_file,)
|
||||
|
||||
|
||||
__all__ = ["BarthezTokenizerFast"]
|
||||
|
@ -11,32 +11,16 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {}
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_bartpho"] = ["BartphoTokenizer"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_bartpho import BartphoTokenizer
|
||||
|
||||
from .tokenization_bartpho import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -22,6 +22,7 @@ import sentencepiece as spm
|
||||
|
||||
from ...tokenization_utils import AddedToken, PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
@ -31,6 +32,7 @@ SPIECE_UNDERLINE = "▁"
|
||||
VOCAB_FILES_NAMES = {"vocab_file": "sentencepiece.bpe.model", "monolingual_vocab_file": "dict.txt"}
|
||||
|
||||
|
||||
@export(backends=("sentencepiece",))
|
||||
class BartphoTokenizer(PreTrainedTokenizer):
|
||||
"""
|
||||
Adapted from [`XLMRobertaTokenizer`]. Based on [SentencePiece](https://github.com/google/sentencepiece).
|
||||
@ -311,3 +313,6 @@ class BartphoTokenizer(PreTrainedTokenizer):
|
||||
fp.write(f"{str(token)} \n")
|
||||
|
||||
return out_vocab_file, out_monolingual_vocab_file
|
||||
|
||||
|
||||
__all__ = ["BartphoTokenizer"]
|
||||
|
@ -11,100 +11,20 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_torch_available,
|
||||
is_vision_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {"configuration_beit": ["BeitConfig", "BeitOnnxConfig"]}
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["feature_extraction_beit"] = ["BeitFeatureExtractor"]
|
||||
_import_structure["image_processing_beit"] = ["BeitImageProcessor"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_beit"] = [
|
||||
"BeitForImageClassification",
|
||||
"BeitForMaskedImageModeling",
|
||||
"BeitForSemanticSegmentation",
|
||||
"BeitModel",
|
||||
"BeitPreTrainedModel",
|
||||
"BeitBackbone",
|
||||
]
|
||||
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_beit"] = [
|
||||
"FlaxBeitForImageClassification",
|
||||
"FlaxBeitForMaskedImageModeling",
|
||||
"FlaxBeitModel",
|
||||
"FlaxBeitPreTrainedModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_beit import BeitConfig, BeitOnnxConfig
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .feature_extraction_beit import BeitFeatureExtractor
|
||||
from .image_processing_beit import BeitImageProcessor
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_beit import (
|
||||
BeitBackbone,
|
||||
BeitForImageClassification,
|
||||
BeitForMaskedImageModeling,
|
||||
BeitForSemanticSegmentation,
|
||||
BeitModel,
|
||||
BeitPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_beit import (
|
||||
FlaxBeitForImageClassification,
|
||||
FlaxBeitForMaskedImageModeling,
|
||||
FlaxBeitModel,
|
||||
FlaxBeitPreTrainedModel,
|
||||
)
|
||||
|
||||
|
||||
from .configuration_beit import *
|
||||
from .feature_extraction_beit import *
|
||||
from .image_processing_beit import *
|
||||
from .modeling_beit import *
|
||||
from .modeling_flax_beit import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -224,3 +224,6 @@ class BeitOnnxConfig(OnnxConfig):
|
||||
@property
|
||||
def atol_for_validation(self) -> float:
|
||||
return 1e-4
|
||||
|
||||
|
||||
__all__ = ["BeitConfig", "BeitOnnxConfig"]
|
||||
|
@ -17,12 +17,14 @@
|
||||
import warnings
|
||||
|
||||
from ...utils import logging
|
||||
from ...utils.import_utils import export
|
||||
from .image_processing_beit import BeitImageProcessor
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
|
||||
|
||||
@export(backends=("vision",))
|
||||
class BeitFeatureExtractor(BeitImageProcessor):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
warnings.warn(
|
||||
@ -31,3 +33,6 @@ class BeitFeatureExtractor(BeitImageProcessor):
|
||||
FutureWarning,
|
||||
)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
__all__ = ["BeitFeatureExtractor"]
|
||||
|
@ -42,6 +42,7 @@ from ...utils import (
|
||||
logging,
|
||||
)
|
||||
from ...utils.deprecation import deprecate_kwarg
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@ -54,6 +55,7 @@ if is_torch_available():
|
||||
logger = logging.get_logger(__name__)
|
||||
|
||||
|
||||
@export(backends=("vision",))
|
||||
class BeitImageProcessor(BaseImageProcessor):
|
||||
r"""
|
||||
Constructs a BEiT image processor.
|
||||
@ -510,3 +512,6 @@ class BeitImageProcessor(BaseImageProcessor):
|
||||
semantic_segmentation = [semantic_segmentation[i] for i in range(semantic_segmentation.shape[0])]
|
||||
|
||||
return semantic_segmentation
|
||||
|
||||
|
||||
__all__ = ["BeitImageProcessor"]
|
||||
|
@ -1576,3 +1576,13 @@ class BeitBackbone(BeitPreTrainedModel, BackboneMixin):
|
||||
hidden_states=outputs.hidden_states if output_hidden_states else None,
|
||||
attentions=outputs.attentions,
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BeitPreTrainedModel",
|
||||
"BeitModel",
|
||||
"BeitForMaskedImageModeling",
|
||||
"BeitForImageClassification",
|
||||
"BeitForSemanticSegmentation",
|
||||
"BeitBackbone",
|
||||
]
|
||||
|
@ -946,3 +946,10 @@ overwrite_call_docstring(FlaxBeitForImageClassification, FLAX_BEIT_CLASSIF_DOCST
|
||||
append_replace_return_docstrings(
|
||||
FlaxBeitForImageClassification, output_type=FlaxSequenceClassifierOutput, config_class=BeitConfig
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FlaxBeitPreTrainedModel",
|
||||
"FlaxBeitModel",
|
||||
"FlaxBeitForMaskedImageModeling",
|
||||
"FlaxBeitForImageClassification",
|
||||
]
|
||||
|
@ -11,183 +11,22 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_tensorflow_text_available,
|
||||
is_tf_available,
|
||||
is_tokenizers_available,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_bert": ["BertConfig", "BertOnnxConfig"],
|
||||
"tokenization_bert": ["BasicTokenizer", "BertTokenizer", "WordpieceTokenizer"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_bert_fast"] = ["BertTokenizerFast"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_bert"] = [
|
||||
"BertForMaskedLM",
|
||||
"BertForMultipleChoice",
|
||||
"BertForNextSentencePrediction",
|
||||
"BertForPreTraining",
|
||||
"BertForQuestionAnswering",
|
||||
"BertForSequenceClassification",
|
||||
"BertForTokenClassification",
|
||||
"BertLayer",
|
||||
"BertLMHeadModel",
|
||||
"BertModel",
|
||||
"BertPreTrainedModel",
|
||||
"load_tf_weights_in_bert",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_bert"] = [
|
||||
"TFBertEmbeddings",
|
||||
"TFBertForMaskedLM",
|
||||
"TFBertForMultipleChoice",
|
||||
"TFBertForNextSentencePrediction",
|
||||
"TFBertForPreTraining",
|
||||
"TFBertForQuestionAnswering",
|
||||
"TFBertForSequenceClassification",
|
||||
"TFBertForTokenClassification",
|
||||
"TFBertLMHeadModel",
|
||||
"TFBertMainLayer",
|
||||
"TFBertModel",
|
||||
"TFBertPreTrainedModel",
|
||||
]
|
||||
try:
|
||||
if not is_tensorflow_text_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_bert_tf"] = ["TFBertTokenizer"]
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_bert"] = [
|
||||
"FlaxBertForCausalLM",
|
||||
"FlaxBertForMaskedLM",
|
||||
"FlaxBertForMultipleChoice",
|
||||
"FlaxBertForNextSentencePrediction",
|
||||
"FlaxBertForPreTraining",
|
||||
"FlaxBertForQuestionAnswering",
|
||||
"FlaxBertForSequenceClassification",
|
||||
"FlaxBertForTokenClassification",
|
||||
"FlaxBertModel",
|
||||
"FlaxBertPreTrainedModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_bert import BertConfig, BertOnnxConfig
|
||||
from .tokenization_bert import BasicTokenizer, BertTokenizer, WordpieceTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_bert_fast import BertTokenizerFast
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_bert import (
|
||||
BertForMaskedLM,
|
||||
BertForMultipleChoice,
|
||||
BertForNextSentencePrediction,
|
||||
BertForPreTraining,
|
||||
BertForQuestionAnswering,
|
||||
BertForSequenceClassification,
|
||||
BertForTokenClassification,
|
||||
BertLayer,
|
||||
BertLMHeadModel,
|
||||
BertModel,
|
||||
BertPreTrainedModel,
|
||||
load_tf_weights_in_bert,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_bert import (
|
||||
TFBertEmbeddings,
|
||||
TFBertForMaskedLM,
|
||||
TFBertForMultipleChoice,
|
||||
TFBertForNextSentencePrediction,
|
||||
TFBertForPreTraining,
|
||||
TFBertForQuestionAnswering,
|
||||
TFBertForSequenceClassification,
|
||||
TFBertForTokenClassification,
|
||||
TFBertLMHeadModel,
|
||||
TFBertMainLayer,
|
||||
TFBertModel,
|
||||
TFBertPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tensorflow_text_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_bert_tf import TFBertTokenizer
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_bert import (
|
||||
FlaxBertForCausalLM,
|
||||
FlaxBertForMaskedLM,
|
||||
FlaxBertForMultipleChoice,
|
||||
FlaxBertForNextSentencePrediction,
|
||||
FlaxBertForPreTraining,
|
||||
FlaxBertForQuestionAnswering,
|
||||
FlaxBertForSequenceClassification,
|
||||
FlaxBertForTokenClassification,
|
||||
FlaxBertModel,
|
||||
FlaxBertPreTrainedModel,
|
||||
)
|
||||
|
||||
from .configuration_bert import *
|
||||
from .modeling_bert import *
|
||||
from .modeling_flax_bert import *
|
||||
from .modeling_tf_bert import *
|
||||
from .tokenization_bert import *
|
||||
from .tokenization_bert_fast import *
|
||||
from .tokenization_bert_tf import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -149,3 +149,6 @@ class BertOnnxConfig(OnnxConfig):
|
||||
("token_type_ids", dynamic_axis),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BertConfig", "BertOnnxConfig"]
|
||||
|
@ -2021,3 +2021,18 @@ class BertForQuestionAnswering(BertPreTrainedModel):
|
||||
hidden_states=outputs.hidden_states,
|
||||
attentions=outputs.attentions,
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"load_tf_weights_in_bert",
|
||||
"BertPreTrainedModel",
|
||||
"BertModel",
|
||||
"BertForPreTraining",
|
||||
"BertLMHeadModel",
|
||||
"BertForMaskedLM",
|
||||
"BertForNextSentencePrediction",
|
||||
"BertForSequenceClassification",
|
||||
"BertForMultipleChoice",
|
||||
"BertForTokenClassification",
|
||||
"BertForQuestionAnswering",
|
||||
]
|
||||
|
@ -1711,3 +1711,16 @@ append_call_sample_docstring(
|
||||
FlaxCausalLMOutputWithCrossAttentions,
|
||||
_CONFIG_FOR_DOC,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FlaxBertPreTrainedModel",
|
||||
"FlaxBertModel",
|
||||
"FlaxBertForPreTraining",
|
||||
"FlaxBertForMaskedLM",
|
||||
"FlaxBertForNextSentencePrediction",
|
||||
"FlaxBertForSequenceClassification",
|
||||
"FlaxBertForMultipleChoice",
|
||||
"FlaxBertForTokenClassification",
|
||||
"FlaxBertForQuestionAnswering",
|
||||
"FlaxBertForCausalLM",
|
||||
]
|
||||
|
@ -2108,3 +2108,18 @@ class TFBertForQuestionAnswering(TFBertPreTrainedModel, TFQuestionAnsweringLoss)
|
||||
if getattr(self, "qa_outputs", None) is not None:
|
||||
with tf.name_scope(self.qa_outputs.name):
|
||||
self.qa_outputs.build([None, None, self.config.hidden_size])
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TFBertPreTrainedModel",
|
||||
"TFBertModel",
|
||||
"TFBertForPreTraining",
|
||||
"TFBertForMaskedLM",
|
||||
"TFBertLMHeadModel",
|
||||
"TFBertForNextSentencePrediction",
|
||||
"TFBertForSequenceClassification",
|
||||
"TFBertForMultipleChoice",
|
||||
"TFBertForTokenClassification",
|
||||
"TFBertForQuestionAnswering",
|
||||
"TFBertMainLayer",
|
||||
]
|
||||
|
@ -497,3 +497,6 @@ class WordpieceTokenizer:
|
||||
else:
|
||||
output_tokens.extend(sub_tokens)
|
||||
return output_tokens
|
||||
|
||||
|
||||
__all__ = ["BertTokenizer", "BasicTokenizer", "WordpieceTokenizer"]
|
||||
|
@ -170,3 +170,6 @@ class BertTokenizerFast(PreTrainedTokenizerFast):
|
||||
def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
||||
files = self._tokenizer.model.save(save_directory, name=filename_prefix)
|
||||
return tuple(files)
|
||||
|
||||
|
||||
__all__ = ["BertTokenizerFast"]
|
||||
|
@ -6,9 +6,11 @@ from tensorflow_text import BertTokenizer as BertTokenizerLayer
|
||||
from tensorflow_text import FastBertTokenizer, ShrinkLongestTrimmer, case_fold_utf8, combine_segments, pad_model_inputs
|
||||
|
||||
from ...modeling_tf_utils import keras
|
||||
from ...utils.import_utils import export
|
||||
from .tokenization_bert import BertTokenizer
|
||||
|
||||
|
||||
@export(backends=("tf",))
|
||||
class TFBertTokenizer(keras.layers.Layer):
|
||||
"""
|
||||
This is an in-graph tokenizer for BERT. It should be initialized similarly to other tokenizers, using the
|
||||
@ -252,3 +254,6 @@ class TFBertTokenizer(keras.layers.Layer):
|
||||
"sep_token_id": self.sep_token_id,
|
||||
"pad_token_id": self.pad_token_id,
|
||||
}
|
||||
|
||||
|
||||
__all__ = ["TFBertTokenizer"]
|
||||
|
@ -11,61 +11,18 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available
|
||||
|
||||
|
||||
_import_structure = {"configuration_bert_generation": ["BertGenerationConfig"]}
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_bert_generation"] = ["BertGenerationTokenizer"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_bert_generation"] = [
|
||||
"BertGenerationDecoder",
|
||||
"BertGenerationEncoder",
|
||||
"BertGenerationPreTrainedModel",
|
||||
"load_tf_weights_in_bert_generation",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_bert_generation import BertGenerationConfig
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_bert_generation import BertGenerationTokenizer
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_bert_generation import (
|
||||
BertGenerationDecoder,
|
||||
BertGenerationEncoder,
|
||||
BertGenerationPreTrainedModel,
|
||||
load_tf_weights_in_bert_generation,
|
||||
)
|
||||
|
||||
from .configuration_bert_generation import *
|
||||
from .modeling_bert_generation import *
|
||||
from .tokenization_bert_generation import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -122,3 +122,6 @@ class BertGenerationConfig(PretrainedConfig):
|
||||
self.layer_norm_eps = layer_norm_eps
|
||||
self.position_embedding_type = position_embedding_type
|
||||
self.use_cache = use_cache
|
||||
|
||||
|
||||
__all__ = ["BertGenerationConfig"]
|
||||
|
@ -1018,3 +1018,11 @@ class BertGenerationDecoder(BertGenerationPreTrainedModel):
|
||||
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
||||
)
|
||||
return reordered_past
|
||||
|
||||
|
||||
__all__ = [
|
||||
"load_tf_weights_in_bert_generation",
|
||||
"BertGenerationPreTrainedModel",
|
||||
"BertGenerationEncoder",
|
||||
"BertGenerationDecoder",
|
||||
]
|
||||
|
@ -22,6 +22,7 @@ import sentencepiece as spm
|
||||
|
||||
from ...tokenization_utils import PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
@ -29,6 +30,7 @@ logger = logging.get_logger(__name__)
|
||||
VOCAB_FILES_NAMES = {"vocab_file": "spiece.model"}
|
||||
|
||||
|
||||
@export(backends=("sentencepiece",))
|
||||
class BertGenerationTokenizer(PreTrainedTokenizer):
|
||||
"""
|
||||
Construct a BertGeneration tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
|
||||
@ -170,3 +172,6 @@ class BertGenerationTokenizer(PreTrainedTokenizer):
|
||||
fi.write(content_spiece_model)
|
||||
|
||||
return (out_vocab_file,)
|
||||
|
||||
|
||||
__all__ = ["BertGenerationTokenizer"]
|
||||
|
@ -11,19 +11,16 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import _LazyModule
|
||||
|
||||
|
||||
_import_structure = {"tokenization_bert_japanese": ["BertJapaneseTokenizer", "CharacterTokenizer", "MecabTokenizer"]}
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .tokenization_bert_japanese import BertJapaneseTokenizer, CharacterTokenizer, MecabTokenizer
|
||||
|
||||
from .tokenization_bert_japanese import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -977,3 +977,6 @@ class SentencepieceTokenizer:
|
||||
new_pieces.append(piece)
|
||||
|
||||
return new_pieces
|
||||
|
||||
|
||||
__all__ = ["BertJapaneseTokenizer", "CharacterTokenizer", "MecabTokenizer"]
|
||||
|
@ -11,19 +11,16 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import _LazyModule
|
||||
|
||||
|
||||
_import_structure = {"tokenization_bertweet": ["BertweetTokenizer"]}
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .tokenization_bertweet import BertweetTokenizer
|
||||
|
||||
from .tokenization_bertweet import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -764,3 +764,5 @@ def casual_tokenize(text, preserve_case=True, reduce_len=False, strip_handles=Fa
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
__all__ = ["BertweetTokenizer"]
|
||||
|
@ -13,133 +13,18 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_sentencepiece_available,
|
||||
is_tf_available,
|
||||
is_tokenizers_available,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_big_bird": ["BigBirdConfig", "BigBirdOnnxConfig"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_big_bird"] = ["BigBirdTokenizer"]
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_big_bird_fast"] = ["BigBirdTokenizerFast"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_big_bird"] = [
|
||||
"BigBirdForCausalLM",
|
||||
"BigBirdForMaskedLM",
|
||||
"BigBirdForMultipleChoice",
|
||||
"BigBirdForPreTraining",
|
||||
"BigBirdForQuestionAnswering",
|
||||
"BigBirdForSequenceClassification",
|
||||
"BigBirdForTokenClassification",
|
||||
"BigBirdLayer",
|
||||
"BigBirdModel",
|
||||
"BigBirdPreTrainedModel",
|
||||
"load_tf_weights_in_big_bird",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_big_bird"] = [
|
||||
"FlaxBigBirdForCausalLM",
|
||||
"FlaxBigBirdForMaskedLM",
|
||||
"FlaxBigBirdForMultipleChoice",
|
||||
"FlaxBigBirdForPreTraining",
|
||||
"FlaxBigBirdForQuestionAnswering",
|
||||
"FlaxBigBirdForSequenceClassification",
|
||||
"FlaxBigBirdForTokenClassification",
|
||||
"FlaxBigBirdModel",
|
||||
"FlaxBigBirdPreTrainedModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_big_bird import BigBirdConfig, BigBirdOnnxConfig
|
||||
|
||||
try:
|
||||
if not is_sentencepiece_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_big_bird import BigBirdTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_big_bird_fast import BigBirdTokenizerFast
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_big_bird import (
|
||||
BigBirdForCausalLM,
|
||||
BigBirdForMaskedLM,
|
||||
BigBirdForMultipleChoice,
|
||||
BigBirdForPreTraining,
|
||||
BigBirdForQuestionAnswering,
|
||||
BigBirdForSequenceClassification,
|
||||
BigBirdForTokenClassification,
|
||||
BigBirdLayer,
|
||||
BigBirdModel,
|
||||
BigBirdPreTrainedModel,
|
||||
load_tf_weights_in_big_bird,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_big_bird import (
|
||||
FlaxBigBirdForCausalLM,
|
||||
FlaxBigBirdForMaskedLM,
|
||||
FlaxBigBirdForMultipleChoice,
|
||||
FlaxBigBirdForPreTraining,
|
||||
FlaxBigBirdForQuestionAnswering,
|
||||
FlaxBigBirdForSequenceClassification,
|
||||
FlaxBigBirdForTokenClassification,
|
||||
FlaxBigBirdModel,
|
||||
FlaxBigBirdPreTrainedModel,
|
||||
)
|
||||
|
||||
from .configuration_big_bird import *
|
||||
from .modeling_big_bird import *
|
||||
from .modeling_flax_big_bird import *
|
||||
from .tokenization_big_bird import *
|
||||
from .tokenization_big_bird_fast import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -171,3 +171,6 @@ class BigBirdOnnxConfig(OnnxConfig):
|
||||
("attention_mask", dynamic_axis),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BigBirdConfig", "BigBirdOnnxConfig"]
|
||||
|
@ -3147,3 +3147,17 @@ class BigBirdForQuestionAnswering(BigBirdPreTrainedModel):
|
||||
mask.unsqueeze_(0) # -> (1, maxlen)
|
||||
mask = torch.where(mask < q_lengths, 1, 0)
|
||||
return mask
|
||||
|
||||
|
||||
__all__ = [
|
||||
"load_tf_weights_in_big_bird",
|
||||
"BigBirdPreTrainedModel",
|
||||
"BigBirdModel",
|
||||
"BigBirdForPreTraining",
|
||||
"BigBirdForMaskedLM",
|
||||
"BigBirdForCausalLM",
|
||||
"BigBirdForSequenceClassification",
|
||||
"BigBirdForMultipleChoice",
|
||||
"BigBirdForTokenClassification",
|
||||
"BigBirdForQuestionAnswering",
|
||||
]
|
||||
|
@ -2633,3 +2633,15 @@ append_call_sample_docstring(
|
||||
FlaxCausalLMOutputWithCrossAttentions,
|
||||
_CONFIG_FOR_DOC,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FlaxBigBirdPreTrainedModel",
|
||||
"FlaxBigBirdModel",
|
||||
"FlaxBigBirdForPreTraining",
|
||||
"FlaxBigBirdForMaskedLM",
|
||||
"FlaxBigBirdForSequenceClassification",
|
||||
"FlaxBigBirdForMultipleChoice",
|
||||
"FlaxBigBirdForTokenClassification",
|
||||
"FlaxBigBirdForQuestionAnswering",
|
||||
"FlaxBigBirdForCausalLM",
|
||||
]
|
||||
|
@ -23,6 +23,7 @@ import sentencepiece as spm
|
||||
|
||||
from ...tokenization_utils import AddedToken, PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
@ -30,6 +31,7 @@ logger = logging.get_logger(__name__)
|
||||
VOCAB_FILES_NAMES = {"vocab_file": "spiece.model"}
|
||||
|
||||
|
||||
@export(backends=("sentencepiece",))
|
||||
class BigBirdTokenizer(PreTrainedTokenizer):
|
||||
"""
|
||||
Construct a BigBird tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece).
|
||||
@ -319,3 +321,6 @@ class BigBirdTokenizer(PreTrainedTokenizer):
|
||||
if token_ids_1 is None:
|
||||
return len(cls + token_ids_0 + sep) * [0]
|
||||
return len(cls + token_ids_0 + sep) * [0] + len(token_ids_1 + sep) * [1]
|
||||
|
||||
|
||||
__all__ = ["BigBirdTokenizer"]
|
||||
|
@ -227,3 +227,6 @@ class BigBirdTokenizerFast(PreTrainedTokenizerFast):
|
||||
copyfile(self.vocab_file, out_vocab_file)
|
||||
|
||||
return (out_vocab_file,)
|
||||
|
||||
|
||||
__all__ = ["BigBirdTokenizerFast"]
|
||||
|
@ -13,55 +13,15 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_bigbird_pegasus": [
|
||||
"BigBirdPegasusConfig",
|
||||
"BigBirdPegasusOnnxConfig",
|
||||
],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_bigbird_pegasus"] = [
|
||||
"BigBirdPegasusForCausalLM",
|
||||
"BigBirdPegasusForConditionalGeneration",
|
||||
"BigBirdPegasusForQuestionAnswering",
|
||||
"BigBirdPegasusForSequenceClassification",
|
||||
"BigBirdPegasusModel",
|
||||
"BigBirdPegasusPreTrainedModel",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_bigbird_pegasus import (
|
||||
BigBirdPegasusConfig,
|
||||
BigBirdPegasusOnnxConfig,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_bigbird_pegasus import (
|
||||
BigBirdPegasusForCausalLM,
|
||||
BigBirdPegasusForConditionalGeneration,
|
||||
BigBirdPegasusForQuestionAnswering,
|
||||
BigBirdPegasusForSequenceClassification,
|
||||
BigBirdPegasusModel,
|
||||
BigBirdPegasusPreTrainedModel,
|
||||
)
|
||||
|
||||
|
||||
from .configuration_bigbird_pegasus import *
|
||||
from .modeling_bigbird_pegasus import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -17,10 +17,10 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Mapping, Optional
|
||||
|
||||
from ... import PreTrainedTokenizer
|
||||
from ...configuration_utils import PretrainedConfig
|
||||
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeq2SeqConfigWithPast
|
||||
from ...onnx.utils import compute_effective_axis_dimension
|
||||
from ...tokenization_utils import PreTrainedTokenizer
|
||||
from ...utils import TensorType, is_torch_available, logging
|
||||
|
||||
|
||||
@ -407,3 +407,6 @@ class BigBirdPegasusOnnxConfig(OnnxSeq2SeqConfigWithPast):
|
||||
flattened_output = super(OnnxSeq2SeqConfigWithPast, self)._flatten_past_key_values_(
|
||||
flattened_output, name, idx, t
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BigBirdPegasusConfig", "BigBirdPegasusOnnxConfig"]
|
||||
|
@ -3083,3 +3083,13 @@ class BigBirdPegasusForCausalLM(BigBirdPegasusPreTrainedModel):
|
||||
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
||||
)
|
||||
return reordered_past
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BigBirdPegasusPreTrainedModel",
|
||||
"BigBirdPegasusModel",
|
||||
"BigBirdPegasusForConditionalGeneration",
|
||||
"BigBirdPegasusForSequenceClassification",
|
||||
"BigBirdPegasusForQuestionAnswering",
|
||||
"BigBirdPegasusForCausalLM",
|
||||
]
|
||||
|
@ -13,49 +13,16 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_biogpt": ["BioGptConfig"],
|
||||
"tokenization_biogpt": ["BioGptTokenizer"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_biogpt"] = [
|
||||
"BioGptForCausalLM",
|
||||
"BioGptForTokenClassification",
|
||||
"BioGptForSequenceClassification",
|
||||
"BioGptModel",
|
||||
"BioGptPreTrainedModel",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_biogpt import BioGptConfig
|
||||
from .tokenization_biogpt import BioGptTokenizer
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_biogpt import (
|
||||
BioGptForCausalLM,
|
||||
BioGptForSequenceClassification,
|
||||
BioGptForTokenClassification,
|
||||
BioGptModel,
|
||||
BioGptPreTrainedModel,
|
||||
)
|
||||
|
||||
|
||||
from .configuration_biogpt import *
|
||||
from .modeling_biogpt import *
|
||||
from .tokenization_biogpt import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -129,3 +129,6 @@ class BioGptConfig(PretrainedConfig):
|
||||
self.layerdrop = layerdrop
|
||||
self.activation_dropout = activation_dropout
|
||||
super().__init__(pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
|
||||
|
||||
|
||||
__all__ = ["BioGptConfig"]
|
||||
|
@ -934,3 +934,12 @@ class BioGptForSequenceClassification(BioGptPreTrainedModel):
|
||||
|
||||
def set_input_embeddings(self, value):
|
||||
self.biogpt.embed_tokens = value
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BioGptPreTrainedModel",
|
||||
"BioGptModel",
|
||||
"BioGptForCausalLM",
|
||||
"BioGptForTokenClassification",
|
||||
"BioGptForSequenceClassification",
|
||||
]
|
||||
|
@ -356,3 +356,6 @@ class BioGptTokenizer(PreTrainedTokenizer):
|
||||
)
|
||||
|
||||
self.sm = sacremoses
|
||||
|
||||
|
||||
__all__ = ["BioGptTokenizer"]
|
||||
|
@ -13,59 +13,16 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
|
||||
|
||||
|
||||
_import_structure = {"configuration_bit": ["BitConfig", "BitOnnxConfig"]}
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_bit"] = [
|
||||
"BitForImageClassification",
|
||||
"BitModel",
|
||||
"BitPreTrainedModel",
|
||||
"BitBackbone",
|
||||
]
|
||||
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["image_processing_bit"] = ["BitImageProcessor"]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_bit import BitConfig, BitOnnxConfig
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_bit import (
|
||||
BitBackbone,
|
||||
BitForImageClassification,
|
||||
BitModel,
|
||||
BitPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .image_processing_bit import BitImageProcessor
|
||||
|
||||
from .configuration_bit import *
|
||||
from .image_processing_bit import *
|
||||
from .modeling_bit import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -131,3 +131,6 @@ class BitConfig(BackboneConfigMixin, PretrainedConfig):
|
||||
self._out_features, self._out_indices = get_aligned_output_features_output_indices(
|
||||
out_features=out_features, out_indices=out_indices, stage_names=self.stage_names
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BitConfig"]
|
||||
|
@ -39,6 +39,7 @@ from ...image_utils import (
|
||||
validate_preprocess_arguments,
|
||||
)
|
||||
from ...utils import TensorType, filter_out_non_signature_kwargs, is_vision_available, logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
logger = logging.get_logger(__name__)
|
||||
@ -48,6 +49,7 @@ if is_vision_available():
|
||||
import PIL
|
||||
|
||||
|
||||
@export(backends=("vision",))
|
||||
class BitImageProcessor(BaseImageProcessor):
|
||||
r"""
|
||||
Constructs a BiT image processor.
|
||||
@ -319,3 +321,6 @@ class BitImageProcessor(BaseImageProcessor):
|
||||
|
||||
data = {"pixel_values": images}
|
||||
return BatchFeature(data=data, tensor_type=return_tensors)
|
||||
|
||||
|
||||
__all__ = ["BitImageProcessor"]
|
||||
|
@ -901,3 +901,6 @@ class BitBackbone(BitPreTrainedModel, BackboneMixin):
|
||||
hidden_states=outputs.hidden_states if output_hidden_states else None,
|
||||
attentions=None,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BitPreTrainedModel", "BitModel", "BitForImageClassification", "BitBackbone"]
|
||||
|
@ -11,128 +11,21 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_tf_available,
|
||||
is_tokenizers_available,
|
||||
is_torch_available,
|
||||
)
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_blenderbot": [
|
||||
"BlenderbotConfig",
|
||||
"BlenderbotOnnxConfig",
|
||||
],
|
||||
"tokenization_blenderbot": ["BlenderbotTokenizer"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_blenderbot_fast"] = ["BlenderbotTokenizerFast"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_blenderbot"] = [
|
||||
"BlenderbotForCausalLM",
|
||||
"BlenderbotForConditionalGeneration",
|
||||
"BlenderbotModel",
|
||||
"BlenderbotPreTrainedModel",
|
||||
]
|
||||
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_blenderbot"] = [
|
||||
"TFBlenderbotForConditionalGeneration",
|
||||
"TFBlenderbotModel",
|
||||
"TFBlenderbotPreTrainedModel",
|
||||
]
|
||||
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_blenderbot"] = [
|
||||
"FlaxBlenderbotForConditionalGeneration",
|
||||
"FlaxBlenderbotModel",
|
||||
"FlaxBlenderbotPreTrainedModel",
|
||||
]
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_blenderbot import (
|
||||
BlenderbotConfig,
|
||||
BlenderbotOnnxConfig,
|
||||
)
|
||||
from .tokenization_blenderbot import BlenderbotTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_blenderbot_fast import BlenderbotTokenizerFast
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_blenderbot import (
|
||||
BlenderbotForCausalLM,
|
||||
BlenderbotForConditionalGeneration,
|
||||
BlenderbotModel,
|
||||
BlenderbotPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_blenderbot import (
|
||||
TFBlenderbotForConditionalGeneration,
|
||||
TFBlenderbotModel,
|
||||
TFBlenderbotPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_blenderbot import (
|
||||
FlaxBlenderbotForConditionalGeneration,
|
||||
FlaxBlenderbotModel,
|
||||
FlaxBlenderbotPreTrainedModel,
|
||||
)
|
||||
|
||||
from .configuration_blenderbot import *
|
||||
from .modeling_blenderbot import *
|
||||
from .modeling_flax_blenderbot import *
|
||||
from .modeling_tf_blenderbot import *
|
||||
from .tokenization_blenderbot import *
|
||||
from .tokenization_blenderbot_fast import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -17,11 +17,11 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Mapping, Optional
|
||||
|
||||
from ... import PreTrainedTokenizer
|
||||
from ...configuration_utils import PretrainedConfig
|
||||
from ...file_utils import TensorType, is_torch_available
|
||||
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeq2SeqConfigWithPast
|
||||
from ...onnx.utils import compute_effective_axis_dimension
|
||||
from ...tokenization_utils import PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
|
||||
|
||||
@ -390,3 +390,6 @@ class BlenderbotOnnxConfig(OnnxSeq2SeqConfigWithPast):
|
||||
inputs_or_outputs[f"{name}.{i}.decoder.value"] = {0: "batch", 2: decoder_sequence}
|
||||
inputs_or_outputs[f"{name}.{i}.encoder.key"] = {0: "batch", 2: encoder_sequence}
|
||||
inputs_or_outputs[f"{name}.{i}.encoder.value"] = {0: "batch", 2: encoder_sequence}
|
||||
|
||||
|
||||
__all__ = ["BlenderbotConfig", "BlenderbotOnnxConfig"]
|
||||
|
@ -1609,3 +1609,11 @@ class BlenderbotForCausalLM(BlenderbotPreTrainedModel):
|
||||
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
||||
)
|
||||
return reordered_past
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BlenderbotPreTrainedModel",
|
||||
"BlenderbotModel",
|
||||
"BlenderbotForConditionalGeneration",
|
||||
"BlenderbotForCausalLM",
|
||||
]
|
||||
|
@ -1503,3 +1503,5 @@ overwrite_call_docstring(
|
||||
append_replace_return_docstrings(
|
||||
FlaxBlenderbotForConditionalGeneration, output_type=FlaxSeq2SeqLMOutput, config_class=_CONFIG_FOR_DOC
|
||||
)
|
||||
|
||||
__all__ = ["FlaxBlenderbotPreTrainedModel", "FlaxBlenderbotModel", "FlaxBlenderbotForConditionalGeneration"]
|
||||
|
@ -1553,3 +1553,11 @@ class TFBlenderbotForConditionalGeneration(TFBlenderbotPreTrainedModel, TFCausal
|
||||
if getattr(self, "bias_layer", None) is not None:
|
||||
with tf.name_scope(self.bias_layer.name):
|
||||
self.bias_layer.build(None)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TFBlenderbotPreTrainedModel",
|
||||
"TFBlenderbotModel",
|
||||
"TFBlenderbotForConditionalGeneration",
|
||||
"TFBlenderbotMainLayer",
|
||||
]
|
||||
|
@ -405,3 +405,6 @@ class BlenderbotTokenizer(PreTrainedTokenizer):
|
||||
`List[int]`: list of [input IDs](../glossary#input-ids) with the appropriate special tokens.
|
||||
"""
|
||||
return token_ids_0 + [self.eos_token_id]
|
||||
|
||||
|
||||
__all__ = ["BlenderbotTokenizer"]
|
||||
|
@ -287,3 +287,6 @@ class BlenderbotTokenizerFast(PreTrainedTokenizerFast):
|
||||
`List[int]`: list of [input IDs](../glossary#input-ids) with the appropriate special tokens.
|
||||
"""
|
||||
return token_ids_0 + [self.eos_token_id]
|
||||
|
||||
|
||||
__all__ = ["BlenderbotTokenizerFast"]
|
||||
|
@ -13,122 +13,19 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_flax_available,
|
||||
is_tf_available,
|
||||
is_tokenizers_available,
|
||||
is_torch_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_blenderbot_small": [
|
||||
"BlenderbotSmallConfig",
|
||||
"BlenderbotSmallOnnxConfig",
|
||||
],
|
||||
"tokenization_blenderbot_small": ["BlenderbotSmallTokenizer"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_blenderbot_small_fast"] = ["BlenderbotSmallTokenizerFast"]
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_blenderbot_small"] = [
|
||||
"BlenderbotSmallForCausalLM",
|
||||
"BlenderbotSmallForConditionalGeneration",
|
||||
"BlenderbotSmallModel",
|
||||
"BlenderbotSmallPreTrainedModel",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_blenderbot_small"] = [
|
||||
"TFBlenderbotSmallForConditionalGeneration",
|
||||
"TFBlenderbotSmallModel",
|
||||
"TFBlenderbotSmallPreTrainedModel",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_blenderbot_small"] = [
|
||||
"FlaxBlenderbotSmallForConditionalGeneration",
|
||||
"FlaxBlenderbotSmallModel",
|
||||
"FlaxBlenderbotSmallPreTrainedModel",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_blenderbot_small import (
|
||||
BlenderbotSmallConfig,
|
||||
BlenderbotSmallOnnxConfig,
|
||||
)
|
||||
from .tokenization_blenderbot_small import BlenderbotSmallTokenizer
|
||||
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_blenderbot_small_fast import BlenderbotSmallTokenizerFast
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_blenderbot_small import (
|
||||
BlenderbotSmallForCausalLM,
|
||||
BlenderbotSmallForConditionalGeneration,
|
||||
BlenderbotSmallModel,
|
||||
BlenderbotSmallPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_blenderbot_small import (
|
||||
TFBlenderbotSmallForConditionalGeneration,
|
||||
TFBlenderbotSmallModel,
|
||||
TFBlenderbotSmallPreTrainedModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_blenderbot_small import (
|
||||
FlaxBlenderbotSmallForConditionalGeneration,
|
||||
FlaxBlenderbotSmallModel,
|
||||
FlaxBlenderbotSmallPreTrainedModel,
|
||||
)
|
||||
|
||||
from .configuration_blenderbot_small import *
|
||||
from .modeling_blenderbot_small import *
|
||||
from .modeling_flax_blenderbot_small import *
|
||||
from .modeling_tf_blenderbot_small import *
|
||||
from .tokenization_blenderbot_small import *
|
||||
from .tokenization_blenderbot_small_fast import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -17,11 +17,11 @@
|
||||
from collections import OrderedDict
|
||||
from typing import Any, Mapping, Optional
|
||||
|
||||
from ... import PreTrainedTokenizer
|
||||
from ...configuration_utils import PretrainedConfig
|
||||
from ...file_utils import TensorType, is_torch_available
|
||||
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeq2SeqConfigWithPast
|
||||
from ...onnx.utils import compute_effective_axis_dimension
|
||||
from ...tokenization_utils import PreTrainedTokenizer
|
||||
from ...utils import logging
|
||||
|
||||
|
||||
@ -385,3 +385,6 @@ class BlenderbotSmallOnnxConfig(OnnxSeq2SeqConfigWithPast):
|
||||
flattened_output = super(OnnxSeq2SeqConfigWithPast, self)._flatten_past_key_values_(
|
||||
flattened_output, name, idx, t
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["BlenderbotSmallConfig", "BlenderbotSmallOnnxConfig"]
|
||||
|
@ -1561,3 +1561,11 @@ class BlenderbotSmallForCausalLM(BlenderbotSmallPreTrainedModel):
|
||||
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
||||
)
|
||||
return reordered_past
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BlenderbotSmallPreTrainedModel",
|
||||
"BlenderbotSmallModel",
|
||||
"BlenderbotSmallForConditionalGeneration",
|
||||
"BlenderbotSmallForCausalLM",
|
||||
]
|
||||
|
@ -1519,3 +1519,9 @@ overwrite_call_docstring(
|
||||
append_replace_return_docstrings(
|
||||
FlaxBlenderbotSmallForConditionalGeneration, output_type=FlaxSeq2SeqLMOutput, config_class=_CONFIG_FOR_DOC
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"FlaxBlenderbotSmallPreTrainedModel",
|
||||
"FlaxBlenderbotSmallModel",
|
||||
"FlaxBlenderbotSmallForConditionalGeneration",
|
||||
]
|
||||
|
@ -1523,3 +1523,11 @@ class TFBlenderbotSmallForConditionalGeneration(TFBlenderbotSmallPreTrainedModel
|
||||
if getattr(self, "bias_layer", None) is not None:
|
||||
with tf.name_scope(self.bias_layer.name):
|
||||
self.bias_layer.build(None)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TFBlenderbotSmallPreTrainedModel",
|
||||
"TFBlenderbotSmallModel",
|
||||
"TFBlenderbotSmallForConditionalGeneration",
|
||||
"TFBlenderbotSmallMainLayer",
|
||||
]
|
||||
|
@ -217,3 +217,6 @@ class BlenderbotSmallTokenizer(PreTrainedTokenizer):
|
||||
index += 1
|
||||
|
||||
return vocab_file, merge_file
|
||||
|
||||
|
||||
__all__ = ["BlenderbotSmallTokenizer"]
|
||||
|
@ -98,3 +98,6 @@ class BlenderbotSmallTokenizerFast(PreTrainedTokenizerFast):
|
||||
if token_ids_1 is None:
|
||||
return len(cls + token_ids_0 + sep) * [0]
|
||||
return len(cls + token_ids_0 + sep + sep + token_ids_1 + sep) * [0]
|
||||
|
||||
|
||||
__all__ = ["BlenderbotSmallTokenizerFast"]
|
||||
|
@ -13,110 +13,20 @@
|
||||
# limitations under the License.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...utils import (
|
||||
OptionalDependencyNotAvailable,
|
||||
_LazyModule,
|
||||
is_tf_available,
|
||||
is_torch_available,
|
||||
is_vision_available,
|
||||
)
|
||||
from ...utils import _LazyModule
|
||||
from ...utils.import_utils import define_import_structure
|
||||
|
||||
|
||||
_import_structure = {
|
||||
"configuration_blip": [
|
||||
"BlipConfig",
|
||||
"BlipTextConfig",
|
||||
"BlipVisionConfig",
|
||||
],
|
||||
"processing_blip": ["BlipProcessor"],
|
||||
}
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["image_processing_blip"] = ["BlipImageProcessor"]
|
||||
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_blip"] = [
|
||||
"BlipModel",
|
||||
"BlipPreTrainedModel",
|
||||
"BlipForConditionalGeneration",
|
||||
"BlipForQuestionAnswering",
|
||||
"BlipVisionModel",
|
||||
"BlipTextModel",
|
||||
"BlipForImageTextRetrieval",
|
||||
]
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_blip"] = [
|
||||
"TFBlipModel",
|
||||
"TFBlipPreTrainedModel",
|
||||
"TFBlipForConditionalGeneration",
|
||||
"TFBlipForQuestionAnswering",
|
||||
"TFBlipVisionModel",
|
||||
"TFBlipTextModel",
|
||||
"TFBlipForImageTextRetrieval",
|
||||
]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_blip import BlipConfig, BlipTextConfig, BlipVisionConfig
|
||||
from .processing_blip import BlipProcessor
|
||||
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .image_processing_blip import BlipImageProcessor
|
||||
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_blip import (
|
||||
BlipForConditionalGeneration,
|
||||
BlipForImageTextRetrieval,
|
||||
BlipForQuestionAnswering,
|
||||
BlipModel,
|
||||
BlipPreTrainedModel,
|
||||
BlipTextModel,
|
||||
BlipVisionModel,
|
||||
)
|
||||
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_blip import (
|
||||
TFBlipForConditionalGeneration,
|
||||
TFBlipForImageTextRetrieval,
|
||||
TFBlipForQuestionAnswering,
|
||||
TFBlipModel,
|
||||
TFBlipPreTrainedModel,
|
||||
TFBlipTextModel,
|
||||
TFBlipVisionModel,
|
||||
)
|
||||
|
||||
from .configuration_blip import *
|
||||
from .image_processing_blip import *
|
||||
from .modeling_blip import *
|
||||
from .modeling_blip_text import *
|
||||
from .modeling_tf_blip import *
|
||||
from .modeling_tf_blip_text import *
|
||||
from .processing_blip import *
|
||||
else:
|
||||
import sys
|
||||
|
||||
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
|
||||
_file = globals()["__file__"]
|
||||
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
||||
|
@ -360,3 +360,6 @@ class BlipConfig(PretrainedConfig):
|
||||
"""
|
||||
|
||||
return cls(text_config=text_config.to_dict(), vision_config=vision_config.to_dict(), **kwargs)
|
||||
|
||||
|
||||
__all__ = ["BlipTextConfig", "BlipVisionConfig", "BlipConfig"]
|
||||
|
@ -34,6 +34,7 @@ from ...image_utils import (
|
||||
validate_preprocess_arguments,
|
||||
)
|
||||
from ...utils import TensorType, filter_out_non_signature_kwargs, is_vision_available, logging
|
||||
from ...utils.import_utils import export
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@ -43,6 +44,7 @@ if is_vision_available():
|
||||
logger = logging.get_logger(__name__)
|
||||
|
||||
|
||||
@export(backends=("vision",))
|
||||
class BlipImageProcessor(BaseImageProcessor):
|
||||
r"""
|
||||
Constructs a BLIP image processor.
|
||||
@ -292,3 +294,6 @@ class BlipImageProcessor(BaseImageProcessor):
|
||||
encoded_outputs = BatchFeature(data={"pixel_values": images}, tensor_type=return_tensors)
|
||||
|
||||
return encoded_outputs
|
||||
|
||||
|
||||
__all__ = ["BlipImageProcessor"]
|
||||
|
@ -1563,3 +1563,13 @@ class BlipForImageTextRetrieval(BlipPreTrainedModel):
|
||||
attentions=vision_outputs.attentions,
|
||||
question_embeds=question_embeds,
|
||||
)
|
||||
|
||||
|
||||
__all__ = [
|
||||
"BlipPreTrainedModel",
|
||||
"BlipVisionModel",
|
||||
"BlipModel",
|
||||
"BlipForConditionalGeneration",
|
||||
"BlipForQuestionAnswering",
|
||||
"BlipForImageTextRetrieval",
|
||||
]
|
||||
|
@ -568,6 +568,8 @@ class BlipTextPreTrainedModel(PreTrainedModel):
|
||||
|
||||
|
||||
# Adapted from https://github.com/salesforce/BLIP/blob/3a29b7410476bf5f2ba0955827390eb6ea1f4f9d/models/med.py#L571
|
||||
|
||||
|
||||
class BlipTextModel(BlipTextPreTrainedModel):
|
||||
"""
|
||||
The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
|
||||
@ -948,3 +950,6 @@ class BlipTextLMHeadModel(BlipTextPreTrainedModel):
|
||||
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
||||
)
|
||||
return reordered_past
|
||||
|
||||
|
||||
__all__ = ["BlipTextModel"]
|
||||
|
@ -1696,3 +1696,14 @@ class TFBlipForImageTextRetrieval(TFBlipPreTrainedModel):
|
||||
if getattr(self, "itm_head", None) is not None:
|
||||
with tf.name_scope(self.itm_head.name):
|
||||
self.itm_head.build([None, None, self.config.text_config.hidden_size])
|
||||
|
||||
|
||||
__all__ = [
|
||||
"TFBlipPreTrainedModel",
|
||||
"TFBlipVisionModel",
|
||||
"TFBlipModel",
|
||||
"TFBlipForConditionalGeneration",
|
||||
"TFBlipForQuestionAnswering",
|
||||
"TFBlipForImageTextRetrieval",
|
||||
"TFBlipMainLayer",
|
||||
]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user