Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
f497f564
Unverified
Commit
f497f564
authored
Feb 16, 2024
by
Lysandre Debut
Committed by
GitHub
Feb 16, 2024
Browse files
Update all references to canonical models (#29001)
* Script & Manual edition * Update
parent
1e402b95
Changes
561
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
72 additions
and
72 deletions
+72
-72
docs/source/ja/model_sharing.md
docs/source/ja/model_sharing.md
+1
-1
docs/source/ja/multilingual.md
docs/source/ja/multilingual.md
+17
-17
docs/source/ja/perf_hardware.md
docs/source/ja/perf_hardware.md
+2
-2
docs/source/ja/perf_train_cpu.md
docs/source/ja/perf_train_cpu.md
+1
-1
docs/source/ja/perf_train_cpu_many.md
docs/source/ja/perf_train_cpu_many.md
+2
-2
docs/source/ja/perf_train_gpu_many.md
docs/source/ja/perf_train_gpu_many.md
+3
-3
docs/source/ja/perf_train_gpu_one.md
docs/source/ja/perf_train_gpu_one.md
+1
-1
docs/source/ja/perplexity.md
docs/source/ja/perplexity.md
+1
-1
docs/source/ja/pipeline_tutorial.md
docs/source/ja/pipeline_tutorial.md
+1
-1
docs/source/ja/pipeline_webserver.md
docs/source/ja/pipeline_webserver.md
+1
-1
docs/source/ja/preprocessing.md
docs/source/ja/preprocessing.md
+1
-1
docs/source/ja/quicktour.md
docs/source/ja/quicktour.md
+6
-6
docs/source/ja/run_scripts.md
docs/source/ja/run_scripts.md
+13
-13
docs/source/ja/serialization.md
docs/source/ja/serialization.md
+4
-4
docs/source/ja/task_summary.md
docs/source/ja/task_summary.md
+1
-1
docs/source/ja/tasks/language_modeling.md
docs/source/ja/tasks/language_modeling.md
+4
-4
docs/source/ja/tasks/masked_language_modeling.md
docs/source/ja/tasks/masked_language_modeling.md
+4
-4
docs/source/ja/tasks/multiple_choice.md
docs/source/ja/tasks/multiple_choice.md
+4
-4
docs/source/ja/tasks/prompting.md
docs/source/ja/tasks/prompting.md
+1
-1
docs/source/ja/tasks/question_answering.md
docs/source/ja/tasks/question_answering.md
+4
-4
No files found.
docs/source/ja/model_sharing.md
View file @
f497f564
...
...
@@ -254,7 +254,7 @@ Hugging Faceプロフィールに移動すると、新しく作成したモデ
*
手動で
`README.md`
ファイルを作成およびアップロードする。
*
モデルリポジトリ内の
**Edit model card**
ボタンをクリックする。
モデルカードに含めるべき情報の例については、DistilBert
[
モデルカード
](
https://huggingface.co/distilbert-base-uncased
)
をご覧ください。
`README.md`
ファイルで制御できる他のオプション、例えばモデルの炭素フットプリントやウィジェットの例などについての詳細は、
[
こちらのドキュメンテーション
](
https://huggingface.co/docs/hub/models-cards
)
を参照してください。
モデルカードに含めるべき情報の例については、DistilBert
[
モデルカード
](
https://huggingface.co/distilbert
/distilbert
-base-uncased
)
をご覧ください。
`README.md`
ファイルで制御できる他のオプション、例えばモデルの炭素フットプリントやウィジェットの例などについての詳細は、
[
こちらのドキュメンテーション
](
https://huggingface.co/docs/hub/models-cards
)
を参照してください。
...
...
docs/source/ja/multilingual.md
View file @
f497f564
...
...
@@ -18,7 +18,7 @@ rendered properly in your Markdown viewer.
[[open-in-colab]]
🤗 Transformers にはいくつかの多言語モデルがあり、それらの推論の使用方法は単一言語モデルとは異なります。ただし、多言語モデルの使用方法がすべて異なるわけではありません。
[
bert-base-multilingual-uncased
](
https://huggingface.co/bert-base-multilingual-uncased
)
などの一部のモデルは、単一言語モデルと同様に使用できます。 このガイドでは、推論のために使用方法が異なる多言語モデルをどのように使うかを示します。
🤗 Transformers にはいくつかの多言語モデルがあり、それらの推論の使用方法は単一言語モデルとは異なります。ただし、多言語モデルの使用方法がすべて異なるわけではありません。
[
google-bert/
bert-base-multilingual-uncased
](
https://huggingface.co/
google-bert/
bert-base-multilingual-uncased
)
などの一部のモデルは、単一言語モデルと同様に使用できます。 このガイドでは、推論のために使用方法が異なる多言語モデルをどのように使うかを示します。
## XLM
...
...
@@ -28,24 +28,24 @@ XLM には10の異なるチェックポイントがあり、そのうちの1つ
次の XLM モデルは、言語の埋め込みを使用して、推論で使用される言語を指定します。
-
`xlm-mlm-ende-1024`
(マスク化された言語モデリング、英語-ドイツ語)
-
`xlm-mlm-enfr-1024`
(マスク化された言語モデリング、英語-フランス語)
-
`xlm-mlm-enro-1024`
(マスク化された言語モデリング、英語-ルーマニア語)
-
`xlm-mlm-xnli15-1024`
(マスク化された言語モデリング、XNLI 言語)
-
`xlm-mlm-tlm-xnli15-1024`
(マスク化された言語モデリング + 翻訳 + XNLI 言語)
-
`xlm-clm-enfr-1024`
(因果言語モデリング、英語-フランス語)
-
`xlm-clm-ende-1024`
(因果言語モデリング、英語-ドイツ語)
-
`
FacebookAI/
xlm-mlm-ende-1024`
(マスク化された言語モデリング、英語-ドイツ語)
-
`
FacebookAI/
xlm-mlm-enfr-1024`
(マスク化された言語モデリング、英語-フランス語)
-
`
FacebookAI/
xlm-mlm-enro-1024`
(マスク化された言語モデリング、英語-ルーマニア語)
-
`
FacebookAI/
xlm-mlm-xnli15-1024`
(マスク化された言語モデリング、XNLI 言語)
-
`
FacebookAI/
xlm-mlm-tlm-xnli15-1024`
(マスク化された言語モデリング + 翻訳 + XNLI 言語)
-
`
FacebookAI/
xlm-clm-enfr-1024`
(因果言語モデリング、英語-フランス語)
-
`
FacebookAI/
xlm-clm-ende-1024`
(因果言語モデリング、英語-ドイツ語)
言語の埋め込みは、モデルに渡される
`input_ids`
と同じ形状のテンソルとして表されます。 これらのテンソルの値は、使用される言語に依存し、トークナイザーの
`lang2id`
および
`id2lang`
属性によって識別されます。
この例では、
`xlm-clm-enfr-1024`
チェックポイントをロードします (因果言語モデリング、英語-フランス語)。
この例では、
`
FacebookAI/
xlm-clm-enfr-1024`
チェックポイントをロードします (因果言語モデリング、英語-フランス語)。
```
py
>>>
import
torch
>>>
from
transformers
import
XLMTokenizer
,
XLMWithLMHeadModel
>>>
tokenizer
=
XLMTokenizer
.
from_pretrained
(
"xlm-clm-enfr-1024"
)
>>>
model
=
XLMWithLMHeadModel
.
from_pretrained
(
"xlm-clm-enfr-1024"
)
>>>
tokenizer
=
XLMTokenizer
.
from_pretrained
(
"
FacebookAI/
xlm-clm-enfr-1024"
)
>>>
model
=
XLMWithLMHeadModel
.
from_pretrained
(
"
FacebookAI/
xlm-clm-enfr-1024"
)
```
トークナイザーの
`lang2id`
属性は、このモデルの言語とその ID を表示します。
...
...
@@ -83,8 +83,8 @@ XLM には10の異なるチェックポイントがあり、そのうちの1つ
次の XLM モデルは、推論中に言語の埋め込みを必要としません。
-
`xlm-mlm-17-1280`
(マスク化された言語モデリング、17の言語)
-
`xlm-mlm-100-1280`
(マスク化された言語モデリング、100の言語)
-
`
FacebookAI/
xlm-mlm-17-1280`
(マスク化された言語モデリング、17の言語)
-
`
FacebookAI/
xlm-mlm-100-1280`
(マスク化された言語モデリング、100の言語)
これらのモデルは、以前の XLM チェックポイントとは異なり、一般的な文の表現に使用されます。
...
...
@@ -92,8 +92,8 @@ XLM には10の異なるチェックポイントがあり、そのうちの1つ
以下の BERT モデルは、多言語タスクに使用できます。
-
`bert-base-multilingual-uncased`
(マスク化された言語モデリング + 次の文の予測、102の言語)
-
`bert-base-multilingual-cased`
(マスク化された言語モデリング + 次の文の予測、104の言語)
-
`
google-bert/
bert-base-multilingual-uncased`
(マスク化された言語モデリング + 次の文の予測、102の言語)
-
`
google-bert/
bert-base-multilingual-cased`
(マスク化された言語モデリング + 次の文の予測、104の言語)
これらのモデルは、推論中に言語の埋め込みを必要としません。 文脈から言語を識別し、それに応じて推測する必要があります。
...
...
@@ -101,8 +101,8 @@ XLM には10の異なるチェックポイントがあり、そのうちの1つ
次の XLM-RoBERTa モデルは、多言語タスクに使用できます。
-
`xlm-roberta-base`
(マスク化された言語モデリング、100の言語)
-
`xlm-roberta-large`
(マスク化された言語モデリング、100の言語)
-
`
FacebookAI/
xlm-roberta-base`
(マスク化された言語モデリング、100の言語)
-
`
FacebookAI/
xlm-roberta-large`
(マスク化された言語モデリング、100の言語)
XLM-RoBERTa は、100の言語で新しく作成およびクリーニングされた2.5 TB の CommonCrawl データでトレーニングされました。 これは、分類、シーケンスのラベル付け、質問応答などのダウンストリームタスクで、mBERT や XLM などの以前にリリースされた多言語モデルを大幅に改善します。
...
...
docs/source/ja/perf_hardware.md
View file @
f497f564
...
...
@@ -140,7 +140,7 @@ NVLinkを使用すると、トレーニングが約23%速く完了すること
# DDP w/ NVLink
rm
-r
/tmp/test-clm
;
CUDA_VISIBLE_DEVICES
=
0,1 torchrun
\
--nproc_per_node
2 examples/pytorch/language-modeling/run_clm.py
--model_name_or_path
gpt2
\
--nproc_per_node
2 examples/pytorch/language-modeling/run_clm.py
--model_name_or_path
openai-community/
gpt2
\
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
--do_train
\
--output_dir
/tmp/test-clm
--per_device_train_batch_size
4
--max_steps
200
...
...
@@ -149,7 +149,7 @@ rm -r /tmp/test-clm; CUDA_VISIBLE_DEVICES=0,1 torchrun \
# DDP w/o NVLink
rm
-r
/tmp/test-clm
;
CUDA_VISIBLE_DEVICES
=
0,1
NCCL_P2P_DISABLE
=
1 torchrun
\
--nproc_per_node
2 examples/pytorch/language-modeling/run_clm.py
--model_name_or_path
gpt2
\
--nproc_per_node
2 examples/pytorch/language-modeling/run_clm.py
--model_name_or_path
openai-community/
gpt2
\
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
--do_train
--output_dir
/tmp/test-clm
--per_device_train_batch_size
4
--max_steps
200
...
...
docs/source/ja/perf_train_cpu.md
View file @
f497f564
...
...
@@ -49,7 +49,7 @@ TrainerでIPEXの自動混合精度を有効にするには、ユーザーはト
-
CPU上でBF16自動混合精度を使用してIPEXでトレーニングを行う場合:
<pre>
python run_qa.py
\
--model_name_or_path bert-base-uncased
\
--model_name_or_path
google-bert/
bert-base-uncased
\
--dataset_name squad
\
--do_train
\
--do_eval
\
...
...
docs/source/ja/perf_train_cpu_many.md
View file @
f497f564
...
...
@@ -100,7 +100,7 @@ IPEXは、Float32およびBFloat16の両方でCPUトレーニングのパフォ
export MASTER_ADDR=127.0.0.1
mpirun -n 2 -genv OMP_NUM_THREADS=23 \
python3 run_qa.py \
--model_name_or_path bert-large-uncased \
--model_name_or_path
google-bert/
bert-large-uncased \
--dataset_name squad \
--do_train \
--do_eval \
...
...
@@ -134,7 +134,7 @@ node0では、各ノードのIPアドレスを含む構成ファイルを作成
mpirun -f hostfile -n 4 -ppn 2 \
-genv OMP_NUM_THREADS=23 \
python3 run_qa.py \
--model_name_or_path bert-large-uncased \
--model_name_or_path
google-bert/
bert-large-uncased \
--dataset_name squad \
--do_train \
--do_eval \
...
...
docs/source/ja/perf_train_gpu_many.md
View file @
f497f564
...
...
@@ -136,7 +136,7 @@ DPとDDPの他にも違いがありますが、この議論には関係ありま
# DP
rm
-r
/tmp/test-clm
;
CUDA_VISIBLE_DEVICES
=
0,1
\
python examples/pytorch/language-modeling/run_clm.py
\
--model_name_or_path
gpt2
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
\
--model_name_or_path
openai-community/
gpt2
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
\
--do_train
--output_dir
/tmp/test-clm
--per_device_train_batch_size
4
--max_steps
200
{
'train_runtime'
: 110.5948,
'train_samples_per_second'
: 1.808,
'epoch'
: 0.69
}
...
...
@@ -144,7 +144,7 @@ python examples/pytorch/language-modeling/run_clm.py \
# DDP w/ NVlink
rm
-r
/tmp/test-clm
;
CUDA_VISIBLE_DEVICES
=
0,1
\
torchrun
--nproc_per_node
2 examples/pytorch/language-modeling/run_clm.py
\
--model_name_or_path
gpt2
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
\
--model_name_or_path
openai-community/
gpt2
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
\
--do_train
--output_dir
/tmp/test-clm
--per_device_train_batch_size
4
--max_steps
200
{
'train_runtime'
: 101.9003,
'train_samples_per_second'
: 1.963,
'epoch'
: 0.69
}
...
...
@@ -152,7 +152,7 @@ torchrun --nproc_per_node 2 examples/pytorch/language-modeling/run_clm.py \
# DDP w/o NVlink
rm
-r
/tmp/test-clm
;
NCCL_P2P_DISABLE
=
1
CUDA_VISIBLE_DEVICES
=
0,1
\
torchrun
--nproc_per_node
2 examples/pytorch/language-modeling/run_clm.py
\
--model_name_or_path
gpt2
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
\
--model_name_or_path
openai-community/
gpt2
--dataset_name
wikitext
--dataset_config_name
wikitext-2-raw-v1
\
--do_train
--output_dir
/tmp/test-clm
--per_device_train_batch_size
4
--max_steps
200
{
'train_runtime'
: 131.4367,
'train_samples_per_second'
: 1.522,
'epoch'
: 0.69
}
...
...
docs/source/ja/perf_train_gpu_one.md
View file @
f497f564
...
...
@@ -193,7 +193,7 @@ AdamWオプティマイザの代替手段について詳しく見てみましょ
1.
[
`Trainer`
]で使用可能な
`adafactor`
2.
Trainerで使用可能な
`adamw_bnb_8bit`
は、デモンストレーション用に以下でサードパーティの統合が提供されています。
比較のため、3Bパラメータモデル(例:「t5-3b」)の場合:
比較のため、3Bパラメータモデル(例:「
google-t5/
t5-3b」)の場合:
*
標準のAdamWオプティマイザは、各パラメータに8バイトを使用するため、24GBのGPUメモリが必要です(8
*
3 => 24GB)。
*
Adafactorオプティマイザは12GB以上必要です。各パラメータにわずか4バイト以上を使用するため、4
*
3と少し余分になります。
*
8ビットのBNB量子化オプティマイザは、すべてのオプティマイザの状態が量子化されている場合、わずか6GBしか使用しません。
...
...
docs/source/ja/perplexity.md
View file @
f497f564
...
...
@@ -56,7 +56,7 @@ GPT-2を使用してこのプロセスをデモンストレーションしてみ
from
transformers
import
GPT2LMHeadModel
,
GPT2TokenizerFast
device
=
"cuda"
model_id
=
"gpt2-large"
model_id
=
"
openai-community/
gpt2-large"
model
=
GPT2LMHeadModel
.
from_pretrained
(
model_id
).
to
(
device
)
tokenizer
=
GPT2TokenizerFast
.
from_pretrained
(
model_id
)
```
...
...
docs/source/ja/pipeline_tutorial.md
View file @
f497f564
...
...
@@ -165,7 +165,7 @@ def data():
yield
f
"My example
{
i
}
"
pipe
=
pipeline
(
model
=
"gpt2"
,
device
=
0
)
pipe
=
pipeline
(
model
=
"
openai-community/
gpt2"
,
device
=
0
)
generated_characters
=
0
for
out
in
pipe
(
data
()):
generated_characters
+=
len
(
out
[
0
][
"generated_text"
])
...
...
docs/source/ja/pipeline_webserver.md
View file @
f497f564
...
...
@@ -36,7 +36,7 @@ async def homepage(request):
async
def
server_loop
(
q
):
pipe
=
pipeline
(
model
=
"bert-base-uncased"
)
pipe
=
pipeline
(
model
=
"
google-bert/
bert-base-uncased"
)
while
True
:
(
string
,
response_q
)
=
await
q
.
get
()
out
=
pipe
(
string
)
...
...
docs/source/ja/preprocessing.md
View file @
f497f564
...
...
@@ -59,7 +59,7 @@ pip install datasets
```
python
>>>
from
transformers
import
AutoTokenizer
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"bert-base-cased"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"
google-bert/
bert-base-cased"
)
```
次に、テキストをトークナイザに渡します:
...
...
docs/source/ja/quicktour.md
View file @
f497f564
...
...
@@ -83,7 +83,7 @@ pip install tensorflow
>>>
classifier
=
pipeline
(
"sentiment-analysis"
)
```
[
`pipeline`]は、感情分析のためのデフォルトの[事前学習済みモデル
](
https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english
)
とトークナイザをダウンロードしてキャッシュし、使用できるようになります。
[
`pipeline`]は、感情分析のためのデフォルトの[事前学習済みモデル
](
https://huggingface.co/distilbert
/distilbert
-base-uncased-finetuned-sst-2-english
)
とトークナイザをダウンロードしてキャッシュし、使用できるようになります。
これで、
`classifier`
を対象のテキストに使用できます:
```
python
...
...
@@ -411,7 +411,7 @@ tensor([[0.0021, 0.0018, 0.0115, 0.2121, 0.7725],
```
python
>>>
from
transformers
import
AutoConfig
>>>
my_config
=
AutoConfig
.
from_pretrained
(
"distilbert-base-uncased"
,
n_heads
=
12
)
>>>
my_config
=
AutoConfig
.
from_pretrained
(
"distilbert
/distilbert
-base-uncased"
,
n_heads
=
12
)
```
<frameworkcontent>
...
...
@@ -452,7 +452,7 @@ tensor([[0.0021, 0.0018, 0.0115, 0.2121, 0.7725],
```py
>>> from transformers import AutoModelForSequenceClassification
>>> model = AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")
>>> model = AutoModelForSequenceClassification.from_pretrained("distilbert
/distilbert
-base-uncased")
```
2.
[
`TrainingArguments`
]には、変更できるモデルのハイパーパラメータが含まれており、学習率、バッチサイズ、トレーニングエポック数などが変更できます。指定しない場合、デフォルト値が使用されます:
...
...
@@ -474,7 +474,7 @@ tensor([[0.0021, 0.0018, 0.0115, 0.2121, 0.7725],
```
py
>>> from transformers import AutoTokenizer
>>> tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
>>> tokenizer = AutoTokenizer.from_pretrained("distilbert
/distilbert
-base-uncased")
```
4. データセットをロードする:
...
...
@@ -547,7 +547,7 @@ tensor([[0.0021, 0.0018, 0.0115, 0.2121, 0.7725],
```
py
>>>
from
transformers
import
TFAutoModelForSequenceClassification
>>>
model
=
TFAutoModelForSequenceClassification
.
from_pretrained
(
"distilbert-base-uncased"
)
>>>
model
=
TFAutoModelForSequenceClassification
.
from_pretrained
(
"distilbert
/distilbert
-base-uncased"
)
```
2.
トークナイザ、画像プロセッサ、特徴量抽出器、またはプロセッサのような前処理クラスをロードします:
...
...
@@ -555,7 +555,7 @@ tensor([[0.0021, 0.0018, 0.0115, 0.2121, 0.7725],
```
py
>>>
from
transformers
import
AutoTokenizer
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilbert-base-uncased"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilbert
/distilbert
-base-uncased"
)
```
3.
データセットをトークナイズするための関数を作成します:
...
...
docs/source/ja/run_scripts.md
View file @
f497f564
...
...
@@ -92,12 +92,12 @@ pip install -r requirements.txt
<frameworkcontent>
<pt>
この例のスクリプトは、🤗
[
Datasets
](
https://huggingface.co/docs/datasets/
)
ライブラリからデータセットをダウンロードし、前処理を行います。次に、
[
Trainer
](
https://huggingface.co/docs/transformers/main_classes/trainer
)
を使用して要約をサポートするアーキテクチャ上でデータセットをファインチューニングします。以下の例では、
[
CNN/DailyMail
](
https://huggingface.co/datasets/cnn_dailymail
)
データセット上で
[
T5-small
](
https://huggingface.co/t5-small
)
をファインチューニングする方法が示されています。T5 モデルは、そのトレーニング方法に起因して追加の
`source_prefix`
引数が必要です。このプロンプトにより、T5 はこれが要約タスクであることを知ることができます。
この例のスクリプトは、🤗
[
Datasets
](
https://huggingface.co/docs/datasets/
)
ライブラリからデータセットをダウンロードし、前処理を行います。次に、
[
Trainer
](
https://huggingface.co/docs/transformers/main_classes/trainer
)
を使用して要約をサポートするアーキテクチャ上でデータセットをファインチューニングします。以下の例では、
[
CNN/DailyMail
](
https://huggingface.co/datasets/cnn_dailymail
)
データセット上で
[
T5-small
](
https://huggingface.co/
google-t5/
t5-small
)
をファインチューニングする方法が示されています。T5 モデルは、そのトレーニング方法に起因して追加の
`source_prefix`
引数が必要です。このプロンプトにより、T5 はこれが要約タスクであることを知ることができます。
```
bash
python examples/pytorch/summarization/run_summarization.py
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--dataset_name
cnn_dailymail
\
...
...
@@ -112,12 +112,12 @@ python examples/pytorch/summarization/run_summarization.py \
</pt>
<tf>
この例のスクリプトは、🤗
[
Datasets
](
https://huggingface.co/docs/datasets/
)
ライブラリからデータセットをダウンロードして前処理します。その後、スクリプトは要約をサポートするアーキテクチャ上で Keras を使用してデータセットをファインチューニングします。以下の例では、
[
T5-small
](
https://huggingface.co/t5-small
)
を
[
CNN/DailyMail
](
https://huggingface.co/datasets/cnn_dailymail
)
データセットでファインチューニングする方法を示しています。T5 モデルは、そのトレーニング方法に起因して追加の
`source_prefix`
引数が必要です。このプロンプトは、T5 にこれが要約タスクであることを知らせます。
この例のスクリプトは、🤗
[
Datasets
](
https://huggingface.co/docs/datasets/
)
ライブラリからデータセットをダウンロードして前処理します。その後、スクリプトは要約をサポートするアーキテクチャ上で Keras を使用してデータセットをファインチューニングします。以下の例では、
[
T5-small
](
https://huggingface.co/
google-t5/
t5-small
)
を
[
CNN/DailyMail
](
https://huggingface.co/datasets/cnn_dailymail
)
データセットでファインチューニングする方法を示しています。T5 モデルは、そのトレーニング方法に起因して追加の
`source_prefix`
引数が必要です。このプロンプトは、T5 にこれが要約タスクであることを知らせます。
```
bash
python examples/tensorflow/summarization/run_summarization.py
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--dataset_name
cnn_dailymail
\
--dataset_config
"3.0.0"
\
--output_dir
/tmp/tst-summarization
\
...
...
@@ -143,7 +143,7 @@ python examples/tensorflow/summarization/run_summarization.py \
torchrun
\
--nproc_per_node
8 pytorch/summarization/run_summarization.py
\
--fp16
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--dataset_name
cnn_dailymail
\
...
...
@@ -167,7 +167,7 @@ Tensor Processing Units (TPUs)は、パフォーマンスを加速させるた
```
bash
python xla_spawn.py
--num_cores
8
\
summarization/run_summarization.py
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--dataset_name
cnn_dailymail
\
...
...
@@ -186,7 +186,7 @@ python xla_spawn.py --num_cores 8 \
```
bash
python run_summarization.py
\
--tpu
name_of_tpu_resource
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--dataset_name
cnn_dailymail
\
--dataset_config
"3.0.0"
\
--output_dir
/tmp/tst-summarization
\
...
...
@@ -226,7 +226,7 @@ Now you are ready to launch the training:
```
bash
accelerate launch run_summarization_no_trainer.py
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--dataset_name
cnn_dailymail
\
--dataset_config
"3.0.0"
\
--source_prefix
"summarize: "
\
...
...
@@ -245,7 +245,7 @@ accelerate launch run_summarization_no_trainer.py \
```
bash
python examples/pytorch/summarization/run_summarization.py
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--train_file
path_to_csv_or_jsonlines_file
\
...
...
@@ -270,7 +270,7 @@ python examples/pytorch/summarization/run_summarization.py \
```
bash
python examples/pytorch/summarization/run_summarization.py
\
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--max_train_samples
50
\
--max_eval_samples
50
\
--max_predict_samples
50
\
...
...
@@ -300,7 +300,7 @@ examples/pytorch/summarization/run_summarization.py -h
```
bash
python examples/pytorch/summarization/run_summarization.py
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--dataset_name
cnn_dailymail
\
...
...
@@ -318,7 +318,7 @@ python examples/pytorch/summarization/run_summarization.py
```
bash
python examples/pytorch/summarization/run_summarization.py
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--dataset_name
cnn_dailymail
\
...
...
@@ -350,7 +350,7 @@ huggingface-cli login
```
bash
python examples/pytorch/summarization/run_summarization.py
--model_name_or_path
t5-small
\
--model_name_or_path
google-t5/
t5-small
\
--do_train
\
--do_eval
\
--dataset_name
cnn_dailymail
\
...
...
docs/source/ja/serialization.md
View file @
f497f564
...
...
@@ -57,10 +57,10 @@ pip install optimum[exporters]
optimum-cli
export
onnx
--help
```
🤗 Hubからモデルのチェックポイントをエクスポートするには、例えば
`distilbert-base-uncased-distilled-squad`
を使いたい場合、以下のコマンドを実行してください:
🤗 Hubからモデルのチェックポイントをエクスポートするには、例えば
`distilbert
/distilbert
-base-uncased-distilled-squad`
を使いたい場合、以下のコマンドを実行してください:
```
bash
optimum-cli
export
onnx
--model
distilbert-base-uncased-distilled-squad distilbert_base_uncased_squad_onnx/
optimum-cli
export
onnx
--model
distilbert/
distilbert-base-uncased-distilled-squad distilbert_base_uncased_squad_onnx/
```
進行状況を示し、結果の
`model.onnx`
が保存される場所を表示するログは、以下のように表示されるはずです:
...
...
@@ -147,7 +147,7 @@ pip install transformers[onnx]
`transformers.onnx`
パッケージをPythonモジュールとして使用して、事前に用意された設定を使用してチェックポイントをエクスポートする方法は以下の通りです:
```
bash
python
-m
transformers.onnx
--model
=
distilbert-base-uncased onnx/
python
-m
transformers.onnx
--model
=
distilbert
/distilbert
-base-uncased onnx/
```
この方法は、
`--model`
引数で定義されたチェックポイントのONNXグラフをエクスポートします。🤗 Hubのいずれかのチェックポイントまたはローカルに保存されたチェックポイントを渡すことができます。エクスポートされた
`model.onnx`
ファイルは、ONNX標準をサポートする多くのアクセラレータで実行できます。例えば、ONNX Runtimeを使用してモデルを読み込んで実行する方法は以下の通りです:
...
...
@@ -157,7 +157,7 @@ python -m transformers.onnx --model=distilbert-base-uncased onnx/
>>>
from
transformers
import
AutoTokenizer
>>>
from
onnxruntime
import
InferenceSession
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilbert-base-uncased"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilbert
/distilbert
-base-uncased"
)
>>>
session
=
InferenceSession
(
"onnx/model.onnx"
)
>>>
# ONNX Runtime expects NumPy arrays as input
>>>
inputs
=
tokenizer
(
"Using DistilBERT with ONNX Runtime!"
,
return_tensors
=
"np"
)
...
...
docs/source/ja/task_summary.md
View file @
f497f564
...
...
@@ -281,7 +281,7 @@ score: 0.9327, start: 30, end: 54, answer: huggingface/transformers
>>>
from
transformers
import
pipeline
>>>
text
=
"translate English to French: Hugging Face is a community-based open-source platform for machine learning."
>>>
translator
=
pipeline
(
task
=
"translation"
,
model
=
"t5-small"
)
>>>
translator
=
pipeline
(
task
=
"translation"
,
model
=
"
google-t5/
t5-small"
)
>>>
translator
(
text
)
[{
'translation_text'
:
"Hugging Face est une tribune communautaire de l'apprentissage des machines."
}]
```
...
...
docs/source/ja/tasks/language_modeling.md
View file @
f497f564
...
...
@@ -32,7 +32,7 @@ rendered properly in your Markdown viewer.
このガイドでは、次の方法を説明します。
1.
[
ELI5
](
https:/
)
の
[
r/askscience
](
https://www.reddit.com/r/askscience/
)
サブセットで
[
DistilGPT2
](
https://huggingface.co/distilgpt2
)
を微調整します。 /huggingface.co/datasets/eli5) データセット。
1.
[
ELI5
](
https:/
)
の
[
r/askscience
](
https://www.reddit.com/r/askscience/
)
サブセットで
[
DistilGPT2
](
https://huggingface.co/
distilbert/
distilgpt2
)
を微調整します。 /huggingface.co/datasets/eli5) データセット。
2.
微調整したモデルを推論に使用します。
<Tip>
...
...
@@ -112,7 +112,7 @@ pip install transformers datasets evaluate
```
py
>>>
from
transformers
import
AutoTokenizer
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilgpt2"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"
distilbert/
distilgpt2"
)
```
上の例からわかるように、
`text`
フィールドは実際には
`answers`
内にネストされています。つまり、次のことが必要になります。
...
...
@@ -234,7 +234,7 @@ Apply the `group_texts` function over the entire dataset:
```
py
>>>
from
transformers
import
AutoModelForCausalLM
,
TrainingArguments
,
Trainer
>>>
model
=
AutoModelForCausalLM
.
from_pretrained
(
"distilgpt2"
)
>>>
model
=
AutoModelForCausalLM
.
from_pretrained
(
"
distilbert/
distilgpt2"
)
```
この時点で残っている手順は次の 3 つだけです。
...
...
@@ -298,7 +298,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数
```
py
>>>
from
transformers
import
TFAutoModelForCausalLM
>>>
model
=
TFAutoModelForCausalLM
.
from_pretrained
(
"distilgpt2"
)
>>>
model
=
TFAutoModelForCausalLM
.
from_pretrained
(
"
distilbert/
distilgpt2"
)
```
[
`~transformers.TFPreTrainedModel.prepare_tf_dataset`
] を使用して、データセットを
`tf.data.Dataset`
形式に変換します。
...
...
docs/source/ja/tasks/masked_language_modeling.md
View file @
f497f564
...
...
@@ -26,7 +26,7 @@ rendered properly in your Markdown viewer.
このガイドでは、次の方法を説明します。
1.
[
ELI5
](
https://huggingface.co/distilroberta-base
)
の
[
r/askscience
](
https://www.reddit.com/r/askscience/
)
サブセットで
[
DistilRoBERTa
](
https://huggingface.co/distilroberta-base
)
を微調整します。 ://huggingface.co/datasets/eli5) データセット。
1.
[
ELI5
](
https://huggingface.co/
distilbert/
distilroberta-base
)
の
[
r/askscience
](
https://www.reddit.com/r/askscience/
)
サブセットで
[
DistilRoBERTa
](
https://huggingface.co/
distilbert/
distilroberta-base
)
を微調整します。 ://huggingface.co/datasets/eli5) データセット。
2.
微調整したモデルを推論に使用します。
<Tip>
...
...
@@ -101,7 +101,7 @@ pip install transformers datasets evaluate
```
py
>>>
from
transformers
import
AutoTokenizer
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilroberta-base"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"
distilbert/
distilroberta-base"
)
```
上の例からわかるように、
`text`
フィールドは実際には
`answers`
内にネストされています。これは、次のことを行う必要があることを意味します
...
...
@@ -219,7 +219,7 @@ pip install transformers datasets evaluate
```
py
>>>
from
transformers
import
AutoModelForMaskedLM
>>>
model
=
AutoModelForMaskedLM
.
from_pretrained
(
"distilroberta-base"
)
>>>
model
=
AutoModelForMaskedLM
.
from_pretrained
(
"
distilbert/
distilroberta-base"
)
```
この時点で残っている手順は次の 3 つだけです。
...
...
@@ -287,7 +287,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数
```
py
>>>
from
transformers
import
TFAutoModelForMaskedLM
>>>
model
=
TFAutoModelForMaskedLM
.
from_pretrained
(
"distilroberta-base"
)
>>>
model
=
TFAutoModelForMaskedLM
.
from_pretrained
(
"
distilbert/
distilroberta-base"
)
```
[
`~transformers.TFPreTrainedModel.prepare_tf_dataset`
] を使用して、データセットを
`tf.data.Dataset`
形式に変換します。
...
...
docs/source/ja/tasks/multiple_choice.md
View file @
f497f564
...
...
@@ -22,7 +22,7 @@ rendered properly in your Markdown viewer.
このガイドでは、次の方法を説明します。
1.
[
SWAG
](
https://huggingface.co/datasets/swag
)
データセットの「通常」構成で
[
BERT
](
https://huggingface.co/bert-base-uncased
)
を微調整して、最適なデータセットを選択します複数の選択肢と何らかのコンテキストを考慮して回答します。
1.
[
SWAG
](
https://huggingface.co/datasets/swag
)
データセットの「通常」構成で
[
BERT
](
https://huggingface.co/
google-bert/
bert-base-uncased
)
を微調整して、最適なデータセットを選択します複数の選択肢と何らかのコンテキストを考慮して回答します。
2.
微調整したモデルを推論に使用します。
<Tip>
...
...
@@ -90,7 +90,7 @@ pip install transformers datasets evaluate
```
py
>>>
from
transformers
import
AutoTokenizer
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"bert-base-uncased"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"
google-bert/
bert-base-uncased"
)
```
作成する前処理関数は次のことを行う必要があります。
...
...
@@ -254,7 +254,7 @@ tokenized_swag = swag.map(preprocess_function, batched=True)
```
py
>>>
from
transformers
import
AutoModelForMultipleChoice
,
TrainingArguments
,
Trainer
>>>
model
=
AutoModelForMultipleChoice
.
from_pretrained
(
"bert-base-uncased"
)
>>>
model
=
AutoModelForMultipleChoice
.
from_pretrained
(
"
google-bert/
bert-base-uncased"
)
```
この時点で残っている手順は次の 3 つだけです。
...
...
@@ -318,7 +318,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数
```
py
>>>
from
transformers
import
TFAutoModelForMultipleChoice
>>>
model
=
TFAutoModelForMultipleChoice
.
from_pretrained
(
"bert-base-uncased"
)
>>>
model
=
TFAutoModelForMultipleChoice
.
from_pretrained
(
"
google-bert/
bert-base-uncased"
)
```
[
`~transformers.TFPreTrainedModel.prepare_tf_dataset`
] を使用して、データセットを
`tf.data.Dataset`
形式に変換します。
...
...
docs/source/ja/tasks/prompting.md
View file @
f497f564
...
...
@@ -76,7 +76,7 @@ Falcon、LLaMA などの大規模言語モデルは、事前にトレーニン
>>>
torch
.
manual_seed
(
0
)
# doctest: +IGNORE_RESULT
>>>
generator
=
pipeline
(
'text-generation'
,
model
=
'gpt2'
)
>>>
generator
=
pipeline
(
'text-generation'
,
model
=
'
openai-community/
gpt2'
)
>>>
prompt
=
"Hello, I'm a language model"
>>>
generator
(
prompt
,
max_length
=
30
)
...
...
docs/source/ja/tasks/question_answering.md
View file @
f497f564
...
...
@@ -27,7 +27,7 @@ rendered properly in your Markdown viewer.
このガイドでは、次の方法を説明します。
1.
抽出的質問応答用に
[
SQuAD
](
https://huggingface.co/datasets/squad
)
データセット上の
[
DistilBERT
](
https://huggingface.co/distilbert-base-uncased
)
を微調整します。
1.
抽出的質問応答用に
[
SQuAD
](
https://huggingface.co/datasets/squad
)
データセット上の
[
DistilBERT
](
https://huggingface.co/distilbert
/distilbert
-base-uncased
)
を微調整します。
2.
微調整したモデルを推論に使用します。
<Tip>
...
...
@@ -102,7 +102,7 @@ pip install transformers datasets evaluate
```
py
>>>
from
transformers
import
AutoTokenizer
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilbert-base-uncased"
)
>>>
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"distilbert
/distilbert
-base-uncased"
)
```
質問応答タスクに特有の、注意すべき前処理手順がいくつかあります。
...
...
@@ -208,7 +208,7 @@ pip install transformers datasets evaluate
```
py
>>>
from
transformers
import
AutoModelForQuestionAnswering
,
TrainingArguments
,
Trainer
>>>
model
=
AutoModelForQuestionAnswering
.
from_pretrained
(
"distilbert-base-uncased"
)
>>>
model
=
AutoModelForQuestionAnswering
.
from_pretrained
(
"distilbert
/distilbert
-base-uncased"
)
```
この時点で残っている手順は次の 3 つだけです。
...
...
@@ -276,7 +276,7 @@ TensorFlow でモデルを微調整するには、オプティマイザー関数
```
py
>>>
from
transformers
import
TFAutoModelForQuestionAnswering
>>>
model
=
TFAutoModelForQuestionAnswering
(
"distilbert-base-uncased"
)
>>>
model
=
TFAutoModelForQuestionAnswering
(
"distilbert
/distilbert
-base-uncased"
)
```
[
`~transformers.TFPreTrainedModel.prepare_tf_dataset`
] を使用して、データセットを
`tf.data.Dataset`
形式に変換します。
...
...
Prev
1
…
4
5
6
7
8
9
10
11
12
…
29
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment