Skip to content

add trainer integration docs#325

Merged
lvwerra merged 9 commits into
mainfrom
add-trainer-instructions
Oct 25, 2022
Merged

add trainer integration docs#325
lvwerra merged 9 commits into
mainfrom
add-trainer-instructions

Conversation

@lvwerra

@lvwerra lvwerra commented Oct 18, 2022

Copy link
Copy Markdown
Member

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

cc @osanseviero

@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented Oct 18, 2022

Copy link
Copy Markdown

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

@osanseviero osanseviero left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread docs/source/metric_integrations.mdx Outdated
Comment thread docs/source/metric_integrations.mdx Outdated
Comment thread docs/source/metric_integrations.mdx Outdated

### 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
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread docs/source/metric_integrations.mdx Outdated

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

## 🤗 Transformers

Copy link
Copy Markdown
Contributor

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.

Comment thread docs/source/_toctree.yml Outdated
Comment thread docs/source/metric_integrations.mdx Outdated
compute_metrics=compute_metrics,
)

trainer.train()

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread docs/source/metric_integrations.mdx Outdated
trainer.train()
```

You can use any `evaluate` metric with the `Trainer` and `Seq2SeqTrainer` as long as they are compatible with the task and predictions. No newline at end of file

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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>

@mathemakitten mathemakitten left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@osanseviero osanseviero left a comment

Copy link
Copy Markdown
Contributor

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.

5 participants