Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add trainer integration docs #325

Merged
merged 9 commits into from
Oct 25, 2022
Merged

add trainer integration docs #325

merged 9 commits into from
Oct 25, 2022

Conversation

lvwerra
Copy link
Member

@lvwerra lvwerra commented Oct 18, 2022

This PR adds an example of how to use evaluate with the 🤗 Transformers Trainer classes.

cc @osanseviero

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Oct 18, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good! I left a couple of suggestions. I would also love @NimaBoscarino's feedback on this

docs/source/metric_integrations.mdx Outdated Show resolved Hide resolved
docs/source/metric_integrations.mdx Outdated Show resolved Hide resolved

### Seq2SeqTrainer

For sequence-to-sequence tasks such as translation or summarization the [`~transformers.Seq2SeqTrainer`] is useful. It allows for the use of the generate method when setting `predict_with_generate=True`. That means we evaluate generated text within the `compute_metric` function, we just need to decode the predictions and labels first.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a bit hard to understand this paragraph with the eyes of a new reader. Why is the predict_with_generate needed? What would be used if not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to elaborate a bit more.


This guide outlines how `evaluate` metrics can be used with popular machine learning frameworks.

## 🤗 Transformers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT Of having separate pages for each library + a general one? Similar to https://huggingface.co/docs/hub/transformers. Then anyone could come and create a new page for their own libraries.

docs/source/_toctree.yml Outdated Show resolved Hide resolved
docs/source/metric_integrations.mdx Outdated Show resolved Hide resolved
compute_metrics=compute_metrics,
)

trainer.train()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI training a model with this setup in Colab + GPU seems to take some time, maybe a lighter version could be useful here as this is just to showcase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tried it, it took about 5min or so. You think that's too long?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 min is ok, although maybe even faster is nice, otherwise a % of your audience will just go away for a thing not vital for the guide

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should now be ~1min to download datasets and ~1min to train for both examples.

trainer.train()
```

You can use any `evaluate` metric with the `Trainer` and `Seq2SeqTrainer` as long as they are compatible with the task and predictions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also worth adding an example of running evaluation in an existing model on the Hub

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment on this. Essentially replacing trainer.train to trainer.evaluate.

@NimaBoscarino
Copy link
Contributor

Nothing to add that hasn't been said already!

lvwerra and others added 4 commits October 19, 2022 15:49
Co-authored-by: helen <31600291+mathemakitten@users.noreply.github.com>
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
Copy link
Contributor

@mathemakitten mathemakitten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@osanseviero osanseviero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks a lot 🔥

@lvwerra lvwerra merged commit 960dc92 into main Oct 25, 2022
@lvwerra lvwerra deleted the add-trainer-instructions branch October 25, 2022 11:47
NimaBoscarino pushed a commit to NimaBoscarino/evaluate that referenced this pull request Nov 9, 2022
* add trainer integration docs

* fix transformers links

* adapt headings

* add installation instructions

* Apply suggestions from code review

Co-authored-by: helen <31600291+mathemakitten@users.noreply.github.com>
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>

* integrate review feedbacks

* move toc

* take smaller sample

* fix toctree

Co-authored-by: helen <31600291+mathemakitten@users.noreply.github.com>
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
arjunpatel7 added a commit to arjunpatel7/evaluate that referenced this pull request Nov 24, 2022
lvwerra added a commit that referenced this pull request Dec 8, 2022
* Added Keras example for Evaluate metrics

Created a markdown file to show how to use Evaluate
when training and evaluate a model using Keras and Tensorflow.

* Added example for using Evaluate with Keras (#325)

Second commit for adding issue number.

* Apply fixes from code review

Fixes included some rephrasing, changing to use keras logs instead of print, and focusing on evaluating on the test set.

Co-authored-by: Leandro von Werra <lvwerra@users.noreply.github.com>

* Added extra sentence to clarify rounding and fixed typo

Typo from last commit accidently broke a code box.

* Added ref in toctree and accuracy in Keras Docs

Fixed incorrect ref addition to toctree, and added a
comment describing the acc score of the example
in the keras documentation.

Co-authored-by: Leandro von Werra <lvwerra@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants