Student0809 commited on
Commit
0e9a03e
·
verified ·
1 Parent(s): b50b784

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. docs/transformers/docs/source/ja/internal/audio_utils.md +39 -0
  2. docs/transformers/docs/source/ja/internal/file_utils.md +49 -0
  3. docs/transformers/docs/source/ja/internal/generation_utils.md +336 -0
  4. docs/transformers/docs/source/ja/internal/image_processing_utils.md +48 -0
  5. docs/transformers/docs/source/ja/internal/modeling_utils.md +66 -0
  6. docs/transformers/docs/source/ja/internal/pipelines_utils.md +44 -0
  7. docs/transformers/docs/source/ja/internal/time_series_utils.md +29 -0
  8. docs/transformers/docs/source/ja/internal/tokenization_utils.md +42 -0
  9. docs/transformers/docs/source/ja/internal/trainer_utils.md +49 -0
  10. docs/transformers/docs/source/ja/main_classes/callback.md +139 -0
  11. docs/transformers/docs/source/ja/main_classes/configuration.md +31 -0
  12. docs/transformers/docs/source/ja/main_classes/data_collator.md +67 -0
  13. docs/transformers/docs/source/ja/main_classes/deepspeed.md +0 -0
  14. docs/transformers/docs/source/ja/main_classes/feature_extractor.md +41 -0
  15. docs/transformers/docs/source/ja/main_classes/image_processor.md +33 -0
  16. docs/transformers/docs/source/ja/main_classes/keras_callbacks.md +28 -0
  17. docs/transformers/docs/source/ja/main_classes/logging.md +121 -0
  18. docs/transformers/docs/source/ja/main_classes/model.md +160 -0
  19. docs/transformers/docs/source/ja/main_classes/onnx.md +55 -0
  20. docs/transformers/docs/source/ja/main_classes/optimizer_schedules.md +73 -0
  21. docs/transformers/docs/source/ja/main_classes/output.md +321 -0
  22. docs/transformers/docs/source/ja/main_classes/pipelines.md +498 -0
  23. docs/transformers/docs/source/ja/main_classes/processors.md +160 -0
  24. docs/transformers/docs/source/ja/main_classes/quantization.md +447 -0
  25. docs/transformers/docs/source/ja/main_classes/text_generation.md +56 -0
  26. docs/transformers/docs/source/ja/main_classes/tokenizer.md +80 -0
  27. docs/transformers/docs/source/ja/main_classes/trainer.md +727 -0
  28. docs/transformers/docs/source/ja/model_doc/albert.md +193 -0
  29. docs/transformers/docs/source/ja/model_doc/align.md +104 -0
  30. docs/transformers/docs/source/ja/model_doc/altclip.md +97 -0
  31. docs/transformers/docs/source/ja/model_doc/audio-spectrogram-transformer.md +69 -0
  32. docs/transformers/docs/source/ja/model_doc/auto.md +374 -0
  33. docs/transformers/docs/source/ja/model_doc/autoformer.md +50 -0
  34. docs/transformers/docs/source/ja/model_doc/bark.md +198 -0
  35. docs/transformers/docs/source/ja/model_doc/bart.md +223 -0
  36. docs/transformers/docs/source/ja/model_doc/barthez.md +60 -0
  37. docs/transformers/docs/source/ja/model_doc/bartpho.md +86 -0
  38. docs/transformers/docs/source/ja/model_doc/beit.md +143 -0
  39. docs/transformers/docs/source/ja/model_doc/bert-generation.md +107 -0
  40. docs/transformers/docs/source/ja/model_doc/bert-japanese.md +81 -0
  41. docs/transformers/docs/source/ja/model_doc/bert.md +312 -0
  42. docs/transformers/docs/source/ja/model_doc/bertweet.md +68 -0
  43. docs/transformers/docs/source/ja/model_doc/big_bird.md +176 -0
  44. docs/transformers/docs/source/ja/model_doc/bigbird_pegasus.md +95 -0
  45. docs/transformers/docs/source/ja/model_doc/biogpt.md +73 -0
  46. docs/transformers/docs/source/ja/model_doc/bit.md +70 -0
  47. docs/transformers/docs/source/ja/model_doc/blenderbot-small.md +110 -0
  48. docs/transformers/docs/source/ja/model_doc/blenderbot.md +132 -0
  49. docs/transformers/docs/source/ja/model_doc/blip-2.md +90 -0
  50. docs/transformers/docs/source/ja/model_doc/blip.md +139 -0
docs/transformers/docs/source/ja/internal/audio_utils.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # `FeatureExtractor` 用のユーティリティ
18
+
19
+ このページには、*短時間フーリエ変換* や *ログ メル スペクトログラム* などの一般的なアルゴリズムを使用して生のオーディオから特別な特徴を計算するために、オーディオ [`FeatureExtractor`] で使用できるすべてのユーティリティ関数がリストされています。
20
+
21
+ これらのほとんどは、ライブラリ内のオーディオ プロセッサのコードを学習する場合にのみ役に立ちます。
22
+
23
+ ## オーディオ変換
24
+
25
+ [[autodoc]] audio_utils.hertz_to_mel
26
+
27
+ [[autodoc]] audio_utils.mel_to_hertz
28
+
29
+ [[autodoc]] audio_utils.mel_filter_bank
30
+
31
+ [[autodoc]] audio_utils.optimal_fft_length
32
+
33
+ [[autodoc]] audio_utils.window_function
34
+
35
+ [[autodoc]] audio_utils.spectrogram
36
+
37
+ [[autodoc]] audio_utils.power_to_db
38
+
39
+ [[autodoc]] audio_utils.amplitude_to_db
docs/transformers/docs/source/ja/internal/file_utils.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2021 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # 一般的なユーティリティ
18
+
19
+ このページには、ファイル `utils.py` にある Transformers の一般的なユーティリティ関数がすべてリストされています。
20
+
21
+ これらのほとんどは、ライブラリで一般的なコードを学習する場合にのみ役に立ちます。
22
+
23
+ ## 列挙型と名前付きタプル
24
+
25
+ [[autodoc]] utils.ExplicitEnum
26
+
27
+ [[autodoc]] utils.PaddingStrategy
28
+
29
+ [[autodoc]] utils.TensorType
30
+
31
+ ## 特別なデコレーター
32
+
33
+ [[autodoc]] utils.add_start_docstrings
34
+
35
+ [[autodoc]] utils.add_start_docstrings_to_model_forward
36
+
37
+ [[autodoc]] utils.add_end_docstrings
38
+
39
+ [[autodoc]] utils.add_code_sample_docstrings
40
+
41
+ [[autodoc]] utils.replace_return_docstrings
42
+
43
+ ## 特殊なプロパティ
44
+
45
+ [[autodoc]] utils.cached_property
46
+
47
+ ## その他のユーティリティ
48
+
49
+ [[autodoc]] utils._LazyModule
docs/transformers/docs/source/ja/internal/generation_utils.md ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # 発電用ユーティリティ
18
+
19
+ このページには、[`~generation.GenerationMixin.generate`] で使用されるすべてのユーティリティ関数がリストされています。
20
+
21
+ ## 出力を生成する
22
+
23
+ [`~generation.GenerationMixin.generate`] の出力は、次のサブクラスのインスタンスです。
24
+ [`~utils.ModelOutput`]。この出力は、返されたすべての情報を含むデータ構造です。
25
+ [`~generation.GenerationMixin.generate`] によって作成されますが、タプルまたは辞書としても使用できます。
26
+
27
+ 以下に例を示します。
28
+
29
+ ```python
30
+ from transformers import GPT2Tokenizer, GPT2LMHeadModel
31
+
32
+ tokenizer = GPT2Tokenizer.from_pretrained("openai-community/gpt2")
33
+ model = GPT2LMHeadModel.from_pretrained("openai-community/gpt2")
34
+
35
+ inputs = tokenizer("Hello, my dog is cute and ", return_tensors="pt")
36
+ generation_output = model.generate(**inputs, return_dict_in_generate=True, output_scores=True)
37
+ ```
38
+
39
+ `generation_output` オブジェクトは、できる限り [`~generation.GenerateDecoderOnlyOutput`] です。
40
+ 以下のそのクラスのドキュメントを参照してください。これは、次の属性があることを意味します。
41
+
42
+ - `sequences`: 生成されたトークンのシーケンス
43
+ - `scores` (オプション): 各生成ステップの言語モデリング ヘッドの予測スコア
44
+ - `hidden_​​states` (オプション): 生成ステップごとのモデルの隠れた状態
45
+ - `attentions` (オプション): 生成ステップごとのモデルのアテンションの重み
46
+
47
+ ここでは、`output_scores=True`を渡したので `scores` がありますが、`hidden_​​states` はありません。
48
+ `attentions` は、`output_hidden_​​states=True`または`output_attentions=True`を渡さなかったためです。
49
+
50
+ 通常と同じように各属性にアクセスできます。その属性がモデルから返されなかった場合は、
51
+ は「なし」を取得します。ここで、たとえば`generation_output.scores`は、生成されたすべての予測スコアです。
52
+ 言語モデリングのヘッドであり、`generation_output.attentions`は`None`です。
53
+
54
+ `generation_output` オブジェクトをタプルとして使用する場合、`None` 値を持たない属性のみが保持されます。
55
+ たとえば、ここには 2 つの要素、`loss`、次に`logits`があります。
56
+
57
+ ```python
58
+ generation_output[:2]
59
+ ```
60
+
61
+ たとえば、タプル `(generation_output.sequences,generation_output.scores)` を返します。
62
+
63
+ `generation_output` オブジェクトを辞書として使用する場合、`None` を持たない属性のみが保持されます。
64
+ ここでは、たとえば、`sequences`と`scores`という 2 つのキーがあります。
65
+
66
+ ここではすべての出力タイプを文書化します。
67
+
68
+ ### PyTorch
69
+
70
+ [[autodoc]] generation.GenerateDecoderOnlyOutput
71
+
72
+ [[autodoc]] generation.GenerateEncoderDecoderOutput
73
+
74
+ [[autodoc]] generation.GenerateBeamDecoderOnlyOutput
75
+
76
+ [[autodoc]] generation.GenerateBeamEncoderDecoderOutput
77
+
78
+ ### TensorFlow
79
+
80
+ [[autodoc]] generation.TFGreedySearchEncoderDecoderOutput
81
+
82
+ [[autodoc]] generation.TFGreedySearchDecoderOnlyOutput
83
+
84
+ [[autodoc]] generation.TFSampleEncoderDecoderOutput
85
+
86
+ [[autodoc]] generation.TFSampleDecoderOnlyOutput
87
+
88
+ [[autodoc]] generation.TFBeamSearchEncoderDecoderOutput
89
+
90
+ [[autodoc]] generation.TFBeamSearchDecoderOnlyOutput
91
+
92
+ [[autodoc]] generation.TFBeamSampleEncoderDecoderOutput
93
+
94
+ [[autodoc]] generation.TFBeamSampleDecoderOnlyOutput
95
+
96
+ [[autodoc]] generation.TFContrastiveSearchEncoderDecoderOutput
97
+
98
+ [[autodoc]] generation.TFContrastiveSearchDecoderOnlyOutput
99
+
100
+ ### FLAX
101
+
102
+ [[autodoc]] generation.FlaxSampleOutput
103
+
104
+ [[autodoc]] generation.FlaxGreedySearchOutput
105
+
106
+ [[autodoc]] generation.FlaxBeamSearchOutput
107
+
108
+ ## LogitsProcessor
109
+
110
+ [`LogitsProcessor`] を使用して、言語モデルのヘッドの予測スコアを変更できます。
111
+ 世代。
112
+
113
+ ### PyTorch
114
+
115
+ [[autodoc]] AlternatingCodebooksLogitsProcessor
116
+ - __call__
117
+
118
+ [[autodoc]] ClassifierFreeGuidanceLogitsProcessor
119
+ - __call__
120
+
121
+ [[autodoc]] EncoderNoRepeatNGramLogitsProcessor
122
+ - __call__
123
+
124
+ [[autodoc]] EncoderRepetitionPenaltyLogitsProcessor
125
+ - __call__
126
+
127
+ [[autodoc]] EpsilonLogitsWarper
128
+ - __call__
129
+
130
+ [[autodoc]] EtaLogitsWarper
131
+ - __call__
132
+
133
+ [[autodoc]] ExponentialDecayLengthPenalty
134
+ - __call__
135
+
136
+ [[autodoc]] ForcedBOSTokenLogitsProcessor
137
+ - __call__
138
+
139
+ [[autodoc]] ForcedEOSTokenLogitsProcessor
140
+ - __call__
141
+
142
+ [[autodoc]] HammingDiversityLogitsProcessor
143
+ - __call__
144
+
145
+ [[autodoc]] InfNanRemoveLogitsProcessor
146
+ - __call__
147
+
148
+ [[autodoc]] LogitNormalization
149
+ - __call__
150
+
151
+ [[autodoc]] LogitsProcessor
152
+ - __call__
153
+
154
+ [[autodoc]] LogitsProcessorList
155
+ - __call__
156
+
157
+ [[autodoc]] MinLengthLogitsProcessor
158
+ - __call__
159
+
160
+ [[autodoc]] MinNewTokensLengthLogitsProcessor
161
+ - __call__
162
+
163
+ [[autodoc]] NoBadWordsLogitsProcessor
164
+ - __call__
165
+
166
+ [[autodoc]] NoRepeatNGramLogitsProcessor
167
+ - __call__
168
+
169
+ [[autodoc]] PrefixConstrainedLogitsProcessor
170
+ - __call__
171
+
172
+ [[autodoc]] RepetitionPenaltyLogitsProcessor
173
+ - __call__
174
+
175
+ [[autodoc]] SequenceBiasLogitsProcessor
176
+ - __call__
177
+
178
+ [[autodoc]] SuppressTokensAtBeginLogitsProcessor
179
+ - __call__
180
+
181
+ [[autodoc]] SuppressTokensLogitsProcessor
182
+ - __call__
183
+
184
+ [[autodoc]] TemperatureLogitsWarper
185
+ - __call__
186
+
187
+ [[autodoc]] TopKLogitsWarper
188
+ - __call__
189
+
190
+ [[autodoc]] TopPLogitsWarper
191
+ - __call__
192
+
193
+ [[autodoc]] TypicalLogitsWarper
194
+ - __call__
195
+
196
+ [[autodoc]] UnbatchedClassifierFreeGuidanceLogitsProcessor
197
+ - __call__
198
+
199
+ [[autodoc]] WhisperTimeStampLogitsProcessor
200
+ - __call__
201
+
202
+ ### TensorFlow
203
+
204
+ [[autodoc]] TFForcedBOSTokenLogitsProcessor
205
+ - __call__
206
+
207
+ [[autodoc]] TFForcedEOSTokenLogitsProcessor
208
+ - __call__
209
+
210
+ [[autodoc]] TFForceTokensLogitsProcessor
211
+ - __call__
212
+
213
+ [[autodoc]] TFLogitsProcessor
214
+ - __call__
215
+
216
+ [[autodoc]] TFLogitsProcessorList
217
+ - __call__
218
+
219
+ [[autodoc]] TFLogitsWarper
220
+ - __call__
221
+
222
+ [[autodoc]] TFMinLengthLogitsProcessor
223
+ - __call__
224
+
225
+ [[autodoc]] TFNoBadWordsLogitsProcessor
226
+ - __call__
227
+
228
+ [[autodoc]] TFNoRepeatNGramLogitsProcessor
229
+ - __call__
230
+
231
+ [[autodoc]] TFRepetitionPenaltyLogitsProcessor
232
+ - __call__
233
+
234
+ [[autodoc]] TFSuppressTokensAtBeginLogitsProcessor
235
+ - __call__
236
+
237
+ [[autodoc]] TFSuppressTokensLogitsProcessor
238
+ - __call__
239
+
240
+ [[autodoc]] TFTemperatureLogitsWarper
241
+ - __call__
242
+
243
+ [[autodoc]] TFTopKLogitsWarper
244
+ - __call__
245
+
246
+ [[autodoc]] TFTopPLogitsWarper
247
+ - __call__
248
+
249
+ ### FLAX
250
+
251
+ [[autodoc]] FlaxForcedBOSTokenLogitsProcessor
252
+ - __call__
253
+
254
+ [[autodoc]] FlaxForcedEOSTokenLogitsProcessor
255
+ - __call__
256
+
257
+ [[autodoc]] FlaxForceTokensLogitsProcessor
258
+ - __call__
259
+
260
+ [[autodoc]] FlaxLogitsProcessor
261
+ - __call__
262
+
263
+ [[autodoc]] FlaxLogitsProcessorList
264
+ - __call__
265
+
266
+ [[autodoc]] FlaxLogitsWarper
267
+ - __call__
268
+
269
+ [[autodoc]] FlaxMinLengthLogitsProcessor
270
+ - __call__
271
+
272
+ [[autodoc]] FlaxSuppressTokensAtBeginLogitsProcessor
273
+ - __call__
274
+
275
+ [[autodoc]] FlaxSuppressTokensLogitsProcessor
276
+ - __call__
277
+
278
+ [[autodoc]] FlaxTemperatureLogitsWarper
279
+ - __call__
280
+
281
+ [[autodoc]] FlaxTopKLogitsWarper
282
+ - __call__
283
+
284
+ [[autodoc]] FlaxTopPLogitsWarper
285
+ - __call__
286
+
287
+ [[autodoc]] FlaxWhisperTimeStampLogitsProcessor
288
+ - __call__
289
+
290
+ ## StoppingCriteria
291
+
292
+ [`StoppingCriteria`] を使用して、(EOS トークン以外の) 生成を停止するタイミングを変更できます。これは PyTorch 実装でのみ利用可能であることに注意してください。
293
+
294
+ [[autodoc]] StoppingCriteria
295
+ - __call__
296
+
297
+ [[autodoc]] StoppingCriteriaList
298
+ - __call__
299
+
300
+ [[autodoc]] MaxLengthCriteria
301
+ - __call__
302
+
303
+ [[autodoc]] MaxTimeCriteria
304
+ - __call__
305
+
306
+ ## Constraints
307
+
308
+ [`Constraint`] を使用すると、生成時に出力に特定のトークンまたはシーケンスが含まれるように強制できます。これは PyTorch 実装でのみ利用可能であることに注意してください。
309
+
310
+ [[autodoc]] Constraint
311
+
312
+ [[autodoc]] PhrasalConstraint
313
+
314
+ [[autodoc]] DisjunctiveConstraint
315
+
316
+ [[autodoc]] ConstraintListState
317
+
318
+ ## BeamSearch
319
+
320
+ [[autodoc]] BeamScorer
321
+ - process
322
+ - finalize
323
+
324
+ [[autodoc]] BeamSearchScorer
325
+ - process
326
+ - finalize
327
+
328
+ [[autodoc]] ConstrainedBeamSearchScorer
329
+ - process
330
+ - finalize
331
+
332
+ ## Streamers
333
+
334
+ [[autodoc]] TextStreamer
335
+
336
+ [[autodoc]] TextIteratorStreamer
docs/transformers/docs/source/ja/internal/image_processing_utils.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2022 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # 画像プロセッサ用ユーティリティ
18
+
19
+ このページには、画像プロセッサーで使用されるすべてのユーティリティー関数がリストされています。主に機能的なものです。
20
+ 画像を処理するために使用される変換。
21
+
22
+ これらのほとんどは、ライブラリ内の画像プロセッサのコードを学習する場合にのみ役に立ちます。
23
+
24
+ ## Image Transformations
25
+
26
+ [[autodoc]] image_transforms.center_crop
27
+
28
+ [[autodoc]] image_transforms.center_to_corners_format
29
+
30
+ [[autodoc]] image_transforms.corners_to_center_format
31
+
32
+ [[autodoc]] image_transforms.id_to_rgb
33
+
34
+ [[autodoc]] image_transforms.normalize
35
+
36
+ [[autodoc]] image_transforms.pad
37
+
38
+ [[autodoc]] image_transforms.rgb_to_id
39
+
40
+ [[autodoc]] image_transforms.rescale
41
+
42
+ [[autodoc]] image_transforms.resize
43
+
44
+ [[autodoc]] image_transforms.to_pil_image
45
+
46
+ ## ImageProcessingMixin
47
+
48
+ [[autodoc]] image_processing_utils.ImageProcessingMixin
docs/transformers/docs/source/ja/internal/modeling_utils.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # カスタムレイヤーとユーティリティ
18
+
19
+ このページには、ライブラリで使用されるすべてのカスタム レイヤーと、モデリングに提供されるユーティリティ関数がリストされます。
20
+
21
+ これらのほとんどは、ライブラリ内のモデルのコードを研究する場合にのみ役に立ちます。
22
+
23
+
24
+ ## Pytorch custom modules
25
+
26
+ [[autodoc]] pytorch_utils.Conv1D
27
+
28
+ ## PyTorch Helper Functions
29
+
30
+ [[autodoc]] pytorch_utils.apply_chunking_to_forward
31
+
32
+ [[autodoc]] pytorch_utils.find_pruneable_heads_and_indices
33
+
34
+ [[autodoc]] pytorch_utils.prune_layer
35
+
36
+ [[autodoc]] pytorch_utils.prune_conv1d_layer
37
+
38
+ [[autodoc]] pytorch_utils.prune_linear_layer
39
+
40
+ ## TensorFlow custom layers
41
+
42
+ [[autodoc]] modeling_tf_utils.TFConv1D
43
+
44
+ [[autodoc]] modeling_tf_utils.TFSequenceSummary
45
+
46
+ ## TensorFlow loss functions
47
+
48
+ [[autodoc]] modeling_tf_utils.TFCausalLanguageModelingLoss
49
+
50
+ [[autodoc]] modeling_tf_utils.TFMaskedLanguageModelingLoss
51
+
52
+ [[autodoc]] modeling_tf_utils.TFMultipleChoiceLoss
53
+
54
+ [[autodoc]] modeling_tf_utils.TFQuestionAnsweringLoss
55
+
56
+ [[autodoc]] modeling_tf_utils.TFSequenceClassificationLoss
57
+
58
+ [[autodoc]] modeling_tf_utils.TFTokenClassificationLoss
59
+
60
+ ## TensorFlow Helper Functions
61
+
62
+ [[autodoc]] modeling_tf_utils.get_initializer
63
+
64
+ [[autodoc]] modeling_tf_utils.keras_serializable
65
+
66
+ [[autodoc]] modeling_tf_utils.shape_list
docs/transformers/docs/source/ja/internal/pipelines_utils.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # パイプライン用のユーティリティ
18
+
19
+ このページには、ライブラリがパイプラインに提供するすべてのユーティリティ関数がリストされます。
20
+
21
+ これらのほとんどは、ライブラリ内のモデルのコードを研究する場合にのみ役に立ちます。
22
+
23
+
24
+ ## Argument handling
25
+
26
+ [[autodoc]] pipelines.ArgumentHandler
27
+
28
+ [[autodoc]] pipelines.ZeroShotClassificationArgumentHandler
29
+
30
+ [[autodoc]] pipelines.QuestionAnsweringArgumentHandler
31
+
32
+ ## Data format
33
+
34
+ [[autodoc]] pipelines.PipelineDataFormat
35
+
36
+ [[autodoc]] pipelines.CsvPipelineDataFormat
37
+
38
+ [[autodoc]] pipelines.JsonPipelineDataFormat
39
+
40
+ [[autodoc]] pipelines.PipedPipelineDataFormat
41
+
42
+ ## Utilities
43
+
44
+ [[autodoc]] pipelines.PipelineException
docs/transformers/docs/source/ja/internal/time_series_utils.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # 時系列ユーティリティ
18
+
19
+ このページには、時系列ベースのモデルに使用できるすべてのユーティリティ関数とクラスがリストされます。
20
+
21
+ これらのほとんどは、時系列モデルのコードを研究している場合、または分散出力クラスのコレクションに追加したい場合にのみ役立ちます。
22
+
23
+ ## Distributional Output
24
+
25
+ [[autodoc]] time_series_utils.NormalOutput
26
+
27
+ [[autodoc]] time_series_utils.StudentTOutput
28
+
29
+ [[autodoc]] time_series_utils.NegativeBinomialOutput
docs/transformers/docs/source/ja/internal/tokenization_utils.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Utilities for Tokenizers
18
+
19
+ このページには、トークナイザーによって使用されるすべてのユーティリティ関数 (主にクラス) がリストされます。
20
+ [`~tokenization_utils_base.PreTrainedTokenizerBase`] 間の共通メソッドを実装します。
21
+ [`PreTrainedTokenizer`] と [`PreTrainedTokenizerFast`] およびミックスイン
22
+ [`~tokenization_utils_base.SpecialTokensMixin`]。
23
+
24
+ これらのほとんどは、ライブラリ内のトークナイザーのコードを学習する場合にのみ役に立ちます。
25
+
26
+ ## PreTrainedTokenizerBase
27
+
28
+ [[autodoc]] tokenization_utils_base.PreTrainedTokenizerBase
29
+ - __call__
30
+ - all
31
+
32
+ ## SpecialTokensMixin
33
+
34
+ [[autodoc]] tokenization_utils_base.SpecialTokensMixin
35
+
36
+ ## Enums and namedtuples
37
+
38
+ [[autodoc]] tokenization_utils_base.TruncationStrategy
39
+
40
+ [[autodoc]] tokenization_utils_base.CharSpan
41
+
42
+ [[autodoc]] tokenization_utils_base.TokenSpan
docs/transformers/docs/source/ja/internal/trainer_utils.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # トレーナー用ユーティリティ
18
+
19
+ このページには、[`Trainer`] で使用されるすべてのユーティリティ関数がリストされています。
20
+
21
+ これらのほとんどは、ライブラリ内のトレーナーのコードを学習する場合にのみ役に立ちます。
22
+
23
+ ## Utilities
24
+
25
+ [[autodoc]] EvalPrediction
26
+
27
+ [[autodoc]] IntervalStrategy
28
+
29
+ [[autodoc]] enable_full_determinism
30
+
31
+ [[autodoc]] set_seed
32
+
33
+ [[autodoc]] torch_distributed_zero_first
34
+
35
+ ## Callbacks internals
36
+
37
+ [[autodoc]] trainer_callback.CallbackHandler
38
+
39
+ ## Distributed Evaluation
40
+
41
+ [[autodoc]] trainer_pt_utils.DistributedTensorGatherer
42
+
43
+ ## Trainer Argument Parser
44
+
45
+ [[autodoc]] HfArgumentParser
46
+
47
+ ## Debug Utilities
48
+
49
+ [[autodoc]] debug_utils.DebugUnderflowOverflow
docs/transformers/docs/source/ja/main_classes/callback.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+
18
+ # コールバック数
19
+
20
+ コールバックは、PyTorch のトレーニング ループの動作をカスタマイズできるオブジェクトです。
21
+ トレーニング ループを検査できる [`Trainer`] (この機能は TensorFlow にはまだ実装されていません)
22
+ 状態を確認し (進捗レポート、TensorBoard または他の ML プラットフォームへのログ記録など)、決定を下します (初期段階など)。
23
+ 停止中)。
24
+
25
+ コールバックは、返される [`TrainerControl`] オブジェクトを除けば、「読み取り専用」のコード部分です。
26
+ トレーニング ループ内では何も変更できません。トレーニング ループの変更が必要なカスタマイズの場合は、次のことを行う必要があります。
27
+ [`Trainer`] をサブクラス化し、必要なメソッドをオーバーライドします (例については、[trainer](trainer) を参照してください)。
28
+
29
+ デフォルトでは、`TrainingArguments.report_to` は `"all"` に設定されているため、[`Trainer`] は次のコールバックを使用します。
30
+
31
+ - [`DefaultFlowCallback`] は、ログ記録、保存、評価のデフォルトの動作を処理します。
32
+ - [`PrinterCallback`] または [`ProgressCallback`] で進行状況を表示し、
33
+ ログ (最初のログは、[`TrainingArguments`] を通じて tqdm を非アクティブ化する場合に使用され、そうでない場合に使用されます)
34
+ 2番目です)。
35
+ - [`~integrations.TensorBoardCallback`] (PyTorch >= 1.4 を介して) tensorboard にアクセスできる場合
36
+ またはテンソルボードX)。
37
+ - [`~integrations.WandbCallback`] [wandb](https://www.wandb.com/) がインストールされている場合。
38
+ - [`~integrations.CometCallback`] [comet_ml](https://www.comet.com/site/) がインストールされている場合。
39
+ - [mlflow](https://www.mlflow.org/) がインストールされている場合は [`~integrations.MLflowCallback`]。
40
+ - [`~integrations.NeptuneCallback`] [neptune](https://neptune.ai/) がインストールされている場合。
41
+ - [`~integrations.AzureMLCallback`] [azureml-sdk](https://pypi.org/project/azureml-sdk/) の場合
42
+ インストールされています。
43
+ - [`~integrations.CodeCarbonCallback`] [codecarbon](https://pypi.org/project/codecarbon/) の場合
44
+ インストールされています。
45
+ - [`~integrations.ClearMLCallback`] [clearml](https://github.com/allegroai/clearml) がインストールされている場合。
46
+ - [`~integrations.DagsHubCallback`] [dagshub](https://dagshub.com/) がインストールされている場合。
47
+ - [`~integrations.FlyteCallback`] [flyte](https://flyte.org/) がインストールされている場合。
48
+ - [`~integrations.DVCLiveCallback`] [dvclive](https://www.dvc.org/doc/dvclive) がインストールされている場合。
49
+ - [`~integrations.SwanLabCallback`] [swanlab](http://swanlab.cn/) がインストールされている場合。
50
+
51
+ パッケージがインストールされているが、付随する統合を使用したくない場合は、`TrainingArguments.report_to` を、使用したい統合のみのリストに変更できます (例: `["azure_ml", "wandb"]`) 。
52
+
53
+ コールバックを実装するメインクラスは [`TrainerCallback`] です。それは、
54
+ [`TrainingArguments`] は [`Trainer`] をインスタンス化するために使用され、それにアクセスできます。
55
+ [`TrainerState`] を介してトレーナーの内部状態を取得し、トレーニング ループ上でいくつかのアクションを実行できます。
56
+ [`TrainerControl`]。
57
+
58
+ ## 利用可能なコールバック
59
+
60
+ ライブラリで利用可能な [`TrainerCallback`] のリストは次のとおりです。
61
+
62
+ [[autodoc]] integrations.CometCallback
63
+ - setup
64
+
65
+ [[autodoc]] DefaultFlowCallback
66
+
67
+ [[autodoc]] PrinterCallback
68
+
69
+ [[autodoc]] ProgressCallback
70
+
71
+ [[autodoc]] EarlyStoppingCallback
72
+
73
+ [[autodoc]] integrations.TensorBoardCallback
74
+
75
+ [[autodoc]] integrations.WandbCallback
76
+ - setup
77
+
78
+ [[autodoc]] integrations.MLflowCallback
79
+ - setup
80
+
81
+ [[autodoc]] integrations.AzureMLCallback
82
+
83
+ [[autodoc]] integrations.CodeCarbonCallback
84
+
85
+ [[autodoc]] integrations.NeptuneCallback
86
+
87
+ [[autodoc]] integrations.ClearMLCallback
88
+
89
+ [[autodoc]] integrations.DagsHubCallback
90
+
91
+ [[autodoc]] integrations.FlyteCallback
92
+
93
+ [[autodoc]] integrations.DVCLiveCallback
94
+ - setup
95
+
96
+ [[autodoc]] integrations.SwanLabCallback
97
+ - setup
98
+
99
+ ## TrainerCallback
100
+
101
+ [[autodoc]] TrainerCallback
102
+
103
+ 以下は、カスタム コールバックを PyTorch [`Trainer`] に登録する方法の例です。
104
+
105
+ ```python
106
+ class MyCallback(TrainerCallback):
107
+ "A callback that prints a message at the beginning of training"
108
+
109
+ def on_train_begin(self, args, state, control, **kwargs):
110
+ print("Starting training")
111
+
112
+
113
+ trainer = Trainer(
114
+ model,
115
+ args,
116
+ train_dataset=train_dataset,
117
+ eval_dataset=eval_dataset,
118
+ callbacks=[MyCallback], # We can either pass the callback class this way or an instance of it (MyCallback())
119
+ )
120
+ ```
121
+
122
+ コールバックを登録する別の方法は、次のように `trainer.add_callback()` を呼び出すことです。
123
+
124
+ ```python
125
+ trainer = Trainer(...)
126
+ trainer.add_callback(MyCallback)
127
+ # Alternatively, we can pass an instance of the callback class
128
+ trainer.add_callback(MyCallback())
129
+ ```
130
+
131
+ ## TrainerState
132
+
133
+ [[autodoc]] TrainerState
134
+
135
+ ## TrainerControl
136
+
137
+ [[autodoc]] TrainerControl
138
+
139
+
docs/transformers/docs/source/ja/main_classes/configuration.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # 構成
18
+
19
+ 基本クラス [`PretrainedConfig`] は、設定をロード/保存するための一般的なメソッドを実装します。
20
+ ローカル ファイルまたはディレクトリから、またはライブラリ (ダウンロードされた) によって提供される事前トレーニング済みモデル構成から
21
+ HuggingFace の AWS S3 リポジトリから)。
22
+
23
+ 各派生構成クラスはモデル固有の属性を実装します。すべての構成クラスに存在する共通の属性は次のとおりです。
24
+ `hidden_​​size`、`num_attention_heads`、および `num_hidden_​​layers`。テキスト モデルはさらに以下を実装します。
25
+ `vocab_size`。
26
+
27
+ ## PretrainedConfig
28
+
29
+ [[autodoc]] PretrainedConfig
30
+ - push_to_hub
31
+ - all
docs/transformers/docs/source/ja/main_classes/data_collator.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # データ照合者
18
+
19
+ データ照合器は、データセット要素のリストを入力として使用してバッチを形成するオブジェクトです。これらの要素は、
20
+ `train_dataset` または `eval_dataset` の要素と同じ型。
21
+
22
+ バッチを構築できるようにするために、データ照合者は何らかの処理 (パディングなど) を適用する場合があります。そのうちのいくつかは(
23
+ [`DataCollat​​orForLanguageModeling`]) ランダムなデータ拡張 (ランダム マスキングなど) も適用します
24
+ 形成されたバッチ上で。
25
+
26
+ 使用例は、[サンプル スクリプト](../examples) または [サンプル ノートブック](../notebooks) にあります。
27
+
28
+ ## Default data collator
29
+
30
+ [[autodoc]] data.data_collator.default_data_collator
31
+
32
+ ## DefaultDataCollator
33
+
34
+ [[autodoc]] data.data_collator.DefaultDataCollator
35
+
36
+ ## DataCollatorWithPadding
37
+
38
+ [[autodoc]] data.data_collator.DataCollatorWithPadding
39
+
40
+ ## DataCollatorForTokenClassification
41
+
42
+ [[autodoc]] data.data_collator.DataCollatorForTokenClassification
43
+
44
+ ## DataCollatorForSeq2Seq
45
+
46
+ [[autodoc]] data.data_collator.DataCollatorForSeq2Seq
47
+
48
+ ## DataCollatorForLanguageModeling
49
+
50
+ [[autodoc]] data.data_collator.DataCollatorForLanguageModeling
51
+ - numpy_mask_tokens
52
+ - tf_mask_tokens
53
+ - torch_mask_tokens
54
+
55
+ ## DataCollatorForWholeWordMask
56
+
57
+ [[autodoc]] data.data_collator.DataCollatorForWholeWordMask
58
+ - numpy_mask_tokens
59
+ - tf_mask_tokens
60
+ - torch_mask_tokens
61
+
62
+ ## DataCollatorForPermutationLanguageModeling
63
+
64
+ [[autodoc]] data.data_collator.DataCollatorForPermutationLanguageModeling
65
+ - numpy_mask_tokens
66
+ - tf_mask_tokens
67
+ - torch_mask_tokens
docs/transformers/docs/source/ja/main_classes/deepspeed.md ADDED
The diff for this file is too large to render. See raw diff
 
docs/transformers/docs/source/ja/main_classes/feature_extractor.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+
16
+ -->
17
+
18
+ # Feature Extractor
19
+
20
+
21
+ フィーチャーエクストラクタは、オーディオまたはビジョンモデルのための入力フィーチャーの準備を担当しています。これには、シーケンスからのフィーチャー抽出(例:オーディオファイルの前処理からLog-Melスペクトログラムフィーチャーへの変換)、画像からのフィーチャー抽出(例:画像ファイルのクロッピング)、またパディング、正規化、そしてNumpy、PyTorch、TensorFlowテンソルへの変換も含まれます。
22
+
23
+
24
+ ## FeatureExtractionMixin
25
+
26
+ [[autodoc]] feature_extraction_utils.FeatureExtractionMixin
27
+ - from_pretrained
28
+ - save_pretrained
29
+
30
+ ## SequenceFeatureExtractor
31
+
32
+ [[autodoc]] SequenceFeatureExtractor
33
+ - pad
34
+
35
+ ## BatchFeature
36
+
37
+ [[autodoc]] BatchFeature
38
+
39
+ ## ImageFeatureExtractionMixin
40
+
41
+ [[autodoc]] image_utils.ImageFeatureExtractionMixin
docs/transformers/docs/source/ja/main_classes/image_processor.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Image Processor
18
+
19
+ 画像プロセッサは、ビジョン モデルの入力特徴の準備とその出力の後処理を担当します。これには、サイズ変更、正規化、PyTorch、TensorFlow、Flax、Numpy テンソルへの変換などの変換が含まれます。ロジットをセグメンテーション マスクに変換するなど、モデル固有の後処理も含まれる場合があります。
20
+
21
+ ## ImageProcessingMixin
22
+
23
+ [[autodoc]] image_processing_utils.ImageProcessingMixin
24
+ - from_pretrained
25
+ - save_pretrained
26
+
27
+ ## BatchFeature
28
+
29
+ [[autodoc]] BatchFeature
30
+
31
+ ## BaseImageProcessor
32
+
33
+ [[autodoc]] image_processing_utils.BaseImageProcessor
docs/transformers/docs/source/ja/main_classes/keras_callbacks.md ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Keras callbacks
18
+
19
+ Keras を使用して Transformers モデルをトレーニングする場合、一般的な処理を自動化するために使用できるライブラリ固有のコールバックがいくつかあります。
20
+ タスク:
21
+
22
+ ## KerasMetricCallback
23
+
24
+ [[autodoc]] KerasMetricCallback
25
+
26
+ ## PushToHubCallback
27
+
28
+ [[autodoc]] PushToHubCallback
docs/transformers/docs/source/ja/main_classes/logging.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Logging
18
+
19
+ 🤗 Transformersには、ライブラリの詳細度を簡単に設定できる中央集中型のロギングシステムがあります。
20
+
21
+ 現在、ライブラリのデフォルトの詳細度は「WARNING」です。
22
+
23
+ 詳細度を変更するには、直接設定メソッドの1つを使用するだけです。例えば、詳細度をINFOレベルに変更する方法は以下の通りです。
24
+
25
+
26
+ ```python
27
+ import transformers
28
+
29
+ transformers.logging.set_verbosity_info()
30
+ ```
31
+
32
+
33
+ 環境変数 `TRANSFORMERS_VERBOSITY` を使用して、デフォルトの冗長性をオーバーライドすることもできます。設定できます
34
+ `debug`、`info`、`warning`、`error`、`critical` のいずれかに変更します。例えば:
35
+
36
+ ```bash
37
+ TRANSFORMERS_VERBOSITY=error ./myprogram.py
38
+ ```
39
+
40
+
41
+ さらに、一部の「警告」は環境変数を設定することで無効にできます。
42
+ `TRANSFORMERS_NO_ADVISORY_WARNINGS` を *1* などの true 値に設定します。これにより、次を使用してログに記録される警告が無効になります。
43
+ [`logger.warning_advice`]。例えば:
44
+
45
+ ```bash
46
+ TRANSFORMERS_NO_ADVISORY_WARNINGS=1 ./myprogram.py
47
+ ```
48
+
49
+
50
+ 以下は、独自のモジュールまたはスクリプトでライブラリと同じロガーを使用する方法の例です。
51
+
52
+ ```python
53
+ from transformers.utils import logging
54
+
55
+ logging.set_verbosity_info()
56
+ logger = logging.get_logger("transformers")
57
+ logger.info("INFO")
58
+ logger.warning("WARN")
59
+ ```
60
+
61
+ このロギング モジュールのすべてのメソッドは以下に文書化されています。主なメソッドは次のとおりです。
62
+ [`logging.get_verbosity`] ロガーの現在の冗長レベルを取得します。
63
+ [`logging.set_verbosity`] を使用して、冗長性を選択したレベルに設定します。順番に(少ないものから)
64
+ 冗長から最も冗長まで)、それらのレベル (括弧内は対応する int 値) は次のとおりです。
65
+
66
+ - `transformers.logging.CRITICAL` または `transformers.logging.FATAL` (int 値、50): 最も多いもののみをレポートします。
67
+ 重大なエラー。
68
+ - `transformers.logging.ERROR` (int 値、40): エラーのみを報告します。
69
+ - `transformers.logging.WARNING` または `transformers.logging.WARN` (int 値、30): エラーと
70
+ 警告。これはライブラリで使用されるデフォルトのレベルです。
71
+ - `transformers.logging.INFO` (int 値、20): エラー、警告、および基本情報をレポートします。
72
+ - `transformers.logging.DEBUG` (int 値、10): すべての情報をレポートします。
73
+
74
+ デフォルトでは、モデルのダウンロード中に「tqdm」進行状況バーが表示されます。 [`logging.disable_progress_bar`] および [`logging.enable_progress_bar`] を使用して、この動作を抑制または抑制解除できます。
75
+
76
+ ## `logging` vs `warnings`
77
+
78
+ Python には、よく組み合わせて使用​​される 2 つのロギング システムがあります。上で説明した `logging` と `warnings` です。
79
+ これにより、特定のバケット内の警告をさらに分類できます (例: 機能またはパスの`FutureWarning`)
80
+ これはすでに非推奨になっており、`DeprecationWarning`は今後の非推奨を示します。
81
+
82
+ 両方とも`transformers`ライブラリで使用します。 `logging`の`captureWarning`メソッドを活用して適応させて、
83
+ これらの警告メッセージは、上記の冗長設定ツールによって管理されます。
84
+
85
+ それはライブラリの開発者にとって何を意味しますか?次のヒューリスティックを尊重する必要があります。
86
+ - `warnings`は、ライブラリおよび`transformers`に依存するライブラリの開発者に優先されるべきです。
87
+ - `logging`は、日常のプロジェクトでライブラリを使用するライブラリのエンドユーザーに使用する必要があります。
88
+
89
+ 以下の`captureWarnings`メソッドのリファレンスを参照してください。
90
+
91
+ [[autodoc]] logging.captureWarnings
92
+
93
+ ## Base setters
94
+
95
+ [[autodoc]] logging.set_verbosity_error
96
+
97
+ [[autodoc]] logging.set_verbosity_warning
98
+
99
+ [[autodoc]] logging.set_verbosity_info
100
+
101
+ [[autodoc]] logging.set_verbosity_debug
102
+
103
+ ## Other functions
104
+
105
+ [[autodoc]] logging.get_verbosity
106
+
107
+ [[autodoc]] logging.set_verbosity
108
+
109
+ [[autodoc]] logging.get_logger
110
+
111
+ [[autodoc]] logging.enable_default_handler
112
+
113
+ [[autodoc]] logging.disable_default_handler
114
+
115
+ [[autodoc]] logging.enable_explicit_format
116
+
117
+ [[autodoc]] logging.reset_format
118
+
119
+ [[autodoc]] logging.enable_progress_bar
120
+
121
+ [[autodoc]] logging.disable_progress_bar
docs/transformers/docs/source/ja/main_classes/model.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Models
18
+
19
+ ベースクラスである [`PreTrainedModel`]、[`TFPreTrainedModel`]、[`FlaxPreTrainedModel`] は、モデルの読み込みと保存に関する共通のメソッドを実装しており、これはローカルのファイルやディレクトリから、またはライブラリが提供する事前学習モデル構成(HuggingFaceのAWS S3リポジトリからダウンロード)からモデルを読み込むために使用できます。
20
+
21
+ [`PreTrainedModel`] と [`TFPreTrainedModel`] は、次の共通のメソッドも実装しています:
22
+
23
+ - 語彙に新しいトークンが追加された場合に、入力トークン埋め込みのリサイズを行う
24
+ - モデルのアテンションヘッドを刈り込む
25
+
26
+ 各モデルに共通するその他のメソッドは、[`~modeling_utils.ModuleUtilsMixin`](PyTorchモデル用)および[`~modeling_tf_utils.TFModuleUtilsMixin`](TensorFlowモデル用)で定義されており、テキスト生成の場合、[`~generation.GenerationMixin`](PyTorchモデル用)、[`~generation.TFGenerationMixin`](TensorFlowモデル用)、および[`~generation.FlaxGenerationMixin`](Flax/JAXモデル用)もあります。
27
+
28
+
29
+ ## PreTrainedModel
30
+
31
+ [[autodoc]] PreTrainedModel
32
+ - push_to_hub
33
+ - all
34
+
35
+ <a id='from_pretrained-torch-dtype'></a>
36
+
37
+
38
+ ### 大規模モデルの読み込み
39
+
40
+ Transformers 4.20.0では、[`~PreTrainedModel.from_pretrained`] メソッドが再設計され、[Accelerate](https://huggingface.co/docs/accelerate/big_modeling) を使用して大規模モデルを扱うことが可能になりました。これには Accelerate >= 0.9.0 と PyTorch >= 1.9.0 が必要です。以前の方法でフルモデルを作成し、その後事前学習の重みを読み込む代わりに(これにはメモリ内のモデルサイズが2倍必要で、ランダムに初期化されたモデル用と重み用の2つが必要でした)、モデルを空の外殻として作成し、事前学習の重みが読み込まれるときにパラメーターを実体化するオプションが追加されました。
41
+
42
+ このオプションは `low_cpu_mem_usage=True` で有効にできます。モデルはまず空の重みを持つメタデバイス上に作成され、その後状態辞書が内部に読み込まれます(シャードされたチェックポイントの場合、シャードごとに読み込まれます)。この方法で使用される最大RAMは、モデルの完全なサイズだけです。
43
+
44
+
45
+ ```py
46
+ from transformers import AutoModelForSeq2SeqLM
47
+
48
+ t0pp = AutoModelForSeq2SeqLM.from_pretrained("bigscience/T0pp", low_cpu_mem_usage=True)
49
+ ```
50
+
51
+ さらに、モデルが完全にRAMに収まらない場合(現時点では推論のみ有効)、異なるデバイスにモデルを直接配置できます。`device_map="auto"` を使用すると、Accelerateは各レイヤーをどのデバイスに配置するかを決定し、最速のデバイス(GPU)を最大限に活用し、残りの部分をCPU、あるいはGPU RAMが不足している場合はハードドライブにオフロードします。モデルが複数のデバイスに分割されていても、通常どおり実行されます。
52
+
53
+ `device_map` を渡す際、`low_cpu_mem_usage` は自動的に `True` に設定されるため、それを指定する必要はありません。
54
+
55
+
56
+ ```py
57
+ from transformers import AutoModelForSeq2SeqLM
58
+
59
+ t0pp = AutoModelForSeq2SeqLM.from_pretrained("bigscience/T0pp", device_map="auto")
60
+ ```
61
+
62
+ モデルがデバイス間でどのように分割されたかは、その `hf_device_map` 属性を見ることで確認できます:
63
+
64
+ ```py
65
+ t0pp.hf_device_map
66
+ ```
67
+
68
+ ```python out
69
+ {'shared': 0,
70
+ 'decoder.embed_tokens': 0,
71
+ 'encoder': 0,
72
+ 'decoder.block.0': 0,
73
+ 'decoder.block.1': 1,
74
+ 'decoder.block.2': 1,
75
+ 'decoder.block.3': 1,
76
+ 'decoder.block.4': 1,
77
+ 'decoder.block.5': 1,
78
+ 'decoder.block.6': 1,
79
+ 'decoder.block.7': 1,
80
+ 'decoder.block.8': 1,
81
+ 'decoder.block.9': 1,
82
+ 'decoder.block.10': 1,
83
+ 'decoder.block.11': 1,
84
+ 'decoder.block.12': 1,
85
+ 'decoder.block.13': 1,
86
+ 'decoder.block.14': 1,
87
+ 'decoder.block.15': 1,
88
+ 'decoder.block.16': 1,
89
+ 'decoder.block.17': 1,
90
+ 'decoder.block.18': 1,
91
+ 'decoder.block.19': 1,
92
+ 'decoder.block.20': 1,
93
+ 'decoder.block.21': 1,
94
+ 'decoder.block.22': 'cpu',
95
+ 'decoder.block.23': 'cpu',
96
+ 'decoder.final_layer_norm': 'cpu',
97
+ 'decoder.dropout': 'cpu',
98
+ 'lm_head': 'cpu'}
99
+ ```
100
+
101
+ 同じフォーマットに従って、独自のデバイスマップを作成することもできます(レイヤー名からデバイスへの辞書です)。モデルのすべてのパラメータを指定されたデバイスにマップする必要がありますが、1つのレイヤーが完全に同じデバイスにある場合、そのレイヤーのサブモジュールのすべてがどこに行くかの詳細を示す必要はありません。例えば、次のデバイスマップはT0ppに適しています(GPUメモリがある場合):
102
+
103
+ ```python
104
+ device_map = {"shared": 0, "encoder": 0, "decoder": 1, "lm_head": 1}
105
+ ```
106
+
107
+ モデルのメモリへの影響を最小限に抑えるもう 1 つの方法は、低精度の dtype (`torch.float16` など) でモデルをインスタンス化するか、以下で説明する直接量子化手法を使用することです。
108
+
109
+ ### Model Instantiation dtype
110
+
111
+ Pytorch では、モデルは通常 `torch.float32` 形式でインスタンス化されます。これは、しようとすると問題になる可能性があります
112
+ 重みが fp16 にあるモデルをロードすると、2 倍のメモリが必要になるためです。この制限を克服するには、次のことができます。
113
+ `torch_dtype` 引数を使用して、目的の `dtype` を明示的に渡します。
114
+
115
+ ```python
116
+ model = T5ForConditionalGeneration.from_pretrained("t5", torch_dtype=torch.float16)
117
+ ```
118
+ または、モデルを常に最適なメモリ パターンでロードしたい場合は、特別な値 `"auto"` を使用できます。
119
+ そして、`dtype` はモデルの重みから自動的に導出されます。
120
+
121
+ ```python
122
+ model = T5ForConditionalGeneration.from_pretrained("t5", torch_dtype="auto")
123
+ ```
124
+
125
+ スクラッチからインスタンス化されたモデルには、どの `dtype` を使用するかを指示することもできます。
126
+
127
+ ```python
128
+ config = T5Config.from_pretrained("t5")
129
+ model = AutoModel.from_config(config)
130
+ ```
131
+
132
+ Pytorch の設計により、この機能は浮動小数点 dtype でのみ使用できます。
133
+
134
+ ## ModuleUtilsMixin
135
+
136
+ [[autodoc]] modeling_utils.ModuleUtilsMixin
137
+
138
+ ## TFPreTrainedModel
139
+
140
+ [[autodoc]] TFPreTrainedModel
141
+ - push_to_hub
142
+ - all
143
+
144
+ ## TFModelUtilsMixin
145
+
146
+ [[autodoc]] modeling_tf_utils.TFModelUtilsMixin
147
+
148
+ ## FlaxPreTrainedModel
149
+
150
+ [[autodoc]] FlaxPreTrainedModel
151
+ - push_to_hub
152
+ - all
153
+
154
+ ## Pushing to the Hub
155
+
156
+ [[autodoc]] utils.PushToHubMixin
157
+
158
+ ## Sharded checkpoints
159
+
160
+ [[autodoc]] modeling_utils.load_sharded_checkpoint
docs/transformers/docs/source/ja/main_classes/onnx.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Exporting 🤗 Transformers models to ONNX
18
+
19
+ 🤗 Transformers は `transformers.onnx` パッケージを提供します。
20
+ 設定オブジェクトを利用することで、モデルのチェックポイントをONNXグラフに変換することができます。
21
+
22
+ 詳細は[ガイド](../serialization) を参照してください。
23
+ を参照してください。
24
+
25
+ ## ONNX Configurations
26
+
27
+ 以下の3つの抽象クラスを提供しています。
28
+ エクスポートしたいモデルアーキテクチャのタイプに応じて、継承すべき3つの抽象クラスを提供します:
29
+
30
+ * エンコーダーベースのモデルは [`~onnx.config.OnnxConfig`] を継承します。
31
+ * デコーダーベースのモデルは [`~onnx.config.OnnxConfigWithPast`] を継承します。
32
+ * エンコーダー・デコーダーモデルは [`~onnx.config.OnnxSeq2SeqConfigWithPast`] を継承しています。
33
+
34
+
35
+ ### OnnxConfig
36
+
37
+ [[autodoc]] onnx.config.OnnxConfig
38
+
39
+ ### OnnxConfigWithPast
40
+
41
+ [[autodoc]] onnx.config.OnnxConfigWithPast
42
+
43
+ ### OnnxSeq2SeqConfigWithPast
44
+
45
+ [[autodoc]] onnx.config.OnnxSeq2SeqConfigWithPast
46
+
47
+ ## ONNX Features
48
+
49
+ 各 ONNX 構成は、次のことを可能にする一連の _機能_ に関連付けられています。
50
+ さまざまなタイプのトポロジまたはタスクのモデルをエクスポートします。
51
+
52
+ ### FeaturesManager
53
+
54
+ [[autodoc]] onnx.features.FeaturesManager
55
+
docs/transformers/docs/source/ja/main_classes/optimizer_schedules.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Optimization
18
+
19
+ `.optimization` モジュールは以下を提供します。
20
+
21
+ - モデルの微調整に使用できる重み減衰が修正されたオプティマイザー、および
22
+ - `_LRSchedule` から継承するスケジュール オブジェクトの形式のいくつかのスケジュール:
23
+ - 複数のバッチの勾配を累積するための勾配累積クラス
24
+
25
+ ## AdaFactor (PyTorch)
26
+
27
+ [[autodoc]] Adafactor
28
+
29
+ ## AdamWeightDecay (TensorFlow)
30
+
31
+ [[autodoc]] AdamWeightDecay
32
+
33
+ [[autodoc]] create_optimizer
34
+
35
+ ## Schedules
36
+
37
+ ### Learning Rate Schedules (Pytorch)
38
+
39
+ [[autodoc]] SchedulerType
40
+
41
+ [[autodoc]] get_scheduler
42
+
43
+ [[autodoc]] get_constant_schedule
44
+
45
+ [[autodoc]] get_constant_schedule_with_warmup
46
+
47
+ <img alt="" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_constant_schedule.png"/>
48
+
49
+ [[autodoc]] get_cosine_schedule_with_warmup
50
+
51
+ <img alt="" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_cosine_schedule.png"/>
52
+
53
+ [[autodoc]] get_cosine_with_hard_restarts_schedule_with_warmup
54
+
55
+ <img alt="" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_cosine_hard_restarts_schedule.png"/>
56
+
57
+ [[autodoc]] get_linear_schedule_with_warmup
58
+
59
+ <img alt="" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/warmup_linear_schedule.png"/>
60
+
61
+ [[autodoc]] get_polynomial_decay_schedule_with_warmup
62
+
63
+ [[autodoc]] get_inverse_sqrt_schedule
64
+
65
+ ### Warmup (TensorFlow)
66
+
67
+ [[autodoc]] WarmUp
68
+
69
+ ## Gradient Strategies
70
+
71
+ ### GradientAccumulator (TensorFlow)
72
+
73
+ [[autodoc]] GradientAccumulator
docs/transformers/docs/source/ja/main_classes/output.md ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Model outputs
18
+
19
+ すべてのモデルには、[`~utils.ModelOutput`] のサブクラスのインスタンスである出力があります。それらは
20
+ モデルによって返されるすべての情報を含むデータ構造ですが、タプルまたは
21
+ 辞書。
22
+
23
+ これがどのようになるかを例で見てみましょう。
24
+
25
+ ```python
26
+ from transformers import BertTokenizer, BertForSequenceClassification
27
+ import torch
28
+
29
+ tokenizer = BertTokenizer.from_pretrained("google-bert/bert-base-uncased")
30
+ model = BertForSequenceClassification.from_pretrained("google-bert/bert-base-uncased")
31
+
32
+ inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
33
+ labels = torch.tensor([1]).unsqueeze(0) # Batch size 1
34
+ outputs = model(**inputs, labels=labels)
35
+ ```
36
+
37
+ `outputs`オブジェクトは[`~modeling_outputs.SequenceClassifierOutput`]である。
38
+ これは、オプションで `loss`、`logits`、オプションで `hidden_states`、オプションで `attentions` 属性を持つことを意味します。
39
+ オプションの `attentions` 属性を持つことを意味する。ここでは、`labels`を渡したので`loss`があるが、`hidden_states`と`attentions`はない。
40
+ `output_hidden_states=True`や`output_attentions=True`を渡していないので、`hidden_states`と`attentions`はない。
41
+ `output_attentions=True`を渡さなかったからだ。
42
+
43
+ <Tip>
44
+
45
+ `output_hidden_states=True`を渡すと、`outputs.hidden_states[-1]`が `outputs.last_hidden_states` と正確に一致することを期待するかもしれない。
46
+ しかし、必ずしもそうなるとは限りません。モデルによっては、最後に隠された状態が返されたときに、正規化やその後の処理を適用するものもあります。
47
+
48
+ </Tip>
49
+
50
+
51
+ 通常と同じように各属性にアクセスできます。その属性がモデルから返されなかった場合は、
52
+ は `None`を取得します。ここで、たとえば`outputs.loss`はモデルによって計算された損失であり、`outputs.attentions`は
53
+ `None`。
54
+
55
+ `outputs`オブジェクトをタプルとして考える場合、`None`値を持たない属性のみが考慮されます。
56
+ たとえば、ここには 2 つの要素、`loss`、次に`logits`があります。
57
+
58
+ ```python
59
+ outputs[:2]
60
+ ```
61
+
62
+ たとえば、タプル `(outputs.loss, Outputs.logits)` を返します。
63
+
64
+ `outputs`オブジェクトを辞書として考慮する場合、「None」を持たない属性のみが考慮されます。
65
+ 価値観。たとえば、ここには`loss` と `logits`という 2 つのキーがあります。
66
+
67
+ ここでは、複数のモデル タイプで使用される汎用モデルの出力を文書化します。具体的な出力タイプは次のとおりです。
68
+ 対応するモデルのページに記載されています。
69
+
70
+ ## ModelOutput
71
+
72
+ [[autodoc]] utils.ModelOutput
73
+ - to_tuple
74
+
75
+ ## BaseModelOutput
76
+
77
+ [[autodoc]] modeling_outputs.BaseModelOutput
78
+
79
+ ## BaseModelOutputWithPooling
80
+
81
+ [[autodoc]] modeling_outputs.BaseModelOutputWithPooling
82
+
83
+ ## BaseModelOutputWithCrossAttentions
84
+
85
+ [[autodoc]] modeling_outputs.BaseModelOutputWithCrossAttentions
86
+
87
+ ## BaseModelOutputWithPoolingAndCrossAttentions
88
+
89
+ [[autodoc]] modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions
90
+
91
+ ## BaseModelOutputWithPast
92
+
93
+ [[autodoc]] modeling_outputs.BaseModelOutputWithPast
94
+
95
+ ## BaseModelOutputWithPastAndCrossAttentions
96
+
97
+ [[autodoc]] modeling_outputs.BaseModelOutputWithPastAndCrossAttentions
98
+
99
+ ## Seq2SeqModelOutput
100
+
101
+ [[autodoc]] modeling_outputs.Seq2SeqModelOutput
102
+
103
+ ## CausalLMOutput
104
+
105
+ [[autodoc]] modeling_outputs.CausalLMOutput
106
+
107
+ ## CausalLMOutputWithCrossAttentions
108
+
109
+ [[autodoc]] modeling_outputs.CausalLMOutputWithCrossAttentions
110
+
111
+ ## CausalLMOutputWithPast
112
+
113
+ [[autodoc]] modeling_outputs.CausalLMOutputWithPast
114
+
115
+ ## MaskedLMOutput
116
+
117
+ [[autodoc]] modeling_outputs.MaskedLMOutput
118
+
119
+ ## Seq2SeqLMOutput
120
+
121
+ [[autodoc]] modeling_outputs.Seq2SeqLMOutput
122
+
123
+ ## NextSentencePredictorOutput
124
+
125
+ [[autodoc]] modeling_outputs.NextSentencePredictorOutput
126
+
127
+ ## SequenceClassifierOutput
128
+
129
+ [[autodoc]] modeling_outputs.SequenceClassifierOutput
130
+
131
+ ## Seq2SeqSequenceClassifierOutput
132
+
133
+ [[autodoc]] modeling_outputs.Seq2SeqSequenceClassifierOutput
134
+
135
+ ## MultipleChoiceModelOutput
136
+
137
+ [[autodoc]] modeling_outputs.MultipleChoiceModelOutput
138
+
139
+ ## TokenClassifierOutput
140
+
141
+ [[autodoc]] modeling_outputs.TokenClassifierOutput
142
+
143
+ ## QuestionAnsweringModelOutput
144
+
145
+ [[autodoc]] modeling_outputs.QuestionAnsweringModelOutput
146
+
147
+ ## Seq2SeqQuestionAnsweringModelOutput
148
+
149
+ [[autodoc]] modeling_outputs.Seq2SeqQuestionAnsweringModelOutput
150
+
151
+ ## Seq2SeqSpectrogramOutput
152
+
153
+ [[autodoc]] modeling_outputs.Seq2SeqSpectrogramOutput
154
+
155
+ ## SemanticSegmenterOutput
156
+
157
+ [[autodoc]] modeling_outputs.SemanticSegmenterOutput
158
+
159
+ ## ImageClassifierOutput
160
+
161
+ [[autodoc]] modeling_outputs.ImageClassifierOutput
162
+
163
+ ## ImageClassifierOutputWithNoAttention
164
+
165
+ [[autodoc]] modeling_outputs.ImageClassifierOutputWithNoAttention
166
+
167
+ ## DepthEstimatorOutput
168
+
169
+ [[autodoc]] modeling_outputs.DepthEstimatorOutput
170
+
171
+ ## Wav2Vec2BaseModelOutput
172
+
173
+ [[autodoc]] modeling_outputs.Wav2Vec2BaseModelOutput
174
+
175
+ ## XVectorOutput
176
+
177
+ [[autodoc]] modeling_outputs.XVectorOutput
178
+
179
+ ## Seq2SeqTSModelOutput
180
+
181
+ [[autodoc]] modeling_outputs.Seq2SeqTSModelOutput
182
+
183
+ ## Seq2SeqTSPredictionOutput
184
+
185
+ [[autodoc]] modeling_outputs.Seq2SeqTSPredictionOutput
186
+
187
+ ## SampleTSPredictionOutput
188
+
189
+ [[autodoc]] modeling_outputs.SampleTSPredictionOutput
190
+
191
+ ## TFBaseModelOutput
192
+
193
+ [[autodoc]] modeling_tf_outputs.TFBaseModelOutput
194
+
195
+ ## TFBaseModelOutputWithPooling
196
+
197
+ [[autodoc]] modeling_tf_outputs.TFBaseModelOutputWithPooling
198
+
199
+ ## TFBaseModelOutputWithPoolingAndCrossAttentions
200
+
201
+ [[autodoc]] modeling_tf_outputs.TFBaseModelOutputWithPoolingAndCrossAttentions
202
+
203
+ ## TFBaseModelOutputWithPast
204
+
205
+ [[autodoc]] modeling_tf_outputs.TFBaseModelOutputWithPast
206
+
207
+ ## TFBaseModelOutputWithPastAndCrossAttentions
208
+
209
+ [[autodoc]] modeling_tf_outputs.TFBaseModelOutputWithPastAndCrossAttentions
210
+
211
+ ## TFSeq2SeqModelOutput
212
+
213
+ [[autodoc]] modeling_tf_outputs.TFSeq2SeqModelOutput
214
+
215
+ ## TFCausalLMOutput
216
+
217
+ [[autodoc]] modeling_tf_outputs.TFCausalLMOutput
218
+
219
+ ## TFCausalLMOutputWithCrossAttentions
220
+
221
+ [[autodoc]] modeling_tf_outputs.TFCausalLMOutputWithCrossAttentions
222
+
223
+ ## TFCausalLMOutputWithPast
224
+
225
+ [[autodoc]] modeling_tf_outputs.TFCausalLMOutputWithPast
226
+
227
+ ## TFMaskedLMOutput
228
+
229
+ [[autodoc]] modeling_tf_outputs.TFMaskedLMOutput
230
+
231
+ ## TFSeq2SeqLMOutput
232
+
233
+ [[autodoc]] modeling_tf_outputs.TFSeq2SeqLMOutput
234
+
235
+ ## TFNextSentencePredictorOutput
236
+
237
+ [[autodoc]] modeling_tf_outputs.TFNextSentencePredictorOutput
238
+
239
+ ## TFSequenceClassifierOutput
240
+
241
+ [[autodoc]] modeling_tf_outputs.TFSequenceClassifierOutput
242
+
243
+ ## TFSeq2SeqSequenceClassifierOutput
244
+
245
+ [[autodoc]] modeling_tf_outputs.TFSeq2SeqSequenceClassifierOutput
246
+
247
+ ## TFMultipleChoiceModelOutput
248
+
249
+ [[autodoc]] modeling_tf_outputs.TFMultipleChoiceModelOutput
250
+
251
+ ## TFTokenClassifierOutput
252
+
253
+ [[autodoc]] modeling_tf_outputs.TFTokenClassifierOutput
254
+
255
+ ## TFQuestionAnsweringModelOutput
256
+
257
+ [[autodoc]] modeling_tf_outputs.TFQuestionAnsweringModelOutput
258
+
259
+ ## TFSeq2SeqQuestionAnsweringModelOutput
260
+
261
+ [[autodoc]] modeling_tf_outputs.TFSeq2SeqQuestionAnsweringModelOutput
262
+
263
+ ## FlaxBaseModelOutput
264
+
265
+ [[autodoc]] modeling_flax_outputs.FlaxBaseModelOutput
266
+
267
+ ## FlaxBaseModelOutputWithPast
268
+
269
+ [[autodoc]] modeling_flax_outputs.FlaxBaseModelOutputWithPast
270
+
271
+ ## FlaxBaseModelOutputWithPooling
272
+
273
+ [[autodoc]] modeling_flax_outputs.FlaxBaseModelOutputWithPooling
274
+
275
+ ## FlaxBaseModelOutputWithPastAndCrossAttentions
276
+
277
+ [[autodoc]] modeling_flax_outputs.FlaxBaseModelOutputWithPastAndCrossAttentions
278
+
279
+ ## FlaxSeq2SeqModelOutput
280
+
281
+ [[autodoc]] modeling_flax_outputs.FlaxSeq2SeqModelOutput
282
+
283
+ ## FlaxCausalLMOutputWithCrossAttentions
284
+
285
+ [[autodoc]] modeling_flax_outputs.FlaxCausalLMOutputWithCrossAttentions
286
+
287
+ ## FlaxMaskedLMOutput
288
+
289
+ [[autodoc]] modeling_flax_outputs.FlaxMaskedLMOutput
290
+
291
+ ## FlaxSeq2SeqLMOutput
292
+
293
+ [[autodoc]] modeling_flax_outputs.FlaxSeq2SeqLMOutput
294
+
295
+ ## FlaxNextSentencePredictorOutput
296
+
297
+ [[autodoc]] modeling_flax_outputs.FlaxNextSentencePredictorOutput
298
+
299
+ ## FlaxSequenceClassifierOutput
300
+
301
+ [[autodoc]] modeling_flax_outputs.FlaxSequenceClassifierOutput
302
+
303
+ ## FlaxSeq2SeqSequenceClassifierOutput
304
+
305
+ [[autodoc]] modeling_flax_outputs.FlaxSeq2SeqSequenceClassifierOutput
306
+
307
+ ## FlaxMultipleChoiceModelOutput
308
+
309
+ [[autodoc]] modeling_flax_outputs.FlaxMultipleChoiceModelOutput
310
+
311
+ ## FlaxTokenClassifierOutput
312
+
313
+ [[autodoc]] modeling_flax_outputs.FlaxTokenClassifierOutput
314
+
315
+ ## FlaxQuestionAnsweringModelOutput
316
+
317
+ [[autodoc]] modeling_flax_outputs.FlaxQuestionAnsweringModelOutput
318
+
319
+ ## FlaxSeq2SeqQuestionAnsweringModelOutput
320
+
321
+ [[autodoc]] modeling_flax_outputs.FlaxSeq2SeqQuestionAnsweringModelOutput
docs/transformers/docs/source/ja/main_classes/pipelines.md ADDED
@@ -0,0 +1,498 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Pipelines
18
+
19
+ パイプラインは、推論にモデルを使うための簡単で優れた方法である。パイプラインは、複雑なコードのほとんどを抽象化したオブジェクトです。
20
+ パイプラインは、ライブラリから複雑なコードのほとんどを抽象化したオブジェクトで、名前付き固有表現認識、マスク言語モデリング、感情分析、特徴抽出、質問応答などのタスクに特化したシンプルなAPIを提供します。
21
+ Recognition、Masked Language Modeling、Sentiment Analysis、Feature Extraction、Question Answeringなどのタスクに特化したシンプルなAPIを提供します。以下を参照のこと。
22
+ [タスク概要](../task_summary)を参照してください。
23
+
24
+
25
+ パイプラインの抽象化には2つのカテゴリーがある:
26
+
27
+ - [`pipeline`] は、他のすべてのパイプラインをカプセル化する最も強力なオブジェクトです。
28
+ - タスク固有のパイプラインは、[オーディオ](#audio)、[コンピューター ビジョン](#computer-vision)、[自然言語処理](#natural-language-processing)、および [マルチモーダル](#multimodal) タスクで使用できます。
29
+
30
+ ## The pipeline abstraction
31
+
32
+ *パイプライン* 抽象化は、他のすべての利用可能なパイプラインのラッパーです。他のものと同様にインスタンス化されます
33
+ パイプラインですが、さらなる生活の質を提供できます。
34
+
35
+ 1 つの項目に対する単純な呼び出し:
36
+
37
+ ```python
38
+ >>> pipe = pipeline("text-classification")
39
+ >>> pipe("This restaurant is awesome")
40
+ [{'label': 'POSITIVE', 'score': 0.9998743534088135}]
41
+ ```
42
+
43
+ [ハブ](https://huggingface.co) の特定のモデルを使用したい場合は、モデルがオンになっている場合はタスクを無視できます。
44
+ ハブはすでにそれを定義しています。
45
+
46
+ ```python
47
+ >>> pipe = pipeline(model="FacebookAI/roberta-large-mnli")
48
+ >>> pipe("This restaurant is awesome")
49
+ [{'label': 'NEUTRAL', 'score': 0.7313136458396912}]
50
+ ```
51
+
52
+ 多くの項目に対してパイプラインを呼び出すには、*list* を使用してパイプラインを呼び出すことができます。
53
+
54
+ ```python
55
+ >>> pipe = pipeline("text-classification")
56
+ >>> pipe(["This restaurant is awesome", "This restaurant is awful"])
57
+ [{'label': 'POSITIVE', 'score': 0.9998743534088135},
58
+ {'label': 'NEGATIVE', 'score': 0.9996669292449951}]
59
+ ```
60
+
61
+ 完全なデータセットを反復するには、`Dataset`を直接使用することをお勧めします。これは、割り当てる必要がないことを意味します
62
+ データセット全体を一度に処理することも、自分でバッチ処理を行う必要もありません。これはカスタムループと同じくらい速く動作するはずです。
63
+ GPU。それが問題でない場合は、ためらわずに問題を作成してください。
64
+
65
+ ```python
66
+ import datasets
67
+ from transformers import pipeline
68
+ from transformers.pipelines.pt_utils import KeyDataset
69
+ from tqdm.auto import tqdm
70
+
71
+ pipe = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h", device=0)
72
+ dataset = datasets.load_dataset("superb", name="asr", split="test")
73
+
74
+ # KeyDataset (only *pt*) will simply return the item in the dict returned by the dataset item
75
+ # as we're not interested in the *target* part of the dataset. For sentence pair use KeyPairDataset
76
+ for out in tqdm(pipe(KeyDataset(dataset, "file"))):
77
+ print(out)
78
+ # {"text": "NUMBER TEN FRESH NELLY IS WAITING ON YOU GOOD NIGHT HUSBAND"}
79
+ # {"text": ....}
80
+ # ....
81
+ ```
82
+
83
+ 使いやすくするために、ジェネレーターを使用することもできます。
84
+
85
+ ```python
86
+ from transformers import pipeline
87
+
88
+ pipe = pipeline("text-classification")
89
+
90
+
91
+ def data():
92
+ while True:
93
+ # This could come from a dataset, a database, a queue or HTTP request
94
+ # in a server
95
+ # Caveat: because this is iterative, you cannot use `num_workers > 1` variable
96
+ # to use multiple threads to preprocess data. You can still have 1 thread that
97
+ # does the preprocessing while the main runs the big inference
98
+ yield "This is a test"
99
+
100
+
101
+ for out in pipe(data()):
102
+ print(out)
103
+ # {"text": "NUMBER TEN FRESH NELLY IS WAITING ON YOU GOOD NIGHT HUSBAND"}
104
+ # {"text": ....}
105
+ # ....
106
+ ```
107
+
108
+ [[autodoc]] pipeline
109
+
110
+
111
+ ## Pipeline batching
112
+
113
+
114
+ すべてのパイプラインでバッチ処理を使用できます。これはうまくいきます
115
+ パイプラインがストリーミング機能を使用するときは常に (つまり、リスト、`dataset`、または `generator`を渡すとき)。
116
+
117
+ ```python
118
+ from transformers import pipeline
119
+ from transformers.pipelines.pt_utils import KeyDataset
120
+ import datasets
121
+
122
+ dataset = datasets.load_dataset("imdb", name="plain_text", split="unsupervised")
123
+ pipe = pipeline("text-classification", device=0)
124
+ for out in pipe(KeyDataset(dataset, "text"), batch_size=8, truncation="only_first"):
125
+ print(out)
126
+ # [{'label': 'POSITIVE', 'score': 0.9998743534088135}]
127
+ # Exactly the same output as before, but the content are passed
128
+ # as batches to the model
129
+ ```
130
+
131
+ <Tip warning={true}>
132
+
133
+
134
+ ただし、これによってパフォーマンスが自動的に向上するわけではありません。状況に応じて、10 倍の高速化または 5 倍の低速化のいずれかになります。
135
+ ハードウェア、データ、使用されている実際のモデルについて。
136
+
137
+ 主に高速化である例:
138
+
139
+
140
+ </Tip>
141
+
142
+ ```python
143
+ from transformers import pipeline
144
+ from torch.utils.data import Dataset
145
+ from tqdm.auto import tqdm
146
+
147
+ pipe = pipeline("text-classification", device=0)
148
+
149
+
150
+ class MyDataset(Dataset):
151
+ def __len__(self):
152
+ return 5000
153
+
154
+ def __getitem__(self, i):
155
+ return "This is a test"
156
+
157
+
158
+ dataset = MyDataset()
159
+
160
+ for batch_size in [1, 8, 64, 256]:
161
+ print("-" * 30)
162
+ print(f"Streaming batch_size={batch_size}")
163
+ for out in tqdm(pipe(dataset, batch_size=batch_size), total=len(dataset)):
164
+ pass
165
+ ```
166
+
167
+ ```
168
+ # On GTX 970
169
+ ------------------------------
170
+ Streaming no batching
171
+ 100%|██████████████████████████████████████████████████████████████████████| 5000/5000 [00:26<00:00, 187.52it/s]
172
+ ------------------------------
173
+ Streaming batch_size=8
174
+ 100%|█████████████████████████████████████████████████████████████████████| 5000/5000 [00:04<00:00, 1205.95it/s]
175
+ ------------------------------
176
+ Streaming batch_size=64
177
+ 100%|█████████████████████████████████████████████████████████████████████| 5000/5000 [00:02<00:00, 2478.24it/s]
178
+ ------------------------------
179
+ Streaming batch_size=256
180
+ 100%|█████████████████████████████████████████████████████████████████████| 5000/5000 [00:01<00:00, 2554.43it/s]
181
+ (diminishing returns, saturated the GPU)
182
+ ```
183
+
184
+ 最も速度が低下する例:
185
+
186
+
187
+ ```python
188
+ class MyDataset(Dataset):
189
+ def __len__(self):
190
+ return 5000
191
+
192
+ def __getitem__(self, i):
193
+ if i % 64 == 0:
194
+ n = 100
195
+ else:
196
+ n = 1
197
+ return "This is a test" * n
198
+ ```
199
+
200
+ これは、他の文に比べて非常に長い文が時折あります。その場合、**全体**のバッチは 400 である必要があります。
201
+ トークンが長いため、バッチ全体が [64, 4] ではなく [64, 400] になり、速度が大幅に低下します。さらに悪いことに、
202
+ バッチが大きくなると、プログラムは単純にクラッシュします。
203
+
204
+ ```
205
+ ------------------------------
206
+ Streaming no batching
207
+ 100%|█████████████████████████████████████████████████████████████████████| 1000/1000 [00:05<00:00, 183.69it/s]
208
+ ------------------------------
209
+ Streaming batch_size=8
210
+ 100%|█████████████████████████████████████████████████████████████████████| 1000/1000 [00:03<00:00, 265.74it/s]
211
+ ------------------------------
212
+ Streaming batch_size=64
213
+ 100%|██████████████████████████████████████████████████████████████████████| 1000/1000 [00:26<00:00, 37.80it/s]
214
+ ------------------------------
215
+ Streaming batch_size=256
216
+ 0%| | 0/1000 [00:00<?, ?it/s]
217
+ Traceback (most recent call last):
218
+ File "/home/nicolas/src/transformers/test.py", line 42, in <module>
219
+ for out in tqdm(pipe(dataset, batch_size=256), total=len(dataset)):
220
+ ....
221
+ q = q / math.sqrt(dim_per_head) # (bs, n_heads, q_length, dim_per_head)
222
+ RuntimeError: CUDA out of memory. Tried to allocate 376.00 MiB (GPU 0; 3.95 GiB total capacity; 1.72 GiB already allocated; 354.88 MiB free; 2.46 GiB reserved in total by PyTorch)
223
+ ```
224
+
225
+ この問題に対する適切な (一般的な) 解決策はなく、使用できる距離はユースケースによって異なる場合があります。のルール
226
+ 親指:
227
+
228
+ ユーザーにとっての経験則は次のとおりです。
229
+
230
+ - **ハードウェアを使用して、負荷に対するパフォーマンスを測定します。測って、測って、測り続ける。実数というのは、
231
+ 進むべき唯一の方法。**
232
+ - レイテンシに制約がある場合 (実際の製品が推論を実行している場合)、バッチ処理を行わないでください。
233
+ - CPU を使用している場合は、バッチ処理を行わないでください。
234
+ - GPU でスループットを使用している場合 (大量の静的データでモデルを実行したい場合)、次のようにします。
235
+
236
+ - sequence_length (「自然な」データ) のサイズについてまったくわからない場合は、デフォルトではバッチ処理や測定を行わず、
237
+ 暫定的に追加してみます。失敗した場合に回復するために OOM チェックを追加します (失敗した場合は、ある時点で回復します)。
238
+ sequence_length を制御します。)
239
+ - sequence_length が非常に規則的である場合、バッチ処理は非常に興味深いものとなる可能性が高く、測定してプッシュしてください。
240
+ OOM が発生するまで続けます。
241
+ - GPU が大きいほど、バッチ処理がより興味深いものになる可能性が高くなります。
242
+ - バッチ処理を有効にしたらすぐに、OOM を適切に処理できることを確認してください。
243
+
244
+
245
+ ## Pipeline chunk batching
246
+
247
+ `zero-shot-classification` と `question-answering` は、単一の入力で結果が得られる可能性があるという意味で、少し特殊です。
248
+ モデルの複数の前方パス。通常の状況では、これにより `batch_size` 引数に関する問題が発生します。
249
+
250
+ この問題を回避するために、これらのパイプラインはどちらも少し特殊になっており、代わりに `ChunkPipeline` になっています。
251
+ 通常の `Pipeline`。要するに:
252
+
253
+ ```python
254
+ preprocessed = pipe.preprocess(inputs)
255
+ model_outputs = pipe.forward(preprocessed)
256
+ outputs = pipe.postprocess(model_outputs)
257
+ ```
258
+
259
+ 今は次のようになります:
260
+
261
+ ```python
262
+ all_model_outputs = []
263
+ for preprocessed in pipe.preprocess(inputs):
264
+ model_outputs = pipe.forward(preprocessed)
265
+ all_model_outputs.append(model_outputs)
266
+ outputs = pipe.postprocess(all_model_outputs)
267
+ ```
268
+
269
+ パイプラインは以下で使用されるため、これはコードに対して非常に透過的である必要があります。
270
+ 同じ方法。
271
+
272
+ パイプラインはバッチを自動的に処理できるため、これは簡略化されたビューです。気にする必要はないという意味です
273
+ 入力が実際にトリガーする前方パスの数については、`batch_size` を最適化できます。
274
+ 入力とは独立して。前のセクションの注意事項が引き続き適用されます。
275
+
276
+ ## Pipeline custom code
277
+
278
+ 特定のパイプラインをオーバーライドする場合。
279
+
280
+ 目の前のタスクに関する問題を作成することを躊躇しないでください。パイプラインの目標は、使いやすく、ほとんどのユーザーをサポートすることです。
281
+ したがって、`transformers`があなたのユースケースをサポートする可能性があります。
282
+
283
+
284
+ 単純に試してみたい場合は、次のことができます。
285
+
286
+ - 選択したパイプラインをサブクラス化します
287
+
288
+ ```python
289
+ class MyPipeline(TextClassificationPipeline):
290
+ def postprocess():
291
+ # Your code goes here
292
+ scores = scores * 100
293
+ # And here
294
+
295
+
296
+ my_pipeline = MyPipeline(model=model, tokenizer=tokenizer, ...)
297
+ # or if you use *pipeline* function, then:
298
+ my_pipeline = pipeline(model="xxxx", pipeline_class=MyPipeline)
299
+ ```
300
+
301
+ これにより、必要なカスタム コードをすべて実行できるようになります。
302
+
303
+ ## Implementing a pipeline
304
+
305
+ [Implementing a new pipeline](../add_new_pipeline)
306
+
307
+ ## Audio
308
+
309
+ オーディオ タスクに使用できるパイプラインには次のものがあります。
310
+
311
+ ### AudioClassificationPipeline
312
+
313
+ [[autodoc]] AudioClassificationPipeline
314
+ - __call__
315
+ - all
316
+
317
+ ### AutomaticSpeechRecognitionPipeline
318
+
319
+ [[autodoc]] AutomaticSpeechRecognitionPipeline
320
+ - __call__
321
+ - all
322
+
323
+ ### TextToAudioPipeline
324
+
325
+ [[autodoc]] TextToAudioPipeline
326
+ - __call__
327
+ - all
328
+
329
+
330
+ ### ZeroShotAudioClassificationPipeline
331
+
332
+ [[autodoc]] ZeroShotAudioClassificationPipeline
333
+ - __call__
334
+ - all
335
+
336
+ ## Computer vision
337
+
338
+ コンピューター ビジョン タスクに使用できるパイプラインには次のものがあります。
339
+
340
+ ### DepthEstimationPipeline
341
+ [[autodoc]] DepthEstimationPipeline
342
+ - __call__
343
+ - all
344
+
345
+ ### ImageClassificationPipeline
346
+
347
+ [[autodoc]] ImageClassificationPipeline
348
+ - __call__
349
+ - all
350
+
351
+ ### ImageSegmentationPipeline
352
+
353
+ [[autodoc]] ImageSegmentationPipeline
354
+ - __call__
355
+ - all
356
+
357
+ ### ImageToImagePipeline
358
+
359
+ [[autodoc]] ImageToImagePipeline
360
+ - __call__
361
+ - all
362
+
363
+ ### ObjectDetectionPipeline
364
+
365
+ [[autodoc]] ObjectDetectionPipeline
366
+ - __call__
367
+ - all
368
+
369
+ ### VideoClassificationPipeline
370
+
371
+ [[autodoc]] VideoClassificationPipeline
372
+ - __call__
373
+ - all
374
+
375
+ ### ZeroShotImageClassificationPipeline
376
+
377
+ [[autodoc]] ZeroShotImageClassificationPipeline
378
+ - __call__
379
+ - all
380
+
381
+ ### ZeroShotObjectDetectionPipeline
382
+
383
+ [[autodoc]] ZeroShotObjectDetectionPipeline
384
+ - __call__
385
+ - all
386
+
387
+ ## Natural Language Processing
388
+
389
+ 自然言語処理タスクに使用できるパイプラインには次のものがあります。
390
+
391
+ ### FillMaskPipeline
392
+
393
+ [[autodoc]] FillMaskPipeline
394
+ - __call__
395
+ - all
396
+
397
+ ### NerPipeline
398
+
399
+ [[autodoc]] NerPipeline
400
+
401
+ 詳細については、[`TokenClassificationPipeline`] を参照してください。
402
+
403
+ ### QuestionAnsweringPipeline
404
+
405
+ [[autodoc]] QuestionAnsweringPipeline
406
+ - __call__
407
+ - all
408
+
409
+ ### SummarizationPipeline
410
+
411
+ [[autodoc]] SummarizationPipeline
412
+ - __call__
413
+ - all
414
+
415
+ ### TableQuestionAnsweringPipeline
416
+
417
+ [[autodoc]] TableQuestionAnsweringPipeline
418
+ - __call__
419
+
420
+ ### TextClassificationPipeline
421
+
422
+ [[autodoc]] TextClassificationPipeline
423
+ - __call__
424
+ - all
425
+
426
+ ### TextGenerationPipeline
427
+
428
+ [[autodoc]] TextGenerationPipeline
429
+ - __call__
430
+ - all
431
+
432
+ ### Text2TextGenerationPipeline
433
+
434
+ [[autodoc]] Text2TextGenerationPipeline
435
+ - __call__
436
+ - all
437
+
438
+ ### TokenClassificationPipeline
439
+
440
+ [[autodoc]] TokenClassificationPipeline
441
+ - __call__
442
+ - all
443
+
444
+ ### TranslationPipeline
445
+
446
+ [[autodoc]] TranslationPipeline
447
+ - __call__
448
+ - all
449
+
450
+ ### ZeroShotClassificationPipeline
451
+
452
+ [[autodoc]] ZeroShotClassificationPipeline
453
+ - __call__
454
+ - all
455
+
456
+ ## Multimodal
457
+
458
+ マルチモーダル タスクに使用できるパイプラインには次のものがあります。
459
+
460
+ ### DocumentQuestionAnsweringPipeline
461
+
462
+ [[autodoc]] DocumentQuestionAnsweringPipeline
463
+ - __call__
464
+ - all
465
+
466
+ ### FeatureExtractionPipeline
467
+
468
+ [[autodoc]] FeatureExtractionPipeline
469
+ - __call__
470
+ - all
471
+
472
+ ### ImageFeatureExtractionPipeline
473
+
474
+ [[autodoc]] ImageFeatureExtractionPipeline
475
+ - __call__
476
+ - all
477
+
478
+ ### ImageToTextPipeline
479
+
480
+ [[autodoc]] ImageToTextPipeline
481
+ - __call__
482
+ - all
483
+
484
+ ### ImageTextToTextPipeline
485
+
486
+ [[autodoc]] ImageTextToTextPipeline
487
+ - __call__
488
+ - all
489
+
490
+ ### VisualQuestionAnsweringPipeline
491
+
492
+ [[autodoc]] VisualQuestionAnsweringPipeline
493
+ - __call__
494
+ - all
495
+
496
+ ## Parent class: `Pipeline`
497
+
498
+ [[autodoc]] Pipeline
docs/transformers/docs/source/ja/main_classes/processors.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Processors
18
+
19
+ Transformers ライブラリでは、プロセッサは 2 つの異なる意味を持ちます。
20
+ - [Wav2Vec2](../model_doc/wav2vec2) などのマルチモーダル モデルの入力を前処理するオブジェクト (音声とテキスト)
21
+ または [CLIP](../model_doc/clip) (テキストとビジョン)
22
+ - 古いバージョンのライブラリで GLUE または SQUAD のデータを前処理するために使用されていたオブジェクトは非推奨になりました。
23
+
24
+ ## Multi-modal processors
25
+
26
+ マルチモーダル モデルでは、オブジェクトが複数のモダリティ (テキスト、
27
+ 視覚と音声)。これは、2 つ以上の処理オブジェクトをグループ化するプロセッサーと呼ばれるオブジェクトによって処理されます。
28
+ トークナイザー (テキスト モダリティ用)、画像プロセッサー (視覚用)、特徴抽出器 (オーディオ用) など。
29
+
30
+ これらのプロセッサは、保存およびロード機能を実装する次の基本クラスを継承します。
31
+
32
+ [[autodoc]] ProcessorMixin
33
+
34
+ ## Deprecated processors
35
+
36
+ すべてのプロセッサは、同じアーキテクチャに従っています。
37
+ [`~data.processors.utils.DataProcessor`]。プロセッサは次のリストを返します。
38
+ [`~data.processors.utils.InputExample`]。これら
39
+ [`~data.processors.utils.InputExample`] は次のように変換できます。
40
+ [`~data.processors.utils.Input features`] をモデルにフィードします。
41
+
42
+ [[autodoc]] data.processors.utils.DataProcessor
43
+
44
+ [[autodoc]] data.processors.utils.InputExample
45
+
46
+ [[autodoc]] data.processors.utils.InputFeatures
47
+
48
+ ## GLUE
49
+
50
+ [一般言語理解評価 (GLUE)](https://gluebenchmark.com/) は、
51
+ 既存の NLU タスクの多様なセットにわたるモデルのパフォーマンス。紙と同時発売された [GLUE: A
52
+ 自然言語理解のためのマルチタスクベンチマークおよび分析プラットフォーム](https://openreview.net/pdf?id=rJ4km2R5t7)
53
+
54
+ このライブラリは、MRPC、MNLI、MNLI (不一致)、CoLA、SST2、STSB、
55
+ QQP、QNLI、RTE、WNLI。
56
+
57
+ それらのプロセッサは次のとおりです。
58
+
59
+ - [`~data.processors.utils.MrpcProcessor`]
60
+ - [`~data.processors.utils.MnliProcessor`]
61
+ - [`~data.processors.utils.MnliMismatchedProcessor`]
62
+ - [`~data.processors.utils.Sst2Processor`]
63
+ - [`~data.processors.utils.StsbProcessor`]
64
+ - [`~data.processors.utils.QqpProcessor`]
65
+ - [`~data.processors.utils.QnliProcessor`]
66
+ - [`~data.processors.utils.RteProcessor`]
67
+ - [`~data.processors.utils.WnliProcessor`]
68
+
69
+
70
+ さらに、次のメソッドを使用して、データ ファイルから値をロードし、それらをリストに変換することができます。
71
+ [`~data.processors.utils.InputExample`]。
72
+
73
+ [[autodoc]] data.processors.glue.glue_convert_examples_to_features
74
+
75
+ ## XNLI
76
+
77
+ [クロスリンガル NLI コーパス (XNLI)](https://www.nyu.edu/projects/bowman/xnli/) は、
78
+ 言語を超えたテキスト表現の品質。 XNLI は、[*MultiNLI*](http://www.nyu.edu/projects/bowman/multinli/) に基づくクラウドソースのデータセットです。テキストのペアには、15 個のテキスト含意アノテーションがラベル付けされています。
79
+ さまざまな言語 (英語などの高リソース言語とスワヒリ語などの低リソース言語の両方を含む)。
80
+
81
+ 論文 [XNLI: Evaluating Cross-lingual Sentence Representations](https://arxiv.org/abs/1809.05053) と同時にリリースされました。
82
+
83
+ このライブラリは、XNLI データをロードするプロセッサをホストします。
84
+
85
+ - [`~data.processors.utils.XnliProcessor`]
86
+
87
+ テストセットにはゴールドラベルが付いているため、評価はテストセットで行われますのでご了承ください。
88
+
89
+ これらのプロセッサを使用する例は、[run_xnli.py](https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-classification/run_xnli.py) スクリプトに示されています。
90
+
91
+ ## SQuAD
92
+
93
+ [The Stanford Question Answering Dataset (SQuAD)](https://rajpurkar.github.io/SQuAD-explorer//) は、次のベンチマークです。
94
+ 質問応答に関するモデルのパフォーマ���スを評価します。 v1.1 と v2.0 の 2 つのバージョンが利用可能です。最初のバージョン
95
+ (v1.1) は、論文 [SQuAD: 100,000+ question for Machine Comprehension of Text](https://arxiv.org/abs/1606.05250) とともにリリースされました。 2 番目のバージョン (v2.0) は、論文 [Know What You Don't と同時にリリースされました。
96
+ 知っておくべき: SQuAD の答えられない質問](https://arxiv.org/abs/1806.03822)。
97
+
98
+ このライブラリは、次の 2 つのバージョンのそれぞれのプロセッサをホストします。
99
+
100
+ ### Processors
101
+
102
+ それらのプロセッサは次のとおりです。
103
+
104
+ - [`~data.processors.utils.SquadV1Processor`]
105
+ - [`~data.processors.utils.SquadV2Processor`]
106
+
107
+ どちらも抽象クラス [`~data.processors.utils.SquadProcessor`] を継承しています。
108
+
109
+ [[autodoc]] data.processors.squad.SquadProcessor
110
+ - all
111
+
112
+ さらに、次のメソッドを使用して、SQuAD の例を次の形式に変換できます。
113
+ モデルの入力として使用できる [`~data.processors.utils.SquadFeatures`]。
114
+
115
+ [[autodoc]] data.processors.squad.squad_convert_examples_to_features
116
+
117
+ これらのプロセッサと前述の方法は、データを含むファイルだけでなく、
118
+ *tensorflow_datasets* パッケージ。以下に例を示します。
119
+
120
+ ### Example usage
121
+
122
+ 以下にプロセッサを使用した例と、データ ファイルを使用した変換方法を示します。
123
+
124
+ ```python
125
+ # Loading a V2 processor
126
+ processor = SquadV2Processor()
127
+ examples = processor.get_dev_examples(squad_v2_data_dir)
128
+
129
+ # Loading a V1 processor
130
+ processor = SquadV1Processor()
131
+ examples = processor.get_dev_examples(squad_v1_data_dir)
132
+
133
+ features = squad_convert_examples_to_features(
134
+ examples=examples,
135
+ tokenizer=tokenizer,
136
+ max_seq_length=max_seq_length,
137
+ doc_stride=args.doc_stride,
138
+ max_query_length=max_query_length,
139
+ is_training=not evaluate,
140
+ )
141
+ ```
142
+
143
+ *tensorflow_datasets* の使用は、データ ファイルを使用するのと同じくらい簡単です。
144
+
145
+ ```python
146
+ # tensorflow_datasets only handle Squad V1.
147
+ tfds_examples = tfds.load("squad")
148
+ examples = SquadV1Processor().get_examples_from_dataset(tfds_examples, evaluate=evaluate)
149
+
150
+ features = squad_convert_examples_to_features(
151
+ examples=examples,
152
+ tokenizer=tokenizer,
153
+ max_seq_length=max_seq_length,
154
+ doc_stride=args.doc_stride,
155
+ max_query_length=max_query_length,
156
+ is_training=not evaluate,
157
+ )
158
+ ```
159
+
160
+ これらのプロセッサを使用する別の例は、[run_squad.py](https://github.com/huggingface/transformers/tree/main/examples/legacy/question-answering/run_squad.py) スクリプトに示されています。
docs/transformers/docs/source/ja/main_classes/quantization.md ADDED
@@ -0,0 +1,447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Quantize 🤗 Transformers models
18
+
19
+ ## `AutoGPTQ` Integration
20
+
21
+
22
+ 🤗 Transformers には、言語モデルで GPTQ 量子化を実行するための `optimum` API が統合されています。パフォーマンスを大幅に低下させることなく、推論速度を高速化することなく、モデルを 8、4、3、さらには 2 ビットでロードおよび量子化できます。これは、ほとんどの GPU ハードウェアでサポートされています。
23
+
24
+ 量子化モデルの詳細については、以下を確認してください。
25
+ - [GPTQ](https://arxiv.org/pdf/2210.17323.pdf) 論文
26
+ - GPTQ 量子化に関する `optimum` [ガイド](https://huggingface.co/docs/optimum/llm_quantization/usage_guides/quantization)
27
+ - バックエンドとして使用される [`AutoGPTQ`](https://github.com/PanQiWei/AutoGPTQ) ライブラリ
28
+
29
+ ### Requirements
30
+
31
+ 以下のコードを実行するには、以下の要件がインストールされている必要があります:
32
+
33
+ - 最新の `AutoGPTQ` ライブラリをインストールする。
34
+ `pip install auto-gptq` をインストールする。
35
+
36
+ - 最新の `optimum` をソースからインストールする。
37
+ `git+https://github.com/huggingface/optimum.git` をインストールする。
38
+
39
+ - 最新の `transformers` をソースからインストールする。
40
+ 最新の `transformers` をソースからインストールする `pip install git+https://github.com/huggingface/transformers.git`
41
+
42
+ - 最新の `accelerate` ライブラリをインストールする。
43
+ `pip install --upgrade accelerate` を実行する。
44
+
45
+ GPTQ統合は今のところテキストモデルのみをサポートしているので、視覚、音声、マルチモーダルモデルでは予期せぬ挙動に遭遇するかもしれないことに注意してください。
46
+
47
+ ### Load and quantize a model
48
+
49
+ GPTQ は、量子化モデルを使用する前に重みのキャリブレーションを必要とする量子化方法です。トランスフォーマー モデルを最初から量子化する場合は、量子化モデルを作成するまでに時間がかかることがあります (`facebook/opt-350m`モデルの Google colab では約 5 分)。
50
+
51
+ したがって、GPTQ 量子化モデルを使用するシナリオは 2 つあります。最初の使用例は、ハブで利用可能な他のユーザーによってすでに量子化されたモデルをロードすることです。2 番目の使用例は、モデルを最初から量子化し、保存するかハブにプッシュして、他のユーザーが使用できるようにすることです。それも使ってください。
52
+
53
+ #### GPTQ Configuration
54
+
55
+ モデルをロードして量子化するには、[`GPTQConfig`] を作成する必要があります。データセットを準備するには、`bits`の数、量子化を調整するための`dataset`、およびモデルの`Tokenizer`を渡す必要があります。
56
+
57
+ ```python
58
+ model_id = "facebook/opt-125m"
59
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
60
+ gptq_config = GPTQConfig(bits=4, dataset = "c4", tokenizer=tokenizer)
61
+ ```
62
+
63
+ 独自のデータセットを文字列のリストとして渡すことができることに注意してください。ただし、GPTQ 論文のデータセットを使用することを強くお勧めします。
64
+
65
+ ```python
66
+ dataset = ["auto-gptq is an easy-to-use model quantization library with user-friendly apis, based on GPTQ algorithm."]
67
+ quantization = GPTQConfig(bits=4, dataset = dataset, tokenizer=tokenizer)
68
+ ```
69
+
70
+ #### Quantization
71
+
72
+ `from_pretrained` を使用し、`quantization_config` を設定することでモデルを量子化できます。
73
+
74
+ ```python
75
+ from transformers import AutoModelForCausalLM
76
+ model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=gptq_config)
77
+ ```
78
+
79
+ モデルを量子化するには GPU が必要であることに注意してください。モデルを CPU に配置し、量子化するためにモジュールを GPU に前後に移動させます。
80
+
81
+ CPU オフロードの使用中に GPU の使用量を最大化したい場合は、`device_map = "auto"` を設定できます。
82
+
83
+ ```python
84
+ from transformers import AutoModelForCausalLM
85
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", quantization_config=gptq_config)
86
+ ```
87
+
88
+ ディスク オフロードはサポートされていないことに注意してください。さらに、データセットが原因でメモリが不足している場合は、`from_pretained` で `max_memory` を渡す必要がある場合があります。 `device_map`と`max_memory`の詳細については、この [ガイド](https://huggingface.co/docs/accelerate/usage_guides/big_modeling#designing-a-device-map) を参照してください。
89
+
90
+ <Tip warning={true}>
91
+ GPTQ 量子化は、現時点ではテキスト モデルでのみ機能します。さらに、量子化プロセスはハードウェアによっては長時間かかる場合があります (NVIDIA A100 を使用した場合、175B モデル = 4 gpu 時間)。モデルの GPTQ 量子化バージョンが存在しない場合は、ハブで確認してください。そうでない場合は、github で要求を送信できます。
92
+ </Tip>
93
+
94
+ ### Push quantized model to 🤗 Hub
95
+
96
+ 他の 🤗 モデルと同様に、`push_to_hub` を使用して量子化モデルをハブにプッシュできます。量子化構成は保存され、モデルに沿ってプッシュされます。
97
+
98
+ ```python
99
+ quantized_model.push_to_hub("opt-125m-gptq")
100
+ tokenizer.push_to_hub("opt-125m-gptq")
101
+ ```
102
+
103
+ 量子化されたモデルをローカル マシンに保存したい場合は、`save_pretrained` を使用して行うこともできます。
104
+
105
+
106
+ ```python
107
+ quantized_model.save_pretrained("opt-125m-gptq")
108
+ tokenizer.save_pretrained("opt-125m-gptq")
109
+ ```
110
+
111
+ `device_map` を使用してモデルを量子化した場合は、保存する前にモデル全体を GPU または `cpu` のいずれかに移動してください。
112
+
113
+ ```python
114
+ quantized_model.to("cpu")
115
+ quantized_model.save_pretrained("opt-125m-gptq")
116
+ ```
117
+
118
+ ### Load a quantized model from the 🤗 Hub
119
+
120
+ `from_pretrained`を使用して、量子化されたモデルをハブからロードできます。
121
+ 属性 `quantization_config` がモデル設定オブジェクトに存在することを確認して、プッシュされた重みが量子化されていることを確認します。
122
+
123
+ ```python
124
+ from transformers import AutoModelForCausalLM
125
+ model = AutoModelForCausalLM.from_pretrained("{your_username}/opt-125m-gptq")
126
+ ```
127
+
128
+ 必要以上のメモリを割り当てずにモデルをより速くロードしたい場合は、`device_map` 引数は量子化モデルでも機能します。 `accelerate`ライブラリがインストールされていることを確認してください。
129
+
130
+ ```python
131
+ from transformers import AutoModelForCausalLM
132
+ model = AutoModelForCausalLM.from_pretrained("{your_username}/opt-125m-gptq", device_map="auto")
133
+ ```
134
+
135
+ ### Exllama kernels for faster inference
136
+
137
+ 4 ビット モデルの場合、推論速度を高めるために exllama カーネルを使用できます。デフォルトで有効になっています。 [`GPTQConfig`] で `disable_exllama` を渡すことで、その動作を変更できます。これにより、設定に保存されている量子化設定が上書きされます。カーネルに関連する属性のみを上書きできることに注意してください。さらに、exllama カーネルを使用したい場合は、モデル全体を GPU 上に置く必要があります。
138
+
139
+
140
+ ```py
141
+ import torch
142
+ gptq_config = GPTQConfig(bits=4, disable_exllama=False)
143
+ model = AutoModelForCausalLM.from_pretrained("{your_username}/opt-125m-gptq", device_map="auto", quantization_config = gptq_config)
144
+ ```
145
+
146
+ 現時点では 4 ビット モデルのみがサポートされていることに注意してください。さらに、peft を使用して量子化モデルを微調整している場合は、exllama カーネルを非アクティブ化することをお勧めします。
147
+
148
+ #### Fine-tune a quantized model
149
+
150
+ Hugging Face エコシステムのアダプターの公式サポートにより、GPTQ で量子化されたモデルを微調整できます。
151
+ 詳細については、[`peft`](https://github.com/huggingface/peft) ライブラリをご覧ください。
152
+
153
+ ### Example demo
154
+
155
+ GPTQ を使用してモデルを量子化する方法と、peft を使用して量子化されたモデルを微調整する方法については、Google Colab [ノートブック](https://colab.research.google.com/drive/1_TIrmuKOFhuRRiTWN94iLKUFu6ZX4ceb?usp=sharing) を参照してください。
156
+
157
+ ### GPTQConfig
158
+
159
+ [[autodoc]] GPTQConfig
160
+
161
+ ## `bitsandbytes` Integration
162
+
163
+ 🤗 Transformers は、`bitsandbytes` で最もよく使用されるモジュールと緊密に統合されています。数行のコードでモデルを 8 ビット精度でロードできます。
164
+ これは、`bitsandbytes`の `0.37.0`リリース以降、ほとんどの GPU ハードウェアでサポートされています。
165
+
166
+ 量子化方法の詳細については、[LLM.int8()](https://arxiv.org/abs/2208.07339) 論文、または [ブログ投稿](https://huggingface.co/blog/hf-bitsandbytes-) をご覧ください。統合)コラボレーションについて。
167
+
168
+ `0.39.0`リリース以降、FP4 データ型を活用し、4 ビット量子化を使用して`device_map`をサポートする任意のモデルをロードできます。
169
+
170
+ 独自の pytorch モデルを量子化したい場合は、🤗 Accelerate ライブラリの [ドキュメント](https://huggingface.co/docs/accelerate/main/en/usage_guides/quantization) をチェックしてください。
171
+
172
+ `bitsandbytes`統合を使用してできることは次のとおりです
173
+
174
+ ### General usage
175
+
176
+ モデルが 🤗 Accelerate による読み込みをサポートし、`torch.nn.Linear` レイヤーが含まれている限り、 [`~PreTrainedModel.from_pretrained`] メソッドを呼び出すときに `load_in_8bit` または `load_in_4bit` 引数を使用してモデルを量子化できます。これはどのようなモダリティでも同様に機能するはずです。
177
+
178
+ ```python
179
+ from transformers import AutoModelForCausalLM
180
+
181
+ model_8bit = AutoModelForCausalLM.from_pretrained("facebook/opt-350m", load_in_8bit=True)
182
+ model_4bit = AutoModelForCausalLM.from_pretrained("facebook/opt-350m", load_in_4bit=True)
183
+ ```
184
+
185
+ デフォルトでは、他のすべてのモジュール (例: `torch.nn.LayerNorm`) は `torch.float16` に変換されますが、その `dtype` を変更したい場合は、`torch_dtype` 引数を上書きできます。
186
+
187
+ ```python
188
+ >>> import torch
189
+ >>> from transformers import AutoModelForCausalLM
190
+
191
+ >>> model_8bit = AutoModelForCausalLM.from_pretrained("facebook/opt-350m", load_in_8bit=True, torch_dtype=torch.float32)
192
+ >>> model_8bit.model.decoder.layers[-1].final_layer_norm.weight.dtype
193
+ torch.float32
194
+ ```
195
+
196
+ ### FP4 quantization
197
+
198
+ #### Requirements
199
+
200
+ 以下のコード スニペットを実行する前に、以下の要件がインストールされていることを確認してください。
201
+
202
+ - 最新の`bitsandbytes`ライブラリ
203
+ `pip install bitsandbytes>=0.39.0`
204
+
205
+ - 最新の`accelerate`をインストールする
206
+ `pip install --upgrade accelerate`
207
+
208
+ - 最新の `transformers` をインストールする
209
+ `pip install --upgrade transformers`
210
+
211
+ #### Tips and best practices
212
+
213
+ - **高度な使用法:** 可能なすべてのオプションを使用した 4 ビット量子化の高度な使用法については、[この Google Colab ノートブック](https://colab.research.google.com/drive/1ge2F1QSK8Q7h0hn3YKuBCOAS0bK8E0wf) を参照してください。
214
+
215
+ - **`batch_size=1` による高速推論 :** bitsandbytes の `0.40.0` リリース以降、`batch_size=1` では高速推論の恩恵を受けることができます。 [これらのリリース ノート](https://github.com/TimDettmers/bitsandbytes/releases/tag/0.40.0) を確認し、この機能を活用するには`0.40.0`以降のバージョンを使用していることを確認してください。箱の。
216
+
217
+ - **トレーニング:** [QLoRA 論文](https://arxiv.org/abs/2305.14314) によると、4 ビット基本モデルをトレーニングする場合 (例: LoRA アダプターを使用)、`bnb_4bit_quant_type='nf4'` を使用する必要があります。 。
218
+
219
+ - **推論:** 推論の場合、`bnb_4bit_quant_type` はパフォーマンスに大きな影響を与えません。ただし、モデルの重みとの一貫性を保つために、必ず同じ `bnb_4bit_compute_dtype` および `torch_dtype` 引数を使用してください。
220
+
221
+
222
+ #### Load a large model in 4bit
223
+
224
+ `.from_pretrained` メソッドを呼び出すときに `load_in_4bit=True` を使用すると、メモリ使用量を (おおよそ) 4 で割ることができます。
225
+
226
+ ```python
227
+ # pip install transformers accelerate bitsandbytes
228
+ from transformers import AutoModelForCausalLM, AutoTokenizer
229
+
230
+ model_id = "bigscience/bloom-1b7"
231
+
232
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
233
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", load_in_4bit=True)
234
+ ```
235
+
236
+ <Tip warning={true}>
237
+
238
+ モデルが 4 ビットでロードされると、現時点では量子化された重みをハブにプッシュすることはできないことに注意してください。 4 ビットの重みはまだサポートされていないため、トレーニングできないことにも注意してください。ただし、4 ビット モデルを使用して追加のパラメーターをトレーニングすることもできます。これについては次のセクションで説明します。
239
+
240
+ </Tip>
241
+
242
+ ### Load a large model in 8bit
243
+
244
+ `.from_pretrained` メソッドを呼び出すときに `load_in_8bit=True` 引数を使用すると、メモリ要件をおよそ半分にしてモデルをロードできます。
245
+
246
+ ```python
247
+ # pip install transformers accelerate bitsandbytes
248
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
249
+
250
+ model_id = "bigscience/bloom-1b7"
251
+
252
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
253
+ model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=BitsAndBytesConfig(load_in_8bit=True))
254
+ ```
255
+
256
+ 次に、通常 [`PreTrainedModel`] を使用するのと同じようにモデルを使用します。
257
+
258
+ `get_memory_footprint` メソッドを使用して、モデルのメモリ フットプリントを確認できます。
259
+
260
+ ```python
261
+ print(model.get_memory_footprint())
262
+ ```
263
+
264
+ この統合により、大きなモデルを小さなデバイスにロードし、問題なく実行できるようになりました。
265
+
266
+ <Tip warning={true}>
267
+ モデルが 8 ビットでロードされると、最新の `transformers`と`bitsandbytes`を使用する場合を除き、量子化された重みをハブにプッシュすることは現在不可能であることに注意してください。 8 ビットの重みはまだサポートされていないため、トレーニングできないことにも注意してください。ただし、8 ビット モデルを使用して追加のパラメーターをトレーニングすることもできます。これについては次のセクションで説明します。
268
+ また、`device_map` はオプションですが、利用可能なリソース上でモデルを効率的にディスパッチするため、推論には `device_map = 'auto'` を設定することが推奨されます。
269
+
270
+ </Tip>
271
+
272
+ #### Advanced use cases
273
+
274
+ ここでは、FP4 量子化を使用して実行できるいくつかの高度な使用例について説明します。
275
+
276
+ ##### Change the compute dtype
277
+
278
+ compute dtype は、計算中に使用される dtype を変更するために使用されます。たとえば、隠し状態は`float32`にありますが、高速化のために計算を bf16 に設定できます。デフォルトでは、compute dtype は `float32` に設定されます。
279
+
280
+ ```python
281
+ import torch
282
+ from transformers import BitsAndBytesConfig
283
+
284
+ quantization_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16)
285
+ ```
286
+
287
+ ##### Using NF4 (Normal Float 4) data type
288
+
289
+ NF4 データ型を使用することもできます。これは、正規分布を使用して初期化された重みに適合した新しい 4 ビット データ型です。その実行のために:
290
+
291
+ ```python
292
+ from transformers import BitsAndBytesConfig
293
+
294
+ nf4_config = BitsAndBytesConfig(
295
+ load_in_4bit=True,
296
+ bnb_4bit_quant_type="nf4",
297
+ )
298
+
299
+ model_nf4 = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=nf4_config)
300
+ ```
301
+
302
+ ##### Use nested quantization for more memory efficient inference
303
+
304
+ また、ネストされた量子化手法を使用することをお勧めします。これにより、パフォーマンスを追加することなく、より多くのメモリが節約されます。経験的な観察から、これにより、NVIDIA-T4 16GB 上でシーケンス長 1024、バッチ サイズ 1、勾配累積ステップ 4 の llama-13b モデルを微調整することが可能になります。
305
+
306
+ ```python
307
+ from transformers import BitsAndBytesConfig
308
+
309
+ double_quant_config = BitsAndBytesConfig(
310
+ load_in_4bit=True,
311
+ bnb_4bit_use_double_quant=True,
312
+ )
313
+
314
+ model_double_quant = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=double_quant_config)
315
+ ```
316
+
317
+
318
+ ### Push quantized models on the 🤗 Hub
319
+
320
+ `push_to_hub`メソッドを単純に使用することで、量子化されたモデルをハブにプッシュできます。これにより、最初に量子化構成ファイルがプッシュされ、次に量子化されたモデルの重みがプッシュされます。
321
+ この機能を使用できるようにするには、必ず `bitsandbytes>0.37.2` を使用してください (この記事の執筆時点では、`bitsandbytes==0.38.0.post1` でテストしました)。
322
+
323
+ ```python
324
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
325
+
326
+ model = AutoModelForCausalLM.from_pretrained("bigscience/bloom-560m", quantization_config=BitsAndBytesConfig(load_in_8bit=True))
327
+ tokenizer = AutoTokenizer.from_pretrained("bigscience/bloom-560m")
328
+
329
+ model.push_to_hub("bloom-560m-8bit")
330
+ ```
331
+
332
+ <Tip warning={true}>
333
+
334
+ 大規模なモデルでは、ハブ上で 8 ビット モデルをプッシュすることが強く推奨されます。これにより、コミュニティはメモリ フットプリントの削減と、たとえば Google Colab での大規模なモデルの読み込みによる恩恵を受けることができます。
335
+
336
+ </Tip>
337
+
338
+ ### Load a quantized model from the 🤗 Hub
339
+
340
+ `from_pretrained`メソッドを使用して、ハブから量子化モデルをロードできます。属性 `quantization_config` がモデル設定オブジェクトに存在することを確認して、プッシュされた重みが量子化されていることを確認します。
341
+
342
+ ```python
343
+ from transformers import AutoModelForCausalLM, AutoTokenizer
344
+
345
+ model = AutoModelForCausalLM.from_pretrained("{your_username}/bloom-560m-8bit", device_map="auto")
346
+ ```
347
+
348
+ この場合、引数 `load_in_8bit=True` を指定する必要はありませんが、`bitsandbytes` と `accelerate` がインストールされていることを確認する必要があることに注意してください。
349
+ また、`device_map` はオプションですが、利用可能なリソース上でモデルを効率的にディスパッチするため、推論には `device_map = 'auto'` を設定することが推奨されます。
350
+
351
+ ### Advanced use cases
352
+
353
+ このセクションは、8 ビット モデルのロードと実行以外に何ができるかを探求したい上級ユーザーを対象としています。
354
+
355
+ #### Offload between `cpu` and `gpu`
356
+
357
+ この高度な使用例の 1 つは、モデルをロードし、`CPU`と`GPU`の間で重みをディスパッチできることです。 CPU 上でディスパッチされる重みは **8 ビットに変換されない**ため、`float32`に保持されることに注意してください。この機能は、非常に大規模なモデルを適合させ、そのモデルを GPU と CPU の間でディスパッチしたいユーザーを対象としています。
358
+
359
+ まず、`transformers` から [`BitsAndBytesConfig`] をロードし、属性 `llm_int8_enable_fp32_cpu_offload` を `True` に設定します。
360
+
361
+ ```python
362
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
363
+
364
+ quantization_config = BitsAndBytesConfig(llm_int8_enable_fp32_cpu_offload=True)
365
+ ```
366
+
367
+ `bigscience/bloom-1b7`モデルをロードする必要があり、`lm_head`を除くモデル全体に​​適合するのに十分な GPU RAM があるとします。したがって、次のようにカスタム device_map を作成します。
368
+
369
+ ```python
370
+ device_map = {
371
+ "transformer.word_embeddings": 0,
372
+ "transformer.word_embeddings_layernorm": 0,
373
+ "lm_head": "cpu",
374
+ "transformer.h": 0,
375
+ "transformer.ln_f": 0,
376
+ }
377
+ ```
378
+
379
+ そして、次のようにモデルをロードします。
380
+ ```python
381
+ model_8bit = AutoModelForCausalLM.from_pretrained(
382
+ "bigscience/bloom-1b7",
383
+ device_map=device_map,
384
+ quantization_config=quantization_config,
385
+ )
386
+ ```
387
+
388
+ 以上です!モデルを楽しんでください!
389
+
390
+ #### Play with `llm_int8_threshold`
391
+
392
+ `llm_int8_threshold` 引数を操作して、外れ値のしきい値を変更できます。 外れ値 とは、特定のしきい値より大きい隠れた状態の値です。
393
+ これは、`LLM.int8()`論文で説明されている外れ値検出の外れ値しきい値に対応します。このしきい値を超える隠し状態の値は外れ値とみなされ、それらの値に対する操作は fp16 で実行されます。通常、値は正規分布します。つまり、ほとんどの値は [-3.5, 3.5] の範囲内にありますが、大規模なモデルでは大きく異なる分布を示す例外的な系統的外れ値がいくつかあります。これらの外れ値は、多くの場合 [-60, -6] または [6, 60] の範囲内にあります。 Int8 量子化は、大きさが 5 程度までの値ではうまく機能しますが、それを超えると、パフォーマンスが大幅に低下します。適切なデフォルトのしきい値は 6 ですが、より不安定なモデル (小規模なモデル、微調整) では、より低いしきい値が必要になる場合があります。
394
+ この引数は、モデルの推論速度に影響を与える可能性があります。このパラメータを試してみて、ユースケースに最適なパラメータを見つけることをお勧めします。
395
+
396
+ ```python
397
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
398
+
399
+ model_id = "bigscience/bloom-1b7"
400
+
401
+ quantization_config = BitsAndBytesConfig(
402
+ llm_int8_threshold=10,
403
+ )
404
+
405
+ model_8bit = AutoModelForCausalLM.from_pretrained(
406
+ model_id,
407
+ device_map=device_map,
408
+ quantization_config=quantization_config,
409
+ )
410
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
411
+ ```
412
+
413
+ #### Skip the conversion of some modules
414
+
415
+ 一部のモデルには、安定性を確保するために 8 ビットに変換する必要がないモジュールがいくつかあります。たとえば、ジュークボックス モデルには、スキップする必要があるいくつかの `lm_head` モジュールがあります。 `llm_int8_skip_modules` で遊んでみる
416
+
417
+ ```python
418
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
419
+
420
+ model_id = "bigscience/bloom-1b7"
421
+
422
+ quantization_config = BitsAndBytesConfig(
423
+ llm_int8_skip_modules=["lm_head"],
424
+ )
425
+
426
+ model_8bit = AutoModelForCausalLM.from_pretrained(
427
+ model_id,
428
+ device_map=device_map,
429
+ quantization_config=quantization_config,
430
+ )
431
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
432
+ ```
433
+
434
+ #### Fine-tune a model that has been loaded in 8-bit
435
+
436
+ Hugging Face エコシステムのアダプターの公式サポートにより、8 ビットでロードされたモデルを微調整できます。
437
+ これにより、単一の Google Colab で`flan-t5-large`や`facebook/opt-6.7b`などの大規模モデルを微調整することができます。詳細については、[`peft`](https://github.com/huggingface/peft) ライブラリをご覧ください。
438
+
439
+ トレーニング用のモデルをロードするときに `device_map` を渡す必要がないことに注意してください。モデルが GPU に自動的にロードされます。必要に応じて、デバイス マップを特定のデバイスに設定することもできます (例: `cuda:0`、`0`、`torch.device('cuda:0')`)。 `device_map=auto`は推論のみに使用する必要があることに注意してください。
440
+
441
+ ### BitsAndBytesConfig
442
+
443
+ [[autodoc]] BitsAndBytesConfig
444
+
445
+ ## Quantization with 🤗 `optimum`
446
+
447
+ `optimum`でサポートされている量子化方法の詳細については、[Optimum ドキュメント](https://huggingface.co/docs/optimum/index) を参照し、これらが自分のユースケースに適用できるかどうかを確認してください。
docs/transformers/docs/source/ja/main_classes/text_generation.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2022 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Generation
18
+
19
+ 各フレームワークには、それぞれの `GenerationMixin` クラスに実装されたテキスト生成のための Generate メソッドがあります。
20
+
21
+ - PyTorch [`~generation.GenerationMixin.generate`] は [`~generation.GenerationMixin`] に実装されています。
22
+ - TensorFlow [`~generation.TFGenerationMixin.generate`] は [`~generation.TFGenerationMixin`] に実装されています。
23
+ - Flax/JAX [`~generation.FlaxGenerationMixin.generate`] は [`~generation.FlaxGenerationMixin`] に実装されています。
24
+
25
+ 選択したフレームワークに関係なく、[`~generation.GenerationConfig`] を使用して生成メソッドをパラメータ化できます。
26
+ クラスインスタンス。動作を制御する生成パラメータの完全なリストについては、このクラスを参照してください。
27
+ 生成方法のこと。
28
+
29
+ モデルの生成構成を検査する方法、デフォルトとは何か、パラメーターをアドホックに変更する方法を学習するには、
30
+ カスタマイズされた生成構成を作成して保存する方法については、「
31
+ [テキスト生成戦略ガイド](../generation_strategies)。このガイドでは、関連機能の使用方法についても説明しています。
32
+ トークンストリーミングのような。
33
+
34
+ ## GenerationConfig
35
+
36
+ [[autodoc]] generation.GenerationConfig
37
+ - from_pretrained
38
+ - from_model_config
39
+ - save_pretrained
40
+
41
+ ## GenerationMixin
42
+
43
+ [[autodoc]] generation.GenerationMixin
44
+ - generate
45
+ - compute_transition_scores
46
+
47
+ ## TFGenerationMixin
48
+
49
+ [[autodoc]] generation.TFGenerationMixin
50
+ - generate
51
+ - compute_transition_scores
52
+
53
+ ## FlaxGenerationMixin
54
+
55
+ [[autodoc]] generation.FlaxGenerationMixin
56
+ - generate
docs/transformers/docs/source/ja/main_classes/tokenizer.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Tokenizer
18
+
19
+ トークナイザーは、モデルの入力の準備を担当します。ライブラリには、すべてのモデルのトークナイザーが含まれています。ほとんど
20
+ トークナイザーの一部は、完全な Python 実装と、
21
+ Rust ライブラリ [🤗 Tokenizers](https://github.com/huggingface/tokenizers)。 「高速」実装では次のことが可能になります。
22
+
23
+ 1. 特にバッチトークン化を行う場合の大幅なスピードアップと
24
+ 2. 元の文字列 (文字と単語) とトークン空間の間でマッピングする追加のメソッド (例:
25
+ 特定の文字を含むトークンのインデックス、または特定のトークンに対応する文字の範囲)。
26
+
27
+ 基本クラス [`PreTrainedTokenizer`] および [`PreTrainedTokenizerFast`]
28
+ モデル入力の文字列入力をエンコードし (以下を参照)、Python をインスタンス化/保存するための一般的なメソッドを実装します。
29
+ ローカル ファイルまたはディレクトリ、またはライブラリによって提供される事前トレーニング済みトークナイザーからの「高速」トークナイザー
30
+ (HuggingFace の AWS S3 リポジトリからダウンロード)。二人とも頼りにしているのは、
31
+ 共通メソッドを含む [`~tokenization_utils_base.PreTrainedTokenizerBase`]
32
+ [`~tokenization_utils_base.SpecialTokensMixin`]。
33
+
34
+ したがって、[`PreTrainedTokenizer`] と [`PreTrainedTokenizerFast`] はメインを実装します。
35
+ すべてのトークナイザーを使用するためのメソッド:
36
+
37
+ - トークン化 (文字列をサブワード トークン文字列に分割)、トークン文字列を ID に変換したり、その逆の変換を行ったりします。
38
+ エンコード/デコード (つまり、トークン化と整数への変換)。
39
+ - 基礎となる構造 (BPE、SentencePiece...) から独立した方法で、語彙に新しいトークンを追加します。
40
+ - 特別なトークン (マスク、文の始まりなど) の管理: トークンの追加、属性への割り当て。
41
+ トークナイザーにより、簡単にアクセスでき、トークン化中に分割されないようにすることができます。
42
+
43
+ [`BatchEncoding`] は、
44
+ [`~tokenization_utils_base.PreTrainedTokenizerBase`] のエンコード メソッド (`__call__`、
45
+ `encode_plus` および `batch_encode_plus`) であり、Python 辞書から派生しています。トークナイザーが純粋な Python の場合
46
+ tokenizer の場合、このクラスは標準の Python 辞書と同じように動作し、によって計算されたさまざまなモデル入力を保持します。
47
+ これらのメソッド (`input_ids`、`attention_mask`...)。トークナイザーが「高速」トークナイザーである場合 (つまり、
48
+ HuggingFace [トークナイザー ライブラリ](https://github.com/huggingface/tokenizers))、このクラスはさらに提供します
49
+ 元の文字列 (文字と単語) と
50
+ トークンスペース (例: 指定された文字または対応する文字の範囲を構成するトークンのインデックスの取得)
51
+ 与えられたトークンに)。
52
+
53
+ ## PreTrainedTokenizer
54
+
55
+ [[autodoc]] PreTrainedTokenizer
56
+ - __call__
57
+ - apply_chat_template
58
+ - batch_decode
59
+ - decode
60
+ - encode
61
+ - push_to_hub
62
+ - all
63
+
64
+ ## PreTrainedTokenizerFast
65
+
66
+ [`PreTrainedTokenizerFast`] は [tokenizers](https://huggingface.co/docs/tokenizers) ライブラリに依存します。 🤗 トークナイザー ライブラリから取得したトークナイザーは、
67
+ 🤗 トランスに非常に簡単にロードされます。これがどのように行われるかを理解するには、[🤗 tokenizers からの tokenizers を使用する](../fast_tokenizers) ページを参照してください。
68
+
69
+ [[autodoc]] PreTrainedTokenizerFast
70
+ - __call__
71
+ - apply_chat_template
72
+ - batch_decode
73
+ - decode
74
+ - encode
75
+ - push_to_hub
76
+ - all
77
+
78
+ ## BatchEncoding
79
+
80
+ [[autodoc]] BatchEncoding
docs/transformers/docs/source/ja/main_classes/trainer.md ADDED
@@ -0,0 +1,727 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Trainer
18
+
19
+ [`Trainer`] クラスは、ほとんどの標準的なユースケースに対して、PyTorch で機能を完全にトレーニングするための API を提供します。これは、[サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples) のほとんどで使用されています。
20
+
21
+ [`Trainer`] をインスタンス化する前に、トレーニング中にカスタマイズのすべてのポイントにアクセスするために [`TrainingArguments`] を作成します。
22
+
23
+ この API は、複数の GPU/TPU での分散トレーニング、[NVIDIA Apex](https://github.com/NVIDIA/apex) および PyTorch のネイティブ AMP による混合精度をサポートします。
24
+
25
+ [`Trainer`] には、上記の機能をサポートする基本的なトレーニング ループが含まれています。カスタム動作を挿入するには、それらをサブクラス化し、次のメソッドをオーバーライドします。
26
+
27
+ - **get_train_dataloader** -- トレーニング データローダーを作成します。
28
+ - **get_eval_dataloader** -- 評価用データローダーを作成します。
29
+ - **get_test_dataloader** -- テスト データローダーを作成します。
30
+ - **log** -- トレーニングを監視しているさまざまなオブジェクトに関する情報をログに記録します。
31
+ - **create_optimizer_and_scheduler** -- オプティマイザと学習率スケジューラが渡されなかった場合にセットアップします。
32
+ 初期化。 `create_optimizer`メソッドと`create_scheduler`メソッドをサブクラス化またはオーバーライドすることもできることに注意してください。
33
+ 別々に。
34
+ - **create_optimizer** -- init で渡されなかった場合にオプティマイザーをセットアップします。
35
+ - **create_scheduler** -- init で渡されなかった場合、学習率スケジューラを設定します。
36
+ - **compute_loss** - トレーニング入力のバッチの損失を計算します。
37
+ - **training_step** -- トレーニング ステップを実行します。
38
+ - **prediction_step** -- 評価/テスト ステップを実行します。
39
+ - **evaluate** -- 評価ループを実行し、メトリクスを返します。
40
+ - **predict** -- テスト セットの予測 (ラベルが使用可能な場合はメトリクスも含む) を返します。
41
+
42
+ <Tip warning={true}>
43
+
44
+ [`Trainer`] クラスは 🤗 Transformers モデル用に最適化されており、驚くべき動作をする可能性があります
45
+ 他の機種で使用する場合。独自のモデルで使用する場合は、次の点を確認してください。
46
+
47
+ - モデルは常に [`~utils.ModelOutput`] のタプルまたはサブクラスを返します。
48
+ - `labels` 引数が指定され、その損失が最初の値として返される場合、モデルは損失を計算できます。
49
+ タプルの要素 (モデルがタプルを返す場合)
50
+ - モデルは複数のラベル引数を受け入れることができます ([`TrainingArguments`] で `label_names` を使用して、その名前を [`Trainer`] に示します) が、それらのいずれにも `"label"` という名前を付ける必要はありません。
51
+
52
+ </Tip>
53
+
54
+ 以下は、加重損失を使用するように [`Trainer`] をカスタマイズする方法の例です (不均衡なトレーニング セットがある場合に役立ちます)。
55
+
56
+ ```python
57
+ from torch import nn
58
+ from transformers import Trainer
59
+
60
+
61
+ class CustomTrainer(Trainer):
62
+ def compute_loss(self, model, inputs, return_outputs=False):
63
+ labels = inputs.pop("labels")
64
+ # forward pass
65
+ outputs = model(**inputs)
66
+ logits = outputs.get("logits")
67
+ # compute custom loss (suppose one has 3 labels with different weights)
68
+ loss_fct = nn.CrossEntropyLoss(weight=torch.tensor([1.0, 2.0, 3.0], device=model.device))
69
+ loss = loss_fct(logits.view(-1, self.model.config.num_labels), labels.view(-1))
70
+ return (loss, outputs) if return_outputs else loss
71
+ ```
72
+
73
+ PyTorch [`Trainer`] のトレーニング ループの動作をカスタマイズするもう 1 つの方法は、トレーニング ループの状態を検査��きる [callbacks](コールバック) を使用することです (進行状況レポート、TensorBoard または他の ML プラットフォームでのログ記録など)。決定(早期停止など)。
74
+
75
+ ## Trainer
76
+
77
+ [[autodoc]] Trainer
78
+ - all
79
+
80
+ ## Seq2SeqTrainer
81
+
82
+ [[autodoc]] Seq2SeqTrainer
83
+ - evaluate
84
+ - predict
85
+
86
+ ## TrainingArguments
87
+
88
+ [[autodoc]] TrainingArguments
89
+ - all
90
+
91
+ ## Seq2SeqTrainingArguments
92
+
93
+ [[autodoc]] Seq2SeqTrainingArguments
94
+ - all
95
+
96
+ ## Checkpoints
97
+
98
+ デフォルトでは、[`Trainer`] はすべてのチェックポイントを、
99
+ [`TrainingArguments`] を使用しています。これらは、xxx を含む`checkpoint-xxx`という名前のサブフォルダーに保存されます。
100
+ それはトレーニングの段階でした。
101
+
102
+ チェックポイントからトレーニングを再開するには、次のいずれかを使用して [`Trainer.train`] を呼び出します。
103
+
104
+ - `resume_from_checkpoint=True` は最新のチェックポイントからトレーニングを再開します
105
+ - `resume_from_checkpoint=checkpoint_dir` ディレクトリ内の特定のチェックポイントからトレーニングを再開します
106
+ 合格した。
107
+
108
+ さらに、`push_to_hub=True` を使用すると、モデル ハブにチェックポイントを簡単に保存できます。デフォルトでは、すべて
109
+ 中間チェックポイントに保存されたモデルは別のコミットに保存されますが、オプティマイザーの状態は保存されません。適応できます
110
+ [`TrainingArguments`] の `hub-strategy` 値を次のいずれかにします。
111
+
112
+ - `"checkpoint"`: 最新のチェックポイントも last-checkpoint という名前のサブフォルダーにプッシュされます。
113
+ `trainer.train(resume_from_checkpoint="output_dir/last-checkpoint")` を使用してトレーニングを簡単に再開します。
114
+ - `"all_checkpoints"`: すべてのチェックポイントは、出力フォルダーに表示されるようにプッシュされます (したがって、1 つのチェックポイントが得られます)
115
+ 最終リポジトリ内のフォルダーごとのチェックポイント フォルダー)
116
+
117
+ ## Logging
118
+
119
+ デフォルトでは、[`Trainer`] はメインプロセスに `logging.INFO` を使用し、レプリカがある場合には `logging.WARNING` を使用します。
120
+
121
+ これらのデフォルトは、[`TrainingArguments`] の 5 つの `logging` レベルのいずれかを使用するようにオーバーライドできます。
122
+ 引数:
123
+
124
+ - `log_level` - メインプロセス用
125
+ - `log_level_replica` - レプリカ用
126
+
127
+ さらに、[`TrainingArguments`] の `log_on_each_node` が `False` に設定されている場合、メイン ノードのみが
128
+ メイン プロセスのログ レベル設定を使用すると、他のすべてのノードはレプリカのログ レベル設定を使用します。
129
+
130
+ [`Trainer`] は、`transformers` のログ レベルをノードごとに個別に設定することに注意してください。
131
+ [`Trainer.__init__`]。したがって、他の機能を利用する場合は、これをより早く設定することをお勧めします (次の例を参照)。
132
+ [`Trainer`] オブジェクトを作成する前の `transformers` 機能。
133
+
134
+ これをアプリケーションで使用する方法の例を次に示します。
135
+
136
+ ```python
137
+ [...]
138
+ logger = logging.getLogger(__name__)
139
+
140
+ # Setup logging
141
+ logging.basicConfig(
142
+ format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
143
+ datefmt="%m/%d/%Y %H:%M:%S",
144
+ handlers=[logging.StreamHandler(sys.stdout)],
145
+ )
146
+
147
+ # set the main code and the modules it uses to the same log-level according to the node
148
+ log_level = training_args.get_process_log_level()
149
+ logger.setLevel(log_level)
150
+ datasets.utils.logging.set_verbosity(log_level)
151
+ transformers.utils.logging.set_verbosity(log_level)
152
+
153
+ trainer = Trainer(...)
154
+ ```
155
+
156
+ そして、メイン ノードと他のすべてのノードで重複する可能性が高いものを出力しないように警告するだけを表示したい場合は、
157
+ 警告: 次のように実行できます。
158
+
159
+ ```bash
160
+ my_app.py ... --log_level warning --log_level_replica error
161
+ ```
162
+
163
+ マルチノード環境で、各ノードのメインプロセスのログを繰り返したくない場合は、次のようにします。
164
+ 上記を次のように変更します。
165
+
166
+ ```bash
167
+ my_app.py ... --log_level warning --log_level_replica error --log_on_each_node 0
168
+ ```
169
+
170
+ その後、最初のノードのメイン プロセスのみが「警告」レベルでログに記録され、メイン ノード上の他のすべてのプロセスはログに記録されます。
171
+ ノードと他のノード上のすべてのプロセスは「エラー」レベルでログに記録されます。
172
+
173
+ アプリケーションをできるだけ静かにする必要がある場合は、次のようにします。
174
+
175
+ ```bash
176
+ my_app.py ... --log_level error --log_level_replica error --log_on_each_node 0
177
+ ```
178
+
179
+ (マルチノード環境の場合は `--log_on_each_node 0` を追加します)
180
+
181
+ ## Randomness
182
+
183
+ [`Trainer`] によって生成されたチェックポイントから再開する場合、すべての努力がその状態を復元するために行われます。
184
+ _python_、_numpy_、および _pytorch_ の RNG 状態は、そのチェックポイントを保存した時点と同じ状態になります。
185
+ これにより、「停止して再開」というスタイルのトレーニングが、ノンストップトレーニングに可能な限り近づけられるはずです。
186
+
187
+ ただし、さまざまなデフォルトの非決定的な pytorch 設定により、これは完全に機能しない可能性があります。フルをご希望の場合は
188
+ 決定論については、[ランダム性のソースの制御](https://pytorch.org/docs/stable/notes/randomness) を参照してください。ドキュメントで説明されているように、これらの設定の一部は
189
+ 物事を決定論的にするもの (例: `torch.backends.cudnn.deterministic`) は物事を遅くする可能性があるため、これは
190
+ デフォルトでは実行できませんが、必要に応じて自分で有効にすることができます。
191
+
192
+ ## Specific GPUs Selection
193
+
194
+ どの GPU をどのような順序で使用するかをプログラムに指示する方法について説明します。
195
+
196
+ [`DistributedDataParallel`](https://pytorch.org/docs/stable/generated/torch.nn.Parallel.DistributedDataParallel.html) を使用して GPU のサブセットのみを使用する場合、使用する GPU の数を指定するだけです。 。たとえば、GPU が 4 つあるが、最初の 2 つを使用したい場合は、次のようにします。
197
+
198
+ ```bash
199
+ torchrun --nproc_per_node=2 trainer-program.py ...
200
+ ```
201
+
202
+ [`accelerate`](https://github.com/huggingface/accelerate) または [`deepspeed`](https://github.com/deepspeedai/DeepSpeed) がインストールされている場合は、次を使用して同じことを達成することもできます。の一つ:
203
+
204
+ ```bash
205
+ accelerate launch --num_processes 2 trainer-program.py ...
206
+ ```
207
+
208
+ ```bash
209
+ deepspeed --num_gpus 2 trainer-program.py ...
210
+ ```
211
+
212
+ これらのランチャーを使用するために、Accelerate または [Deepspeed 統合](deepspeed) 機能を使用する必要はありません。
213
+
214
+
215
+ これまでは、プログラムに使用する GPU の数を指示できました。次に、特定の GPU を選択し、その順序を制御する方法について説明します。
216
+
217
+ 次の環境変数は、使用する GPU とその順序を制御するのに役立ちます。
218
+
219
+ **`CUDA_VISIBLE_DEVICES`**
220
+
221
+ 複数の GPU があり、そのうちの 1 つまたはいくつかの GPU だけを使用したい場合は、環境変数 `CUDA_VISIBLE_DEVICES` を使用する GPU のリストに設定します。
222
+
223
+ たとえば、4 つの GPU (0、1、2、3) があるとします。物理 GPU 0 と 2 のみで実行するには、次のようにします。
224
+
225
+ ```bash
226
+ CUDA_VISIBLE_DEVICES=0,2 torchrun trainer-program.py ...
227
+ ```
228
+
229
+ したがって、pytorch は 2 つの GPU のみを認識し、物理 GPU 0 と 2 はそれぞれ `cuda:0` と `cuda:1` にマッピングされます。
230
+
231
+ 順序を変更することもできます。
232
+
233
+ ```bash
234
+ CUDA_VISIBLE_DEVICES=2,0 torchrun trainer-program.py ...
235
+ ```
236
+
237
+ ここでは、物理 GPU 0 と 2 がそれぞれ`cuda:1`と`cuda:0`にマッピングされています。
238
+
239
+ 上記の例はすべて `DistributedDataParallel` 使用パターンのものですが、同じ方法が [`DataParallel`](https://pytorch.org/docs/stable/generated/torch.nn.DataParallel.html) でも機能します。
240
+
241
+
242
+ ```bash
243
+ CUDA_VISIBLE_DEVICES=2,0 python trainer-program.py ...
244
+ ```
245
+
246
+ GPU のない環境をエミュレートするには、次のようにこの環境変数を空の値に設定するだけです。
247
+
248
+ ```bash
249
+ CUDA_VISIBLE_DEVICES= python trainer-program.py ...
250
+ ```
251
+
252
+ 他の環境変数と同様に、これらをコマンド ラインに追加する代わりに、次のようにエクスポートすることもできます。
253
+
254
+ ```bash
255
+ export CUDA_VISIBLE_DEVICES=0,2
256
+ torchrun trainer-program.py ...
257
+ ```
258
+
259
+ ただし、この方法では、以前に環境変数を設定したことを忘れて、なぜ間違った GPU が使用されているのか理解できない可能性があるため、混乱を招く可能性があります。したがって、このセクションのほとんどの例で示されているように、同じコマンド ラインで特定の実行に対してのみ環境変数を設定するのが一般的です。
260
+
261
+ **`CUDA_DEVICE_ORDER`**
262
+
263
+ 物理デバイスの順序を制御する追加の環境変数 `CUDA_DEVICE_ORDER` があります。選択肢は次の 2 つです。
264
+
265
+ 1. PCIe バス ID 順 (`nvidia-smi` の順序と一致) - これがデフォルトです。
266
+
267
+ ```bash
268
+ export CUDA_DEVICE_ORDER=PCI_BUS_ID
269
+ ```
270
+
271
+ 2. GPU コンピューティング能力順に並べる
272
+
273
+ ```bash
274
+ export CUDA_DEVICE_ORDER=FASTEST_FIRST
275
+ ```
276
+
277
+ ほとんどの場合、この環境変数を気にする必要はありませんが、古い GPU と新しい GPU が物理的に挿入されているため、遅い古いカードが遅くなっているように見えるような偏ったセットアップを行っている場合には、非常に役立ちます。初め。これを解決する 1 つの方法は、カードを交換することです。ただし、カードを交換できない場合 (デバイスの冷却が影響を受けた場合など)、`CUDA_DEVICE_ORDER=FASTEST_FIRST`を設定すると、常に新しい高速カードが最初に配置されます。ただし、`nvidia-smi`は依然として PCIe の順序でレポートするため、多少混乱するでしょう。
278
+
279
+ 順序を入れ替えるもう 1 つの解決策は、以下を使用することです。
280
+
281
+ ```bash
282
+ export CUDA_VISIBLE_DEVICES=1,0
283
+ ```
284
+
285
+ この例では 2 つの GPU だけを使用していますが、もちろん、コンピューターに搭載されている数の GPU にも同じことが当てはまります。
286
+
287
+ また、この環境変数を設定する場合は、`~/.bashrc` ファイルまたはその他の起動設定ファイルに設定して、忘れるのが最善です。
288
+
289
+ ## Trainer Integrations
290
+
291
+ [`Trainer`] は、トレーニングを劇的に改善する可能性のあるライブラリをサポートするように拡張されました。
292
+ 時間とはるかに大きなモデルに適合します。
293
+
294
+ 現在、サードパーティのソリューション [DeepSpeed](https://github.com/deepspeedai/DeepSpeed) および [PyTorch FSDP](https://pytorch.org/docs/stable/fsdp.html) をサポートしています。論文 [ZeRO: メモリの最適化兆パラメータ モデルのトレーニングに向けて、Samyam Rajbhandari、Jeff Rasley、Olatunji Ruwase、Yuxiong He 著](https://arxiv.org/abs/1910.02054)。
295
+
296
+ この提供されるサポートは、この記事の執筆時点では新しくて実験的なものです。 DeepSpeed と PyTorch FSDP のサポートはアクティブであり、それに関する問題は歓迎しますが、FairScale 統合は PyTorch メインに統合されているため、もうサポートしていません ([PyTorch FSDP 統合](#pytorch-fully-sharded-data-parallel))
297
+
298
+ <a id='zero-install-notes'></a>
299
+
300
+ ### CUDA Extension Installation Notes
301
+
302
+ この記事の執筆時点では、Deepspeed を使用するには、CUDA C++ コードをコンパイルする必要があります。
303
+
304
+ すべてのインストールの問題は、[Deepspeed](https://github.com/deepspeedai/DeepSpeed/issues) の対応する GitHub の問題を通じて対処する必要がありますが、ビルド中に発生する可能性のある一般的な問題がいくつかあります。
305
+ CUDA 拡張機能を構築する必要がある PyTorch 拡張機能。
306
+
307
+ したがって、次の操作を実行中に CUDA 関連のビルドの問題が発生した場合は、次のとおりです。
308
+
309
+ ```bash
310
+ pip install deepspeed
311
+ ```
312
+
313
+ まず次の注意事項をお読みください。
314
+
315
+ これらのノートでは、`pytorch` が CUDA `10.2` でビルドされた場合に何をすべきかの例を示します。あなたの状況が次のような場合
316
+ 異なる場合は、バージョン番号を目的のバージョンに調整することを忘れないでください。
317
+
318
+ #### Possible problem #1
319
+
320
+ Pytorch には独自の CUDA ツールキットが付属していますが、これら 2 つのプロジェクトをビルドするには、同一バージョンの CUDA が必要です。
321
+ システム全体にインストールされます。
322
+
323
+ たとえば、Python 環境に `cudatoolkit==10.2` を指定して `pytorch` をインストールした場合は、次のものも必要です。
324
+ CUDA `10.2` がシステム全体にインストールされました。
325
+
326
+ 正確な場所はシステムによって異なる場合がありますが、多くのシステムでは`/usr/local/cuda-10.2`が最も一般的な場所です。
327
+ Unix システム。 CUDA が正しく設定され、`PATH`環境変数に追加されると、
328
+ 次のようにしてインストール場所を指定します。
329
+
330
+
331
+ ```bash
332
+ which nvcc
333
+ ```
334
+
335
+ CUDA がシステム全体にインストールされていない場合は、最初にインストールしてください。お気に入りを使用して手順を見つけることができます
336
+ 検索エンジン。たとえば、Ubuntu を使用している場合は、[ubuntu cuda 10.2 install](https://www.google.com/search?q=ubuntu+cuda+10.2+install) を検索するとよいでしょう。
337
+
338
+ #### Possible problem #2
339
+
340
+ もう 1 つの考えられる一般的な問題は、システム全体に複数の CUDA ツールキットがインストールされている可能性があることです。たとえばあなた
341
+ がある可能性があり:
342
+
343
+ ```bash
344
+ /usr/local/cuda-10.2
345
+ /usr/local/cuda-11.0
346
+ ```
347
+
348
+ この状況では、`PATH` および `LD_LIBRARY_PATH` 環境変数に以下が含まれていることを確認する必要があります。
349
+ 目的の CUDA バージョンへの正しいパス。通常、パッケージ インストーラーは、これらに、
350
+ 最後のバージョンがインストールされました。適切なパッケージが見つからないためにパッケージのビルドが失敗するという問題が発生した場合は、
351
+ CUDA バージョンがシステム全体にインストールされているにもかかわらず、前述の 2 つを調整する必要があることを意味します
352
+ 環境変数。
353
+
354
+ まず、その内容を見てみましょう。
355
+
356
+ ```bash
357
+ echo $PATH
358
+ echo $LD_LIBRARY_PATH
359
+ ```
360
+
361
+ それで、中に何が入っているかがわかります。
362
+
363
+ `LD_LIBRARY_PATH` が空である可能性があります。
364
+
365
+ `PATH` は実行可能ファイルが存在する場所をリストし、`LD_LIBRARY_PATH` は共有ライブラリの場所を示します。
366
+ 探すことです。どちらの場合も、前のエントリが後のエントリより優先されます。 `:` は複数を区切るために使用されます
367
+ エントリ。
368
+
369
+ ここで、ビルド プログラムに特定の CUDA ツールキットの場所を指示するには、最初にリストされる希望のパスを挿入します。
370
+ やっていること:
371
+
372
+ ```bash
373
+ export PATH=/usr/local/cuda-10.2/bin:$PATH
374
+ export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
375
+ ```
376
+
377
+ 既存の値を上書きするのではなく、先頭に追加することに注意してください。
378
+
379
+ もちろん、必要に応じてバージョン番号やフルパスを調整します。割り当てたディレクトリが実際に機能することを確認してください
380
+ 存在する。 `lib64` サブディレクトリは、`libcudart.so` などのさまざまな CUDA `.so` オブジェクトが存在する場所です。
381
+ システムでは別の名前が付けられますが、現実を反映するように調整してください。
382
+
383
+ #### Possible problem #3
384
+
385
+ 一部の古い CUDA バージョンは、新しいコンパイラでのビルドを拒否する場合があります。たとえば、あなたは`gcc-9`を持っていますが、それが必要です
386
+ `gcc-7`。
387
+
388
+ それにはさまざまな方法があります。
389
+
390
+ 最新の CUDA ツールキットをインストールできる場合は、通常、新しいコンパイラがサポートされているはずです。
391
+
392
+ あるいは、既に所有しているコンパイラに加えて、下位バージョンのコンパイラをインストールすることもできます。
393
+ すでに存在しますが、デフォルトではないため、ビルドシステムはそれを認識できません。 「gcc-7」がインストールされているが、
394
+ ビルドシステムが見つからないというメッセージを表示する場合は、次の方法で解決できる可能性があります。
395
+
396
+ ```bash
397
+ sudo ln -s /usr/bin/gcc-7 /usr/local/cuda-10.2/bin/gcc
398
+ sudo ln -s /usr/bin/g++-7 /usr/local/cuda-10.2/bin/g++
399
+ ```
400
+
401
+ ここでは、`/usr/local/cuda-10.2/bin/gcc` から `gcc-7` へのシンボリックリンクを作成しています。
402
+ `/usr/local/cuda-10.2/bin/` は `PATH` 環境変数内にある必要があります (前の問題の解決策を参照)。
403
+ `gcc-7` (および `g++7`) が見つかるはずで、ビルドは成功します。
404
+
405
+ いつものように、状況に合わせて例のパスを編集してください。
406
+
407
+ ### PyTorch Fully Sharded Data parallel
408
+
409
+ より大きなバッチ サイズで巨大なモデルのトレーニングを高速化するには、完全にシャード化されたデータ並列モデルを使用できます。
410
+ このタイプのデータ並列パラダイムでは、オプティマイザーの状態、勾配、パラメーターをシャーディングすることで、より多くのデータと大規模なモデルをフィッティングできます。
411
+ この機能とその利点の詳細については、[完全シャーディング データ並列ブログ](https://pytorch.org/blog/introducing-pytorch-full-sharded-data-Parallel-api/) をご覧ください。
412
+ 最新の PyTorch の Fully Sharded Data Parallel (FSDP) トレーニング機能を統合しました。
413
+ 必要なのは、設定を通じて有効にすることだけです。
414
+
415
+ **FSDP サポートに必要な PyTorch バージョン**: PyTorch Nightly (リリース後にこれを読んだ場合は 1.12.0)
416
+ FSDP を有効にしたモデルの保存は、最近の修正でのみ利用できるためです。
417
+
418
+ **使用法**:
419
+
420
+ - 配布されたランチャーが追加されていることを確認してください
421
+ まだ使用していない場合は、`-m torch.distributed.launch --nproc_per_node=NUMBER_OF_GPUS_YOU_HAVE`を使用します。
422
+
423
+ - **シャーディング戦略**:
424
+ - FULL_SHARD : データ並列ワーカー/GPU にわたるシャード オプティマイザーの状態 + 勾配 + モデル パラメーター。
425
+ このためには、コマンドライン引数に`--fsdp full_shard`を追加します。
426
+ - SHARD_GRAD_OP : シャード オプティマイザーの状態 + データ並列ワーカー/GPU 全体の勾配。
427
+ このためには、コマンドライン引数に`--fsdp shard_grad_op`を追加します。
428
+ - NO_SHARD : シャーディングなし。このためには、コマンドライン引数に`--fsdp no_shard`を追加します。
429
+ - パラメータと勾配を CPU にオフロードするには、
430
+ コマンドライン引数に`--fsdp "full_shard offload"`または`--fsdp "shard_grad_op offload"`を追加します。
431
+ - `default_auto_wrap_policy` を使用して FSDP でレイヤーを自動的に再帰的にラップするには、
432
+ コマンドライン引数に`--fsdp "full_shard auto_wrap"`または`--fsdp "shard_grad_op auto_wrap"`を追加します。
433
+ - CPU オフロードと自動ラッピングの両方を有効にするには、
434
+ コマンドライン引数に`--fsdp "full_shard offload auto_wrap"`または`--fsdp "shard_grad_op offload auto_wrap"`を追加します。
435
+ - 残りの FSDP 構成は、`--fsdp_config <path_to_fsdp_config.json>`を介して渡されます。それは、次のいずれかの場所です。
436
+ FSDP json 構成ファイル (例: `fsdp_config.json`)、またはすでにロードされている json ファイルを `dict` として使用します。
437
+ - 自動ラッピングが有効な場合は、トランスベースの自動ラップ ポリシーまたはサイズ ベースの自動ラップ ポリシーを使用できます。
438
+ - トランスフォーマーベースの自動ラップポリシーの場合、構成ファイルで `fsdp_transformer_layer_cls_to_wrap` を指定することをお勧めします。指定しない場合、使用可能な場合、デフォルト値は `model._no_split_modules` になります。
439
+ これは、ラップするトランスフォーマー層クラス名のリスト (大文字と小文字を区別) を指定します (例: [`BertLayer`]、[`GPTJBlock`]、[`T5Block`] ...)。
440
+ 重みを共有するサブモジュール (埋め込み層など) が異なる FSDP ラップされたユニットにならないようにする必要があるため、これは重要です。
441
+ このポリシーを使用すると、マルチヘッド アテンションとそれに続くいくつかの MLP レイヤーを含むブロックごとにラッピングが発生します。
442
+ 共有埋め込みを含む残りの層は、同じ最も外側の FSDP ユニットにラップされるのが便利です。
443
+ したがって、トランスベースのモデルにはこれを使用してください。
444
+ - サイズベースの自動ラップポリシーの場合は、設定ファイルに`fsdp_min_num_params`を追加してください。
445
+ 自動ラッピングのための FSDP のパラメータの最小数を指定します。
446
+ - 設定ファイルで `fsdp_backward_prefetch` を指定できるようになりました。次のパラメータのセットをいつプリフェッチするかを制御します。
447
+ `backward_pre` と `backward_pos` が利用可能なオプションです。
448
+ 詳細については、`torch.distributed.fsdp.full_sharded_data_Parallel.BackwardPrefetch`を参照してください。
449
+ - 設定ファイルで `fsdp_forward_prefetch` を指定できるようになりました。次のパラメータのセットをいつプリフェッチするかを制御します。
450
+ `True`の場合、FSDP はフォワード パスでの実行中に、次に来るオールギャザーを明示的にプリフェッチします。
451
+ - 設定ファイルで `limit_all_gathers` を指定できるようになりました。
452
+ `True`の場合、FSDP は CPU スレッドを明示的に同期して、実行中のオールギャザが多すぎるのを防ぎます。
453
+ - `activation_checkpointing`を設定ファイルで指定できるようになりました。
454
+ `True`の場合、FSDP アクティベーション チェックポイントは、FSDP のアクティベーションをクリアすることでメモリ使用量を削減する手法です。
455
+ 特定のレイヤーを処理し、バックワード パス中にそれらを再計算します。事実上、これは余分な計算時間を犠牲にします
456
+ メモリ使用量を削減します。
457
+
458
+ **注意すべき注意点がいくつかあります**
459
+ - これは `generate` と互換性がないため、 `--predict_with_generate` とも互換性がありません
460
+ すべての seq2seq/clm スクリプト (翻訳/要約/clm など)。
461
+ 問題 [#21667](https://github.com/huggingface/transformers/issues/21667) を参照してください。
462
+
463
+ ### PyTorch/XLA Fully Sharded Data parallel
464
+
465
+ TPU ユーザーの皆様に朗報です。 PyTorch/XLA は FSDP をサポートするようになりました。
466
+ 最新の Fully Sharded Data Parallel (FSDP) トレーニングがすべてサポートされています。
467
+ 詳細については、[FSDP を使用した Cloud TPU での PyTorch モデルのスケーリング](https://pytorch.org/blog/scaling-pytorch-models-on-cloud-tpus-with-fsdp/) および [PyTorch/XLA 実装 を参照してください。 FSDP の](https://github.com/pytorch/xla/tree/master/torch_xla/distributed/fsdp)
468
+ 必要なのは、設定を通じて有効にすることだけです。
469
+
470
+ **FSDP サポートに必要な PyTorch/XLA バージョン**: >=2.0
471
+
472
+ **使用法**:
473
+
474
+ `--fsdp "full shard"` を、`--fsdp_config <path_to_fsdp_config.json>` に加えられる次の変更とともに渡します。
475
+ - PyTorch/XLA FSDP を有効にするには、`xla`を`True`に設定する必要があります。
476
+ - `xla_fsdp_settings` 値は、XLA FSDP ラッピング パラメータを格納する辞書です。
477
+ オプションの完全なリストについては、[こちら](
478
+ https://github.com/pytorch/xla/blob/master/torch_xla/distributed/fsdp/xla_full_sharded_data_Parallel.py)。
479
+ - `xla_fsdp_grad_ckpt`。 `True`の場合、ネストされた XLA FSDP でラップされた各レイヤー上で勾配チェックポイントを使用します。
480
+ この設定は、xla フラグが true に設定されており、自動ラッピング ポリシーが指定されている場合にのみ使用できます。
481
+ `fsdp_min_num_params` または `fsdp_transformer_layer_cls_to_wrap`。
482
+ - トランスフォーマー ベースの自動ラップ ポリシーまたはサイズ ベースの自動ラップ ポリシーのいずれかを使用できます。
483
+ - トランスフォーマーベースの自動ラップポリシーの場合、構成ファイルで `fsdp_transformer_layer_cls_to_wrap` を指定することをお勧めします。指定しない場合、使用可能な場合、デフォルト値は `model._no_split_modules` になります。
484
+ これは、ラップするトランスフォーマー層クラス名のリスト (大文字と小文字を区別) を指定します (例: [`BertLayer`]、[`GPTJBlock`]、[`T5Block`] ...)。
485
+ 重みを共有するサブモジュール (埋め込み層など) が異なる FSDP ラップされたユニットにならないようにする必要があるため、これは重要です。
486
+ このポリシーを使用すると、マルチヘッド アテンションとそれに続くいくつかの MLP レイヤーを含むブロックごとにラッピングが発生します。
487
+ 共有埋め込みを含む残りの層は、同じ最も外側の FSDP ユニットにラップされるのが便利です。
488
+ したがって、トランスベースのモデルにはこれを使用してください。
489
+ - サイズベースの自動ラップポリシーの場合は、設定ファイルに`fsdp_min_num_params`を追加してください。
490
+ 自動ラッピングのための FSDP のパラメータの最小数を指定します。
491
+
492
+ ### Using Trainer for accelerated PyTorch Training on Mac
493
+
494
+ PyTorch v1.12 リリースにより、開発者と研究者は Apple シリコン GPU を利用してモデル トレーニングを大幅に高速化できます。
495
+ これにより、プロトタイピングや微調整などの機械学習ワークフローを Mac 上でローカルで実行できるようになります。
496
+ PyTorch のバックエンドとしての Apple の Metal Performance Shaders (MPS) はこれを可能にし、新しい `"mps"` デバイス経由で使用できます。
497
+ これにより、計算グラフとプリミティブが MPS Graph フレームワークと MPS によって提供される調整されたカーネルにマッピングされます。
498
+ 詳細については、公式ドキュメント [Mac での Accelerated PyTorch Training の紹介](https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/) を参照してください。
499
+ および [MPS バックエンド](https://pytorch.org/docs/stable/notes/mps.html)。
500
+
501
+ <Tip warning={false}>
502
+
503
+ MacOS マシンに PyTorch >= 1.13 (執筆時点ではナイトリー バージョン) をインストールすることを強くお勧めします。
504
+ トランスベースのモデルのモデルの正確性とパフォーマンスの向上に関連する主要な修正が行われています。
505
+ 詳細については、https://github.com/pytorch/pytorch/issues/82707 を参照してください。
506
+
507
+ </Tip>
508
+
509
+ **Apple Silicon チップを使用したトレーニングと推論の利点**
510
+
511
+ 1. ユーザーがローカルで大規模なネットワークやバッチ サイズをトレーニングできるようにします
512
+ 2. ユニファイド メモリ アーキテクチャにより、データ取得の遅延が短縮され、GPU がメモリ ストア全体に直接アクセスできるようになります。
513
+ したがって、エンドツーエンドのパフォーマンスが向上します。
514
+ 3. クラウドベースの開発に関連するコストや追加のローカル GPU の必要性を削減します。
515
+
516
+ **前提条件**: mps サポートを備えたトーチをイン��トールするには、
517
+ この素晴らしいメディア記事 [GPU アクセラレーションが M1 Mac の PyTorch に登場](https://medium.com/towards-data-science/gpu-acceleration-comes-to-pytorch-on-m1-macs-195c399efcc1) に従ってください。 。
518
+
519
+ **使用法**:
520
+ `mps` デバイスは、`cuda` デバイスが使用される方法と同様に利用可能な場合、デフォルトで使用されます。
521
+ したがって、ユーザーによるアクションは必要ありません。
522
+ たとえば、以下のコマンドを使用して、Apple Silicon GPU を使用して公式の Glue テキスト分類タスクを (ルート フォルダーから) 実行できます。
523
+
524
+ ```bash
525
+ export TASK_NAME=mrpc
526
+
527
+ python examples/pytorch/text-classification/run_glue.py \
528
+ --model_name_or_path google-bert/bert-base-cased \
529
+ --task_name $TASK_NAME \
530
+ --do_train \
531
+ --do_eval \
532
+ --max_seq_length 128 \
533
+ --per_device_train_batch_size 32 \
534
+ --learning_rate 2e-5 \
535
+ --num_train_epochs 3 \
536
+ --output_dir /tmp/$TASK_NAME/ \
537
+ --overwrite_output_dir
538
+ ```
539
+
540
+ **注意すべきいくつかの注意事項**
541
+
542
+ 1. 一部の PyTorch 操作は mps に実装されていないため、エラーがスローされます。
543
+ これを回避する 1 つの方法は、環境変数 `PYTORCH_ENABLE_MPS_FALLBACK=1` を設定することです。
544
+ これらの操作では CPU にフォールバックします。ただし、それでも UserWarning がスローされます。
545
+ 2. 分散セットアップ`gloo`および`nccl`は、`mps`デバイスでは動作しません。
546
+ これは、現在「mps」デバイス タイプの単一 GPU のみを使用できることを意味します。
547
+
548
+ 最後に、覚えておいてください。 🤗 `Trainer` は MPS バックエンドのみを統合するため、
549
+ MPS バックエンドの使用に関して問題や質問がある場合は、
550
+ [PyTorch GitHub](https://github.com/pytorch/pytorch/issues) に問題を提出してください。
551
+
552
+ ## Using Accelerate Launcher with Trainer
553
+
554
+ 加速してトレーナーにパワーを与えましょう。ユーザーが期待することに関しては、次のとおりです。
555
+ - トレーナー引数に対して FSDP、DeepSpeed などのトレーナー インテレーションを変更せずに使用し続けることができます。
556
+ - トレーナーで Accelerate Launcher を使用できるようになりました (推奨)。
557
+
558
+ トレーナーで Accelerate Launcher を使用する手順:
559
+ 1. 🤗 Accelerate がインストールされていることを確認してください。Accelerate がないと `Trainer` を使用することはできません。そうでない場合は、`pip install accelerate`してください。 Accelerate のバージョンを更新する必要がある場合もあります: `pip install activate --upgrade`
560
+ 2. `accelerate config`を実行し、アンケートに記入します。以下は加速設定の例です。
561
+ a. DDP マルチノード マルチ GPU 構成:
562
+ ```yaml
563
+ compute_environment: LOCAL_MACHINE
564
+ distributed_type: MULTI_GPU
565
+ downcast_bf16: 'no'
566
+ gpu_ids: all
567
+ machine_rank: 0 #change rank as per the node
568
+ main_process_ip: 192.168.20.1
569
+ main_process_port: 9898
570
+ main_training_function: main
571
+ mixed_precision: fp16
572
+ num_machines: 2
573
+ num_processes: 8
574
+ rdzv_backend: static
575
+ same_network: true
576
+ tpu_env: []
577
+ tpu_use_cluster: false
578
+ tpu_use_sudo: false
579
+ use_cpu: false
580
+ ```
581
+
582
+ b. FSDP config:
583
+ ```yaml
584
+ compute_environment: LOCAL_MACHINE
585
+ distributed_type: FSDP
586
+ downcast_bf16: 'no'
587
+ fsdp_config:
588
+ fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP
589
+ fsdp_backward_prefetch_policy: BACKWARD_PRE
590
+ fsdp_forward_prefetch: true
591
+ fsdp_offload_params: false
592
+ fsdp_sharding_strategy: 1
593
+ fsdp_state_dict_type: FULL_STATE_DICT
594
+ fsdp_sync_module_states: true
595
+ fsdp_transformer_layer_cls_to_wrap: BertLayer
596
+ fsdp_use_orig_params: true
597
+ machine_rank: 0
598
+ main_training_function: main
599
+ mixed_precision: bf16
600
+ num_machines: 1
601
+ num_processes: 2
602
+ rdzv_backend: static
603
+ same_network: true
604
+ tpu_env: []
605
+ tpu_use_cluster: false
606
+ tpu_use_sudo: false
607
+ use_cpu: false
608
+ ```
609
+ c.ファイルを指す DeepSpeed 構成:
610
+ ```yaml
611
+ compute_environment: LOCAL_MACHINE
612
+ deepspeed_config:
613
+ deepspeed_config_file: /home/user/configs/ds_zero3_config.json
614
+ zero3_init_flag: true
615
+ distributed_type: DEEPSPEED
616
+ downcast_bf16: 'no'
617
+ machine_rank: 0
618
+ main_training_function: main
619
+ num_machines: 1
620
+ num_processes: 4
621
+ rdzv_backend: static
622
+ same_network: true
623
+ tpu_env: []
624
+ tpu_use_cluster: false
625
+ tpu_use_sudo: false
626
+ use_cpu: false
627
+ ```
628
+
629
+ d.加速プラグインを使用した DeepSpeed ���成:
630
+
631
+ ```yaml
632
+ compute_environment: LOCAL_MACHINE
633
+ deepspeed_config:
634
+ gradient_accumulation_steps: 1
635
+ gradient_clipping: 0.7
636
+ offload_optimizer_device: cpu
637
+ offload_param_device: cpu
638
+ zero3_init_flag: true
639
+ zero_stage: 2
640
+ distributed_type: DEEPSPEED
641
+ downcast_bf16: 'no'
642
+ machine_rank: 0
643
+ main_training_function: main
644
+ mixed_precision: bf16
645
+ num_machines: 1
646
+ num_processes: 4
647
+ rdzv_backend: static
648
+ same_network: true
649
+ tpu_env: []
650
+ tpu_use_cluster: false
651
+ tpu_use_sudo: false
652
+ use_cpu: false
653
+ ```
654
+
655
+ 3. 加速設定またはランチャー引数によって上記で処理された引数以外の引数を使用して、トレーナー スクリプトを実行します。
656
+ 以下は、上記の FSDP 構成で`accelerate launcher`を使用して`run_glue.py`を実行する例です。
657
+
658
+ ```bash
659
+ cd transformers
660
+
661
+ accelerate launch \
662
+ ./examples/pytorch/text-classification/run_glue.py \
663
+ --model_name_or_path google-bert/bert-base-cased \
664
+ --task_name $TASK_NAME \
665
+ --do_train \
666
+ --do_eval \
667
+ --max_seq_length 128 \
668
+ --per_device_train_batch_size 16 \
669
+ --learning_rate 5e-5 \
670
+ --num_train_epochs 3 \
671
+ --output_dir /tmp/$TASK_NAME/ \
672
+ --overwrite_output_dir
673
+ ```
674
+
675
+ 4. `accelerate launch`するための cmd 引数を直接使用することもできます。上の例は次のようにマッピングされます。
676
+
677
+ ```bash
678
+ cd transformers
679
+
680
+ accelerate launch --num_processes=2 \
681
+ --use_fsdp \
682
+ --mixed_precision=bf16 \
683
+ --fsdp_auto_wrap_policy=TRANSFORMER_BASED_WRAP \
684
+ --fsdp_transformer_layer_cls_to_wrap="BertLayer" \
685
+ --fsdp_sharding_strategy=1 \
686
+ --fsdp_state_dict_type=FULL_STATE_DICT \
687
+ ./examples/pytorch/text-classification/run_glue.py
688
+ --model_name_or_path google-bert/bert-base-cased \
689
+ --task_name $TASK_NAME \
690
+ --do_train \
691
+ --do_eval \
692
+ --max_seq_length 128 \
693
+ --per_device_train_batch_size 16 \
694
+ --learning_rate 5e-5 \
695
+ --num_train_epochs 3 \
696
+ --output_dir /tmp/$TASK_NAME/ \
697
+ --overwrite_output_dir
698
+ ```
699
+
700
+ 詳細については、🤗 Accelerate CLI ガイドを参照してください: [🤗 Accelerate スクリプトの起動](https://huggingface.co/docs/accelerate/basic_tutorials/launch)。
701
+
702
+ 移動されたセクション:
703
+
704
+ [ <a href="./deepspeed#deepspeed-trainer-integration">DeepSpeed</a><a id="deepspeed"></a>
705
+ | <a href="./deepspeed#deepspeed-installation">Installation</a><a id="installation"></a>
706
+ | <a href="./deepspeed#deepspeed-multi-gpu">Deployment with multiple GPUs</a><a id="deployment-with-multiple-gpus"></a>
707
+ | <a href="./deepspeed#deepspeed-one-gpu">Deployment with one GPU</a><a id="deployment-with-one-gpu"></a>
708
+ | <a href="./deepspeed#deepspeed-notebook">Deployment in Notebooks</a><a id="deployment-in-notebooks"></a>
709
+ | <a href="./deepspeed#deepspeed-config">Configuration</a><a id="configuration"></a>
710
+ | <a href="./deepspeed#deepspeed-config-passing">Passing Configuration</a><a id="passing-configuration"></a>
711
+ | <a href="./deepspeed#deepspeed-config-shared">Shared Configuration</a><a id="shared-configuration"></a>
712
+ | <a href="./deepspeed#deepspeed-zero">ZeRO</a><a id="zero"></a>
713
+ | <a href="./deepspeed#deepspeed-zero2-config">ZeRO-2 Config</a><a id="zero-2-config"></a>
714
+ | <a href="./deepspeed#deepspeed-zero3-config">ZeRO-3 Config</a><a id="zero-3-config"></a>
715
+ | <a href="./deepspeed#deepspeed-nvme">NVMe Support</a><a id="nvme-support"></a>
716
+ | <a href="./deepspeed#deepspeed-zero2-zero3-performance">ZeRO-2 vs ZeRO-3 Performance</a><a id="zero-2-vs-zero-3-performance"></a>
717
+ | <a href="./deepspeed#deepspeed-zero2-example">ZeRO-2 Example</a><a id="zero-2-example"></a>
718
+ | <a href="./deepspeed#deepspeed-zero3-example">ZeRO-3 Example</a><a id="zero-3-example"></a>
719
+ | <a href="./deepspeed#deepspeed-optimizer">Optimizer</a><a id="optimizer"></a>
720
+ | <a href="./deepspeed#deepspeed-scheduler">Scheduler</a><a id="scheduler"></a>
721
+ | <a href="./deepspeed#deepspeed-fp32">fp32 Precision</a><a id="fp32-precision"></a>
722
+ | <a href="./deepspeed#deepspeed-amp">Automatic Mixed Precision</a><a id="automatic-mixed-precision"></a>
723
+ | <a href="./deepspeed#deepspeed-bs">Batch Size</a><a id="batch-size"></a>
724
+ | <a href="./deepspeed#deepspeed-grad-acc">Gradient Accumulation</a><a id="gradient-accumulation"></a>
725
+ | <a href="./deepspeed#deepspeed-grad-clip">Gradient Clipping</a><a id="gradient-clipping"></a>
726
+ | <a href="./deepspeed#deepspeed-weight-extraction">Getting The Model Weights Out</a><a id="getting-the-model-weights-out"></a>
727
+ ]
docs/transformers/docs/source/ja/model_doc/albert.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # ALBERT
18
+
19
+ <div class="flex flex-wrap space-x-1">
20
+ <a href="https://huggingface.co/models?filter=albert">
21
+ <img alt="Models" src="https://img.shields.io/badge/All_model_pages-albert-blueviolet">
22
+ </a>
23
+ <a href="https://huggingface.co/spaces/docs-demos/albert-base-v2">
24
+ <img alt="Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue">
25
+ </a>
26
+ </div>
27
+
28
+ ## 概要
29
+
30
+ ALBERTモデルは、「[ALBERT: A Lite BERT for Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942)」という論文でZhenzhong Lan、Mingda Chen、Sebastian Goodman、Kevin Gimpel、Piyush Sharma、Radu Soricutによって提案されました。BERTのメモリ消費を減らしトレーニングを高速化するためのパラメータ削減技術を2つ示しています:
31
+
32
+ - 埋め込み行列を2つの小さな行列に分割する。
33
+ - グループ間で分割された繰り返し層を使用する。
34
+
35
+ 論文の要旨は以下の通りです:
36
+
37
+ *自然言語表現の事前学習時にモデルのサイズを増やすと、下流タスクのパフォーマンスが向上することがしばしばあります。しかし、ある時点でさらなるモデルの増大は、GPU/TPUのメモリ制限、長い訓練時間、予期せぬモデルの劣化といった問題のために困難になります。これらの問題に対処するために、我々はBERTのメモリ消費を低減し、訓練速度を高めるための2つのパラメータ削減技術を提案します。包括的な実証的証拠は、我々の提案方法が元のBERTに比べてはるかによくスケールするモデルを生み出すことを示しています。また、文間の一貫性をモデリングに焦点を当てた自己教師あり損失を使用し、複数の文が含まれる下流タスクに一貫して助けとなることを示します。その結果、我々の最良のモデルは、BERT-largeに比べてパラメータが少ないにもかかわらず、GLUE、RACE、SQuADベンチマークで新たな最先端の結果を確立します。*
38
+
39
+ このモデルは[lysandre](https://huggingface.co/lysandre)により提供されました。このモデルのjaxバージョンは[kamalkraj](https://huggingface.co/kamalkraj)により提供されました。オリジナルのコードは[こちら](https://github.com/google-research/ALBERT)で見ることができます。
40
+
41
+ ## 使用上のヒント
42
+
43
+ - ALBERTは絶対位置埋め込みを使用するモデルなので、通常、入力を左側ではなく右側にパディングすることが推奨されます。
44
+ - ALBERTは繰り返し層を使用するためメモリ使用量は小さくなりますが、同じ数の(繰り返し)層を反復しなければならないため、隠れ層の数が同じであればBERTのようなアーキテクチャと同様の計算コストがかかります。
45
+ - 埋め込みサイズEは隠れサイズHと異なりますが、これは埋め込みが文脈に依存しない(一つの埋め込みベクトルが一つのトークンを表す)のに対し、隠れ状態は文脈に依存する(1つの隠れ状態がトークン系列を表す)ため、H >> Eとすることがより論理的です。また、埋め込み行列のサイズはV x Eと大きいです(Vは語彙サイズ)。E < Hであれば、パラメータは少なくなります。
46
+ - 層はパラメータを共有するグループに分割されています(メモリ節約のため)。次文予測(NSP: Next Sentence Prediction)は文の順序予測に置き換えられます:入力では、2つの文AとB(それらは連続している)があり、Aに続いてBを与えるか、Bに続いてAを与えます。モデルはそれらが入れ替わっているかどうかを予測する必要があります。
47
+
48
+ ## 参考資料
49
+
50
+ - [テキスト分類タスクガイド](../tasks/sequence_classification)
51
+ - [トークン分類タスクガイド](../tasks/token_classification)
52
+ - [質問応答タスクガイド](../tasks/question_answering)
53
+ - [マスクされた言語モデルタスクガイド](../tasks/masked_language_modeling)
54
+ - [多肢選択タスクガイド](../tasks/multiple_choice)
55
+
56
+ ## AlbertConfig
57
+
58
+ [[autodoc]] AlbertConfig
59
+
60
+ ## AlbertTokenizer
61
+
62
+ [[autodoc]] AlbertTokenizer
63
+ - build_inputs_with_special_tokens
64
+ - get_special_tokens_mask
65
+ - create_token_type_ids_from_sequences
66
+ - save_vocabulary
67
+
68
+ ## AlbertTokenizerFast
69
+
70
+ [[autodoc]] AlbertTokenizerFast
71
+
72
+ ## Albert specific outputs
73
+
74
+ [[autodoc]] models.albert.modeling_albert.AlbertForPreTrainingOutput
75
+
76
+ [[autodoc]] models.albert.modeling_tf_albert.TFAlbertForPreTrainingOutput
77
+
78
+ <frameworkcontent>
79
+ <pt>
80
+
81
+ ## AlbertModel
82
+
83
+ [[autodoc]] AlbertModel
84
+ - forward
85
+
86
+ ## AlbertForPreTraining
87
+
88
+ [[autodoc]] AlbertForPreTraining
89
+ - forward
90
+
91
+ ## AlbertForMaskedLM
92
+
93
+ [[autodoc]] AlbertForMaskedLM
94
+ - forward
95
+
96
+ ## AlbertForSequenceClassification
97
+
98
+ [[autodoc]] AlbertForSequenceClassification
99
+ - forward
100
+
101
+ ## AlbertForMultipleChoice
102
+
103
+ [[autodoc]] AlbertForMultipleChoice
104
+
105
+ ## AlbertForTokenClassification
106
+
107
+ [[autodoc]] AlbertForTokenClassification
108
+ - forward
109
+
110
+ ## AlbertForQuestionAnswering
111
+
112
+ [[autodoc]] AlbertForQuestionAnswering
113
+ - forward
114
+
115
+ </pt>
116
+
117
+ <tf>
118
+
119
+ ## TFAlbertModel
120
+
121
+ [[autodoc]] TFAlbertModel
122
+ - call
123
+
124
+ ## TFAlbertForPreTraining
125
+
126
+ [[autodoc]] TFAlbertForPreTraining
127
+ - call
128
+
129
+ ## TFAlbertForMaskedLM
130
+
131
+ [[autodoc]] TFAlbertForMaskedLM
132
+ - call
133
+
134
+ ## TFAlbertForSequenceClassification
135
+
136
+ [[autodoc]] TFAlbertForSequenceClassification
137
+ - call
138
+
139
+ ## TFAlbertForMultipleChoice
140
+
141
+ [[autodoc]] TFAlbertForMultipleChoice
142
+ - call
143
+
144
+ ## TFAlbertForTokenClassification
145
+
146
+ [[autodoc]] TFAlbertForTokenClassification
147
+ - call
148
+
149
+ ## TFAlbertForQuestionAnswering
150
+
151
+ [[autodoc]] TFAlbertForQuestionAnswering
152
+ - call
153
+
154
+ </tf>
155
+ <jax>
156
+
157
+ ## FlaxAlbertModel
158
+
159
+ [[autodoc]] FlaxAlbertModel
160
+ - __call__
161
+
162
+ ## FlaxAlbertForPreTraining
163
+
164
+ [[autodoc]] FlaxAlbertForPreTraining
165
+ - __call__
166
+
167
+ ## FlaxAlbertForMaskedLM
168
+
169
+ [[autodoc]] FlaxAlbertForMaskedLM
170
+ - __call__
171
+
172
+ ## FlaxAlbertForSequenceClassification
173
+
174
+ [[autodoc]] FlaxAlbertForSequenceClassification
175
+ - __call__
176
+
177
+ ## FlaxAlbertForMultipleChoice
178
+
179
+ [[autodoc]] FlaxAlbertForMultipleChoice
180
+ - __call__
181
+
182
+ ## FlaxAlbertForTokenClassification
183
+
184
+ [[autodoc]] FlaxAlbertForTokenClassification
185
+ - __call__
186
+
187
+ ## FlaxAlbertForQuestionAnswering
188
+
189
+ [[autodoc]] FlaxAlbertForQuestionAnswering
190
+ - __call__
191
+
192
+ </jax>
193
+ </frameworkcontent>
docs/transformers/docs/source/ja/model_doc/align.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # ALIGN
18
+
19
+ ## 概要
20
+
21
+ ALIGNモデルは、「[Scaling Up Visual and Vision-Language Representation Learning With Noisy Text Supervision](https://arxiv.org/abs/2102.05918)」という論文でChao Jia、Yinfei Yang、Ye Xia、Yi-Ting Chen、Zarana Parekh、Hieu Pham、Quoc V. Le、Yunhsuan Sung、Zhen Li、Tom Duerigによって提案されました。ALIGNはマルチモーダルな視覚言語モデルです。これは画像とテキストの類似度や、ゼロショット画像分類に使用できます。ALIGNは[EfficientNet](efficientnet)を視覚エンコーダーとして、[BERT](bert)をテキストエンコーダーとして搭載したデュアルエンコーダー構造を特徴とし、対照学習によって視覚とテキストの表現を整合させることを学びます。それまでの研究とは異なり、ALIGNは巨大でノイジーなデータセットを活用し、コーパスのスケールを利用して単純な方法ながら最先端の表現を達成できることを示しています。
22
+
23
+ 論文の要旨は以下の通りです:
24
+
25
+ *事前学習された表現は、多くの自然言語処理(NLP)および知覚タスクにとって重要になっています。NLPにおける表現学習は、人間のアノテーションのない生のテキストでの学習へと移行していますが、視覚および視覚言語の表現は依然として精巧な学習データセットに大きく依存しており、これは高価であったり専門知識を必要としたりします。視覚アプリケーションの場合、ImageNetやOpenImagesのような明示的なクラスラベルを持つデータセットを使用して学習されることがほとんどです。視覚言語の場合、Conceptual Captions、MSCOCO、CLIPなどの人気のあるデータセットはすべて、それぞれ無視できないデータ収集(およびクリーニング)プロセスを含みます。このコストのかかるキュレーションプロセスはデータセットのサイズを制限し、訓練されたモデルのスケーリングを妨げます。本論文では、Conceptual Captionsデータセットの高価なフィルタリングや後処理ステップなしで得られた、10億を超える画像alt-textペアのノイズの多いデータセットを活用します。シンプルなデュアルエンコーダーアーキテクチャは、対照損失を使用して画像とテキストペアの視覚的および言語的表現を整合させることを学習します。我々は、コーパスの規模がそのノイズを補い、このような単純な学習スキームでも最先端の表現につながることを示します。我々の視覚表現は、ImageNetやVTABなどの分類タスクへの転移において強力な性能を発揮します。整合した視覚的および言語的表現は、ゼロショット画像分類を可能にし、また、より洗練されたクロスアテンションモデルと比較しても、Flickr30KおよびMSCOCO画像テキスト検索ベンチマークにおいて新たな最先端の結果を達成します。また、これらの表現は、複雑なテキストおよびテキスト+画像のクエリを用いたクロスモーダル検索を可能にします。*
26
+
27
+ このモデルは[Alara Dirik](https://huggingface.co/adirik)により提供されました。
28
+ オリジナルのコードは公開されておらず、この実装は元論文に基づいたKakao Brainの実装をベースにしています。
29
+
30
+ ## 使用例
31
+
32
+ ALIGNはEfficientNetを使用して視覚的特徴を、BERTを使用してテキスト特徴を取得します。テキストと視覚の両方の特徴は、同一の次元を持つ潜在空間に射影されます。射影された画像とテキスト特徴間のドット積が類似度スコアとして使用されます。
33
+
34
+ [`AlignProcessor`]は、テキストのエンコードと画像の前処理を両方行うために、[`EfficientNetImageProcessor`]と[`BertTokenizer`]を単一のインスタンスにラップします。以下の例は、[`AlignProcessor`]と[`AlignModel`]を使用して画像-テキスト類似度スコアを取得する方法を示しています。
35
+
36
+ ```python
37
+ import requests
38
+ import torch
39
+ from PIL import Image
40
+ from transformers import AlignProcessor, AlignModel
41
+
42
+ processor = AlignProcessor.from_pretrained("kakaobrain/align-base")
43
+ model = AlignModel.from_pretrained("kakaobrain/align-base")
44
+
45
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
46
+ image = Image.open(requests.get(url, stream=True).raw)
47
+ candidate_labels = ["an image of a cat", "an image of a dog"]
48
+
49
+ inputs = processor(text=candidate_labels, images=image, return_tensors="pt")
50
+
51
+ with torch.no_grad():
52
+ outputs = model(**inputs)
53
+
54
+ # this is the image-text similarity score
55
+ logits_per_image = outputs.logits_per_image
56
+
57
+ # we can take the softmax to get the label probabilities
58
+ probs = logits_per_image.softmax(dim=1)
59
+ print(probs)
60
+ ```
61
+
62
+ ## 参考資料
63
+
64
+ ALIGNの使用を開始するのに役立つ公式のHugging Faceとコミュニティ(🌎で示されている)の参考資料の一覧です。
65
+
66
+ - [ALIGNとCOYO-700Mデータセット](https://huggingface.co/blog/vit-align)に関するブログ投稿。
67
+ - ゼロショット画像分類[デモ](https://huggingface.co/spaces/adirik/ALIGN-zero-shot-image-classification)。
68
+ - `kakaobrain/align-base` モデルの[モデルカード](https://huggingface.co/kakaobrain/align-base)。
69
+
70
+ ここに参考資料を提出したい場合は、気兼ねなくPull Requestを開いてください。私たちはそれをレビューいたします!参考資料は、既存のものを複製するのではなく、何か新しいことを示すことが理想的です。
71
+
72
+ ## AlignConfig
73
+
74
+ [[autodoc]] AlignConfig
75
+ - from_text_vision_configs
76
+
77
+ ## AlignTextConfig
78
+
79
+ [[autodoc]] AlignTextConfig
80
+
81
+ ## AlignVisionConfig
82
+
83
+ [[autodoc]] AlignVisionConfig
84
+
85
+ ## AlignProcessor
86
+
87
+ [[autodoc]] AlignProcessor
88
+
89
+ ## AlignModel
90
+
91
+ [[autodoc]] AlignModel
92
+ - forward
93
+ - get_text_features
94
+ - get_image_features
95
+
96
+ ## AlignTextModel
97
+
98
+ [[autodoc]] AlignTextModel
99
+ - forward
100
+
101
+ ## AlignVisionModel
102
+
103
+ [[autodoc]] AlignVisionModel
104
+ - forward
docs/transformers/docs/source/ja/model_doc/altclip.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2022 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # AltCLIP
18
+
19
+ ## 概要
20
+
21
+
22
+ AltCLIPモデルは、「[AltCLIP: Altering the Language Encoder in CLIP for Extended Language Capabilities](https://arxiv.org/abs/2211.06679v2)」という論文でZhongzhi Chen、Guang Liu、Bo-Wen Zhang、Fulong Ye、Qinghong Yang、Ledell Wuによって提案されました。AltCLIP(CLIPの言語エンコーダーの代替)は、様々な画像-テキストペアおよびテキスト-テキストペアでトレーニングされたニューラルネットワークです。CLIPのテキストエンコーダーを事前学習済みの多言語テキストエンコーダーXLM-Rに置き換えることで、ほぼ全てのタスクでCLIPに非常に近い性能を得られ、オリジナルのCLIPの能力を多言語理解などに拡張しました。
23
+
24
+ 論文の要旨は以下の通りです:
25
+
26
+ *この研究では、強力なバイリンガルマルチモーダル表現モデルを訓練するための概念的に単純で効果的な方法を提案します。OpenAIによってリリースされたマルチモーダル表現モデルCLIPから開始し、そのテキストエンコーダを事前学習済みの多言語テキストエンコーダXLM-Rに交換し、教師学習と対照学習からなる2段階のトレーニングスキーマを用いて言語と画像の表現を整合させました。幅広いタスクの評価を通じて、我々の方法を検証します。ImageNet-CN、Flicker30k-CN、COCO-CNを含む多くのタスクで新たな最先端の性能を達成しました。さらに、ほぼすべてのタスクでCLIPに非常に近い性能を得ており、これはCLIPのテキストエンコーダを変更するだけで、多言語理解などの拡張を実現できることを示唆しています。*
27
+
28
+ このモデルは[jongjyh](https://huggingface.co/jongjyh)により提供されました。
29
+
30
+ ## 使用上のヒントと使用例
31
+
32
+ AltCLIPの使用方法はCLIPに非常に似ています。CLIPとの違いはテキストエンコーダーにあります。私たちはカジュアルアテンションではなく双方向アテンションを使用し、XLM-Rの[CLS]トークンをテキスト埋め込みを表すものとして取ることに留意してください。
33
+
34
+ AltCLIPはマルチモーダルな視覚言語モデルです。これは画像とテキストの類似度や、ゼロショット画像分類に使用できます。AltCLIPはViTのようなTransformerを使用して視覚的特徴を、双方向言語モデルを使用してテキスト特徴を取得します。テキストと視覚の両方の特徴は、同一の次元を持つ潜在空間に射影されます。射影された画像とテキスト特徴間のドット積が類似度スコアとして使用されます。
35
+
36
+ Transformerエンコーダーに画像を与えるには、各画像を固定サイズの重複しないパッチの系列に分割し、それらを線形に埋め込みます。画像全体を表現するための[CLS]トークンが追加されます。著者は絶対位置埋め込みも追加し、結果として得られるベクトルの系列を標準的なTransformerエンコーダーに供給します。[`CLIPImageProcessor`]を使用して、モデルのために画像のサイズ変更(または拡大縮小)と正規化を行うことができます。
37
+
38
+ [`AltCLIPProcessor`]は、テキストのエンコードと画像の前処理を両方行うために、[`CLIPImageProcessor`]と[`XLMRobertaTokenizer`]を単一のインスタンスにラップします。以下の例は、[`AltCLIPProcessor`]と[`AltCLIPModel`]を使用して画像-テキスト類似スコアを取得する方法を示しています。
39
+
40
+ ```python
41
+ >>> from PIL import Image
42
+ >>> import requests
43
+
44
+ >>> from transformers import AltCLIPModel, AltCLIPProcessor
45
+
46
+ >>> model = AltCLIPModel.from_pretrained("BAAI/AltCLIP")
47
+ >>> processor = AltCLIPProcessor.from_pretrained("BAAI/AltCLIP")
48
+
49
+ >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
50
+ >>> image = Image.open(requests.get(url, stream=True).raw)
51
+
52
+ >>> inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
53
+
54
+ >>> outputs = model(**inputs)
55
+ >>> logits_per_image = outputs.logits_per_image # this is the image-text similarity score
56
+ >>> probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
57
+ ```
58
+
59
+ <Tip>
60
+
61
+ このモデルは`CLIPModel`をベースにしており、オリジナルの[CLIP](clip)と同じように使用してください。
62
+
63
+ </Tip>
64
+
65
+ ## AltCLIPConfig
66
+
67
+ [[autodoc]] AltCLIPConfig
68
+ - from_text_vision_configs
69
+
70
+ ## AltCLIPTextConfig
71
+
72
+ [[autodoc]] AltCLIPTextConfig
73
+
74
+ ## AltCLIPVisionConfig
75
+
76
+ [[autodoc]] AltCLIPVisionConfig
77
+
78
+ ## AltCLIPProcessor
79
+
80
+ [[autodoc]] AltCLIPProcessor
81
+
82
+ ## AltCLIPModel
83
+
84
+ [[autodoc]] AltCLIPModel
85
+ - forward
86
+ - get_text_features
87
+ - get_image_features
88
+
89
+ ## AltCLIPTextModel
90
+
91
+ [[autodoc]] AltCLIPTextModel
92
+ - forward
93
+
94
+ ## AltCLIPVisionModel
95
+
96
+ [[autodoc]] AltCLIPVisionModel
97
+ - forward
docs/transformers/docs/source/ja/model_doc/audio-spectrogram-transformer.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2022 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Audio Spectrogram Transformer
18
+
19
+ ## 概要
20
+
21
+ Audio Spectrogram Transformerモデルは、[AST: Audio Spectrogram Transformer](https://arxiv.org/abs/2104.01778)という論文でYuan Gong、Yu-An Chung、James Glassによって提案されました。これは、音声を画像(スペクトログラム)に変換することで、音声に[Vision Transformer](vit)を適用します。このモデルは音声分類において最先端の結果を得ています。
22
+
23
+ 論文の要旨は以下の通りです:
24
+
25
+ *過去10年間で、畳み込みニューラルネットワーク(CNN)は、音声スペクトログラムから対応するラベルへの直接的なマッピングを学習することを目指す、エンドツーエンドの音声分類モデルの主要な構成要素として広く採用されてきました。長距離のグローバルなコンテキストをより良く捉えるため、最近の傾向として、CNNの上にセルフアテンション機構を追加し、CNN-アテンションハイブリッドモデルを形成することがあります。しかし、CNNへの依存が必要かどうか、そして純粋にアテンションに基づくニューラルネットワークだけで音声分類において良いパフォーマンスを得ることができるかどうかは明らかではありません。本論文では、これらの問いに答えるため、音声分類用では最初の畳み込みなしで純粋にアテンションベースのモデルであるAudio Spectrogram Transformer(AST)を紹介します。我々はASTを様々なオーディオ分類ベンチマークで評価し、AudioSetで0.485 mAP、ESC-50で95.6%の正解率、Speech Commands V2で98.1%の正解率という新たな最先端の結果を達成しました。*
26
+
27
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/audio_spectogram_transformer_architecture.png"
28
+ alt="drawing" width="600"/>
29
+
30
+ <small> Audio Spectrogram Transformerのアーキテクチャ。<a href="https://arxiv.org/abs/2104.01778">元論文</a>より抜粋。</small>
31
+
32
+ このモデルは[nielsr](https://huggingface.co/nielsr)より提供されました。
33
+ オリジナルのコードは[こちら](https://github.com/YuanGongND/ast)で見ることができます。
34
+
35
+ ## 使用上のヒント
36
+
37
+ - 独自のデータセットでAudio Spectrogram Transformer(AST)をファインチューニングする場合、入力の正規化(入力の平均を0、標準偏差を0.5にすること)処理することが推奨されます。[`ASTFeatureExtractor`]はこれを処理します。デフォルトではAudioSetの平均と標準偏差を使用していることに注意してください。著者が下流のデータセットの統計をどのように計算しているかは、[`ast/src/get_norm_stats.py`](https://github.com/YuanGongND/ast/blob/master/src/get_norm_stats.py)で確認することができます。
38
+ - ASTは低い学習率が必要であり 著者は[PSLA論文](https://arxiv.org/abs/2102.01243)で提案されたCNNモデルに比べて10倍小さい学習率を使用しています)、素早く収束するため、タスクに適した学習率と学習率スケジューラーを探すことをお勧めします。
39
+
40
+ ## 参考資料
41
+
42
+ Audio Spectrogram Transformerの使用を開始するのに役立つ公式のHugging Faceおよびコミュニティ(🌎で示されている)の参考資料の一覧です。
43
+
44
+ <PipelineTag pipeline="audio-classification"/>
45
+
46
+ - ASTを用いた音声分類の推論を説明するノートブックは[こちら](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/AST)で見ることができます。
47
+ - [`ASTForAudioClassification`]は、この[例示スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/audio-classification)と[ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/audio_classification.ipynb)によってサポートされています。
48
+ - こちらも参照:[音声分類タスク](../tasks/audio_classification)。
49
+
50
+ ここに参考資料を提出したい場合は、気兼ねなくPull Requestを開いてください。私たちはそれをレビューいたします!参考資料は、既存のものを複製するのではなく、何か新しいことを示すことが理想的です。
51
+
52
+ ## ASTConfig
53
+
54
+ [[autodoc]] ASTConfig
55
+
56
+ ## ASTFeatureExtractor
57
+
58
+ [[autodoc]] ASTFeatureExtractor
59
+ - __call__
60
+
61
+ ## ASTModel
62
+
63
+ [[autodoc]] ASTModel
64
+ - forward
65
+
66
+ ## ASTForAudioClassification
67
+
68
+ [[autodoc]] ASTForAudioClassification
69
+ - forward
docs/transformers/docs/source/ja/model_doc/auto.md ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Auto Classes
18
+
19
+ 多くの場合、`from_pretrained()`メソッドに与えられた事前学習済みモデルの名前やパスから、使用したいアーキテクチャを推測することができます。自動クラスはこの仕事をあなたに代わって行うためにここにありますので、事前学習済みの重み/設定/語彙への名前/パスを与えると自動的に関連するモデルを取得できます。
20
+
21
+ [`AutoConfig`]、[`AutoModel`]、[`AutoTokenizer`]のいずれかをインスタンス化すると、関連するアーキテクチャのクラスが直接作成されます。例えば、
22
+
23
+ ```python
24
+ model = AutoModel.from_pretrained("google-bert/bert-base-cased")
25
+ ```
26
+
27
+ これは[`BertModel`]のインスタンスであるモデルを作成します。
28
+
29
+ 各タスクごと、そして各バックエンド(PyTorch、TensorFlow、またはFlax)ごとに`AutoModel`のクラスが存在します。
30
+
31
+ ## 自動クラスの拡張
32
+
33
+ それぞれの自動クラスには、カスタムクラスで拡張するためのメソッドがあります。例えば、`NewModel`というモデルのカスタムクラスを定義した場合、`NewModelConfig`を確保しておけばこのようにして自動クラスに追加することができます:
34
+
35
+ ```python
36
+ from transformers import AutoConfig, AutoModel
37
+
38
+ AutoConfig.register("new-model", NewModelConfig)
39
+ AutoModel.register(NewModelConfig, NewModel)
40
+ ```
41
+
42
+ その後、通常どおりauto classesを使用することができるようになります!
43
+
44
+ <Tip warning={true}>
45
+
46
+ あなたの`NewModelConfig`が[`~transformers.PretrainedConfig`]のサブクラスである場合、その`model_type`属性がコンフィグを登録するときに使用するキー(ここでは`"new-model"`)と同じに設定されていることを確認してください。
47
+
48
+ 同様に、あなたの`NewModel`が[`PreTrainedModel`]のサブクラスである場合、その`config_class`属性がモデルを登録する際に使用するクラス(ここでは`NewModelConfig`)と同じに設定されていることを確認してください。
49
+
50
+ </Tip>
51
+
52
+ ## AutoConfig
53
+
54
+ [[autodoc]] AutoConfig
55
+
56
+ ## AutoTokenizer
57
+
58
+ [[autodoc]] AutoTokenizer
59
+
60
+ ## AutoFeatureExtractor
61
+
62
+ [[autodoc]] AutoFeatureExtractor
63
+
64
+ ## AutoImageProcessor
65
+
66
+ [[autodoc]] AutoImageProcessor
67
+
68
+ ## AutoProcessor
69
+
70
+ [[autodoc]] AutoProcessor
71
+
72
+ ## Generic model classes
73
+
74
+ 以下の自動クラスは、特定のヘッドを持たないベースモデルクラスをインスタンス化するために利用可能です。
75
+
76
+ ### AutoModel
77
+
78
+ [[autodoc]] AutoModel
79
+
80
+ ### TFAutoModel
81
+
82
+ [[autodoc]] TFAutoModel
83
+
84
+ ### FlaxAutoModel
85
+
86
+ [[autodoc]] FlaxAutoModel
87
+
88
+ ## Generic pretraining classes
89
+
90
+ 以下の自動クラスは、事前学習ヘッドを持つモデルをインスタンス化するために利用可能です。
91
+
92
+ ### AutoModelForPreTraining
93
+
94
+ [[autodoc]] AutoModelForPreTraining
95
+
96
+ ### TFAutoModelForPreTraining
97
+
98
+ [[autodoc]] TFAutoModelForPreTraining
99
+
100
+ ### FlaxAutoModelForPreTraining
101
+
102
+ [[autodoc]] FlaxAutoModelForPreTraining
103
+
104
+ ## Natural Language Processing
105
+
106
+ 以下の自動クラスは、次の自然言語処理タスクに利用可能です。
107
+
108
+ ### AutoModelForCausalLM
109
+
110
+ [[autodoc]] AutoModelForCausalLM
111
+
112
+ ### TFAutoModelForCausalLM
113
+
114
+ [[autodoc]] TFAutoModelForCausalLM
115
+
116
+ ### FlaxAutoModelForCausalLM
117
+
118
+ [[autodoc]] FlaxAutoModelForCausalLM
119
+
120
+ ### AutoModelForMaskedLM
121
+
122
+ [[autodoc]] AutoModelForMaskedLM
123
+
124
+ ### TFAutoModelForMaskedLM
125
+
126
+ [[autodoc]] TFAutoModelForMaskedLM
127
+
128
+ ### FlaxAutoModelForMaskedLM
129
+
130
+ [[autodoc]] FlaxAutoModelForMaskedLM
131
+
132
+ ### AutoModelForMaskGeneration
133
+
134
+ [[autodoc]] AutoModelForMaskGeneration
135
+
136
+ ### TFAutoModelForMaskGeneration
137
+
138
+ [[autodoc]] TFAutoModelForMaskGeneration
139
+
140
+ ### AutoModelForSeq2SeqLM
141
+
142
+ [[autodoc]] AutoModelForSeq2SeqLM
143
+
144
+ ### TFAutoModelForSeq2SeqLM
145
+
146
+ [[autodoc]] TFAutoModelForSeq2SeqLM
147
+
148
+ ### FlaxAutoModelForSeq2SeqLM
149
+
150
+ [[autodoc]] FlaxAutoModelForSeq2SeqLM
151
+
152
+ ### AutoModelForSequenceClassification
153
+
154
+ [[autodoc]] AutoModelForSequenceClassification
155
+
156
+ ### TFAutoModelForSequenceClassification
157
+
158
+ [[autodoc]] TFAutoModelForSequenceClassification
159
+
160
+ ### FlaxAutoModelForSequenceClassification
161
+
162
+ [[autodoc]] FlaxAutoModelForSequenceClassification
163
+
164
+ ### AutoModelForMultipleChoice
165
+
166
+ [[autodoc]] AutoModelForMultipleChoice
167
+
168
+ ### TFAutoModelForMultipleChoice
169
+
170
+ [[autodoc]] TFAutoModelForMultipleChoice
171
+
172
+ ### FlaxAutoModelForMultipleChoice
173
+
174
+ [[autodoc]] FlaxAutoModelForMultipleChoice
175
+
176
+ ### AutoModelForNextSentencePrediction
177
+
178
+ [[autodoc]] AutoModelForNextSentencePrediction
179
+
180
+ ### TFAutoModelForNextSentencePrediction
181
+
182
+ [[autodoc]] TFAutoModelForNextSentencePrediction
183
+
184
+ ### FlaxAutoModelForNextSentencePrediction
185
+
186
+ [[autodoc]] FlaxAutoModelForNextSentencePrediction
187
+
188
+ ### AutoModelForTokenClassification
189
+
190
+ [[autodoc]] AutoModelForTokenClassification
191
+
192
+ ### TFAutoModelForTokenClassification
193
+
194
+ [[autodoc]] TFAutoModelForTokenClassification
195
+
196
+ ### FlaxAutoModelForTokenClassification
197
+
198
+ [[autodoc]] FlaxAutoModelForTokenClassification
199
+
200
+ ### AutoModelForQuestionAnswering
201
+
202
+ [[autodoc]] AutoModelForQuestionAnswering
203
+
204
+ ### TFAutoModelForQuestionAnswering
205
+
206
+ [[autodoc]] TFAutoModelForQuestionAnswering
207
+
208
+ ### FlaxAutoModelForQuestionAnswering
209
+
210
+ [[autodoc]] FlaxAutoModelForQuestionAnswering
211
+
212
+ ### AutoModelForTextEncoding
213
+
214
+ [[autodoc]] AutoModelForTextEncoding
215
+
216
+ ### TFAutoModelForTextEncoding
217
+
218
+ [[autodoc]] TFAutoModelForTextEncoding
219
+
220
+ ## Computer vision
221
+
222
+ 以下の自動クラスは、次のコンピュータービジョンタスクに利用可能です。
223
+
224
+ ### AutoModelForDepthEstimation
225
+
226
+ [[autodoc]] AutoModelForDepthEstimation
227
+
228
+ ### AutoModelForImageClassification
229
+
230
+ [[autodoc]] AutoModelForImageClassification
231
+
232
+ ### TFAutoModelForImageClassification
233
+
234
+ [[autodoc]] TFAutoModelForImageClassification
235
+
236
+ ### FlaxAutoModelForImageClassification
237
+
238
+ [[autodoc]] FlaxAutoModelForImageClassification
239
+
240
+ ### AutoModelForVideoClassification
241
+
242
+ [[autodoc]] AutoModelForVideoClassification
243
+
244
+ ### AutoModelForMaskedImageModeling
245
+
246
+ [[autodoc]] AutoModelForMaskedImageModeling
247
+
248
+ ### TFAutoModelForMaskedImageModeling
249
+
250
+ [[autodoc]] TFAutoModelForMaskedImageModeling
251
+
252
+ ### AutoModelForObjectDetection
253
+
254
+ [[autodoc]] AutoModelForObjectDetection
255
+
256
+ ### AutoModelForImageSegmentation
257
+
258
+ [[autodoc]] AutoModelForImageSegmentation
259
+
260
+ ### AutoModelForImageToImage
261
+
262
+ [[autodoc]] AutoModelForImageToImage
263
+
264
+ ### AutoModelForSemanticSegmentation
265
+
266
+ [[autodoc]] AutoModelForSemanticSegmentation
267
+
268
+ ### TFAutoModelForSemanticSegmentation
269
+
270
+ [[autodoc]] TFAutoModelForSemanticSegmentation
271
+
272
+ ### AutoModelForInstanceSegmentation
273
+
274
+ [[autodoc]] AutoModelForInstanceSegmentation
275
+
276
+ ### AutoModelForUniversalSegmentation
277
+
278
+ [[autodoc]] AutoModelForUniversalSegmentation
279
+
280
+ ### AutoModelForZeroShotImageClassification
281
+
282
+ [[autodoc]] AutoModelForZeroShotImageClassification
283
+
284
+ ### TFAutoModelForZeroShotImageClassification
285
+
286
+ [[autodoc]] TFAutoModelForZeroShotImageClassification
287
+
288
+ ### AutoModelForZeroShotObjectDetection
289
+
290
+ [[autodoc]] AutoModelForZeroShotObjectDetection
291
+
292
+ ## Audio
293
+
294
+ 以下の自動クラスは、次の音声タスクに利用可能です。
295
+
296
+ ### AutoModelForAudioClassification
297
+
298
+ [[autodoc]] AutoModelForAudioClassification
299
+
300
+ ### AutoModelForAudioFrameClassification
301
+
302
+ [[autodoc]] TFAutoModelForAudioClassification
303
+
304
+ ### TFAutoModelForAudioFrameClassification
305
+
306
+ [[autodoc]] AutoModelForAudioFrameClassification
307
+
308
+ ### AutoModelForCTC
309
+
310
+ [[autodoc]] AutoModelForCTC
311
+
312
+ ### AutoModelForSpeechSeq2Seq
313
+
314
+ [[autodoc]] AutoModelForSpeechSeq2Seq
315
+
316
+ ### TFAutoModelForSpeechSeq2Seq
317
+
318
+ [[autodoc]] TFAutoModelForSpeechSeq2Seq
319
+
320
+ ### FlaxAutoModelForSpeechSeq2Seq
321
+
322
+ [[autodoc]] FlaxAutoModelForSpeechSeq2Seq
323
+
324
+ ### AutoModelForAudioXVector
325
+
326
+ [[autodoc]] AutoModelForAudioXVector
327
+
328
+ ### AutoModelForTextToSpectrogram
329
+
330
+ [[autodoc]] AutoModelForTextToSpectrogram
331
+
332
+ ### AutoModelForTextToWaveform
333
+
334
+ [[autodoc]] AutoModelForTextToWaveform
335
+
336
+ ## Multimodal
337
+
338
+ 以下の自動クラスは、次のマルチモーダルタスクに利用可能です。
339
+
340
+ ### AutoModelForTableQuestionAnswering
341
+
342
+ [[autodoc]] AutoModelForTableQuestionAnswering
343
+
344
+ ### TFAutoModelForTableQuestionAnswering
345
+
346
+ [[autodoc]] TFAutoModelForTableQuestionAnswering
347
+
348
+ ### AutoModelForDocumentQuestionAnswering
349
+
350
+ [[autodoc]] AutoModelForDocumentQuestionAnswering
351
+
352
+ ### TFAutoModelForDocumentQuestionAnswering
353
+
354
+ [[autodoc]] TFAutoModelForDocumentQuestionAnswering
355
+
356
+ ### AutoModelForVisualQuestionAnswering
357
+
358
+ [[autodoc]] AutoModelForVisualQuestionAnswering
359
+
360
+ ### AutoModelForVision2Seq
361
+
362
+ [[autodoc]] AutoModelForVision2Seq
363
+
364
+ ### TFAutoModelForVision2Seq
365
+
366
+ [[autodoc]] TFAutoModelForVision2Seq
367
+
368
+ ### FlaxAutoModelForVision2Seq
369
+
370
+ [[autodoc]] FlaxAutoModelForVision2Seq
371
+
372
+ ### AutoModelForImageTextToText
373
+
374
+ [[autodoc]] AutoModelForImageTextToText
docs/transformers/docs/source/ja/model_doc/autoformer.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Autoformer
18
+
19
+ ## 概要
20
+
21
+ Autoformerモデルは、「[Autoformer: Decomposition Transformers with Auto-Correlation for Long-Term Series Forecasting](https://arxiv.org/abs/2106.13008)」という論文でHaixu Wu、Jiehui Xu、Jianmin Wang、Mingsheng Longによって提案されました。
22
+
23
+ このモデルは、予測プロセス中にトレンドと季節性成分を逐次的に分解できる深層分解アーキテクチャとしてTransformerを増強します。
24
+
25
+ 論文の要旨は以下の通りです:
26
+
27
+ *例えば異常気象の早期警告や長期的なエネルギー消費計画といった実応用において、予測時間を延長することは重要な要求です。本論文では、時系列の長期予測問題を研究しています。以前のTransformerベースのモデルは、長距離依存関係を発見するために様々なセルフアテンション機構を採用しています。しかし、長期未来の複雑な時間的パターンによってモデルが信頼できる依存関係を見つけることを妨げられます。また、Transformerは、長い系列の効率化のためにポイントワイズなセルフアテンションのスパースバージョンを採用する必要があり、情報利用のボトルネックとなります。Transformerを超えて、我々は自己相関機構を持つ新しい分解アーキテクチャとしてAutoformerを設計しました。系列分解の事前処理の慣行を破り、それを深層モデルの基本的な内部ブロックとして革新します。この設計は、複雑な時系列に対するAutoformerの進行的な分解能力を強化します。さらに、確率過程理論に触発されて、系列の周期性に基づいた自己相関機構を設計し、サブ系列レベルでの依存関係の発見と表現の集約を行います。自己相関は効率と精度の両方でセルフアテンションを上回ります。長期予測において、Autoformerは、エネルギー、交通、経済、気象、疾病の5つの実用的な応用をカバーする6つのベンチマークで38%の相対的な改善をもたらし、最先端の精度を達成します。*
28
+
29
+ このモデルは[elisim](https://huggingface.co/elisim)と[kashif](https://huggingface.co/kashif)より提供されました。
30
+ オリジナルのコードは[こちら](https://github.com/thuml/Autoformer)で見ることができます。
31
+
32
+ ## 参考資料
33
+
34
+ Autoformerの使用を開始するのに役立つ公式のHugging Faceおよびコミュニティ(🌎で示されている)の参考資料の一覧です。ここに参考資料を提出したい場合は、気兼ねなくPull Requestを開いてください。私たちはそれをレビューいたします!参考資料は、既存のものを複製するのではなく、何か新しいことを示すことが理想的です。
35
+
36
+ - HuggingFaceブログでAutoformerに関するブログ記事をチェックしてください:[はい、Transformersは時系列予測に効果的です(+ Autoformer)](https://huggingface.co/blog/autoformer)
37
+
38
+ ## AutoformerConfig
39
+
40
+ [[autodoc]] AutoformerConfig
41
+
42
+ ## AutoformerModel
43
+
44
+ [[autodoc]] AutoformerModel
45
+ - forward
46
+
47
+ ## AutoformerForPrediction
48
+
49
+ [[autodoc]] AutoformerForPrediction
50
+ - forward
docs/transformers/docs/source/ja/model_doc/bark.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+ -->
12
+
13
+ # Bark
14
+
15
+ ## Overview
16
+
17
+ Bark は、[suno-ai/bark](https://github.com/suno-ai/bark) で Suno AI によって提案されたトランスフォーマーベースのテキスト読み上げモデルです。
18
+
19
+
20
+ Bark は 4 つの主要なモデルで構成されています。
21
+
22
+ - [`BarkSemanticModel`] ('テキスト'モデルとも呼ばれる): トークン化されたテキストを入力として受け取り、テキストの意味を捉えるセマンティック テキスト トークンを予測する因果的自己回帰変換モデル。
23
+ - [`BarkCoarseModel`] ('粗い音響' モデルとも呼ばれる): [`BarkSemanticModel`] モデルの結果を入力として受け取る因果的自己回帰変換器。 EnCodec に必要な最初の 2 つのオーディオ コードブックを予測することを目的としています。
24
+ - [`BarkFineModel`] ('微細音響' モデル)、今回は非因果的オートエンコーダー トランスフォーマーで、以前のコードブック埋め込みの合計に基づいて最後のコードブックを繰り返し予測します。
25
+ - [`EncodecModel`] からすべてのコードブック チャネルを予測したので、Bark はそれを使用して出力オーディオ配列をデコードします。
26
+
27
+ 最初の 3 つのモジュールはそれぞれ、特定の事前定義された音声に従って出力サウンドを調整するための条件付きスピーカー埋め込みをサポートできることに注意してください。
28
+
29
+ ### Optimizing Bark
30
+
31
+ Bark は、コードを数行追加するだけで最適化でき、**メモリ フットプリントが大幅に削減**され、**推論が高速化**されます。
32
+
33
+ #### Using half-precision
34
+
35
+ モデルを半精度でロードするだけで、推論を高速化し、メモリ使用量を 50% 削減できます。
36
+
37
+ ```python
38
+ from transformers import BarkModel
39
+ import torch
40
+
41
+ device = "cuda" if torch.cuda.is_available() else "cpu"
42
+ model = BarkModel.from_pretrained("suno/bark-small", torch_dtype=torch.float16).to(device)
43
+ ```
44
+
45
+ #### Using 🤗 Better Transformer
46
+
47
+ Better Transformer は、内部でカーネル融合を実行する 🤗 最適な機能です。パフォーマンスを低下させることなく、速度を 20% ~ 30% 向上させることができます。モデルを 🤗 Better Transformer にエクスポートするのに必要なコードは 1 行だけです。
48
+
49
+ ```python
50
+ model = model.to_bettertransformer()
51
+ ```
52
+
53
+ この機能を使用する前に 🤗 Optimum をインストールする必要があることに注意してください。 [インストール方法はこちら](https://huggingface.co/docs/optimum/installation)
54
+
55
+ #### Using CPU offload
56
+
57
+ 前述したように、Bark は 4 つのサブモデルで構成されており、オーディオ生成中に順番に呼び出されます。言い換えれば、1 つのサブモデルが使用されている間、他のサブモデルはアイドル状態になります。
58
+
59
+ CUDA デバイスを使用している場合、メモリ フットプリントの 80% 削減による恩恵を受ける簡単な解決策は、アイドル状態の GPU のサブモデルをオフロードすることです。この操作は CPU オフロードと呼ばれます。 1行のコードで使用できます。
60
+
61
+ ```python
62
+ model.enable_cpu_offload()
63
+ ```
64
+
65
+ この機能を使用する前に、🤗 Accelerate をインストールする必要があることに注意してください。 [インストール方法はこちら](https://huggingface.co/docs/accelerate/basic_tutorials/install)
66
+
67
+ #### Combining optimization techniques
68
+
69
+ 最適化手法を組み合わせて、CPU オフロード、半精度、🤗 Better Transformer をすべて一度に使用できます。
70
+
71
+ ```python
72
+ from transformers import BarkModel
73
+ import torch
74
+
75
+ device = "cuda" if torch.cuda.is_available() else "cpu"
76
+
77
+ # load in fp16
78
+ model = BarkModel.from_pretrained("suno/bark-small", torch_dtype=torch.float16).to(device)
79
+
80
+ # convert to bettertransformer
81
+ model = BetterTransformer.transform(model, keep_original_model=False)
82
+
83
+ # enable CPU offload
84
+ model.enable_cpu_offload()
85
+ ```
86
+
87
+ 推論最適化手法の詳細については、[こちら](https://huggingface.co/docs/transformers/perf_infer_gpu_one) をご覧ください。
88
+
89
+ ### Tips
90
+
91
+ Suno は、多くの言語で音声プリセットのライブラリを提供しています [こちら](https://suno-ai.notion.site/8b8e8749ed514b0cbf3f699013548683?v=bc67cff786b04b50b3ceb756fd05f68c)。
92
+ これらのプリセットは、ハブ [こちら](https://huggingface.co/suno/bark-small/tree/main/speaker_embeddings) または [こちら](https://huggingface.co/suno/bark/tree/main/speaker_embeddings)。
93
+
94
+ ```python
95
+ >>> from transformers import AutoProcessor, BarkModel
96
+
97
+ >>> processor = AutoProcessor.from_pretrained("suno/bark")
98
+ >>> model = BarkModel.from_pretrained("suno/bark")
99
+
100
+ >>> voice_preset = "v2/en_speaker_6"
101
+
102
+ >>> inputs = processor("Hello, my dog is cute", voice_preset=voice_preset)
103
+
104
+ >>> audio_array = model.generate(**inputs)
105
+ >>> audio_array = audio_array.cpu().numpy().squeeze()
106
+ ```
107
+
108
+ Bark は、非常にリアルな **多言語** 音声だけでなく、音楽、背景ノイズ、単純な効果音などの他の音声も生成できます。
109
+
110
+ ```python
111
+ >>> # Multilingual speech - simplified Chinese
112
+ >>> inputs = processor("惊人的!我会说中文")
113
+
114
+ >>> # Multilingual speech - French - let's use a voice_preset as well
115
+ >>> inputs = processor("Incroyable! Je peux générer du son.", voice_preset="fr_speaker_5")
116
+
117
+ >>> # Bark can also generate music. You can help it out by adding music notes around your lyrics.
118
+ >>> inputs = processor("♪ Hello, my dog is cute ♪")
119
+
120
+ >>> audio_array = model.generate(**inputs)
121
+ >>> audio_array = audio_array.cpu().numpy().squeeze()
122
+ ```
123
+
124
+ このモデルは、笑う、ため息、泣くなどの**非言語コミュニケーション**を生成することもできます。
125
+
126
+
127
+ ```python
128
+ >>> # Adding non-speech cues to the input text
129
+ >>> inputs = processor("Hello uh ... [clears throat], my dog is cute [laughter]")
130
+
131
+ >>> audio_array = model.generate(**inputs)
132
+ >>> audio_array = audio_array.cpu().numpy().squeeze()
133
+ ```
134
+
135
+ オーディオを保存するには、モデル設定と scipy ユーティリティからサンプル レートを取得するだけです。
136
+
137
+ ```python
138
+ >>> from scipy.io.wavfile import write as write_wav
139
+
140
+ >>> # save audio to disk, but first take the sample rate from the model config
141
+ >>> sample_rate = model.generation_config.sample_rate
142
+ >>> write_wav("bark_generation.wav", sample_rate, audio_array)
143
+ ```
144
+
145
+ このモデルは、[Yoach Lacombe (ylacombe)](https://huggingface.co/ylacombe) および [Sanchit Gandhi (sanchit-gandhi)](https://github.com/sanchit-gandhi) によって提供されました。
146
+ 元のコードは [ここ](https://github.com/suno-ai/bark) にあります。
147
+
148
+ ## BarkConfig
149
+
150
+ [[autodoc]] BarkConfig
151
+ - all
152
+
153
+ ## BarkProcessor
154
+
155
+ [[autodoc]] BarkProcessor
156
+ - all
157
+ - __call__
158
+
159
+ ## BarkModel
160
+
161
+ [[autodoc]] BarkModel
162
+ - generate
163
+ - enable_cpu_offload
164
+
165
+ ## BarkSemanticModel
166
+
167
+ [[autodoc]] BarkSemanticModel
168
+ - forward
169
+
170
+ ## BarkCoarseModel
171
+
172
+ [[autodoc]] BarkCoarseModel
173
+ - forward
174
+
175
+ ## BarkFineModel
176
+
177
+ [[autodoc]] BarkFineModel
178
+ - forward
179
+
180
+ ## BarkCausalModel
181
+
182
+ [[autodoc]] BarkCausalModel
183
+ - forward
184
+
185
+ ## BarkCoarseConfig
186
+
187
+ [[autodoc]] BarkCoarseConfig
188
+ - all
189
+
190
+ ## BarkFineConfig
191
+
192
+ [[autodoc]] BarkFineConfig
193
+ - all
194
+
195
+ ## BarkSemanticConfig
196
+
197
+ [[autodoc]] BarkSemanticConfig
198
+ - all
docs/transformers/docs/source/ja/model_doc/bart.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BART
18
+
19
+ <div class="flex flex-wrap space-x-1">
20
+ <a href="https://huggingface.co/models?filter=bart">
21
+ <img alt="Models" src="https://img.shields.io/badge/All_model_pages-bart-blueviolet">
22
+ </a>
23
+ <a href="https://huggingface.co/spaces/docs-demos/bart-large-mnli">
24
+ <img alt="Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue">
25
+ </a>
26
+ </div>
27
+
28
+ **免責事項:** 何か奇妙なものを見つけた場合は、[Github 問題](https://github.com/huggingface/transformers/issues/new?assignees=&labels=&template=bug-report.md&title) を提出し、割り当ててください。
29
+ @patrickvonplaten
30
+
31
+ ## Overview
32
+
33
+ Bart モデルは、[BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation、
34
+ 翻訳と理解](https://arxiv.org/abs/1910.13461) Mike Lewis、Yinhan Liu、Naman Goyal、Marjan 著
35
+ ガズビニネジャド、アブデルラフマン・モハメド、オメル・レヴィ、ベス・ストヤノフ、ルーク・ゼトルモイヤー、2019年10月29日。
36
+
37
+ 要約によると、
38
+
39
+ - Bart は、双方向エンコーダ (BERT など) を備えた標準の seq2seq/機械翻訳アーキテクチャを使用します。
40
+ 左から右へのデコーダ (GPT など)。
41
+ - 事前トレーニング タスクには、元の文の順序をランダムにシャッフルし、新しい埋め込みスキームが含まれます。
42
+ ここで、テキストの範囲は単一のマスク トークンに置き換えられます。
43
+ - BART は、テキスト生成用に微調整した場合に特に効果的ですが、理解タスクにも適しています。それ
44
+ RoBERTa のパフォーマンスを GLUE および SQuAD の同等のトレーニング リソースと同等にし、新たな成果を達成します。
45
+ さまざまな抽象的な対話、質問応答、要約タスクに関する最先端の結果が得られ、成果が得られます。
46
+ ルージュは最大6枚まで。
47
+
48
+ チップ:
49
+
50
+ - BART は絶対位置埋め込みを備えたモデルであるため、通常は入力を右側にパディングすることをお勧めします。
51
+ 左。
52
+ - エンコーダーとデコーダーを備えたシーケンスツーシーケンス モデル。エンコーダには破損したバージョンのトークンが供給され、デコーダには元のトークンが供給されます(ただし、通常のトランスフォーマー デコーダと同様に、将来のワードを隠すためのマスクがあります)。次の変換の構成は、エンコーダーの事前トレーニング タスクに適用されます。
53
+
54
+ * ランダムなトークンをマスクします (BERT と同様)
55
+ * ランダムなトークンを削除します
56
+ * k 個のトークンのスパンを 1 つのマスク トークンでマスクします (0 トークンのスパンはマスク トークンの挿入です)
57
+ * 文を並べ替えます
58
+ * ドキュメントを回転して特定のトークンから開始するようにします
59
+
60
+ このモデルは [sshleifer](https://huggingface.co/sshleifer) によって提供されました。著者のコードは [ここ](https://github.com/pytorch/fairseq/tree/master/examples/bart) にあります。
61
+
62
+ ### Examples
63
+
64
+ - シーケンス間タスク用の BART およびその他のモデルを微調整するための例とスクリプトは、次の場所にあります。
65
+ [examples/pytorch/summarization/](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization/README.md)。
66
+ - Hugging Face `datasets` を使用して [`BartForConditionalGeneration`] をトレーニングする方法の例
67
+ オブジェクトは、この [フォーラム ディスカッション](https://discuss.huggingface.co/t/train-bart-for-conditional-generation-e-g-summarization/1904) で見つけることができます。
68
+ - [抽出されたチェックポイント](https://huggingface.co/models?search=distilbart) は、この [論文](https://arxiv.org/abs/2010.13002) で説明されています。
69
+
70
+ ## Implementation Notes
71
+
72
+ - Bart はシーケンスの分類に `token_type_ids` を使用しません。 [`BartTokenizer`] を使用するか、
73
+ [`~BartTokenizer.encode`] を使用して適切に分割します。
74
+ - [`BartModel`] のフォワードパスは、渡されなかった場合、`decoder_input_ids` を作成します。
75
+ これは、他のモデリング API とは異なります。この機能の一般的な使用例は、マスクの塗りつぶしです。
76
+ - モデルの予測は、次の場合に元の実装と同一になるように意図されています。
77
+ `forced_bos_token_id=0`。ただし、これは、渡す文字列が次の場合にのみ機能します。
78
+ [`fairseq.encode`] はスペースで始まります。
79
+ - [`~generation.GenerationMixin.generate`] は、次のような条件付き生成タスクに使用する必要があります。
80
+ 要約については、その docstring の例を参照してください。
81
+ - *facebook/bart-large-cnn* 重みをロードするモデルには `mask_token_id` がないか、実行できません。
82
+ マスクを埋めるタスク。
83
+
84
+ ## Mask Filling
85
+
86
+ `facebook/bart-base` および `facebook/bart-large` チェックポイントを使用して、マルチトークン マスクを埋めることができます。
87
+
88
+ ```python
89
+ from transformers import BartForConditionalGeneration, BartTokenizer
90
+
91
+ model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", forced_bos_token_id=0)
92
+ tok = BartTokenizer.from_pretrained("facebook/bart-large")
93
+ example_english_phrase = "UN Chief Says There Is No <mask> in Syria"
94
+ batch = tok(example_english_phrase, return_tensors="pt")
95
+ generated_ids = model.generate(batch["input_ids"])
96
+ assert tok.batch_decode(generated_ids, skip_special_tokens=True) == [
97
+ "UN Chief Says There Is No Plan to Stop Chemical Weapons in Syria"
98
+ ]
99
+ ```
100
+
101
+ ## Resources
102
+
103
+ BART を始めるのに役立つ公式 Hugging Face およびコミュニティ (🌎 で示されている) リソースのリスト。ここに含めるリソースの送信に興味がある場合は、お気軽にプル リクエストを開いてください。審査させていただきます。リソースは、既存のリソースを複製するのではなく、何か新しいものを示すことが理想的です。
104
+
105
+ <PipelineTag pipeline="summarization"/>
106
+
107
+ - に関するブログ投稿 [分散トレーニング: 🤗 Transformers と Amazon SageMaker を使用した要約のための BART/T5 のトレーニング](https://huggingface.co/blog/sagemaker-distributed-training-seq2seq)。
108
+ - 方法に関するノートブック [blurr を使用して fastai で要約するために BART を微調整する](https://colab.research.google.com/github/ohmeow/ohmeow_website/blob/master/posts/2021-05-25-mbart-sequence-classification-with-blurr.ipynb). 🌎 🌎
109
+ - 方法に関するノートブック [トレーナー クラスを使用して 2 つの言語で要約するために BART を微調整する](https://colab.research.google.com/github/elsanns/xai-nlp-notebooks/blob/master/fine_tune_bart_summarization_two_langs.ipynb)。 🌎
110
+ - [`BartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization.ipynb)。
111
+ - [`TFBartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/summarization) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/summarization-tf.ipynb)。
112
+ - [`FlaxBartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/flax/summarization) でサポートされています。
113
+ - [要約](https://huggingface.co/course/chapter7/5?fw=pt#summarization) 🤗 ハグフェイスコースの章。
114
+ - [要約タスクガイド](../tasks/summarization.md)
115
+
116
+ <PipelineTag pipeline="fill-mask"/>
117
+
118
+ - [`BartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling#robertabertdistilbert-and-masked-language-modeling) でサポートされており、 [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb)。
119
+ - [`TFBartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling#run_mlmpy) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb)。
120
+ - [`FlaxBartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling#masked-language-modeling) および [ノートブック]( https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/masked_language_modeling_flax.ipynb)。
121
+ - [マスクされた言語モデリング](https://huggingface.co/course/chapter7/3?fw=pt) 🤗 顔ハグ コースの章。
122
+ - [マスクされた言語モデリング タスク ガイド](../tasks/masked_lang_modeling)
123
+
124
+ <PipelineTag pipeline="translation"/>
125
+
126
+ - [ヒンディー語から英語への翻訳に Seq2SeqTrainer を使用して mBART を微調整する方法に関するノート](https://colab.research.google.com/github/vasudevgupta7/huggingface-tutorials/blob/main/translation_training.ipynb)。 🌎
127
+ - [`BartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/translation) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/translation.ipynb)。
128
+ - [`TFBartForConditionalGeneration`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/translation) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/translation-tf.ipynb)。
129
+ - [翻訳タスクガイド](../tasks/translation)
130
+
131
+ 以下も参照してください。
132
+ - [テキスト分類タスクガイド](../tasks/sequence_classification)
133
+ - [質問回答タスク ガイド](../tasks/question_answering)
134
+ - [因果言語モデリング タスク ガイド](../tasks/language_modeling)
135
+ - [抽出されたチェックポイント](https://huggingface.co/models?search=distilbart) は、この [論文](https://arxiv.org/abs/2010.13002) で説明されています。
136
+
137
+ ## BartConfig
138
+
139
+ [[autodoc]] BartConfig
140
+ - all
141
+
142
+ ## BartTokenizer
143
+
144
+ [[autodoc]] BartTokenizer
145
+ - all
146
+
147
+ ## BartTokenizerFast
148
+
149
+ [[autodoc]] BartTokenizerFast
150
+ - all
151
+
152
+ ## BartModel
153
+
154
+ [[autodoc]] BartModel
155
+ - forward
156
+
157
+ ## BartForConditionalGeneration
158
+
159
+ [[autodoc]] BartForConditionalGeneration
160
+ - forward
161
+
162
+ ## BartForSequenceClassification
163
+
164
+ [[autodoc]] BartForSequenceClassification
165
+ - forward
166
+
167
+ ## BartForQuestionAnswering
168
+
169
+ [[autodoc]] BartForQuestionAnswering
170
+ - forward
171
+
172
+ ## BartForCausalLM
173
+
174
+ [[autodoc]] BartForCausalLM
175
+ - forward
176
+
177
+ ## TFBartModel
178
+
179
+ [[autodoc]] TFBartModel
180
+ - call
181
+
182
+ ## TFBartForConditionalGeneration
183
+
184
+ [[autodoc]] TFBartForConditionalGeneration
185
+ - call
186
+
187
+ ## TFBartForSequenceClassification
188
+
189
+ [[autodoc]] TFBartForSequenceClassification
190
+ - call
191
+
192
+ ## FlaxBartModel
193
+
194
+ [[autodoc]] FlaxBartModel
195
+ - __call__
196
+ - encode
197
+ - decode
198
+
199
+ ## FlaxBartForConditionalGeneration
200
+
201
+ [[autodoc]] FlaxBartForConditionalGeneration
202
+ - __call__
203
+ - encode
204
+ - decode
205
+
206
+ ## FlaxBartForSequenceClassification
207
+
208
+ [[autodoc]] FlaxBartForSequenceClassification
209
+ - __call__
210
+ - encode
211
+ - decode
212
+
213
+ ## FlaxBartForQuestionAnswering
214
+
215
+ [[autodoc]] FlaxBartForQuestionAnswering
216
+ - __call__
217
+ - encode
218
+ - decode
219
+
220
+ ## FlaxBartForCausalLM
221
+
222
+ [[autodoc]] FlaxBartForCausalLM
223
+ - __call__
docs/transformers/docs/source/ja/model_doc/barthez.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BARThez
18
+
19
+ ## Overview
20
+
21
+ BARThez モデルは、Moussa Kamal Eddine、Antoine J.-P によって [BARThez: a Skilled Pretrained French Sequence-to-Sequence Model](https://arxiv.org/abs/2010.12321) で提案されました。ティクシエ、ミカリス・ヴァジルジャンニス、10月23日、
22
+ 2020年。
23
+
24
+ 論文の要約:
25
+
26
+
27
+ *帰納的転移学習は、自己教師あり学習によって可能になり、自然言語処理全体を実行します。
28
+ (NLP) 分野は、BERT や BART などのモデルにより、無数の自然言語に新たな最先端技術を確立し、嵐を巻き起こしています。
29
+ タスクを理解すること。いくつかの注目すべき例外はありますが、利用可能なモデルと研究のほとんどは、
30
+ 英語を対象に実施されました。この作品では、フランス語用の最初の BART モデルである BARTez を紹介します。
31
+ (我々の知る限りに)。 BARThez は、過去の研究から得た非常に大規模な単一言語フランス語コーパスで事前トレーニングされました
32
+ BART の摂動スキームに合わせて調整しました。既存の BERT ベースのフランス語モデルとは異なり、
33
+ CamemBERT と FlauBERT、BARThez は、エンコーダだけでなく、
34
+ そのデコーダは事前トレーニングされています。 FLUE ベンチマークからの識別タスクに加えて、BARThez を新しい評価に基づいて評価します。
35
+ この論文とともにリリースする要約データセット、OrangeSum。また、すでに行われている事前トレーニングも継続します。
36
+ BARTHez のコーパス上で多言語 BART を事前訓練し、結果として得られるモデル (mBARTHez と呼ぶ) が次のことを示します。
37
+ バニラの BARThez を大幅に強化し、CamemBERT や FlauBERT と同等かそれを上回ります。*
38
+
39
+ このモデルは [moussakam](https://huggingface.co/moussakam) によって寄稿されました。著者のコードは[ここ](https://github.com/moussaKam/BARThez)にあります。
40
+
41
+ <Tip>
42
+
43
+ BARThez の実装は、トークン化を除いて BART と同じです。詳細については、[BART ドキュメント](bart) を参照してください。
44
+ 構成クラスとそのパラメータ。 BARThez 固有のトークナイザーについては以下に記載されています。
45
+
46
+ </Tip>
47
+
48
+ ### Resources
49
+
50
+ - BARThez は、BART と同様の方法でシーケンス間のタスクを微調整できます。以下を確認してください。
51
+ [examples/pytorch/summarization/](https://github.com/huggingface/transformers/tree/main/examples/pytorch/summarization/README.md)。
52
+
53
+
54
+ ## BarthezTokenizer
55
+
56
+ [[autodoc]] BarthezTokenizer
57
+
58
+ ## BarthezTokenizerFast
59
+
60
+ [[autodoc]] BarthezTokenizerFast
docs/transformers/docs/source/ja/model_doc/bartpho.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2021 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BARTpho
18
+
19
+ ## Overview
20
+
21
+ BARTpho モデルは、Nguyen Luong Tran、Duong Minh Le、Dat Quoc Nguyen によって [BARTpho: Pre-trained Sequence-to-Sequence Models for Vietnam](https://arxiv.org/abs/2109.09701) で提案されました。
22
+
23
+ 論文の要約は次のとおりです。
24
+
25
+ *BARTpho には、BARTpho_word と BARTpho_syllable の 2 つのバージョンがあり、初の公開された大規模な単一言語です。
26
+ ベトナム語用に事前トレーニングされたシーケンスツーシーケンス モデル。当社の BARTpho は「大規模な」アーキテクチャと事前トレーニングを使用します
27
+ シーケンス間ノイズ除去モデル BART のスキームなので、生成 NLP タスクに特に適しています。実験
28
+ ベトナム語テキスト要約の下流タスクでは、自動評価と人間による評価の両方で、BARTpho が
29
+ 強力なベースライン mBART を上回り、最先端の性能を向上させます。将来を容易にするためにBARTphoをリリースします
30
+ 生成的なベトナム語 NLP タスクの研究と応用。*
31
+
32
+ このモデルは [dqnguyen](https://huggingface.co/dqnguyen) によって提供されました。元のコードは [こちら](https://github.com/VinAIResearch/BARTpho) にあります。
33
+
34
+ ## Usage example
35
+
36
+ ```python
37
+ >>> import torch
38
+ >>> from transformers import AutoModel, AutoTokenizer
39
+
40
+ >>> bartpho = AutoModel.from_pretrained("vinai/bartpho-syllable")
41
+
42
+ >>> tokenizer = AutoTokenizer.from_pretrained("vinai/bartpho-syllable")
43
+
44
+ >>> line = "Chúng tôi là những nghiên cứu viên."
45
+
46
+ >>> input_ids = tokenizer(line, return_tensors="pt")
47
+
48
+ >>> with torch.no_grad():
49
+ ... features = bartpho(**input_ids) # Models outputs are now tuples
50
+
51
+ >>> # With TensorFlow 2.0+:
52
+ >>> from transformers import TFAutoModel
53
+
54
+ >>> bartpho = TFAutoModel.from_pretrained("vinai/bartpho-syllable")
55
+ >>> input_ids = tokenizer(line, return_tensors="tf")
56
+ >>> features = bartpho(**input_ids)
57
+ ```
58
+
59
+ ## Usage tips
60
+
61
+ - mBARTに続いて、BARTphoはBARTの「大規模な」アーキテクチャを使用し、その上に追加の層正規化層を備えています。
62
+ エンコーダとデコーダの両方。したがって、[BART のドキュメント](bart) の使用例は、使用に適応する場合に使用されます。
63
+ BARTpho を使用する場合は、BART に特化したクラスを mBART に特化した対応するクラスに置き換えることによって調整する必要があります。
64
+ 例えば:
65
+
66
+ ```python
67
+ >>> from transformers import MBartForConditionalGeneration
68
+
69
+ >>> bartpho = MBartForConditionalGeneration.from_pretrained("vinai/bartpho-syllable")
70
+ >>> TXT = "Chúng tôi là <mask> nghiên cứu viên."
71
+ >>> input_ids = tokenizer([TXT], return_tensors="pt")["input_ids"]
72
+ >>> logits = bartpho(input_ids).logits
73
+ >>> masked_index = (input_ids[0] == tokenizer.mask_token_id).nonzero().item()
74
+ >>> probs = logits[0, masked_index].softmax(dim=0)
75
+ >>> values, predictions = probs.topk(5)
76
+ >>> print(tokenizer.decode(predictions).split())
77
+ ```
78
+
79
+ - この実装はトークン化のみを目的としています。`monolingual_vocab_file`はベトナム語に特化した型で構成されています
80
+ 多言語 XLM-RoBERTa から利用できる事前トレーニング済み SentencePiece モデル`vocab_file`から抽出されます。
81
+ 他の言語 (サブワードにこの事前トレーニング済み多言語 SentencePiece モデル`vocab_file`を使用する場合)
82
+ セグメンテーションにより、独自の言語に特化した`monolingual_vocab_file`を使用して BartphoTokenizer を再利用できます。
83
+
84
+ ## BartphoTokenizer
85
+
86
+ [[autodoc]] BartphoTokenizer
docs/transformers/docs/source/ja/model_doc/beit.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2021 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BEiT
18
+
19
+ ## Overview
20
+
21
+ BEiT モデルは、[BEiT: BERT Pre-Training of Image Transformers](https://arxiv.org/abs/2106.08254) で提案されました。
22
+ ハンボ・バオ、リー・ドン、フル・ウェイ。 BERT に触発された BEiT は、自己教師ありの事前トレーニングを作成した最初の論文です。
23
+ ビジョン トランスフォーマー (ViT) は、教師付き事前トレーニングよりも優れたパフォーマンスを発揮します。クラスを予測するためにモデルを事前トレーニングするのではなく
24
+ ([オリジナルの ViT 論文](https://arxiv.org/abs/2010.11929) で行われたように) 画像の BEiT モデルは、次のように事前トレーニングされています。
25
+ マスクされた OpenAI の [DALL-E モデル](https://arxiv.org/abs/2102.12092) のコードブックからビジュアル トークンを予測します
26
+ パッチ。
27
+
28
+ 論文の要約は次のとおりです。
29
+
30
+ *自己教師あり視覚表現モデル BEiT (Bidirectional Encoderpresentation) を導入します。
31
+ イメージトランスフォーマーより。自然言語処理分野で開発されたBERTに倣い、マスク画像を提案します。
32
+ ビジョントランスフォーマーを事前にトレーニングするためのモデリングタスク。具体的には、事前トレーニングでは各画像に 2 つのビューがあります。
33
+ パッチ (16x16 ピクセルなど)、およびビジュアル トークン (つまり、個別のトークン)。まず、元の画像を「トークン化」して、
34
+ ビジュアルトークン。次に、いくつかの画像パッチをランダムにマスクし、それらをバックボーンの Transformer に供給します。事前トレーニング
35
+ 目的は、破損したイメージ パッチに基づいて元のビジュアル トークンを回復することです。 BEiTの事前トレーニング後、
36
+ 事前トレーニングされたエンコーダーにタスク レイヤーを追加することで、ダウンストリーム タスクのモデル パラメーターを直接微調整します。
37
+ 画像分類とセマンティックセグメンテーションに関する実験結果は、私たちのモデルが競争力のある結果を達成することを示しています
38
+ 以前の事前トレーニング方法を使用して。たとえば、基本サイズの BEiT は、ImageNet-1K で 83.2% のトップ 1 精度を達成します。
39
+ 同じ設定でゼロからの DeiT トレーニング (81.8%) を大幅に上回りました。また、大型BEiTは
40
+ 86.3% は ImageNet-1K のみを使用しており、ImageNet-22K での教師付き事前トレーニングを使用した ViT-L (85.2%) を上回っています。*
41
+
42
+ ## Usage tips
43
+
44
+ - BEiT モデルは通常のビジョン トランスフォーマーですが、教師ありではなく自己教師ありの方法で事前トレーニングされています。彼らは
45
+ ImageNet-1K および CIFAR-100 で微調整すると、[オリジナル モデル (ViT)](vit) と [データ効率の高いイメージ トランスフォーマー (DeiT)](deit) の両方を上回るパフォーマンスを発揮します。推論に関するデモノートブックもチェックできます。
46
+ カスタム データの微調整は [こちら](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/VisionTransformer) (置き換えるだけで済みます)
47
+ [`BeitImageProcessor`] による [`ViTFeatureExtractor`] と
48
+ [`ViTForImageClassification`] by [`BeitForImageClassification`])。
49
+ - DALL-E の画像トークナイザーと BEiT を組み合わせる方法を紹介するデモ ノートブックも利用可能です。
50
+ マスクされた画像モデリングを実行します。 [ここ](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/BEiT) で見つけることができます。
51
+ - BEiT モデルは各画像が同じサイズ (解像度) であることを期待しているため、次のように使用できます。
52
+ [`BeitImageProcessor`] を使用して、モデルの画像のサイズを変更 (または再スケール) し、正規化します。
53
+ - 事前トレーニングまたは微調整中に使用されるパッ���解像度と画像解像度の両方が名前に反映されます。
54
+ 各チェックポイント。たとえば、`microsoft/beit-base-patch16-224`は、パッチ付きの基本サイズのアーキテクチャを指します。
55
+ 解像度は 16x16、微調整解像度は 224x224 です。すべてのチェックポイントは [ハブ](https://huggingface.co/models?search=microsoft/beit) で見つけることができます。
56
+ - 利用可能なチェックポイントは、(1) [ImageNet-22k](http://www.image-net.org/) で事前トレーニングされています (
57
+ 1,400 万の画像と 22,000 のクラス) のみ、(2) ImageNet-22k でも微調整、または (3) [ImageNet-1k](http://www.image-net.org/challenges/LSVRC)でも微調整/2012/) (ILSVRC 2012 とも呼ばれ、130 万件のコレクション)
58
+ 画像と 1,000 クラス)。
59
+ - BEiT は、T5 モデルからインスピレーションを得た相対位置埋め込みを使用します。事前トレーニング中に、著者は次のことを共有しました。
60
+ いくつかの自己注意層間の相対的な位置の偏り。微調整中、各レイヤーの相対位置
61
+ バイアスは、事前トレーニング後に取得された共有相対位置バイアスで初期化されます。ご希望の場合は、
62
+ モデルを最初から事前トレーニングするには、`use_relative_position_bias` または
63
+ 追加するには、[`BeitConfig`] の `use_relative_position_bias` 属性を `True` に設定します。
64
+ 位置の埋め込み。
65
+
66
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/beit_architecture.jpg"
67
+ alt="drawing" width="600"/>
68
+
69
+ <small> BEiT の事前トレーニング。 <a href="https://arxiv.org/abs/2106.08254">元の論文から抜粋。</a> </small>
70
+
71
+ このモデルは、[nielsr](https://huggingface.co/nielsr) によって提供されました。このモデルの JAX/FLAX バージョンは、
72
+ [kamalkraj](https://huggingface.co/kamalkraj) による投稿。元のコードは [ここ](https://github.com/microsoft/unilm/tree/master/beit) にあります。
73
+
74
+ ## Resources
75
+
76
+ BEiT の使用を開始するのに役立つ公式 Hugging Face およびコミュニティ (🌎 で示されている) リソースのリスト。
77
+
78
+ <PipelineTag pipeline="image-classification"/>
79
+
80
+ - [`BeitForImageClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb)。
81
+ - 参照: [画像分類タスク ガイド](../tasks/image_classification)
82
+
83
+ **セマンティック セグメンテーション**
84
+ - [セマンティック セグメンテーション タスク ガイド](../tasks/semantic_segmentation)
85
+
86
+ ここに含めるリソースの送信に興味がある場合は、お気軽にプル リクエストを開いてください。審査させていただきます。リソースは、既存のリソースを複製するのではなく、何か新しいものを示すことが理想的です。
87
+
88
+ ## BEiT specific outputs
89
+
90
+ [[autodoc]] models.beit.modeling_beit.BeitModelOutputWithPooling
91
+
92
+ [[autodoc]] models.beit.modeling_flax_beit.FlaxBeitModelOutputWithPooling
93
+
94
+ ## BeitConfig
95
+
96
+ [[autodoc]] BeitConfig
97
+
98
+ ## BeitFeatureExtractor
99
+
100
+ [[autodoc]] BeitFeatureExtractor
101
+ - __call__
102
+ - post_process_semantic_segmentation
103
+
104
+ ## BeitImageProcessor
105
+
106
+ [[autodoc]] BeitImageProcessor
107
+ - preprocess
108
+ - post_process_semantic_segmentation
109
+
110
+ ## BeitModel
111
+
112
+ [[autodoc]] BeitModel
113
+ - forward
114
+
115
+ ## BeitForMaskedImageModeling
116
+
117
+ [[autodoc]] BeitForMaskedImageModeling
118
+ - forward
119
+
120
+ ## BeitForImageClassification
121
+
122
+ [[autodoc]] BeitForImageClassification
123
+ - forward
124
+
125
+ ## BeitForSemanticSegmentation
126
+
127
+ [[autodoc]] BeitForSemanticSegmentation
128
+ - forward
129
+
130
+ ## FlaxBeitModel
131
+
132
+ [[autodoc]] FlaxBeitModel
133
+ - __call__
134
+
135
+ ## FlaxBeitForMaskedImageModeling
136
+
137
+ [[autodoc]] FlaxBeitForMaskedImageModeling
138
+ - __call__
139
+
140
+ ## FlaxBeitForImageClassification
141
+
142
+ [[autodoc]] FlaxBeitForImageClassification
143
+ - __call__
docs/transformers/docs/source/ja/model_doc/bert-generation.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BertGeneration
18
+
19
+ ## Overview
20
+
21
+ BertGeneration モデルは、次を使用してシーケンス間のタスクに利用できる BERT モデルです。
22
+ [Leveraging Pre-trained Checkpoints for Sequence Generation Tasks](https://arxiv.org/abs/1907.12461) で提案されている [`EncoderDecoderModel`]
23
+ タスク、Sascha Rothe、Sishi Nagayan、Aliaksei Severyn 著。
24
+
25
+ 論文の要約は次のとおりです。
26
+
27
+ *大規模なニューラル モデルの教師なし事前トレーニングは、最近、自然言語処理に革命をもたらしました。による
28
+ NLP 実践者は、公開されたチェックポイントからウォームスタートして、複数の項目で最先端の技術を推進してきました。
29
+ コンピューティング時間を大幅に節約しながらベンチマークを実行します。これまでのところ、主に自然言語に焦点を当ててきました。
30
+ タスクを理解する。この論文では、シーケンス生成のための事前トレーニングされたチェックポイントの有効性を実証します。私たちは
31
+ 公開されている事前トレーニング済み BERT と互換性のある Transformer ベースのシーケンス間モデルを開発しました。
32
+ GPT-2 および RoBERTa チェックポイントを使用し、モデルの初期化の有用性について広範な実証研究を実施しました。
33
+ エンコーダとデコーダ、これらのチェックポイント。私たちのモデルは、機械翻訳に関する新しい最先端の結果をもたらします。
34
+ テキストの要約、文の分割、および文の融合。*
35
+
36
+ ## Usage examples and tips
37
+
38
+ - モデルを [`EncoderDecoderModel`] と組み合わせて使用​​して、2 つの事前トレーニングされたモデルを活用できます。
39
+ 後続の微調整のための BERT チェックポイント。
40
+
41
+ ```python
42
+ >>> # leverage checkpoints for Bert2Bert model...
43
+ >>> # use BERT's cls token as BOS token and sep token as EOS token
44
+ >>> encoder = BertGenerationEncoder.from_pretrained("google-bert/bert-large-uncased", bos_token_id=101, eos_token_id=102)
45
+ >>> # add cross attention layers and use BERT's cls token as BOS token and sep token as EOS token
46
+ >>> decoder = BertGenerationDecoder.from_pretrained(
47
+ ... "google-bert/bert-large-uncased", add_cross_attention=True, is_decoder=True, bos_token_id=101, eos_token_id=102
48
+ ... )
49
+ >>> bert2bert = EncoderDecoderModel(encoder=encoder, decoder=decoder)
50
+
51
+ >>> # create tokenizer...
52
+ >>> tokenizer = BertTokenizer.from_pretrained("google-bert/bert-large-uncased")
53
+
54
+ >>> input_ids = tokenizer(
55
+ ... "This is a long article to summarize", add_special_tokens=False, return_tensors="pt"
56
+ ... ).input_ids
57
+ >>> labels = tokenizer("This is a short summary", return_tensors="pt").input_ids
58
+
59
+ >>> # train...
60
+ >>> loss = bert2bert(input_ids=input_ids, decoder_input_ids=labels, labels=labels).loss
61
+ >>> loss.backward()
62
+ ```
63
+
64
+ - 事前トレーニングされた [`EncoderDecoderModel`] もモデル ハブで直接利用できます。
65
+
66
+ ```python
67
+ >>> # instantiate sentence fusion model
68
+ >>> sentence_fuser = EncoderDecoderModel.from_pretrained("google/roberta2roberta_L-24_discofuse")
69
+ >>> tokenizer = AutoTokenizer.from_pretrained("google/roberta2roberta_L-24_discofuse")
70
+
71
+ >>> input_ids = tokenizer(
72
+ ... "This is the first sentence. This is the second sentence.", add_special_tokens=False, return_tensors="pt"
73
+ ... ).input_ids
74
+
75
+ >>> outputs = sentence_fuser.generate(input_ids)
76
+
77
+ >>> print(tokenizer.decode(outputs[0]))
78
+ ```
79
+
80
+ チップ:
81
+
82
+ - [`BertGenerationEncoder`] と [`BertGenerationDecoder`] は、
83
+ [`EncoderDecoder`] と組み合わせます。
84
+ - 要約、文の分割、文の融合、および翻訳の場合、入力に特別なトークンは必要ありません。
85
+ したがって、入力の末尾に EOS トークンを追加しないでください。
86
+
87
+ このモデルは、[patrickvonplaten](https://huggingface.co/patrickvonplaten) によって提供されました。元のコードは次のとおりです
88
+ [ここ](https://tfhub.dev/s?module-type=text-generation&subtype=module,placeholder) があります。
89
+
90
+ ## BertGenerationConfig
91
+
92
+ [[autodoc]] BertGenerationConfig
93
+
94
+ ## BertGenerationTokenizer
95
+
96
+ [[autodoc]] BertGenerationTokenizer
97
+ - save_vocabulary
98
+
99
+ ## BertGenerationEncoder
100
+
101
+ [[autodoc]] BertGenerationEncoder
102
+ - forward
103
+
104
+ ## BertGenerationDecoder
105
+
106
+ [[autodoc]] BertGenerationDecoder
107
+ - forward
docs/transformers/docs/source/ja/model_doc/bert-japanese.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BertJapanese
18
+
19
+ ## Overview
20
+
21
+ BERT モデルは日本語テキストでトレーニングされました。
22
+
23
+ 2 つの異なるトークン化方法を備えたモデルがあります。
24
+
25
+ - MeCab と WordPiece を使用してトークン化します。これには、[MeCab](https://taku910.github.io/mecab/) のラッパーである [fugashi](https://github.com/polm/fugashi) という追加の依存関係が必要です。
26
+ - 文字にトークン化します。
27
+
28
+ *MecabTokenizer* を使用するには、`pip installTransformers["ja"]` (または、インストールする場合は `pip install -e .["ja"]`) する必要があります。
29
+ ソースから)依存関係をインストールします。
30
+
31
+ [cl-tohakuリポジトリの詳細](https://github.com/cl-tohaku/bert-japanese)を参照してください。
32
+
33
+ MeCab および WordPiece トークン化でモデルを使用する例:
34
+
35
+
36
+ ```python
37
+ >>> import torch
38
+ >>> from transformers import AutoModel, AutoTokenizer
39
+
40
+ >>> bertjapanese = AutoModel.from_pretrained("cl-tohoku/bert-base-japanese")
41
+ >>> tokenizer = AutoTokenizer.from_pretrained("cl-tohoku/bert-base-japanese")
42
+
43
+ >>> ## Input Japanese Text
44
+ >>> line = "吾輩は猫である。"
45
+
46
+ >>> inputs = tokenizer(line, return_tensors="pt")
47
+
48
+ >>> print(tokenizer.decode(inputs["input_ids"][0]))
49
+ [CLS] 吾輩 は 猫 で ある 。 [SEP]
50
+
51
+ >>> outputs = bertjapanese(**inputs)
52
+ ```
53
+
54
+ 文字トークン化を使用したモデルの使用例:
55
+
56
+ ```python
57
+ >>> bertjapanese = AutoModel.from_pretrained("cl-tohoku/bert-base-japanese-char")
58
+ >>> tokenizer = AutoTokenizer.from_pretrained("cl-tohoku/bert-base-japanese-char")
59
+
60
+ >>> ## Input Japanese Text
61
+ >>> line = "吾輩は猫である。"
62
+
63
+ >>> inputs = tokenizer(line, return_tensors="pt")
64
+
65
+ >>> print(tokenizer.decode(inputs["input_ids"][0]))
66
+ [CLS] 吾 輩 は 猫 で あ る 。 [SEP]
67
+
68
+ >>> outputs = bertjapanese(**inputs)
69
+ ```
70
+
71
+ <Tip>
72
+
73
+ - この実装はトークン化方法を除いて BERT と同じです。その他の使用例については、[BERT のドキュメント](bert) を参照してください。
74
+
75
+ </Tip>
76
+
77
+ このモデルは[cl-tohaku](https://huggingface.co/cl-tohaku)から提供されました。
78
+
79
+ ## BertJapaneseTokenizer
80
+
81
+ [[autodoc]] BertJapaneseTokenizer
docs/transformers/docs/source/ja/model_doc/bert.md ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BERT
18
+
19
+ <div class="flex flex-wrap space-x-1">
20
+ <a href="https://huggingface.co/models?filter=bert">
21
+ <img alt="Models" src="https://img.shields.io/badge/All_model_pages-bert-blueviolet">
22
+ </a>
23
+ <a href="https://huggingface.co/spaces/docs-demos/bert-base-uncased">
24
+ <img alt="Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue">
25
+ </a>
26
+ </div>
27
+
28
+ ## Overview
29
+
30
+ BERT モデルは、Jacob Devlin、Ming-Wei Chang、Kenton Lee、Kristina Toutanova によって [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805) で提案されました。それは
31
+ マスクされた言語モデリング目標と次の文の組み合わせを使用して事前トレーニングされた双方向トランスフォーマー
32
+ Toronto Book Corpus と Wikipedia からなる大規模なコーパスでの予測。
33
+
34
+ 論文の要約は次のとおりです。
35
+
36
+ *BERT と呼ばれる新しい言語表現モデルを導入します。これは Bidirectional Encoder Representations の略です
37
+ トランスフォーマーより。最近の言語表現モデルとは異なり、BERT は深い双方向性を事前にトレーニングするように設計されています。
38
+ すべてのレイヤーの左と右の両方のコンテキストを共同で条件付けすることにより、ラベルのないテキストから表現します。結果として、
39
+ 事前トレーニングされた BERT モデルは、出力層を 1 つ追加するだけで微調整して、最先端のモデルを作成できます。
40
+ 実質的なタスク固有のものを必要とせず、質問応答や言語推論などの幅広いタスクに対応
41
+ アーキテクチャの変更。*
42
+
43
+ *BERT は概念的にはシンプルですが、経験的に強力です。 11 の自然な要素に関する新しい最先端の結果が得られます。
44
+ 言語処理タスク(GLUE スコアを 80.5% に押し上げる(7.7% ポイントの絶対改善)、MultiNLI を含む)
45
+ 精度は 86.7% (絶対値 4.6% 向上)、SQuAD v1.1 質問応答テスト F1 は 93.2 (絶対値 1.5 ポイント)
46
+ 改善) および SQuAD v2.0 テスト F1 から 83.1 (5.1 ポイントの絶対改善)。*
47
+
48
+ ## Usage tips
49
+
50
+ - BERT は絶対位置埋め込みを備えたモデルであるため、通常は入力を右側にパディングすることをお勧めします。
51
+ 左。
52
+ - BERT は、マスク言語モデリング (MLM) および次の文予測 (NSP) の目標を使用してトレーニングされました。それは
53
+ マスクされたトークンの予測や NLU では一般に効率的ですが、テキスト生成には最適ではありません。
54
+ - ランダム マスキングを使用して入力を破壊します。より正確には、事前トレーニング中に、トークンの指定された割合 (通常は 15%) が次によってマスクされます。
55
+
56
+ * 確率0.8の特別なマスクトークン
57
+ * 確率 0.1 でマスクされたトークンとは異なるランダムなトークン
58
+ * 確率 0.1 の同じトークン
59
+
60
+ - モデルは元の文を予測する必要がありますが、2 番目の目的があります。入力は 2 つの文 A と B (間に分離トークンあり) です。確率 50% では、文はコーパス内で連続していますが、残りの 50% では関連性がありません。モデルは、文が連続しているかどうかを予測する必要があります。
61
+
62
+
63
+
64
+ このモデルは [thomwolf](https://huggingface.co/thomwolf) によって提供されました。元のコードは [こちら](https://github.com/google-research/bert) にあります。
65
+
66
+ ## Resources
67
+
68
+ BERT を始めるのに役立つ公式 Hugging Face およびコミュニティ (🌎 で示される) リソースのリスト。ここに含めるリソースの送信に興味がある場合は、お気軽にプル リクエストを開いてください。審査させていただきます。リソースは、既存のリソースを複製するのではなく、何か新しいものを示すことが理想的です。
69
+
70
+ <PipelineTag pipeline="text-classification"/>
71
+
72
+ - に関するブログ投稿 [別の言語での BERT テキスト分類](https://www.philschmid.de/bert-text-classification-in-a-different-language)。
73
+ - [マルチラベル テキスト分類のための BERT (およびその友人) の微調整](https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/BERT/Fine_tuning_BERT_(and_friends)_for_multi_label_text_classification.ipynb) のノートブック.
74
+ - 方法に関するノートブック [PyTorch を使用したマルチラベル分類のための BERT の微調整](https://colab.research.google.com/github/abhmishra91/transformers-tutorials/blob/master/transformers_multi_label_classification.ipynb)。
75
+ - 方法に関するノートブック [要約のために BERT を使用して EncoderDecoder モデルをウォームスタートする](https://colab.research.google.com/github/patrickvonplaten/notebooks/blob/master/BERT2BERT_for_CNN_Dailymail.ipynb)。
76
+ - [`BertForSequenceClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/text-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification.ipynb)。
77
+ - [`TFBertForSequenceClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/text-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification-tf.ipynb)。
78
+ - [`FlaxBertForSequenceClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/flax/text-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification_flax.ipynb)。
79
+ - [テキスト分類タスクガイド](../tasks/sequence_classification)
80
+
81
+ <PipelineTag pipeline="token-classification"/>
82
+
83
+ - [Hugging Face Transformers with Keras: Fine-tune a non-English BERT for Named Entity Recognition](https://www.philschmid.de/huggingface-transformers-keras-tf) の使用方法に関するブログ投稿。
84
+ - 各単語の最初の単語部分のみを使用した [固有表現認識のための BERT の微調整](https://colab.research.google.com/github/NielsRogge/Transformers-Tutorials/blob/master/Custom_Named_Entity_Recognition_with_BERT_only_first_wordpiece.ipynb) のノートブックトークン化中の単語ラベル内。単語のラベルをすべての単語部分に伝播するには、代わりにノートブックのこの [バージョン](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/BERT/Custom_Named_Entity_Recognition_with_BERT.ipynb) を参照してください。
85
+ - [`BertForTokenClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/token-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification.ipynb)。
86
+ - [`TFBertForTokenClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/token-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/token_classification-tf.ipynb)。
87
+ - [`FlaxBertForTokenClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/flax/token-classification) によってサポートされています。
88
+ - [トークン分類](https://huggingface.co/course/chapter7/2?fw=pt) 🤗 ハグフェイスコースの章。
89
+ - [トークン分類タスクガイド](../tasks/token_classification)
90
+
91
+ <PipelineTag pipeline="fill-mask"/>
92
+
93
+ - [`BertForMaskedLM`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling#robertabertdistilbert-and-masked-language-modeling) でサポートされており、 [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb)。
94
+ - [`TFBertForMaskedLM`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/lang-modeling#run_mlmpy) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb)。
95
+ - [`FlaxBertForMaskedLM`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/flax/language-modeling#masked-language-modeling) および [ノートブック]( https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/masked_language_modeling_flax.ipynb)。
96
+ - [マスクされた言語モデリング](https://huggingface.co/course/chapter7/3?fw=pt) 🤗 顔ハグ コースの章。
97
+ - [マスクされた言語モデリング タスク ガイド](../tasks/masked_lang_modeling)
98
+
99
+
100
+ <PipelineTag pipeline="question-answering"/>
101
+
102
+ - [`BertForQuestionAnswering`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/question-answering) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/question_answering.ipynb)。
103
+ - [`TFBertForQuestionAnswering`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/question-answering) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/question_answering-tf.ipynb)。
104
+ - [`FlaxBertForQuestionAnswering`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/flax/question-answering) でサポートされています。
105
+ - [質問回答](https://huggingface.co/course/chapter7/7?fw=pt) 🤗 ハグフェイスコースの章。
106
+ - [質問回答タスク ガイド](../tasks/question_answering)
107
+
108
+ **複数の選択肢**
109
+ - [`BertForMultipleChoice`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/multiple-choice) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice.ipynb)。
110
+ - [`TFBertForMultipleChoice`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/multiple-choice) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/multiple_choice-tf.ipynb)。
111
+ - [多肢選択タスク ガイド](../tasks/multiple_choice)
112
+
113
+ ⚡️ **推論**
114
+ - 方法に関するブログ投稿 [Hugging Face Transformers と AWS Inferentia を使用して BERT 推論を高速化する](https://huggingface.co/blog/bert-inferentia-sagemaker)。
115
+ - 方法に関するブログ投稿 [GPU 上の DeepSpeed-Inference を使用して BERT 推論を高速化する](https://www.philschmid.de/bert-deepspeed-inference)。
116
+
117
+ ⚙️ **事前トレーニング**
118
+ - [Hugging Face Transformers と Habana Gaudi を使用した BERT の事前トレーニング に関するブログ投稿](https://www.philschmid.de/pre-training-bert-habana)。
119
+
120
+ 🚀 **デプロイ**
121
+ - 方法に関するブログ投稿 [ハグフェイス最適化でトランスフォーマーを ONNX に変換する](https://www.philschmid.de/convert-transformers-to-onnx)。
122
+ - 方法に関するブログ投稿 [AWS 上の Habana Gaudi を使用したハグ顔トランスフォーマーのための深層学習環境のセットアップ](https://www.philschmid.de/getting-started-habana-gaudi#conclusion)。
123
+ - に関するブログ投稿 [Hugging Face Transformers、Amazon SageMaker、および Terraform モジュールを使用した自動スケーリング BERT](https://www.philschmid.de/terraform-huggingface-amazon-sagemaker-advanced)。
124
+ - に関するブログ投稿 [HuggingFace、AWS Lambda、Docker を使用したサーバーレス BERT](https://www.philschmid.de/serverless-bert-with-huggingface-aws-lambda-docker)。
125
+ - に関するブログ投稿 [Amazon SageMaker と Training Compiler を使用した Hugging Face Transformers BERT 微調整](https://www.philschmid.de/huggingface-amazon-sagemaker-training-compiler)。
126
+ - に関するブログ投稿 [Transformers と Amazon SageMaker を使用した BERT のタスク固有の知識の蒸留](https://www.philschmid.de/knowledge-distillation-bert-transformers)
127
+
128
+ ## BertConfig
129
+
130
+ [[autodoc]] BertConfig
131
+ - all
132
+
133
+ ## BertTokenizer
134
+
135
+ [[autodoc]] BertTokenizer
136
+ - build_inputs_with_special_tokens
137
+ - get_special_tokens_mask
138
+ - create_token_type_ids_from_sequences
139
+ - save_vocabulary
140
+
141
+ <frameworkcontent>
142
+ <pt>
143
+
144
+ ## BertTokenizerFast
145
+
146
+ [[autodoc]] BertTokenizerFast
147
+
148
+ </pt>
149
+ <tf>
150
+
151
+ ## TFBertTokenizer
152
+
153
+ [[autodoc]] TFBertTokenizer
154
+
155
+ </tf>
156
+ </frameworkcontent>
157
+
158
+ ## Bert specific outputs
159
+
160
+ [[autodoc]] models.bert.modeling_bert.BertForPreTrainingOutput
161
+
162
+ [[autodoc]] models.bert.modeling_tf_bert.TFBertForPreTrainingOutput
163
+
164
+ [[autodoc]] models.bert.modeling_flax_bert.FlaxBertForPreTrainingOutput
165
+
166
+ <frameworkcontent>
167
+ <pt>
168
+
169
+ ## BertModel
170
+
171
+ [[autodoc]] BertModel
172
+ - forward
173
+
174
+ ## BertForPreTraining
175
+
176
+ [[autodoc]] BertForPreTraining
177
+ - forward
178
+
179
+ ## BertLMHeadModel
180
+
181
+ [[autodoc]] BertLMHeadModel
182
+ - forward
183
+
184
+ ## BertForMaskedLM
185
+
186
+ [[autodoc]] BertForMaskedLM
187
+ - forward
188
+
189
+ ## BertForNextSentencePrediction
190
+
191
+ [[autodoc]] BertForNextSentencePrediction
192
+ - forward
193
+
194
+ ## BertForSequenceClassification
195
+
196
+ [[autodoc]] BertForSequenceClassification
197
+ - forward
198
+
199
+ ## BertForMultipleChoice
200
+
201
+ [[autodoc]] BertForMultipleChoice
202
+ - forward
203
+
204
+ ## BertForTokenClassification
205
+
206
+ [[autodoc]] BertForTokenClassification
207
+ - forward
208
+
209
+ ## BertForQuestionAnswering
210
+
211
+ [[autodoc]] BertForQuestionAnswering
212
+ - forward
213
+
214
+ </pt>
215
+ <tf>
216
+
217
+ ## TFBertModel
218
+
219
+ [[autodoc]] TFBertModel
220
+ - call
221
+
222
+ ## TFBertForPreTraining
223
+
224
+ [[autodoc]] TFBertForPreTraining
225
+ - call
226
+
227
+ ## TFBertModelLMHeadModel
228
+
229
+ [[autodoc]] TFBertLMHeadModel
230
+ - call
231
+
232
+ ## TFBertForMaskedLM
233
+
234
+ [[autodoc]] TFBertForMaskedLM
235
+ - call
236
+
237
+ ## TFBertForNextSentencePrediction
238
+
239
+ [[autodoc]] TFBertForNextSentencePrediction
240
+ - call
241
+
242
+ ## TFBertForSequenceClassification
243
+
244
+ [[autodoc]] TFBertForSequenceClassification
245
+ - call
246
+
247
+ ## TFBertForMultipleChoice
248
+
249
+ [[autodoc]] TFBertForMultipleChoice
250
+ - call
251
+
252
+ ## TFBertForTokenClassification
253
+
254
+ [[autodoc]] TFBertForTokenClassification
255
+ - call
256
+
257
+ ## TFBertForQuestionAnswering
258
+
259
+ [[autodoc]] TFBertForQuestionAnswering
260
+ - call
261
+
262
+ </tf>
263
+ <jax>
264
+
265
+
266
+ ## FlaxBertModel
267
+
268
+ [[autodoc]] FlaxBertModel
269
+ - __call__
270
+
271
+ ## FlaxBertForPreTraining
272
+
273
+ [[autodoc]] FlaxBertForPreTraining
274
+ - __call__
275
+
276
+ ## FlaxBertForCausalLM
277
+
278
+ [[autodoc]] FlaxBertForCausalLM
279
+ - __call__
280
+
281
+ ## FlaxBertForMaskedLM
282
+
283
+ [[autodoc]] FlaxBertForMaskedLM
284
+ - __call__
285
+
286
+ ## FlaxBertForNextSentencePrediction
287
+
288
+ [[autodoc]] FlaxBertForNextSentencePrediction
289
+ - __call__
290
+
291
+ ## FlaxBertForSequenceClassification
292
+
293
+ [[autodoc]] FlaxBertForSequenceClassification
294
+ - __call__
295
+
296
+ ## FlaxBertForMultipleChoice
297
+
298
+ [[autodoc]] FlaxBertForMultipleChoice
299
+ - __call__
300
+
301
+ ## FlaxBertForTokenClassification
302
+
303
+ [[autodoc]] FlaxBertForTokenClassification
304
+ - __call__
305
+
306
+ ## FlaxBertForQuestionAnswering
307
+
308
+ [[autodoc]] FlaxBertForQuestionAnswering
309
+ - __call__
310
+
311
+ </jax>
312
+ </frameworkcontent>
docs/transformers/docs/source/ja/model_doc/bertweet.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BERTweet
18
+
19
+ ## Overview
20
+
21
+ BERTweet モデルは、Dat Quoc Nguyen、Thanh Vu によって [BERTweet: A pre-trained language model for English Tweets](https://www.aclweb.org/anthology/2020.emnlp-demos.2.pdf) で提案されました。アン・トゥアン・グエンさん。
22
+
23
+ 論文の要約は次のとおりです。
24
+
25
+ *私たちは、英語ツイート用に初めて公開された大規模な事前トレーニング済み言語モデルである BERTweet を紹介します。私たちのBERTweetは、
26
+ BERT ベースと同じアーキテクチャ (Devlin et al., 2019) は、RoBERTa 事前トレーニング手順 (Liu et al.) を使用してトレーニングされます。
27
+ al.、2019)。実験では、BERTweet が強力なベースラインである RoBERTa ベースおよび XLM-R ベースを上回るパフォーマンスを示すことが示されています (Conneau et al.,
28
+ 2020)、3 つのツイート NLP タスクにおいて、以前の最先端モデルよりも優れたパフォーマンス結果が得られました。
29
+ 品詞タグ付け、固有表現認識およびテキスト分類。*
30
+
31
+ ## Usage example
32
+
33
+ ```python
34
+ >>> import torch
35
+ >>> from transformers import AutoModel, AutoTokenizer
36
+
37
+ >>> bertweet = AutoModel.from_pretrained("vinai/bertweet-base")
38
+
39
+ >>> # For transformers v4.x+:
40
+ >>> tokenizer = AutoTokenizer.from_pretrained("vinai/bertweet-base", use_fast=False)
41
+
42
+ >>> # For transformers v3.x:
43
+ >>> # tokenizer = AutoTokenizer.from_pretrained("vinai/bertweet-base")
44
+
45
+ >>> # INPUT TWEET IS ALREADY NORMALIZED!
46
+ >>> line = "SC has first two presumptive cases of coronavirus , DHEC confirms HTTPURL via @USER :cry:"
47
+
48
+ >>> input_ids = torch.tensor([tokenizer.encode(line)])
49
+
50
+ >>> with torch.no_grad():
51
+ ... features = bertweet(input_ids) # Models outputs are now tuples
52
+
53
+ >>> # With TensorFlow 2.0+:
54
+ >>> # from transformers import TFAutoModel
55
+ >>> # bertweet = TFAutoModel.from_pretrained("vinai/bertweet-base")
56
+ ```
57
+ <Tip>
58
+
59
+ この実装は、トークン化方法を除いて BERT と同じです。詳細については、[BERT ドキュメント](bert) を参照してください。
60
+ API リファレンス情報。
61
+
62
+ </Tip>
63
+
64
+ このモデルは [dqnguyen](https://huggingface.co/dqnguyen) によって提供されました。元のコードは [ここ](https://github.com/VinAIResearch/BERTweet) にあります。
65
+
66
+ ## BertweetTokenizer
67
+
68
+ [[autodoc]] BertweetTokenizer
docs/transformers/docs/source/ja/model_doc/big_bird.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2021 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BigBird
18
+
19
+ ## Overview
20
+
21
+ BigBird モデルは、[Big Bird: Transformers for Longer Sequences](https://arxiv.org/abs/2007.14062) で提案されました。
22
+ ザヒール、マンジルとグルガネシュ、グルとダベイ、クマール・アヴィナヴァとエインズリー、ジョシュアとアルベルティ、クリスとオンタノン、
23
+ サンティアゴとファム、フィリップとラブラ、アニルードとワン、キーファンとヤン、リーなど。 BigBird は注目度が低い
24
+ BERT などの Transformer ベースのモデルをさらに長いシーケンスに拡張する、Transformer ベースのモデル。まばらに加えて
25
+ アテンションと同様に、BigBird は入力シーケンスにランダム アテンションだけでなくグローバル アテンションも適用します。理論的には、
26
+ まばらで全体的でランダムな注意を適用すると、完全な注意に近づくことが示されていますが、
27
+ 長いシーケンスでは計算効率が大幅に向上します。より長いコンテキストを処理できる機能の結果として、
28
+ BigBird は、質問応答や
29
+ BERT または RoBERTa と比較した要約。
30
+
31
+ 論文の要約は次のとおりです。
32
+
33
+ *BERT などのトランスフォーマーベースのモデルは、NLP で最も成功した深層学習モデルの 1 つです。
34
+ 残念ながら、それらの中核的な制限の 1 つは、シーケンスに対する二次依存性 (主にメモリに関する) です。
35
+ 完全な注意メカニズムによる長さです。これを解決するために、BigBird は、まばらな注意メカニズムを提案します。
36
+ この二次依存関係を線形に削減します。 BigBird がシーケンス関数の汎用近似器であることを示します。
37
+ チューリングは完全であるため、二次完全注意モデルのこれらの特性が保存されます。途中、私たちの
38
+ 理論分析により、O(1) 個のグローバル トークン (CLS など) を持つ利点の一部が明らかになり、
39
+ スパース注意メカニズムの一部としてのシーケンス。提案されたスパース アテンションは、次の長さのシーケンスを処理できます。
40
+ 同様のハードウェアを使用して以前に可能であったものの 8 倍。より長いコンテキストを処理できる機能の結果として、
41
+ BigBird は、質問応答や要約などのさまざまな NLP タスクのパフォーマンスを大幅に向上させます。私達も
42
+ ゲノミクスデータへの新しいアプリケーションを提案します。*
43
+
44
+ チップ:
45
+
46
+ - BigBird の注意がどのように機能するかについての詳細な説明については、[このブログ投稿](https://huggingface.co/blog/big-bird) を参照してください。
47
+ - BigBird には、**original_full** と **block_sparse** の 2 つの実装が付属しています。シーケンス長が 1024 未満の場合、次を使用します。
48
+ **block_sparse** を使用してもメリットがないため、**original_full** を使用することをお勧めします。
49
+ - コードは現在、3 ブロックと 2 グローバル ブロックのウィンドウ サイズを使用しています。
50
+ - シーケンスの長さはブロック サイズで割り切れる必要があります。
51
+ - 現在の実装では **ITC** のみがサポートされています。
52
+ - 現在の実装では **num_random_blocks = 0** はサポートされていません
53
+ - BigBird は絶対位置埋め込みを備えたモデルであるため、通常は入力を右側にパディングすることをお勧めします。
54
+ 左。
55
+
56
+ このモデルは、[vasudevgupta](https://huggingface.co/vasudevgupta) によって提供されました。元のコードが見つかる
57
+ [こちら](https://github.com/google-research/bigbird)。
58
+
59
+ ## ドキュメント リソース
60
+
61
+ - [テキスト分類タスクガイド](../tasks/sequence_classification)
62
+ - [トークン分類タスクガイド](../tasks/token_classification)
63
+ - [質問回答タスク ガイド](../tasks/question_answering)
64
+ - [因果言語モデリング タスク ガイド](../tasks/language_modeling)
65
+ - [マスクされた��語モデリング タスク ガイド](../tasks/masked_lang_modeling)
66
+ - [多肢選択タスク ガイド](../tasks/multiple_choice)
67
+
68
+ ## BigBirdConfig
69
+
70
+ [[autodoc]] BigBirdConfig
71
+
72
+ ## BigBirdTokenizer
73
+
74
+ [[autodoc]] BigBirdTokenizer
75
+ - build_inputs_with_special_tokens
76
+ - get_special_tokens_mask
77
+ - create_token_type_ids_from_sequences
78
+ - save_vocabulary
79
+
80
+ ## BigBirdTokenizerFast
81
+
82
+ [[autodoc]] BigBirdTokenizerFast
83
+
84
+ ## BigBird specific outputs
85
+
86
+ [[autodoc]] models.big_bird.modeling_big_bird.BigBirdForPreTrainingOutput
87
+
88
+ <frameworkcontent>
89
+ <pt>
90
+
91
+ ## BigBirdModel
92
+
93
+ [[autodoc]] BigBirdModel
94
+ - forward
95
+
96
+ ## BigBirdForPreTraining
97
+
98
+ [[autodoc]] BigBirdForPreTraining
99
+ - forward
100
+
101
+ ## BigBirdForCausalLM
102
+
103
+ [[autodoc]] BigBirdForCausalLM
104
+ - forward
105
+
106
+ ## BigBirdForMaskedLM
107
+
108
+ [[autodoc]] BigBirdForMaskedLM
109
+ - forward
110
+
111
+ ## BigBirdForSequenceClassification
112
+
113
+ [[autodoc]] BigBirdForSequenceClassification
114
+ - forward
115
+
116
+ ## BigBirdForMultipleChoice
117
+
118
+ [[autodoc]] BigBirdForMultipleChoice
119
+ - forward
120
+
121
+ ## BigBirdForTokenClassification
122
+
123
+ [[autodoc]] BigBirdForTokenClassification
124
+ - forward
125
+
126
+ ## BigBirdForQuestionAnswering
127
+
128
+ [[autodoc]] BigBirdForQuestionAnswering
129
+ - forward
130
+
131
+ </pt>
132
+ <jax>
133
+
134
+ ## FlaxBigBirdModel
135
+
136
+ [[autodoc]] FlaxBigBirdModel
137
+ - __call__
138
+
139
+ ## FlaxBigBirdForPreTraining
140
+
141
+ [[autodoc]] FlaxBigBirdForPreTraining
142
+ - __call__
143
+
144
+ ## FlaxBigBirdForCausalLM
145
+
146
+ [[autodoc]] FlaxBigBirdForCausalLM
147
+ - __call__
148
+
149
+ ## FlaxBigBirdForMaskedLM
150
+
151
+ [[autodoc]] FlaxBigBirdForMaskedLM
152
+ - __call__
153
+
154
+ ## FlaxBigBirdForSequenceClassification
155
+
156
+ [[autodoc]] FlaxBigBirdForSequenceClassification
157
+ - __call__
158
+
159
+ ## FlaxBigBirdForMultipleChoice
160
+
161
+ [[autodoc]] FlaxBigBirdForMultipleChoice
162
+ - __call__
163
+
164
+ ## FlaxBigBirdForTokenClassification
165
+
166
+ [[autodoc]] FlaxBigBirdForTokenClassification
167
+ - __call__
168
+
169
+ ## FlaxBigBirdForQuestionAnswering
170
+
171
+ [[autodoc]] FlaxBigBirdForQuestionAnswering
172
+ - __call__
173
+
174
+ </jax>
175
+ </frameworkcontent>
176
+
docs/transformers/docs/source/ja/model_doc/bigbird_pegasus.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2021 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BigBirdPegasus
18
+
19
+ ## Overview
20
+
21
+ BigBird モデルは、[Big Bird: Transformers for Longer Sequences](https://arxiv.org/abs/2007.14062) で提案されました。
22
+ ザヒール、マンジルとグルガネシュ、グルとダベイ、クマール・アヴィナヴァとエインズリー、ジョシュアとアルベルティ、クリスとオンタノン、
23
+ サンティアゴとファム、フィリップとラブラ、アニルードとワン、キーファンとヤン、リーなど。 BigBird は注目度が低い
24
+ BERT などの Transformer ベースのモデルをさらに長いシーケンスに拡張する、Transformer ベースのモデル。まばらに加えて
25
+ アテンションと同様に、BigBird は入力シーケンスにランダム アテンションだけでなくグローバル アテンションも適用します。理論的には、
26
+ まばらで全体的でランダムな注意を適用すると、完全な注意に近づくことが示されていますが、
27
+ 長いシーケンスでは計算効率が大幅に向上します。より長いコンテキストを処理できる機能の結果として、
28
+ BigBird は、質問応答や
29
+ BERT または RoBERTa と比較した要約。
30
+
31
+ 論文の要約は次のとおりです。
32
+
33
+ *BERT などのトランスフォーマーベースのモデルは、NLP で最も成功した深層学習モデルの 1 つです。
34
+ 残念ながら、それらの中核的な制限の 1 つは、シーケンスに対する二次依存性 (主にメモリに関する) です。
35
+ 完全な注意メカニズムによる長さです。これを解決するために、BigBird は、まばらな注意メカニズムを提案します。
36
+ この二次依存関係を線形に削減します。 BigBird がシーケンス関数の汎用近似器であることを示します。
37
+ チューリングは完全であるため、二次完全注意モデルのこれらの特性が保存されます。途中、私たちの
38
+ 理論分析により、O(1) 個のグローバル トークン (CLS など) を持つ利点の一部が明らかになり、
39
+ スパース注意メカニズムの一部としてのシーケンス。提案されたスパース アテンションは、次の長さのシーケンスを処理できます。
40
+ 同様のハードウェアを使用して以前に可能であったものの 8 倍。より長いコンテキストを処理できる機能の結果として、
41
+ BigBird は、質問応答や要約などのさまざまな NLP タスクのパフォーマンスを大幅に向上させます。私達も
42
+ ゲノミクスデータへの新しいアプリケーションを提案します。*
43
+
44
+ ## Usage tips
45
+
46
+ - BigBird の注意がどのように機能するかについての詳細な説明については、[このブログ投稿](https://huggingface.co/blog/big-bird) を参照してください。
47
+ - BigBird には、**original_full** と **block_sparse** の 2 つの実装が付属しています。シーケンス長が 1024 未満の場合、次を使用します。
48
+ **block_sparse** を使用してもメリットがないため、**original_full** を使用することをお勧めします。
49
+ - コードは現在、3 ブロックと 2 グローバル ブロックのウィンドウ サイズを使用しています。
50
+ - シーケンスの長さはブロック サイズで割り切れる必要があります。
51
+ - 現在の実装では **ITC** のみがサポートされています。
52
+ - 現在の実装では **num_random_blocks = 0** はサポートされていません。
53
+ - BigBirdPegasus は [PegasusTokenizer](https://github.com/huggingface/transformers/blob/main/src/transformers/models/pegasus/tokenization_pegasus.py) を使用します。
54
+ - BigBird は絶対位置埋め込みを備えたモデルであるため、通常は入力を右側にパディングすることをお勧めします。
55
+ 左。
56
+
57
+ 元のコードは [こちら](https://github.com/google-research/bigbird) にあります。
58
+
59
+ ## ドキュメント リソース
60
+
61
+ - [テキスト分類タスクガイド](../tasks/sequence_classification)
62
+ - [質問回答タスク ガイド](../tasks/question_answering)
63
+ - [因果言語モデリング タスク ガイド](../tasks/language_modeling)
64
+ - [翻訳タスク��イド](../tasks/translation)
65
+ - [要約タスクガイド](../tasks/summarization)
66
+
67
+ ## BigBirdPegasusConfig
68
+
69
+ [[autodoc]] BigBirdPegasusConfig
70
+ - all
71
+
72
+ ## BigBirdPegasusModel
73
+
74
+ [[autodoc]] BigBirdPegasusModel
75
+ - forward
76
+
77
+ ## BigBirdPegasusForConditionalGeneration
78
+
79
+ [[autodoc]] BigBirdPegasusForConditionalGeneration
80
+ - forward
81
+
82
+ ## BigBirdPegasusForSequenceClassification
83
+
84
+ [[autodoc]] BigBirdPegasusForSequenceClassification
85
+ - forward
86
+
87
+ ## BigBirdPegasusForQuestionAnswering
88
+
89
+ [[autodoc]] BigBirdPegasusForQuestionAnswering
90
+ - forward
91
+
92
+ ## BigBirdPegasusForCausalLM
93
+
94
+ [[autodoc]] BigBirdPegasusForCausalLM
95
+ - forward
docs/transformers/docs/source/ja/model_doc/biogpt.md ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2022 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BioGPT
18
+
19
+ ## Overview
20
+
21
+ BioGPT モデルは、[BioGPT: generative pre-trained transformer for biomedical text generation and mining](https://academic.oup.com/bib/advance-article/doi/10.1093/bib/bbac409/6713511?guestAccessKey=a66d9b5d-4f83-4017-bb52-405815c907b9) by Renqian Luo、Liai Sun、Yingce Xia、 Tao Qin、Sheng Zhang、Hoifung Poon、Tie-Yan Liu。 BioGPT は、生物医学テキストの生成とマイニングのための、ドメイン固有の生成事前トレーニング済み Transformer 言語モデルです。 BioGPT は、Transformer 言語モデルのバックボーンに従い、1,500 万の PubMed 抄録で最初から事前トレーニングされています。
22
+
23
+ 論文の要約は次のとおりです。
24
+
25
+ *事前トレーニング済み言語モデルは、一般的な自然言語領域での大きな成功に触発されて、生物医学領域でますます注目を集めています。一般言語ドメインの事前トレーニング済み言語モデルの 2 つの主なブランチ、つまり BERT (およびそのバリアント) と GPT (およびそのバリアント) のうち、1 つ目は BioBERT や PubMedBERT などの生物医学ドメインで広く研究されています。これらはさまざまな下流の生物医学的タスクで大きな成功を収めていますが、生成能力の欠如により応用範囲が制限されています。この論文では、大規模な生物医学文献で事前トレーニングされたドメイン固有の生成 Transformer 言語モデルである BioGPT を提案します。私たちは 6 つの生物医学的自然言語処理タスクで BioGPT を評価し、ほとんどのタスクで私たちのモデルが以前のモデルよりも優れていることを実証しました。特に、BC5CDR、KD-DTI、DDI のエンドツーエンド関係抽出タスクではそれぞれ 44.98%、38.42%、40.76% の F1 スコアを獲得し、PubMedQA では 78.2% の精度を獲得し、新記録を樹立しました。テキスト生成に関する私たちのケーススタディは、生物医学文献における BioGPT の利点をさらに実証し、生物医学用語の流暢な説明を生成します。*
26
+
27
+ ## Usage tips
28
+
29
+ - BioGPT は絶対位置埋め込みを備えたモデルであるため、通常は入力を左側ではなく右側にパディングすることをお勧めします。
30
+ - BioGPT は因果言語モデリング (CLM) 目的でトレーニングされているため、シーケンス内の次のトークンを予測するのに強力です。 run_generation.py サンプル スクリプトで確認できるように、この機能を利用すると、BioGPT は構文的に一貫したテキストを生成できます。
31
+ - モデルは、以前に計算されたキーと値のアテンション ペアである`past_key_values`(PyTorch の場合) を入力として受け取ることができます。この (past_key_values または past) 値を使用すると、モデルがテキスト生成のコンテキストで事前に計算された値を再計算できなくなります。 PyTorch の使用法の詳細については、BioGptForCausalLM.forward() メソッドの past_key_values 引数を参照してください。
32
+
33
+ このモデルは、[kamalkraj](https://huggingface.co/kamalkraj) によって提供されました。元のコードは [ここ](https://github.com/microsoft/BioGPT) にあります。
34
+
35
+ ## Documentation resources
36
+
37
+ - [因果言語モデリング タスク ガイド](../tasks/language_modeling)
38
+
39
+ ## BioGptConfig
40
+
41
+ [[autodoc]] BioGptConfig
42
+
43
+
44
+ ## BioGptTokenizer
45
+
46
+ [[autodoc]] BioGptTokenizer
47
+ - save_vocabulary
48
+
49
+
50
+ ## BioGptModel
51
+
52
+ [[autodoc]] BioGptModel
53
+ - forward
54
+
55
+
56
+ ## BioGptForCausalLM
57
+
58
+ [[autodoc]] BioGptForCausalLM
59
+ - forward
60
+
61
+
62
+ ## BioGptForTokenClassification
63
+
64
+ [[autodoc]] BioGptForTokenClassification
65
+ - forward
66
+
67
+
68
+ ## BioGptForSequenceClassification
69
+
70
+ [[autodoc]] BioGptForSequenceClassification
71
+ - forward
72
+
73
+
docs/transformers/docs/source/ja/model_doc/bit.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2022 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Big Transfer (BiT)
18
+
19
+ ## Overview
20
+
21
+ BiT モデルは、Alexander Kolesnikov、Lucas Beyer、Xiaohua Zhai、Joan Puigcerver、Jessica Yung、Sylvain Gelly によって [Big Transfer (BiT): General Visual Representation Learning](https://arxiv.org/abs/1912.11370) で提案されました。ニール・ホールズビー。
22
+ BiT は、[ResNet](resnet) のようなアーキテクチャ (具体的には ResNetv2) の事前トレーニングをスケールアップするための簡単なレシピです。この方法により、転移学習が大幅に改善されます。
23
+
24
+ 論文の要約は次のとおりです。
25
+
26
+ *事前トレーニングされた表現の転送により、サンプル効率が向上し、視覚用のディープ ニューラル ネットワークをトレーニングする際のハイパーパラメーター調整が簡素化されます。大規模な教師ありデータセットでの事前トレーニングと、ターゲット タスクでのモデルの微調整のパラダイムを再検討します。私たちは事前トレーニングをスケールアップし、Big Transfer (BiT) と呼ぶシンプルなレシピを提案します。いくつかの慎重に選択されたコンポーネントを組み合わせ、シンプルなヒューリスティックを使用して転送することにより、20 を超えるデータセットで優れたパフォーマンスを実現します。 BiT は、クラスごとに 1 つのサンプルから合計 100 万のサンプルまで、驚くほど広範囲のデータ領域にわたって良好にパフォーマンスを発揮します。 BiT は、ILSVRC-2012 で 87.5%、CIFAR-10 で 99.4%、19 タスクの Visual Task Adaptation Benchmark (VTAB) で 76.3% のトップ 1 精度を達成しました。小規模なデータセットでは、BiT は ILSVRC-2012 (クラスあたり 10 例) で 76.8%、CIFAR-10 (クラスあたり 10 例) で 97.0% を達成しました。高い転写性能を実現する主要成分を詳細に分析※。
27
+
28
+ ## Usage tips
29
+
30
+ - BiT モデルは、アーキテクチャの点で ResNetv2 と同等ですが、次の点が異なります: 1) すべてのバッチ正規化層が [グループ正規化](https://arxiv.org/abs/1803.08494) に置き換えられます。
31
+ 2) [重みの標準化](https://arxiv.org/abs/1903.10520) は畳み込み層に使用されます。著者らは、両方の組み合わせが大きなバッチサイズでのトレーニングに役立ち、重要な効果があることを示しています。
32
+ 転移学習への影響。
33
+
34
+ このモデルは、[nielsr](https://huggingface.co/nielsr) によって提供されました。
35
+ 元のコードは [こちら](https://github.com/google-research/big_transfer) にあります。
36
+
37
+ ## Resources
38
+
39
+ BiT を始めるのに役立つ公式 Hugging Face およびコミュニティ (🌎 で示されている) リソースのリスト。
40
+
41
+ <PipelineTag pipeline="image-classification"/>
42
+
43
+ - [`BitForImageClassification`] は、この [サンプル スクリプト](https://github.com/huggingface/transformers/tree/main/examples/pytorch/image-classification) および [ノートブック](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/image_classification.ipynb)。
44
+ - 参照: [画像分類タスク ガイド](../tasks/image_classification)
45
+
46
+ ここに含めるリソースの送信に興味がある場合は、お気軽にプル リクエストを開いてください。審査させていただきます。リソースは、既存のリソースを複製するのではなく、何か新しいものを示すことが理想的です。
47
+
48
+ ## BitConfig
49
+
50
+ [[autodoc]] BitConfig
51
+
52
+ ## BitImageProcessor
53
+
54
+ [[autodoc]] BitImageProcessor
55
+ - preprocess
56
+
57
+ ## BitImageProcessorFast
58
+
59
+ [[autodoc]] BitImageProcessorFast
60
+ - preprocess
61
+
62
+ ## BitModel
63
+
64
+ [[autodoc]] BitModel
65
+ - forward
66
+
67
+ ## BitForImageClassification
68
+
69
+ [[autodoc]] BitForImageClassification
70
+ - forward
docs/transformers/docs/source/ja/model_doc/blenderbot-small.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Blenderbot Small
18
+
19
+ [`BlenderbotSmallModel`] と
20
+ [`BlenderbotSmallForConditionalGeneration`] はチェックポイントと組み合わせてのみ使用されます
21
+ [facebook/blenderbot-90M](https://huggingface.co/facebook/blenderbot-90M)。より大規模な Blenderbot チェックポイントは、
22
+ 代わりに [`BlenderbotModel`] とともに使用してください。
23
+ [`BlenderbotForConditionalGeneration`]
24
+
25
+ ## Overview
26
+
27
+ Blender チャットボット モデルは、[Recipes for building an open-domain chatbot](https://arxiv.org/pdf/2004.13637.pdf) Stephen Roller、Emily Dinan、Naman Goyal、Da Ju、Mary Williamson、yinghan Liu、で提案されました。
28
+ ジン・シュー、マイル・オット、カート・シャスター、エリック・M・スミス、Y-ラン・ブーロー、ジェイソン・ウェストン、2020年4月30日。
29
+
30
+ 論文の要旨は次のとおりです。
31
+
32
+ *オープンドメインのチャットボットの構築は、機械学習研究にとって難しい分野です。これまでの研究では次のことが示されていますが、
33
+ ニューラル モデルをパラメーターの数とトレーニング対象のデータのサイズでスケーリングすると、結果が向上します。
34
+ 高性能のチャットボットには他の要素も重要であることを示します。良い会話には多くのことが必要です
35
+ 会話の専門家がシームレスに融合するスキル: 魅力的な話のポイントを提供し、話を聞く
36
+ 一貫した態度を維持しながら、知識、共感、個性を適切に表現する
37
+ ペルソナ。適切なトレーニング データと選択が与えられた場合、大規模モデルがこれらのスキルを学習できることを示します。
38
+ 世代戦略。 90M、2.7B、9.4B パラメーター モデルを使用してこれらのレシピのバリアントを構築し、モデルを作成します。
39
+ コードは公開されています。人間による評価では、当社の最良のモデルが既存のアプローチよりも優れていることがマルチターンで示されています
40
+ 魅力と人間性の測定という観点からの対話。次に、分析によってこの作業の限界について説明します。
41
+ 弊社機種の故障事例*
42
+
43
+ チップ:
44
+
45
+ - Blenderbot Small は絶対位置埋め込みを備えたモデルなので、通常は入力を右側にパディングすることをお勧めします。
46
+ 左。
47
+
48
+ このモデルは、[patrickvonplaten](https://huggingface.co/patrickvonplaten) によって提供されました。著者のコードは次のとおりです
49
+ [ここ](https://github.com/facebookresearch/ParlAI) をご覧ください。
50
+
51
+ ## Documentation resources
52
+
53
+ - [因果言語モデリング タスク ガイド](../tasks/language_modeling)
54
+ - [翻訳タスクガイド](../tasks/translation)
55
+ - [要約タスクガイド](../tasks/summarization)
56
+
57
+ ## BlenderbotSmallConfig
58
+
59
+ [[autodoc]] BlenderbotSmallConfig
60
+
61
+ ## BlenderbotSmallTokenizer
62
+
63
+ [[autodoc]] BlenderbotSmallTokenizer
64
+ - build_inputs_with_special_tokens
65
+ - get_special_tokens_mask
66
+ - create_token_type_ids_from_sequences
67
+ - save_vocabulary
68
+
69
+ ## BlenderbotSmallTokenizerFast
70
+
71
+ [[autodoc]] BlenderbotSmallTokenizerFast
72
+
73
+ ## BlenderbotSmallModel
74
+
75
+ [[autodoc]] BlenderbotSmallModel
76
+ - forward
77
+
78
+ ## BlenderbotSmallForConditionalGeneration
79
+
80
+ [[autodoc]] BlenderbotSmallForConditionalGeneration
81
+ - forward
82
+
83
+ ## BlenderbotSmallForCausalLM
84
+
85
+ [[autodoc]] BlenderbotSmallForCausalLM
86
+ - forward
87
+
88
+ ## TFBlenderbotSmallModel
89
+
90
+ [[autodoc]] TFBlenderbotSmallModel
91
+ - call
92
+
93
+ ## TFBlenderbotSmallForConditionalGeneration
94
+
95
+ [[autodoc]] TFBlenderbotSmallForConditionalGeneration
96
+ - call
97
+
98
+ ## FlaxBlenderbotSmallModel
99
+
100
+ [[autodoc]] FlaxBlenderbotSmallModel
101
+ - __call__
102
+ - encode
103
+ - decode
104
+
105
+ ## FlaxBlenderbotForConditionalGeneration
106
+
107
+ [[autodoc]] FlaxBlenderbotSmallForConditionalGeneration
108
+ - __call__
109
+ - encode
110
+ - decode
docs/transformers/docs/source/ja/model_doc/blenderbot.md ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2020 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # Blenderbot
18
+
19
+ **免責事項:** 何か奇妙なものを見つけた場合は、 [Github Issue](https://github.com/huggingface/transformers/issues/new?assignees=&labels=&template=bug-report.md&title) を報告してください。
20
+
21
+ ## Overview
22
+
23
+ Blender チャットボット モデルは、[Recipes for building an open-domain chatbot](https://arxiv.org/pdf/2004.13637.pdf) Stephen Roller、Emily Dinan、Naman Goyal、Da Ju、Mary Williamson、yinghan Liu、で提案されました。
24
+ ジン・シュー、マイル・オット、カート・シャスター、エリック・M・スミス、Y-ラン・ブーロー、ジェイソン・ウェストン、2020年4月30日。
25
+
26
+ 論文の要旨は次のとおりです。
27
+
28
+ *オープンドメインのチャットボットの構築は、機械学習研究にとって難しい分野です。これまでの研究では次のことが示されていますが、
29
+ ニューラル モデルをパラメーターの数とトレーニング対象のデータのサイズでスケーリングすると、結果が向上します。
30
+ 高性能のチャットボットには他の要素も重要であることを示します。良い会話には多くのことが必要です
31
+ 会話の専門家がシームレスに融合するスキル: 魅力的な話のポイントを提供し、話を聞く
32
+ 一貫した態度を維持しながら、知識、共感、個性を適切に表現する
33
+ ペルソナ。適切なトレーニング データと選択が与えられた場合、大規模モデルがこれらのスキルを学習できることを示します。
34
+ 世代戦略。 90M、2.7B、9.4B パラメーター モデルを使用してこれらのレシピのバリアントを構築し、モデルを作成します。
35
+ コードは公開されています。人間による評価では、当社の最良のモデルが既存のアプローチよりも優れていることがマルチターンで示されています
36
+ 魅力と人間性の測定という観点からの対話。次に、分析によってこの作業の限界について説明します。
37
+ 弊社機種の故障事例*
38
+
39
+ チップ:
40
+
41
+ - Blenderbot は絶対位置埋め込みを備えたモデルであるため、通常は入力を右側にパディングすることをお勧めします。
42
+ 左。
43
+
44
+ このモデルは [sshleifer](https://huggingface.co/sshleifer) によって提供されました。著者のコードは [ここ](https://github.com/facebookresearch/ParlAI) にあります。
45
+
46
+ ## Implementation Notes
47
+
48
+ - Blenderbot は、標準の [seq2seq モデル トランスフォーマー](https://arxiv.org/pdf/1706.03762.pdf) ベースのアーキテクチャを使用します。
49
+ - 利用可能なチェックポイントは、[モデル ハブ](https://huggingface.co/models?search=blenderbot) で見つけることができます。
50
+ - これは *デフォルト* Blenderbot モデル クラスです。ただし、次のような小さなチェックポイントもいくつかあります。
51
+ `facebook/blenderbot_small_90M` はアーキテクチャが異なるため、一緒に使用する必要があります。
52
+ [BlenderbotSmall](ブレンダーボット小)。
53
+
54
+ ## Usage
55
+
56
+ モデルの使用例を次に示します。
57
+
58
+ ```python
59
+ >>> from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
60
+
61
+ >>> mname = "facebook/blenderbot-400M-distill"
62
+ >>> model = BlenderbotForConditionalGeneration.from_pretrained(mname)
63
+ >>> tokenizer = BlenderbotTokenizer.from_pretrained(mname)
64
+ >>> UTTERANCE = "My friends are cool but they eat too many carbs."
65
+ >>> inputs = tokenizer([UTTERANCE], return_tensors="pt")
66
+ >>> reply_ids = model.generate(**inputs)
67
+ >>> print(tokenizer.batch_decode(reply_ids))
68
+ ["<s> That's unfortunate. Are they trying to lose weight or are they just trying to be healthier?</s>"]
69
+ ```
70
+
71
+ ## Documentation resources
72
+
73
+ - [因果言語モデリング タスク ガイド](../tasks/language_modeling)
74
+ - [翻訳タスクガイド](../tasks/translation)
75
+ - [要約タスクガイド](../tasks/summarization)
76
+
77
+ ## BlenderbotConfig
78
+
79
+ [[autodoc]] BlenderbotConfig
80
+
81
+ ## BlenderbotTokenizer
82
+
83
+ [[autodoc]] BlenderbotTokenizer
84
+ - build_inputs_with_special_tokens
85
+
86
+ ## BlenderbotTokenizerFast
87
+
88
+ [[autodoc]] BlenderbotTokenizerFast
89
+ - build_inputs_with_special_tokens
90
+
91
+ ## BlenderbotModel
92
+
93
+ *forward* および *generate* の引数については、`transformers.BartModel`を参照してください。
94
+
95
+ [[autodoc]] BlenderbotModel
96
+ - forward
97
+
98
+ ## BlenderbotForConditionalGeneration
99
+
100
+ *forward* と *generate* の引数については、[`~transformers.BartForConditionalGeneration`] を参照してください。
101
+
102
+ [[autodoc]] BlenderbotForConditionalGeneration
103
+ - forward
104
+
105
+ ## BlenderbotForCausalLM
106
+
107
+ [[autodoc]] BlenderbotForCausalLM
108
+ - forward
109
+
110
+ ## TFBlenderbotModel
111
+
112
+ [[autodoc]] TFBlenderbotModel
113
+ - call
114
+
115
+ ## TFBlenderbotForConditionalGeneration
116
+
117
+ [[autodoc]] TFBlenderbotForConditionalGeneration
118
+ - call
119
+
120
+ ## FlaxBlenderbotModel
121
+
122
+ [[autodoc]] FlaxBlenderbotModel
123
+ - __call__
124
+ - encode
125
+ - decode
126
+
127
+ ## FlaxBlenderbotForConditionalGeneration
128
+
129
+ [[autodoc]] FlaxBlenderbotForConditionalGeneration
130
+ - __call__
131
+ - encode
132
+ - decode
docs/transformers/docs/source/ja/model_doc/blip-2.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BLIP-2
18
+
19
+ ## Overview
20
+
21
+ BLIP-2 モデルは、[BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models](https://arxiv.org/abs/2301.12597) で提案されました。
22
+ Junnan Li, Dongxu Li, Silvio Savarese, Steven Hoi.・サバレーゼ、スティーブン・ホイ。 BLIP-2 は、軽量の 12 層 Transformer をトレーニングすることで、フリーズされた事前トレーニング済み画像エンコーダーと大規模言語モデル (LLM) を活用します。
23
+ それらの間にエンコーダーを配置し、さまざまな視覚言語タスクで最先端のパフォーマンスを実現します。最も注目すべき点は、BLIP-2 が 800 億パラメータ モデルである [Flamingo](https://arxiv.org/abs/2204.14198) を 8.7% 改善していることです。
24
+ ゼロショット VQAv2 ではトレーニング可能なパラメーターが 54 分の 1 に減少します。
25
+
26
+ 論文の要約は次のとおりです。
27
+
28
+ *大規模モデルのエンドツーエンドのトレーニングにより、視覚と言語の事前トレーニングのコストはますます法外なものになってきています。この論文では、市販の凍結済み事前トレーニング画像エンコーダと凍結された大規模言語モデルから視覚言語の事前トレーニングをブートストラップする、汎用的で効率的な事前トレーニング戦略である BLIP-2 を提案します。 BLIP-2 は、2 段階で事前トレーニングされた軽量の Querying Transformer でモダリティのギャップを橋渡しします。最初のステージでは、フリーズされた画像エンコーダーから学習する視覚言語表現をブートストラップします。第 2 段階では、凍結された言語モデルから視覚から言語への生成学習をブートストラップします。 BLIP-2 は、既存の方法よりもトレーニング可能なパラメーターが大幅に少ないにもかかわらず、さまざまな視覚言語タスクで最先端のパフォーマンスを実現します。たとえば、私たちのモデルは、トレーニング可能なパラメーターが 54 分の 1 少ないゼロショット VQAv2 で、Flamingo80B を 8.7% 上回っています。また、自然言語の命令に従うことができる、ゼロショット画像からテキストへの生成というモデルの新しい機能も実証します*
29
+
30
+ <img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/blip2_architecture.jpg"
31
+ alt="drawing" width="600"/>
32
+
33
+ <small> BLIP-2 アーキテクチャ。 <a href="https://arxiv.org/abs/2301.12597">元の論文から抜粋。</a> </small>
34
+
35
+ このモデルは、[nielsr](https://huggingface.co/nielsr) によって提供されました。
36
+ 元のコードは [ここ](https://github.com/salesforce/LAVIS/tree/5ee63d688ba4cebff63acee04adaef2dee9af207) にあります。
37
+
38
+ ## Usage tips
39
+
40
+ - BLIP-2 は、画像とオプションのテキスト プロンプトを指定して条件付きテキストを生成するために使用できます。推論時には、 [`generate`] メソッドを使用することをお勧めします。
41
+ - [`Blip2Processor`] を使用してモデル用の画像を準備し、予測されたトークン ID をデコードしてテキストに戻すことができます。
42
+
43
+ ## Resources
44
+
45
+ BLIP-2 の使用を開始するのに役立つ公式 Hugging Face およびコミュニティ (🌎 で示されている) リソースのリスト。
46
+
47
+ - 画像キャプション、ビジュアル質問応答 (VQA)、およびチャットのような会話のための BLIP-2 のデモ ノートブックは、[こちら](https://github.com/NielsRogge/Transformers-Tutorials/tree/master/BLIP-2) にあります。
48
+
49
+ ここに含めるリソースの送信に興味がある場合は、お気軽にプル リクエストを開いてください。審査させていただきます。リソースは、既存のリソースを複製するのではなく、何か新しいものを示すことが理想的です。
50
+
51
+ ## Blip2Config
52
+
53
+ [[autodoc]] Blip2Config
54
+ - from_vision_qformer_text_configs
55
+
56
+ ## Blip2VisionConfig
57
+
58
+ [[autodoc]] Blip2VisionConfig
59
+
60
+ ## Blip2QFormerConfig
61
+
62
+ [[autodoc]] Blip2QFormerConfig
63
+
64
+ ## Blip2Processor
65
+
66
+ [[autodoc]] Blip2Processor
67
+
68
+ ## Blip2VisionModel
69
+
70
+ [[autodoc]] Blip2VisionModel
71
+ - forward
72
+
73
+ ## Blip2QFormerModel
74
+
75
+ [[autodoc]] Blip2QFormerModel
76
+ - forward
77
+
78
+ ## Blip2Model
79
+
80
+ [[autodoc]] Blip2Model
81
+ - forward
82
+ - get_text_features
83
+ - get_image_features
84
+ - get_qformer_features
85
+
86
+ ## Blip2ForConditionalGeneration
87
+
88
+ [[autodoc]] Blip2ForConditionalGeneration
89
+ - forward
90
+ - generate
docs/transformers/docs/source/ja/model_doc/blip.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Copyright 2023 The HuggingFace Team. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4
+ the License. You may obtain a copy of the License at
5
+
6
+ http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10
+ specific language governing permissions and limitations under the License.
11
+
12
+ ⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
13
+ rendered properly in your Markdown viewer.
14
+
15
+ -->
16
+
17
+ # BLIP
18
+
19
+ ## Overview
20
+
21
+ BLIP モデルは、[BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation](https://arxiv.org/abs/2201.12086) で Junnan Li、Dongxu Li、Caiming Xiong、Steven Hoi によって提案されました。 。
22
+
23
+ BLIP は、次のようなさまざまなマルチモーダル タスクを実行できるモデルです。
24
+ - 視覚的な質問応答
25
+ - 画像とテキストの検索(画像とテキストのマッチング)
26
+ - 画像キャプション
27
+
28
+ 論文の要約は次のとおりです。
29
+
30
+ *視覚言語事前トレーニング (VLP) により、多くの視覚言語タスクのパフォーマンスが向上しました。
31
+ ただし、既存の事前トレーニング済みモデルのほとんどは、理解ベースのタスクまたは世代ベースのタスクのいずれかでのみ優れています。さらに、最適ではない監視ソースである Web から収集されたノイズの多い画像とテキストのペアを使用してデータセットをスケールアップすることで、パフォーマンスの向上が大幅に達成されました。この論文では、視覚言語の理解と生成タスクの両方に柔軟に移行する新しい VLP フレームワークである BLIP を提案します。 BLIP は、キャプションをブートストラップすることでノイズの多い Web データを効果的に利用します。キャプショナーが合成キャプションを生成し、フィルターがノイズの多いキャプションを除去します。画像テキスト検索 (平均再現率 +2.7%@1)、画像キャプション作成 (CIDEr で +2.8%)、VQA ( VQA スコアは +1.6%)。 BLIP は、ゼロショット方式でビデオ言語タスクに直接転送した場合にも、強力な一般化能力を発揮します。コード、モデル、データセットがリリースされています。*
32
+
33
+ ![BLIP.gif](https://cdn-uploads.huggingface.co/production/uploads/1670928184033-62441d1d9fdefb55a0b7d12c.gif)
34
+
35
+ このモデルは [ybelkada](https://huggingface.co/ybelkada) によって提供されました。
36
+ 元のコードは [ここ](https://github.com/salesforce/BLIP) にあります。
37
+
38
+ ## Resources
39
+
40
+ - [Jupyter ノートブック](https://github.com/huggingface/notebooks/blob/main/examples/image_captioning_blip.ipynb) カスタム データセットの画像キャプション用に BLIP を微調整する方法
41
+
42
+ ## BlipConfig
43
+
44
+ [[autodoc]] BlipConfig
45
+ - from_text_vision_configs
46
+
47
+ ## BlipTextConfig
48
+
49
+ [[autodoc]] BlipTextConfig
50
+
51
+ ## BlipVisionConfig
52
+
53
+ [[autodoc]] BlipVisionConfig
54
+
55
+ ## BlipProcessor
56
+
57
+ [[autodoc]] BlipProcessor
58
+
59
+ ## BlipImageProcessor
60
+
61
+ [[autodoc]] BlipImageProcessor
62
+ - preprocess
63
+
64
+ ## BlipImageProcessorFast
65
+
66
+ [[autodoc]] BlipImageProcessorFast
67
+ - preprocess
68
+
69
+ <frameworkcontent>
70
+ <pt>
71
+
72
+ ## BlipModel
73
+
74
+ [[autodoc]] BlipModel
75
+ - forward
76
+ - get_text_features
77
+ - get_image_features
78
+
79
+ ## BlipTextModel
80
+
81
+ [[autodoc]] BlipTextModel
82
+ - forward
83
+
84
+ ## BlipVisionModel
85
+
86
+ [[autodoc]] BlipVisionModel
87
+ - forward
88
+
89
+ ## BlipForConditionalGeneration
90
+
91
+ [[autodoc]] BlipForConditionalGeneration
92
+ - forward
93
+
94
+ ## BlipForImageTextRetrieval
95
+
96
+ [[autodoc]] BlipForImageTextRetrieval
97
+ - forward
98
+
99
+ ## BlipForQuestionAnswering
100
+
101
+ [[autodoc]] BlipForQuestionAnswering
102
+ - forward
103
+
104
+ </pt>
105
+ <tf>
106
+
107
+ ## TFBlipModel
108
+
109
+ [[autodoc]] TFBlipModel
110
+ - call
111
+ - get_text_features
112
+ - get_image_features
113
+
114
+ ## TFBlipTextModel
115
+
116
+ [[autodoc]] TFBlipTextModel
117
+ - call
118
+
119
+ ## TFBlipVisionModel
120
+
121
+ [[autodoc]] TFBlipVisionModel
122
+ - call
123
+
124
+ ## TFBlipForConditionalGeneration
125
+
126
+ [[autodoc]] TFBlipForConditionalGeneration
127
+ - call
128
+
129
+ ## TFBlipForImageTextRetrieval
130
+
131
+ [[autodoc]] TFBlipForImageTextRetrieval
132
+ - call
133
+
134
+ ## TFBlipForQuestionAnswering
135
+
136
+ [[autodoc]] TFBlipForQuestionAnswering
137
+ - call
138
+ </tf>
139
+ </frameworkcontent>