"comfy/ldm/models/vscode:/vscode.git/clone" did not exist on "e619278730656bec681443e33aa0aff53831443a"
__init__.py 11.3 KB
Newer Older
LysandreJik's avatar
LysandreJik committed
1
__version__ = "2.2.1"
thomwolf's avatar
thomwolf committed
2

thomwolf's avatar
thomwolf committed
3
4
5
6
7
8
9
10
11
12
13
# Work around to update TensorFlow's absl.logging threshold which alters the
# default Python logging output behavior when present.
# see: https://github.com/abseil/abseil-py/issues/99
# and: https://github.com/tensorflow/tensorflow/issues/26691#issuecomment-500369493
try:
    import absl.logging
    absl.logging.set_verbosity('info')
    absl.logging.set_stderrthreshold('info')
    absl.logging._warn_preinit_stderr = False
except:
    pass
14

thomwolf's avatar
thomwolf committed
15
16
17
18
import logging

logger = logging.getLogger(__name__)  # pylint: disable=invalid-name

thomwolf's avatar
thomwolf committed
19
# Files and general utilities
20
from .file_utils import (TRANSFORMERS_CACHE, PYTORCH_TRANSFORMERS_CACHE, PYTORCH_PRETRAINED_BERT_CACHE,
thomwolf's avatar
thomwolf committed
21
22
23
24
25
26
27
                         cached_path, add_start_docstrings, add_end_docstrings,
                         WEIGHTS_NAME, TF2_WEIGHTS_NAME, TF_WEIGHTS_NAME, CONFIG_NAME,
                         is_tf_available, is_torch_available)

from .data import (is_sklearn_available,
                   InputExample, InputFeatures, DataProcessor,
                   glue_output_modes, glue_convert_examples_to_features,
28
29
                   glue_processors, glue_tasks_num_labels,
                   xnli_output_modes, xnli_processors, xnli_tasks_num_labels)
thomwolf's avatar
thomwolf committed
30
31

if is_sklearn_available():
32
    from .data import glue_compute_metrics, xnli_compute_metrics
thomwolf's avatar
thomwolf committed
33
34

# Tokenizers
35
from .tokenization_utils import (PreTrainedTokenizer)
thomwolf's avatar
thomwolf committed
36
from .tokenization_auto import AutoTokenizer
thomwolf's avatar
thomwolf committed
37
from .tokenization_bert import BertTokenizer, BasicTokenizer, WordpieceTokenizer
thomwolf's avatar
thomwolf committed
38
from .tokenization_openai import OpenAIGPTTokenizer
39
from .tokenization_transfo_xl import (TransfoXLTokenizer, TransfoXLCorpus)
thomwolf's avatar
thomwolf committed
40
from .tokenization_gpt2 import GPT2Tokenizer
keskarnitish's avatar
keskarnitish committed
41
from .tokenization_ctrl import CTRLTokenizer
42
from .tokenization_xlnet import XLNetTokenizer, SPIECE_UNDERLINE
thomwolf's avatar
thomwolf committed
43
from .tokenization_xlm import XLMTokenizer
44
from .tokenization_roberta import RobertaTokenizer
thomwolf's avatar
thomwolf committed
45
from .tokenization_distilbert import DistilBertTokenizer
Lysandre's avatar
Lysandre committed
46
from .tokenization_albert import AlbertTokenizer
47
from .tokenization_camembert import CamembertTokenizer
48

49
# Configurations
50
from .configuration_utils import PretrainedConfig
51
52
53
54
55
from .configuration_auto import AutoConfig
from .configuration_bert import BertConfig, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP
from .configuration_openai import OpenAIGPTConfig, OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP
from .configuration_transfo_xl import TransfoXLConfig, TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP
from .configuration_gpt2 import GPT2Config, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP
keskarnitish's avatar
keskarnitish committed
56
from .configuration_ctrl import CTRLConfig, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP
57
from .configuration_xlnet import XLNetConfig, XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP
keskarnitish's avatar
keskarnitish committed
58
from .configuration_ctrl import CTRLConfig, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP
59
60
61
from .configuration_xlm import XLMConfig, XLM_PRETRAINED_CONFIG_ARCHIVE_MAP
from .configuration_roberta import RobertaConfig, ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP
from .configuration_distilbert import DistilBertConfig, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
Lysandre's avatar
Lysandre committed
62
from .configuration_albert import AlbertConfig, ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
63
from .configuration_camembert import CamembertConfig, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
64

65
# Modeling
thomwolf's avatar
thomwolf committed
66
if is_torch_available():
thomwolf's avatar
thomwolf committed
67
68
69
70
71
72
73
74
    from .modeling_utils import (PreTrainedModel, prune_layer, Conv1D)
    from .modeling_auto import (AutoModel, AutoModelForSequenceClassification, AutoModelForQuestionAnswering,
                                AutoModelWithLMHead)

    from .modeling_bert import (BertPreTrainedModel, BertModel, BertForPreTraining,
                                BertForMaskedLM, BertForNextSentencePrediction,
                                BertForSequenceClassification, BertForMultipleChoice,
                                BertForTokenClassification, BertForQuestionAnswering,
75
                                load_tf_weights_in_bert, BERT_PRETRAINED_MODEL_ARCHIVE_MAP)
thomwolf's avatar
thomwolf committed
76
77
78
79
    from .modeling_openai import (OpenAIGPTPreTrainedModel, OpenAIGPTModel,
                                OpenAIGPTLMHeadModel, OpenAIGPTDoubleHeadsModel,
                                load_tf_weights_in_openai_gpt, OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_MAP)
    from .modeling_transfo_xl import (TransfoXLPreTrainedModel, TransfoXLModel, TransfoXLLMHeadModel,
80
                                    AdaptiveEmbedding,
thomwolf's avatar
thomwolf committed
81
82
83
84
                                    load_tf_weights_in_transfo_xl, TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP)
    from .modeling_gpt2 import (GPT2PreTrainedModel, GPT2Model,
                                GPT2LMHeadModel, GPT2DoubleHeadsModel,
                                load_tf_weights_in_gpt2, GPT2_PRETRAINED_MODEL_ARCHIVE_MAP)
keskarnitish's avatar
keskarnitish committed
85
86
87
    from .modeling_ctrl import (CTRLPreTrainedModel, CTRLModel,
                                CTRLLMHeadModel,
                                CTRL_PRETRAINED_MODEL_ARCHIVE_MAP)
thomwolf's avatar
thomwolf committed
88
    from .modeling_xlnet import (XLNetPreTrainedModel, XLNetModel, XLNetLMHeadModel,
89
90
                                XLNetForSequenceClassification, XLNetForMultipleChoice,
                                XLNetForQuestionAnsweringSimple, XLNetForQuestionAnswering,
thomwolf's avatar
thomwolf committed
91
92
93
                                load_tf_weights_in_xlnet, XLNET_PRETRAINED_MODEL_ARCHIVE_MAP)
    from .modeling_xlm import (XLMPreTrainedModel , XLMModel,
                            XLMWithLMHeadModel, XLMForSequenceClassification,
94
95
                            XLMForQuestionAnswering, XLMForQuestionAnsweringSimple,
                            XLM_PRETRAINED_MODEL_ARCHIVE_MAP)
96
97
    from .modeling_roberta import (RobertaForMaskedLM, RobertaModel,
                                RobertaForSequenceClassification, RobertaForMultipleChoice,
Matt Maybeno's avatar
Matt Maybeno committed
98
                                RobertaForTokenClassification,
thomwolf's avatar
thomwolf committed
99
100
101
                                ROBERTA_PRETRAINED_MODEL_ARCHIVE_MAP)
    from .modeling_distilbert import (DistilBertForMaskedLM, DistilBertModel,
                                DistilBertForSequenceClassification, DistilBertForQuestionAnswering,
102
                                DistilBertForTokenClassification,
thomwolf's avatar
thomwolf committed
103
                                DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP)
104
105
    from .modeling_camembert import (CamembertForMaskedLM, CamembertModel,
                                CamembertForSequenceClassification, CamembertForMultipleChoice,
106
                                CamembertForTokenClassification,
107
                                CAMEMBERT_PRETRAINED_MODEL_ARCHIVE_MAP)
108
    from .modeling_encoder_decoder import PreTrainedEncoderDecoder, Model2Model
thomwolf's avatar
thomwolf committed
109

Lysandre's avatar
Lysandre committed
110
    from .modeling_albert import (AlbertModel, AlbertForMaskedLM, AlbertForSequenceClassification,
Lysandre's avatar
Lysandre committed
111
                                AlbertForQuestionAnswering,
Lysandre's avatar
Lysandre committed
112
                                load_tf_weights_in_albert, ALBERT_PRETRAINED_MODEL_ARCHIVE_MAP)
Lysandre's avatar
Lysandre committed
113

thomwolf's avatar
thomwolf committed
114
    # Optimization
115
116
    from .optimization import (AdamW, get_constant_schedule, get_constant_schedule_with_warmup, get_cosine_schedule_with_warmup,
                               get_cosine_with_hard_restarts_schedule_with_warmup, get_linear_schedule_with_warmup)
thomwolf's avatar
thomwolf committed
117
118
119


# TensorFlow
thomwolf's avatar
thomwolf committed
120
if is_tf_available():
121
    from .modeling_tf_utils import TFPreTrainedModel, TFSharedEmbeddings, TFSequenceSummary, shape_list
thomwolf's avatar
thomwolf committed
122
123
124
    from .modeling_tf_auto import (TFAutoModel, TFAutoModelForSequenceClassification, TFAutoModelForQuestionAnswering,
                                   TFAutoModelWithLMHead)

125
126
    from .modeling_tf_bert import (TFBertPreTrainedModel, TFBertMainLayer, TFBertEmbeddings,
                                   TFBertModel, TFBertForPreTraining,
thomwolf's avatar
thomwolf committed
127
128
129
130
                                   TFBertForMaskedLM, TFBertForNextSentencePrediction,
                                   TFBertForSequenceClassification, TFBertForMultipleChoice,
                                   TFBertForTokenClassification, TFBertForQuestionAnswering,
                                   TF_BERT_PRETRAINED_MODEL_ARCHIVE_MAP)
thomwolf's avatar
thomwolf committed
131

thomwolf's avatar
thomwolf committed
132
    from .modeling_tf_gpt2 import (TFGPT2PreTrainedModel, TFGPT2MainLayer,
133
134
135
                                   TFGPT2Model, TFGPT2LMHeadModel, TFGPT2DoubleHeadsModel,
                                   TF_GPT2_PRETRAINED_MODEL_ARCHIVE_MAP)

136
137
138
139
    from .modeling_tf_openai import (TFOpenAIGPTPreTrainedModel, TFOpenAIGPTMainLayer,
                                     TFOpenAIGPTModel, TFOpenAIGPTLMHeadModel, TFOpenAIGPTDoubleHeadsModel,
                                     TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_MAP)

thomwolf's avatar
thomwolf committed
140
141
142
143
    from .modeling_tf_transfo_xl import (TFTransfoXLPreTrainedModel, TFTransfoXLMainLayer,
                                         TFTransfoXLModel, TFTransfoXLLMHeadModel,
                                         TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP)

144
145
146
147
148
    from .modeling_tf_xlnet import (TFXLNetPreTrainedModel, TFXLNetMainLayer,
                                    TFXLNetModel, TFXLNetLMHeadModel,
                                    TFXLNetForSequenceClassification,
                                    TFXLNetForQuestionAnsweringSimple,
                                    TF_XLNET_PRETRAINED_MODEL_ARCHIVE_MAP)
149

thomwolf's avatar
thomwolf committed
150
151
152
153
154
155
    from .modeling_tf_xlm import (TFXLMPreTrainedModel, TFXLMMainLayer,
                                  TFXLMModel, TFXLMWithLMHeadModel,
                                  TFXLMForSequenceClassification,
                                  TFXLMForQuestionAnsweringSimple,
                                  TF_XLM_PRETRAINED_MODEL_ARCHIVE_MAP)

156
    from .modeling_tf_roberta import (TFRobertaPreTrainedModel, TFRobertaMainLayer,
thomwolf's avatar
thomwolf committed
157
                                      TFRobertaModel, TFRobertaForMaskedLM,
158
                                      TFRobertaForSequenceClassification,
Matt Maybeno's avatar
Matt Maybeno committed
159
                                      TFRobertaForTokenClassification,
160
161
162
163
164
                                      TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_MAP)

    from .modeling_tf_distilbert import (TFDistilBertPreTrainedModel, TFDistilBertMainLayer,
                                         TFDistilBertModel, TFDistilBertForMaskedLM,
                                         TFDistilBertForSequenceClassification,
Julien Plu's avatar
Julien Plu committed
165
                                         TFDistilBertForTokenClassification,
166
                                         TFDistilBertForQuestionAnswering,
167
168
                                         TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP)

thomwolf's avatar
thomwolf committed
169
170
171
172
    from .modeling_tf_ctrl import (TFCTRLPreTrainedModel, TFCTRLModel,
                                    TFCTRLLMHeadModel,
                                    TF_CTRL_PRETRAINED_MODEL_ARCHIVE_MAP)

Lysandre's avatar
Lysandre committed
173
    from .modeling_tf_albert import (TFAlbertPreTrainedModel, TFAlbertModel, TFAlbertForMaskedLM,
Lysandre's avatar
Lysandre committed
174
                                     TFAlbertForSequenceClassification,
Lysandre's avatar
Lysandre committed
175
                                    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_MAP)
176
177
    # Optimization
    from .optimization_tf import (WarmUp, create_optimizer, AdamWeightDecay, GradientAccumulator)
Lysandre's avatar
Lysandre committed
178

thomwolf's avatar
thomwolf committed
179
# TF 2.0 <=> PyTorch conversion utilities
180
181
182
183
184
185
186
from .modeling_tf_pytorch_utils import (convert_tf_weight_name_to_pt_weight_name,
                                        load_pytorch_checkpoint_in_tf2_model,
                                        load_pytorch_weights_in_tf2_model,
                                        load_pytorch_model_in_tf2_model,
                                        load_tf2_checkpoint_in_pytorch_model,
                                        load_tf2_weights_in_pytorch_model,
                                        load_tf2_model_in_pytorch_model)
187
188
189
190
191

if not is_tf_available() and not is_torch_available():
    logger.warning("Neither PyTorch nor TensorFlow >= 2.0 have been found."
                   "Models won't be available and only tokenizers, configuration"
                   "and file/data utilities can be used.")