Update no_trainer scripts to include gather_for_metrics
See original GitHub issueFeature request
🤗 Accelerate has a wrapper to help with distributed metric calculation (a tough problem!), and the no_trainer
scripts should be updated to include it!
An example can be seen here, below is an example diff of what the integration would look like:
- predictions, references = accelerator.gather((predictions, batch["labels"]))
- # If we are in a multiprocess environment, the last batch has duplicates
- if accelerator.num_processes > 1:
- if step == len(eval_dataloader) - 1:
- predictions = predictions[: len(eval_dataloader.dataset) - samples_seen]
- references = references[: len(eval_dataloader.dataset) - samples_seen]
- else:
- samples_seen += references.shape[0]
+ predictions, references = accelerator.gather_for_metrics((predictions, batch["labels"]))
The list of available scripts to update include:
- examples/pytorch/image-classification/run_image_classification_no_trainer.py
- examples/pytorch/language-modeling/run_clm_no_trainer.py
- examples/pytorch/language-modeling/run_mlm_no_trainer.py
- examples/pytorch/multiple-choice/run_swag_no_trainer.py
- examples/pytorch/question-answering/run_qa_beam_search_no_trainer.py
- examples/pytorch/question_answering/run_qa_no_trainer.py
- examples/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
- examples/pytorch/speech-pretraining/run_wav2vec2_pretraining_no_trainer.py
- examples/pytorch/summarization/run_summarization_no_trainer.py
Motivation
This is a great first issue for someone who wants to learn how to use some of the latest bits in Accelerate and get an easy beginner contribution to the library 🤗
Your contribution
If you decide to pick up this issue, feel free to ping myself (@muellerzr), @sgugger, or @pacman100 to review 🤗
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
After update the instance script action and script... - ServiceNow
I created two catalogs where I am using two script actions and a common script include for both. here is my script action....
Read more >Update and manage your published add-on | Apps Script
When you're ready to publish, create a new version for your add-on deployment. From the Apps Script project, take the following steps: At...
Read more >UPDATE SCRIPT - IBM Spectrum Protect
UPDATE SCRIPT (Update an IBM Spectrum Protect script). Use this command to change a command line or to add a new command line...
Read more >Update Data Logic scripts - Cisco IoT Operations Dashboard
To update a script, you must first undeploy it from all EI Agents. You can then update the script using VS Code and...
Read more >Update a Script | BigCommerce Dev Center
It will enable automatic cleanup of the script when the single click app is uninstalled or OAuth token is revoked. load_method. string. The...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @muellerzr opened PR #18443 for first three examples in the list.
Hi @muellerzr I opened this PR https://github.com/huggingface/transformers/pull/18474 for examples 5,6 and 7.