From af74ec65a7d5a1fbe220164f0c3ece601c091114 Mon Sep 17 00:00:00 2001 From: eromomon Date: Fri, 11 Jul 2025 11:58:26 -0600 Subject: [PATCH] Update Readme to Run Multiple Choice Script from Example Directory (#39323) * Update Readme to run in current place * Update Readme files to execute PyTorch examples from their respective folders --- examples/pytorch/README.md | 4 ++-- examples/pytorch/contrastive-image-text/README.md | 2 +- examples/pytorch/multiple-choice/README.md | 2 +- examples/pytorch/summarization/README.md | 4 ++-- examples/pytorch/translation/README.md | 10 +++++----- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/pytorch/README.md b/examples/pytorch/README.md index 4e318b3edb..9022fdb570 100644 --- a/examples/pytorch/README.md +++ b/examples/pytorch/README.md @@ -65,7 +65,7 @@ examples/pytorch/token-classification/run_ner.py \ Most example scripts should have the first two command line arguments and some have the third one. You can quickly check if a given example supports any of these by passing a `-h` option, e.g.: ```bash -examples/pytorch/token-classification/run_ner.py -h +token-classification/run_ner.py -h ``` ## Resuming training @@ -110,7 +110,7 @@ classification MNLI task using the `run_glue` script, with 8 GPUs: ```bash torchrun \ - --nproc_per_node 8 pytorch/text-classification/run_glue.py \ + --nproc_per_node 8 text-classification/run_glue.py \ --model_name_or_path google-bert/bert-large-uncased-whole-word-masking \ --task_name mnli \ --do_train \ diff --git a/examples/pytorch/contrastive-image-text/README.md b/examples/pytorch/contrastive-image-text/README.md index c39f17a138..864a31b603 100644 --- a/examples/pytorch/contrastive-image-text/README.md +++ b/examples/pytorch/contrastive-image-text/README.md @@ -84,7 +84,7 @@ loaded using the pre-trained weights. Finally, we can run the example script to train the model: ```bash -python examples/pytorch/contrastive-image-text/run_clip.py \ +python run_clip.py \ --output_dir ./clip-roberta-finetuned \ --model_name_or_path ./clip-roberta \ --data_dir $PWD/data \ diff --git a/examples/pytorch/multiple-choice/README.md b/examples/pytorch/multiple-choice/README.md index 91e28a51c8..71462eecb5 100644 --- a/examples/pytorch/multiple-choice/README.md +++ b/examples/pytorch/multiple-choice/README.md @@ -21,7 +21,7 @@ limitations under the License. `run_swag` allows you to fine-tune any model from our [hub](https://huggingface.co/models) (as long as its architecture as a `ForMultipleChoice` version in the library) on the SWAG dataset or your own csv/jsonlines files as long as they are structured the same way. To make it works on another dataset, you will need to tweak the `preprocess_function` inside the script. ```bash -python examples/pytorch/multiple-choice/run_swag.py \ +python run_swag.py \ --model_name_or_path FacebookAI/roberta-base \ --do_train \ --do_eval \ diff --git a/examples/pytorch/summarization/README.md b/examples/pytorch/summarization/README.md index 0d332564de..26561df242 100644 --- a/examples/pytorch/summarization/README.md +++ b/examples/pytorch/summarization/README.md @@ -40,7 +40,7 @@ and you also will find examples of these below. Here is an example on a summarization task: ```bash -python examples/pytorch/summarization/run_summarization.py \ +python run_summarization.py \ --model_name_or_path google-t5/t5-small \ --do_train \ --do_eval \ @@ -64,7 +64,7 @@ And here is how you would use it on your own files, after adjusting the values f `--train_file`, `--validation_file`, `--text_column` and `--summary_column` to match your setup: ```bash -python examples/pytorch/summarization/run_summarization.py \ +python run_summarization.py \ --model_name_or_path google-t5/t5-small \ --do_train \ --do_eval \ diff --git a/examples/pytorch/translation/README.md b/examples/pytorch/translation/README.md index 8285355fb0..4659843c66 100644 --- a/examples/pytorch/translation/README.md +++ b/examples/pytorch/translation/README.md @@ -42,7 +42,7 @@ and you also will find examples of these below. Here is an example of a translation fine-tuning with a MarianMT model: ```bash -python examples/pytorch/translation/run_translation.py \ +python run_translation.py \ --model_name_or_path Helsinki-NLP/opus-mt-en-ro \ --do_train \ --do_eval \ @@ -62,7 +62,7 @@ MBart and some T5 models require special handling. T5 models `google-t5/t5-small`, `google-t5/t5-base`, `google-t5/t5-large`, `google-t5/t5-3b` and `google-t5/t5-11b` must use an additional argument: `--source_prefix "translate {source_lang} to {target_lang}"`. For example: ```bash -python examples/pytorch/translation/run_translation.py \ +python run_translation.py \ --model_name_or_path google-t5/t5-small \ --do_train \ --do_eval \ @@ -85,7 +85,7 @@ For the aforementioned group of T5 models it's important to remember that if you MBart models require a different format for `--source_lang` and `--target_lang` values, e.g. instead of `en` it expects `en_XX`, for `ro` it expects `ro_RO`. The full MBart specification for language codes can be found [here](https://huggingface.co/facebook/mbart-large-cc25). For example: ```bash -python examples/pytorch/translation/run_translation.py \ +python run_translation.py \ --model_name_or_path facebook/mbart-large-en-ro \ --do_train \ --do_eval \ @@ -104,7 +104,7 @@ And here is how you would use the translation finetuning on your own files, afte values for the arguments `--train_file`, `--validation_file` to match your setup: ```bash -python examples/pytorch/translation/run_translation.py \ +python run_translation.py \ --model_name_or_path google-t5/t5-small \ --do_train \ --do_eval \ @@ -133,7 +133,7 @@ Here the languages are Romanian (`ro`) and English (`en`). If you want to use a pre-processed dataset that leads to high BLEU scores, but for the `en-de` language pair, you can use `--dataset_name stas/wmt14-en-de-pre-processed`, as following: ```bash -python examples/pytorch/translation/run_translation.py \ +python run_translation.py \ --model_name_or_path google-t5/t5-small \ --do_train \ --do_eval \