"examples/research_projects/bertabs/run_summarization.py" did not exist on "4d1819990294f27ab1cf0113034f52cdb4136eaf"
auto.md 8.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<!--Copyright 2020 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, 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.
11
12
13
14

鈿狅笍 Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

15
16
17
18
19
20
21
22
23
24
25
26
27
-->

# Auto Classes

In many cases, the architecture you want to use can be guessed from the name or the path of the pretrained model you
are supplying to the `from_pretrained()` method. AutoClasses are here to do this job for you so that you
automatically retrieve the relevant model given the name/path to the pretrained weights/config/vocabulary.

Instantiating one of [`AutoConfig`], [`AutoModel`], and
[`AutoTokenizer`] will directly create a class of the relevant architecture. For instance


```python
28
model = AutoModel.from_pretrained("google-bert/bert-base-cased")
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
```

will create a model that is an instance of [`BertModel`].

There is one class of `AutoModel` for each task, and for each backend (PyTorch, TensorFlow, or Flax).

## Extending the Auto Classes

Each of the auto classes has a method to be extended with your custom classes. For instance, if you have defined a
custom class of model `NewModel`, make sure you have a `NewModelConfig` then you can add those to the auto
classes like this:

```python
from transformers import AutoConfig, AutoModel

AutoConfig.register("new-model", NewModelConfig)
AutoModel.register(NewModelConfig, NewModel)
```

You will then be able to use the auto classes like you would usually do!

<Tip warning={true}>

52
If your `NewModelConfig` is a subclass of [`~transformers.PretrainedConfig`], make sure its
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
`model_type` attribute is set to the same key you use when registering the config (here `"new-model"`).

Likewise, if your `NewModel` is a subclass of [`PreTrainedModel`], make sure its
`config_class` attribute is set to the same class you use when registering the model (here
`NewModelConfig`).

</Tip>

## AutoConfig

[[autodoc]] AutoConfig

## AutoTokenizer

[[autodoc]] AutoTokenizer

## AutoFeatureExtractor

[[autodoc]] AutoFeatureExtractor

amyeroberts's avatar
amyeroberts committed
73
74
75
76
## AutoImageProcessor

[[autodoc]] AutoImageProcessor

77
78
79
80
## AutoProcessor

[[autodoc]] AutoProcessor

81
82
83
84
85
## Generic model classes

The following auto classes are available for instantiating a base model class without a specific head.

### AutoModel
86
87
88

[[autodoc]] AutoModel

89
90
91
92
93
94
95
96
97
98
99
100
101
### TFAutoModel

[[autodoc]] TFAutoModel

### FlaxAutoModel

[[autodoc]] FlaxAutoModel

## Generic pretraining classes

The following auto classes are available for instantiating a model with a pretraining head.

### AutoModelForPreTraining
102
103
104

[[autodoc]] AutoModelForPreTraining

105
### TFAutoModelForPreTraining
106

107
[[autodoc]] TFAutoModelForPreTraining
108

109
### FlaxAutoModelForPreTraining
110

111
[[autodoc]] FlaxAutoModelForPreTraining
112

113
## Natural Language Processing
114

115
The following auto classes are available for the following natural language processing tasks.
116

117
### AutoModelForCausalLM
118

119
[[autodoc]] AutoModelForCausalLM
120

121
### TFAutoModelForCausalLM
122

123
[[autodoc]] TFAutoModelForCausalLM
124

125
### FlaxAutoModelForCausalLM
126

127
[[autodoc]] FlaxAutoModelForCausalLM
128

129
### AutoModelForMaskedLM
130

131
[[autodoc]] AutoModelForMaskedLM
132

133
### TFAutoModelForMaskedLM
134

135
[[autodoc]] TFAutoModelForMaskedLM
136

137
### FlaxAutoModelForMaskedLM
138

139
[[autodoc]] FlaxAutoModelForMaskedLM
140

141
142
143
144
### AutoModelForMaskGeneration

[[autodoc]] AutoModelForMaskGeneration

145
146
147
148
### TFAutoModelForMaskGeneration

[[autodoc]] TFAutoModelForMaskGeneration

149
### AutoModelForSeq2SeqLM
150

151
[[autodoc]] AutoModelForSeq2SeqLM
152

153
### TFAutoModelForSeq2SeqLM
154

155
[[autodoc]] TFAutoModelForSeq2SeqLM
156

157
### FlaxAutoModelForSeq2SeqLM
158

159
[[autodoc]] FlaxAutoModelForSeq2SeqLM
160

161
### AutoModelForSequenceClassification
NielsRogge's avatar
NielsRogge committed
162

163
[[autodoc]] AutoModelForSequenceClassification
NielsRogge's avatar
NielsRogge committed
164

165
### TFAutoModelForSequenceClassification
166

167
[[autodoc]] TFAutoModelForSequenceClassification
168

169
### FlaxAutoModelForSequenceClassification
170

171
[[autodoc]] FlaxAutoModelForSequenceClassification
172

173
### AutoModelForMultipleChoice
174

175
[[autodoc]] AutoModelForMultipleChoice
176

177
### TFAutoModelForMultipleChoice
178

179
[[autodoc]] TFAutoModelForMultipleChoice
180

181
### FlaxAutoModelForMultipleChoice
182

183
[[autodoc]] FlaxAutoModelForMultipleChoice
184

185
### AutoModelForNextSentencePrediction
186

187
[[autodoc]] AutoModelForNextSentencePrediction
188

189
### TFAutoModelForNextSentencePrediction
190

191
[[autodoc]] TFAutoModelForNextSentencePrediction
192

193
### FlaxAutoModelForNextSentencePrediction
NielsRogge's avatar
NielsRogge committed
194

195
[[autodoc]] FlaxAutoModelForNextSentencePrediction
NielsRogge's avatar
NielsRogge committed
196

197
### AutoModelForTokenClassification
198

199
[[autodoc]] AutoModelForTokenClassification
200

201
### TFAutoModelForTokenClassification
202

203
[[autodoc]] TFAutoModelForTokenClassification
204

205
### FlaxAutoModelForTokenClassification
206

207
[[autodoc]] FlaxAutoModelForTokenClassification
208

209
### AutoModelForQuestionAnswering
210

211
[[autodoc]] AutoModelForQuestionAnswering
212

213
### TFAutoModelForQuestionAnswering
214

215
[[autodoc]] TFAutoModelForQuestionAnswering
216

217
### FlaxAutoModelForQuestionAnswering
218

219
[[autodoc]] FlaxAutoModelForQuestionAnswering
220

221
222
223
224
225
226
227
228
### AutoModelForTextEncoding

[[autodoc]] AutoModelForTextEncoding

### TFAutoModelForTextEncoding

[[autodoc]] TFAutoModelForTextEncoding

229
## Computer vision
230

231
The following auto classes are available for the following computer vision tasks.
232

233
### AutoModelForDepthEstimation
234

235
[[autodoc]] AutoModelForDepthEstimation
236

237
238
239
240
241
### AutoModelForImageClassification

[[autodoc]] AutoModelForImageClassification

### TFAutoModelForImageClassification
242
243
244

[[autodoc]] TFAutoModelForImageClassification

245
### FlaxAutoModelForImageClassification
246

247
[[autodoc]] FlaxAutoModelForImageClassification
248

249
### AutoModelForVideoClassification
250

251
[[autodoc]] AutoModelForVideoClassification
252

253
254
255
256
### AutoModelForKeypointDetection

[[autodoc]] AutoModelForKeypointDetection

257
### AutoModelForMaskedImageModeling
258

259
[[autodoc]] AutoModelForMaskedImageModeling
260

261
262
263
264
### TFAutoModelForMaskedImageModeling

[[autodoc]] TFAutoModelForMaskedImageModeling

265
### AutoModelForObjectDetection
266

267
[[autodoc]] AutoModelForObjectDetection
268

269
### AutoModelForImageSegmentation
270

271
[[autodoc]] AutoModelForImageSegmentation
272

273
274
275
276
### AutoModelForImageToImage

[[autodoc]] AutoModelForImageToImage

277
### AutoModelForSemanticSegmentation
278

279
[[autodoc]] AutoModelForSemanticSegmentation
280

281
### TFAutoModelForSemanticSegmentation
282

283
[[autodoc]] TFAutoModelForSemanticSegmentation
284

285
### AutoModelForInstanceSegmentation
286

287
[[autodoc]] AutoModelForInstanceSegmentation
288

289
290
291
292
### AutoModelForUniversalSegmentation

[[autodoc]] AutoModelForUniversalSegmentation

293
294
295
296
297
298
299
300
### AutoModelForZeroShotImageClassification

[[autodoc]] AutoModelForZeroShotImageClassification

### TFAutoModelForZeroShotImageClassification

[[autodoc]] TFAutoModelForZeroShotImageClassification

301
### AutoModelForZeroShotObjectDetection
302

303
[[autodoc]] AutoModelForZeroShotObjectDetection
304

305
## Audio
306

307
The following auto classes are available for the following audio tasks.
308

309
### AutoModelForAudioClassification
310

311
[[autodoc]] AutoModelForAudioClassification
312

313
### AutoModelForAudioFrameClassification
Joao Gante's avatar
Joao Gante committed
314

315
316
317
318
[[autodoc]] TFAutoModelForAudioClassification

### TFAutoModelForAudioFrameClassification

319
[[autodoc]] AutoModelForAudioFrameClassification
Joao Gante's avatar
Joao Gante committed
320

321
### AutoModelForCTC
322

323
[[autodoc]] AutoModelForCTC
324

325
### AutoModelForSpeechSeq2Seq
326

327
[[autodoc]] AutoModelForSpeechSeq2Seq
328

329
### TFAutoModelForSpeechSeq2Seq
330

331
[[autodoc]] TFAutoModelForSpeechSeq2Seq
332

333
334
335
336
### FlaxAutoModelForSpeechSeq2Seq

[[autodoc]] FlaxAutoModelForSpeechSeq2Seq

337
### AutoModelForAudioXVector
338

339
[[autodoc]] AutoModelForAudioXVector
340

341
342
343
344
345
346
347
348
### AutoModelForTextToSpectrogram

[[autodoc]] AutoModelForTextToSpectrogram

### AutoModelForTextToWaveform

[[autodoc]] AutoModelForTextToWaveform

349
## Multimodal
350

351
The following auto classes are available for the following multimodal tasks.
352

353
### AutoModelForTableQuestionAnswering
354

355
[[autodoc]] AutoModelForTableQuestionAnswering
356

357
### TFAutoModelForTableQuestionAnswering
358

359
[[autodoc]] TFAutoModelForTableQuestionAnswering
360

361
### AutoModelForDocumentQuestionAnswering
362

363
[[autodoc]] AutoModelForDocumentQuestionAnswering
364

365
### TFAutoModelForDocumentQuestionAnswering
366

367
[[autodoc]] TFAutoModelForDocumentQuestionAnswering
368

369
### AutoModelForVisualQuestionAnswering
370

371
[[autodoc]] AutoModelForVisualQuestionAnswering
372

373
### AutoModelForVision2Seq
374

375
376
377
378
379
[[autodoc]] AutoModelForVision2Seq

### TFAutoModelForVision2Seq

[[autodoc]] TFAutoModelForVision2Seq
380

381
### FlaxAutoModelForVision2Seq
382
383

[[autodoc]] FlaxAutoModelForVision2Seq