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

[METRICS] Various improvements on metrics #466

Merged
merged 20 commits into from
Aug 17, 2020
Merged

[METRICS] Various improvements on metrics #466

merged 20 commits into from
Aug 17, 2020

Conversation

thomwolf
Copy link
Member

@thomwolf thomwolf commented Aug 1, 2020

  • Disallow the use of positional arguments to avoid predictions vs references mistakes
  • Allow to directly feed numpy/pytorch/tensorflow/pandas objects in metrics

@lhoestq lhoestq marked this pull request as ready for review August 12, 2020 15:46
@lhoestq
Copy link
Member

lhoestq commented Aug 12, 2020

The cast function is now called inside features.encode_example.
I also added encode_batch that was missing.

Moreover I used the cast function in Dataset.map to support torch/tensorflow tensors or numpy arrays inputs.

There are tests for tensors inputs in metrics and in .map

Copy link
Member Author

@thomwolf thomwolf left a comment

Choose a reason for hiding this comment

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

This is really cool and it's really nice to start seeing some test on metrics :)

A few comments

src/nlp/metric.py Show resolved Hide resolved
src/nlp/metric.py Outdated Show resolved Hide resolved
src/nlp/metric.py Outdated Show resolved Hide resolved
@@ -89,6 +90,38 @@
INCOMPLETE_SUFFIX = ".incomplete"


@contextmanager
def temp_seed(seed: int, set_pytorch=False, set_tensorflow=False):
Copy link
Member Author

Choose a reason for hiding this comment

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

Here there is an error with the tensorflow seed setter that I didn't have time to debug before my time off, maybe you can take a look? You can see the error simply by running the colab at https://colab.research.google.com/drive/1I_B1mcX0cOzOskr0rJN8u8xh_0CIken-?usp=sharing and using set_tensorflow=True in its call of temp_seed.

Copy link
Member

Choose a reason for hiding this comment

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

I fixed tensorflow's rng for eager mode.
Not sure how to do it when eager mode is off. I tried a few things but it didn't work

Copy link
Member Author

@thomwolf thomwolf left a comment

Choose a reason for hiding this comment

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

Awesome!

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

I think it's all good :)
Did you want to add something else @thomwolf ?

@thomwolf
Copy link
Member Author

I think we can merge

@thomwolf thomwolf merged commit 1840f3f into master Aug 17, 2020
@thomwolf thomwolf deleted the improve-metrics branch August 17, 2020 15:15
vegarab pushed a commit to vegarab/nlp that referenced this pull request Aug 18, 2020
* disallow positional arguments in metrics methods

* allow to use numpy/pytorch/tf/pandas objects in metrics

* clean up GLUE dataset and metric doc

* better checks to avoid positional arguments

* style and quality

* temp seed for everyone

* fixes

* more control

* move cast to python in encode_example + add encode_batch

* add metrics tests

* cast to python objects in map

* test cast to python objects in map

* style

* quality

* remove kwargs in add and add_batch

* fix download issue

* add local + aws signature test on metrics

* fix temp_seed for TF + add tests

* better test

Co-authored-by: Quentin Lhoest <lhoest.q@gmail.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.

2 participants