CSS-LM
671 строка · 21.8 Кб
1# flake8: noqa
2# There's no way to ignore "F401 '...' imported but unused" warnings in this
3# module, but to preserve other warnings. So, don't check this module at all.
4
5__version__ = "3.0.2"
6
7# Work around to update TensorFlow's absl.logging threshold which alters the
8# default Python logging output behavior when present.
9# see: https://github.com/abseil/abseil-py/issues/99
10# and: https://github.com/tensorflow/tensorflow/issues/26691#issuecomment-500369493
11try:
12import absl.logging
13except ImportError:
14pass
15else:
16absl.logging.set_verbosity("info")
17absl.logging.set_stderrthreshold("info")
18absl.logging._warn_preinit_stderr = False
19
20import logging
21
22# Configurations
23from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig
24from .configuration_auto import ALL_PRETRAINED_CONFIG_ARCHIVE_MAP, CONFIG_MAPPING, AutoConfig
25from .configuration_bart import BartConfig, MBartConfig
26from .configuration_bert import BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BertConfig
27from .configuration_camembert import CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CamembertConfig
28from .configuration_ctrl import CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRLConfig
29from .configuration_distilbert import DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DistilBertConfig
30from .configuration_dpr import DPR_PRETRAINED_CONFIG_ARCHIVE_MAP, DPRConfig
31from .configuration_electra import ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP, ElectraConfig
32from .configuration_encoder_decoder import EncoderDecoderConfig
33from .configuration_flaubert import FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, FlaubertConfig
34from .configuration_gpt2 import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2Config
35from .configuration_longformer import LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, LongformerConfig
36from .configuration_marian import MarianConfig
37from .configuration_mmbt import MMBTConfig
38from .configuration_mobilebert import MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, MobileBertConfig
39from .configuration_openai import OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OpenAIGPTConfig
40from .configuration_reformer import REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, ReformerConfig
41from .configuration_retribert import RETRIBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, RetriBertConfig
42from .configuration_roberta import ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, RobertaConfig
43from .configuration_t5 import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, T5Config
44from .configuration_transfo_xl import TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP, TransfoXLConfig
45from .configuration_utils import PretrainedConfig
46from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig
47from .configuration_xlm_roberta import XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMRobertaConfig
48from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig
49from .data import (
50DataProcessor,
51InputExample,
52InputFeatures,
53SingleSentenceClassificationProcessor,
54SquadExample,
55SquadFeatures,
56SquadV1Processor,
57SquadV2Processor,
58glue_convert_examples_to_features,
59glue_output_modes,
60glue_processors,
61glue_tasks_num_labels,
62is_sklearn_available,
63squad_convert_examples_to_features,
64xnli_output_modes,
65xnli_processors,
66xnli_tasks_num_labels,
67)
68
69# Files and general utilities
70from .file_utils import (
71CONFIG_NAME,
72MODEL_CARD_NAME,
73PYTORCH_PRETRAINED_BERT_CACHE,
74PYTORCH_TRANSFORMERS_CACHE,
75TF2_WEIGHTS_NAME,
76TF_WEIGHTS_NAME,
77TRANSFORMERS_CACHE,
78WEIGHTS_NAME,
79add_end_docstrings,
80add_start_docstrings,
81cached_path,
82is_apex_available,
83is_psutil_available,
84is_py3nvml_available,
85is_tf_available,
86is_torch_available,
87is_torch_tpu_available,
88)
89from .hf_argparser import HfArgumentParser
90
91# Model Cards
92from .modelcard import ModelCard
93
94# TF 2.0 <=> PyTorch conversion utilities
95from .modeling_tf_pytorch_utils import (
96convert_tf_weight_name_to_pt_weight_name,
97load_pytorch_checkpoint_in_tf2_model,
98load_pytorch_model_in_tf2_model,
99load_pytorch_weights_in_tf2_model,
100load_tf2_checkpoint_in_pytorch_model,
101load_tf2_model_in_pytorch_model,
102load_tf2_weights_in_pytorch_model,
103)
104
105# Pipelines
106from .pipelines import (
107Conversation,
108ConversationalPipeline,
109CsvPipelineDataFormat,
110FeatureExtractionPipeline,
111FillMaskPipeline,
112JsonPipelineDataFormat,
113NerPipeline,
114PipedPipelineDataFormat,
115Pipeline,
116PipelineDataFormat,
117QuestionAnsweringPipeline,
118SummarizationPipeline,
119TextClassificationPipeline,
120TextGenerationPipeline,
121TokenClassificationPipeline,
122TranslationPipeline,
123pipeline,
124)
125
126# Tokenizers
127from .tokenization_albert import AlbertTokenizer
128from .tokenization_auto import TOKENIZER_MAPPING, AutoTokenizer
129from .tokenization_bart import BartTokenizer, BartTokenizerFast, MBartTokenizer
130from .tokenization_bert import BasicTokenizer, BertTokenizer, BertTokenizerFast, WordpieceTokenizer
131from .tokenization_bert_japanese import BertJapaneseTokenizer, CharacterTokenizer, MecabTokenizer
132from .tokenization_camembert import CamembertTokenizer
133from .tokenization_ctrl import CTRLTokenizer
134from .tokenization_distilbert import DistilBertTokenizer, DistilBertTokenizerFast
135from .tokenization_dpr import (
136DPRContextEncoderTokenizer,
137DPRContextEncoderTokenizerFast,
138DPRQuestionEncoderTokenizer,
139DPRQuestionEncoderTokenizerFast,
140DPRReaderTokenizer,
141DPRReaderTokenizerFast,
142)
143from .tokenization_electra import ElectraTokenizer, ElectraTokenizerFast
144from .tokenization_flaubert import FlaubertTokenizer
145from .tokenization_gpt2 import GPT2Tokenizer, GPT2TokenizerFast
146from .tokenization_longformer import LongformerTokenizer, LongformerTokenizerFast
147from .tokenization_mobilebert import MobileBertTokenizer, MobileBertTokenizerFast
148from .tokenization_openai import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast
149from .tokenization_reformer import ReformerTokenizer
150from .tokenization_retribert import RetriBertTokenizer, RetriBertTokenizerFast
151from .tokenization_roberta import RobertaTokenizer, RobertaTokenizerFast
152from .tokenization_t5 import T5Tokenizer
153from .tokenization_transfo_xl import TransfoXLCorpus, TransfoXLTokenizer, TransfoXLTokenizerFast
154from .tokenization_utils import PreTrainedTokenizer
155from .tokenization_utils_base import (
156BatchEncoding,
157CharSpan,
158PreTrainedTokenizerBase,
159SpecialTokensMixin,
160TensorType,
161TokenSpan,
162)
163from .tokenization_utils_fast import PreTrainedTokenizerFast
164from .tokenization_xlm import XLMTokenizer
165from .tokenization_xlm_roberta import XLMRobertaTokenizer
166from .tokenization_xlnet import SPIECE_UNDERLINE, XLNetTokenizer
167
168# Trainer
169from .trainer_utils import EvalPrediction, set_seed
170from .training_args import TrainingArguments
171from .training_args_tf import TFTrainingArguments
172
173
174logger = logging.getLogger(__name__) # pylint: disable=invalid-name
175
176
177if is_sklearn_available():
178from .data import glue_compute_metrics, xnli_compute_metrics
179
180
181# Modeling
182if is_torch_available():
183from .generation_utils import top_k_top_p_filtering
184from .modeling_utils import PreTrainedModel, prune_layer, Conv1D, apply_chunking_to_forward
185from .modeling_auto import (
186AutoModel,
187AutoModelForPreTraining,
188AutoModelForSequenceClassification,
189AutoModelForQuestionAnswering,
190AutoModelWithLMHead,
191AutoModelForCausalLM,
192AutoModelForMaskedLM,
193AutoModelForSeq2SeqLM,
194AutoModelForTokenClassification,
195AutoModelForMultipleChoice,
196MODEL_MAPPING,
197MODEL_FOR_PRETRAINING_MAPPING,
198MODEL_WITH_LM_HEAD_MAPPING,
199MODEL_FOR_CAUSAL_LM_MAPPING,
200MODEL_FOR_MASKED_LM_MAPPING,
201MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
202MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
203MODEL_FOR_QUESTION_ANSWERING_MAPPING,
204MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
205MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
206)
207
208from .modeling_mobilebert import (
209MobileBertPreTrainedModel,
210MobileBertModel,
211MobileBertForPreTraining,
212MobileBertForSequenceClassification,
213MobileBertForQuestionAnswering,
214MobileBertForMaskedLM,
215MobileBertForNextSentencePrediction,
216MobileBertForMultipleChoice,
217MobileBertForTokenClassification,
218load_tf_weights_in_mobilebert,
219MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
220MobileBertLayer,
221)
222
223from .modeling_bert import (
224BertPreTrainedModel,
225BertModel,
226BertForPreTraining,
227BertForMaskedLM,
228BertLMHeadModel,
229BertForNextSentencePrediction,
230BertForSequenceClassification,
231BertForMultipleChoice,
232BertForTokenClassification,
233BertForQuestionAnswering,
234load_tf_weights_in_bert,
235BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
236BertLayer,
237)
238from .modeling_openai import (
239OpenAIGPTPreTrainedModel,
240OpenAIGPTModel,
241OpenAIGPTLMHeadModel,
242OpenAIGPTDoubleHeadsModel,
243load_tf_weights_in_openai_gpt,
244OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
245)
246from .modeling_transfo_xl import (
247TransfoXLPreTrainedModel,
248TransfoXLModel,
249TransfoXLLMHeadModel,
250AdaptiveEmbedding,
251load_tf_weights_in_transfo_xl,
252TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
253)
254from .modeling_gpt2 import (
255GPT2PreTrainedModel,
256GPT2Model,
257GPT2LMHeadModel,
258GPT2DoubleHeadsModel,
259load_tf_weights_in_gpt2,
260GPT2_PRETRAINED_MODEL_ARCHIVE_LIST,
261)
262from .modeling_ctrl import CTRLPreTrainedModel, CTRLModel, CTRLLMHeadModel, CTRL_PRETRAINED_MODEL_ARCHIVE_LIST
263from .modeling_xlnet import (
264XLNetPreTrainedModel,
265XLNetModel,
266XLNetLMHeadModel,
267XLNetForSequenceClassification,
268XLNetForTokenClassification,
269XLNetForMultipleChoice,
270XLNetForQuestionAnsweringSimple,
271XLNetForQuestionAnswering,
272load_tf_weights_in_xlnet,
273XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
274)
275from .modeling_xlm import (
276XLMPreTrainedModel,
277XLMModel,
278XLMWithLMHeadModel,
279XLMForSequenceClassification,
280XLMForTokenClassification,
281XLMForQuestionAnswering,
282XLMForQuestionAnsweringSimple,
283XLMForMultipleChoice,
284XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
285)
286from .modeling_bart import (
287PretrainedBartModel,
288BartForSequenceClassification,
289BartModel,
290BartForConditionalGeneration,
291BartForQuestionAnswering,
292BART_PRETRAINED_MODEL_ARCHIVE_LIST,
293)
294from .modeling_marian import MarianMTModel
295from .tokenization_marian import MarianTokenizer
296from .modeling_roberta import (
297RobertaForMaskedLM,
298RobertaModel,
299RobertaForSequenceClassification,
300RobertaForMultipleChoice,
301RobertaForTokenClassification,
302RobertaForQuestionAnswering,
303ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
304)
305from .modeling_distilbert import (
306DistilBertPreTrainedModel,
307DistilBertForMaskedLM,
308DistilBertModel,
309DistilBertForMultipleChoice,
310DistilBertForSequenceClassification,
311DistilBertForQuestionAnswering,
312DistilBertForTokenClassification,
313DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
314)
315from .modeling_camembert import (
316CamembertForMaskedLM,
317CamembertModel,
318CamembertForSequenceClassification,
319CamembertForMultipleChoice,
320CamembertForTokenClassification,
321CamembertForQuestionAnswering,
322CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
323)
324from .modeling_encoder_decoder import EncoderDecoderModel
325from .modeling_t5 import (
326T5PreTrainedModel,
327T5Model,
328T5ForConditionalGeneration,
329load_tf_weights_in_t5,
330T5_PRETRAINED_MODEL_ARCHIVE_LIST,
331)
332from .modeling_albert import (
333AlbertPreTrainedModel,
334AlbertModel,
335AlbertForPreTraining,
336AlbertForMaskedLM,
337AlbertForMultipleChoice,
338AlbertForSequenceClassification,
339AlbertForQuestionAnswering,
340AlbertForTokenClassification,
341load_tf_weights_in_albert,
342ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
343)
344from .modeling_xlm_roberta import (
345XLMRobertaForMaskedLM,
346XLMRobertaModel,
347XLMRobertaForMultipleChoice,
348XLMRobertaForSequenceClassification,
349XLMRobertaForTokenClassification,
350XLMRobertaForQuestionAnswering,
351XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
352)
353from .modeling_mmbt import ModalEmbeddings, MMBTModel, MMBTForClassification
354
355from .modeling_flaubert import (
356FlaubertModel,
357FlaubertWithLMHeadModel,
358FlaubertForSequenceClassification,
359FlaubertForTokenClassification,
360FlaubertForQuestionAnswering,
361FlaubertForQuestionAnsweringSimple,
362FlaubertForTokenClassification,
363FlaubertForMultipleChoice,
364FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
365)
366
367from .modeling_electra import (
368ElectraForPreTraining,
369ElectraForMaskedLM,
370ElectraForTokenClassification,
371ElectraPreTrainedModel,
372ElectraForMultipleChoice,
373ElectraForSequenceClassification,
374ElectraForQuestionAnswering,
375ElectraModel,
376load_tf_weights_in_electra,
377ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
378)
379
380from .modeling_reformer import (
381ReformerAttention,
382ReformerLayer,
383ReformerModel,
384ReformerForMaskedLM,
385ReformerModelWithLMHead,
386ReformerForSequenceClassification,
387ReformerForQuestionAnswering,
388REFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
389)
390
391from .modeling_longformer import (
392LongformerModel,
393LongformerForMaskedLM,
394LongformerForSequenceClassification,
395LongformerForMultipleChoice,
396LongformerForTokenClassification,
397LongformerForQuestionAnswering,
398LONGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
399)
400
401from .modeling_dpr import (
402DPRPretrainedContextEncoder,
403DPRPretrainedQuestionEncoder,
404DPRPretrainedReader,
405DPRContextEncoder,
406DPRQuestionEncoder,
407DPRReader,
408)
409from .modeling_retribert import (
410RetriBertPreTrainedModel,
411RetriBertModel,
412RETRIBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
413)
414
415# Optimization
416from .optimization import (
417AdamW,
418get_constant_schedule,
419get_constant_schedule_with_warmup,
420get_cosine_schedule_with_warmup,
421get_cosine_with_hard_restarts_schedule_with_warmup,
422get_linear_schedule_with_warmup,
423)
424
425# Trainer
426from .trainer import Trainer, set_seed, torch_distributed_zero_first, EvalPrediction
427from .data.data_collator import (
428default_data_collator,
429DataCollator,
430DataCollatorForLanguageModeling,
431DataCollatorForPermutationLanguageModeling,
432)
433from .data.datasets import (
434GlueDataset,
435TextDataset,
436LineByLineTextDataset,
437GlueDataTrainingArguments,
438SquadDataset,
439SquadDataTrainingArguments,
440)
441
442# Benchmarks
443from .benchmark.benchmark import PyTorchBenchmark
444from .benchmark.benchmark_args import PyTorchBenchmarkArguments
445
446# TensorFlow
447if is_tf_available():
448from .generation_tf_utils import tf_top_k_top_p_filtering
449from .modeling_tf_utils import (
450shape_list,
451TFPreTrainedModel,
452TFSequenceSummary,
453TFSharedEmbeddings,
454)
455from .modeling_tf_auto import (
456TF_MODEL_MAPPING,
457TF_MODEL_FOR_MULTIPLE_CHOICE_MAPPING,
458TF_MODEL_FOR_PRETRAINING_MAPPING,
459TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
460TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
461TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING,
462TF_MODEL_WITH_LM_HEAD_MAPPING,
463TF_MODEL_FOR_CAUSAL_LM_MAPPING,
464TF_MODEL_FOR_MASKED_LM_MAPPING,
465TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
466TFAutoModel,
467TFAutoModelForMultipleChoice,
468TFAutoModelForPreTraining,
469TFAutoModelForQuestionAnswering,
470TFAutoModelForSequenceClassification,
471TFAutoModelForTokenClassification,
472TFAutoModelWithLMHead,
473TFAutoModelForCausalLM,
474TFAutoModelForMaskedLM,
475TFAutoModelForSeq2SeqLM,
476)
477
478from .modeling_tf_albert import (
479TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
480TFAlbertForMaskedLM,
481TFAlbertForMultipleChoice,
482TFAlbertForPreTraining,
483TFAlbertForQuestionAnswering,
484TFAlbertForSequenceClassification,
485TFAlbertForTokenClassification,
486TFAlbertMainLayer,
487TFAlbertModel,
488TFAlbertPreTrainedModel,
489)
490
491from .modeling_tf_bert import (
492TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
493TFBertEmbeddings,
494TFBertLMHeadModel,
495TFBertForMaskedLM,
496TFBertForMultipleChoice,
497TFBertForNextSentencePrediction,
498TFBertForPreTraining,
499TFBertForQuestionAnswering,
500TFBertForSequenceClassification,
501TFBertForTokenClassification,
502TFBertMainLayer,
503TFBertModel,
504TFBertPreTrainedModel,
505)
506
507from .modeling_tf_camembert import (
508TF_CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
509TFCamembertForMaskedLM,
510TFCamembertModel,
511TFCamembertForMultipleChoice,
512TFCamembertForQuestionAnswering,
513TFCamembertForSequenceClassification,
514TFCamembertForTokenClassification,
515)
516
517from .modeling_tf_ctrl import (
518TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
519TFCTRLLMHeadModel,
520TFCTRLModel,
521TFCTRLPreTrainedModel,
522)
523
524from .modeling_tf_distilbert import (
525TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
526TFDistilBertForMaskedLM,
527TFDistilBertForMultipleChoice,
528TFDistilBertForQuestionAnswering,
529TFDistilBertForSequenceClassification,
530TFDistilBertForTokenClassification,
531TFDistilBertMainLayer,
532TFDistilBertModel,
533TFDistilBertPreTrainedModel,
534)
535
536from .modeling_tf_electra import (
537TF_ELECTRA_PRETRAINED_MODEL_ARCHIVE_LIST,
538TFElectraForMaskedLM,
539TFElectraForPreTraining,
540TFElectraForQuestionAnswering,
541TFElectraForTokenClassification,
542TFElectraModel,
543TFElectraPreTrainedModel,
544)
545
546from .modeling_tf_flaubert import (
547TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
548TFFlaubertForMultipleChoice,
549TFFlaubertForQuestionAnsweringSimple,
550TFFlaubertForSequenceClassification,
551TFFlaubertForTokenClassification,
552TFFlaubertWithLMHeadModel,
553TFFlaubertModel,
554)
555
556from .modeling_tf_gpt2 import (
557TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST,
558TFGPT2DoubleHeadsModel,
559TFGPT2LMHeadModel,
560TFGPT2MainLayer,
561TFGPT2Model,
562TFGPT2PreTrainedModel,
563)
564
565from .modeling_tf_mobilebert import (
566TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
567TFMobileBertModel,
568TFMobileBertPreTrainedModel,
569TFMobileBertForPreTraining,
570TFMobileBertForSequenceClassification,
571TFMobileBertForQuestionAnswering,
572TFMobileBertForMaskedLM,
573TFMobileBertForNextSentencePrediction,
574TFMobileBertForMultipleChoice,
575TFMobileBertForTokenClassification,
576TFMobileBertMainLayer,
577)
578
579from .modeling_tf_openai import (
580TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
581TFOpenAIGPTDoubleHeadsModel,
582TFOpenAIGPTLMHeadModel,
583TFOpenAIGPTMainLayer,
584TFOpenAIGPTModel,
585TFOpenAIGPTPreTrainedModel,
586)
587
588from .modeling_tf_roberta import (
589TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
590TFRobertaForMaskedLM,
591TFRobertaForMultipleChoice,
592TFRobertaForQuestionAnswering,
593TFRobertaForSequenceClassification,
594TFRobertaForTokenClassification,
595TFRobertaMainLayer,
596TFRobertaModel,
597TFRobertaPreTrainedModel,
598)
599
600from .modeling_tf_t5 import (
601TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST,
602TFT5ForConditionalGeneration,
603TFT5Model,
604TFT5PreTrainedModel,
605)
606
607from .modeling_tf_transfo_xl import (
608TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
609TFAdaptiveEmbedding,
610TFTransfoXLLMHeadModel,
611TFTransfoXLMainLayer,
612TFTransfoXLModel,
613TFTransfoXLPreTrainedModel,
614)
615
616from .modeling_tf_xlm import (
617TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
618TFXLMForMultipleChoice,
619TFXLMForQuestionAnsweringSimple,
620TFXLMForSequenceClassification,
621TFXLMForTokenClassification,
622TFXLMWithLMHeadModel,
623TFXLMMainLayer,
624TFXLMModel,
625TFXLMPreTrainedModel,
626)
627
628from .modeling_tf_xlm_roberta import (
629TF_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
630TFXLMRobertaForMaskedLM,
631TFXLMRobertaForMultipleChoice,
632TFXLMRobertaForQuestionAnswering,
633TFXLMRobertaForSequenceClassification,
634TFXLMRobertaForTokenClassification,
635TFXLMRobertaModel,
636)
637
638from .modeling_tf_xlnet import (
639TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
640TFXLNetForMultipleChoice,
641TFXLNetForQuestionAnsweringSimple,
642TFXLNetForSequenceClassification,
643TFXLNetForTokenClassification,
644TFXLNetLMHeadModel,
645TFXLNetMainLayer,
646TFXLNetModel,
647TFXLNetPreTrainedModel,
648)
649
650# Optimization
651from .optimization_tf import (
652AdamWeightDecay,
653create_optimizer,
654GradientAccumulator,
655WarmUp,
656)
657
658# Trainer
659from .trainer_tf import TFTrainer
660
661# Benchmarks
662from .benchmark.benchmark_tf import TensorFlowBenchmark
663from .benchmark.benchmark_args_tf import TensorFlowBenchmarkArguments
664
665
666if not is_tf_available() and not is_torch_available():
667logger.warning(
668"Neither PyTorch nor TensorFlow >= 2.0 have been found."
669"Models won't be available and only tokenizers, configuration"
670"and file/data utilities can be used."
671)
672