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 comet scorer #118

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add comet scorer #118

wants to merge 8 commits into from

Conversation

anthdr
Copy link

@anthdr anthdr commented Sep 25, 2024

Added comet scorers for validation in NMT training.
I left progress_bar=True, num_workers=0, batch_size=64 and gpu=0 for cpu inference, should it be like that by default and should it be modifiable via config ?
I did not modify tests as it would greatly extend the tests duration (downloading comet models and inferencing on cpu).
I also took the liberty to lightly modify wmt17 recipe/doc to make it more beginner friendly.

Fix #34

@vince62s
Copy link
Contributor

Thanks for your PR! I think it would be better to use a single block of code for all comet-like scorer and add a setting for the model path at start-up.

@vince62s
Copy link
Contributor

vince62s commented Oct 2, 2024

In a real world, COMET requires a GPU so it would be great to unload the model being trained or/and specify another gpu for comet. What do you think ?

Copy link
Member

@francoishernandez francoishernandez left a comment

Choose a reason for hiding this comment

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

👋 @anthdr !
Here are a few comments.

eole/scorers/__init__.py Show resolved Hide resolved
eole/scorers/comet.py Outdated Show resolved Hide resolved
Comment on lines 31 to 38
if self.model_name == "COMET-KIWI":
for _src, _hyp in zip(texts_srcs, preds):
current_segment = {"src": _src, "mt": _hyp}
data.append(current_segment)
else:
for _src, _tgt, _hyp in zip(texts_srcs, texts_refs, preds):
current_segment = {"src": _src, "mt": _hyp, "ref": _tgt}
data.append(current_segment)
Copy link
Member

Choose a reason for hiding this comment

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

Not super fan of this condition, but I guess that works. Not sure we could do much cleaner without defining subclasses for each metric, which would probably be overkill here.

data.append(current_segment)
if len(preds) > 0:
score = self.comet_model.predict(
data, batch_size=64, gpus=0, num_workers=0, progress_bar=True
Copy link
Member

Choose a reason for hiding this comment

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

batch_size is a bit hidden here. Do we expect to need to change this at some point?
Might not be necessary to have a dedicated flag for this, but maybe set this explicitly in the init so that it's a bit more explicit.

Copy link
Author

Choose a reason for hiding this comment

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

Maybe we should let these 3 (4?) option to be customized indeed

@anthdr
Copy link
Author

anthdr commented Oct 14, 2024

Continuing the discussion here:
There are multiple way for doing this, off-loading current model to run comet scoring on gpu as @vince62s suggested, we could run it parallel of the training (subprocessing a comet cpu scoring), dedicating a second gpu to score.
That's why I first implemented it on cpu during eval (to not mess with vram) and have it working transparently for a naiver user.
What would you recommend ?

@vince62s
Copy link
Contributor

I think the easiest for 1) user convenience 2) speed is to unload the model being trained, load the comet model on the same gpu, and relaod the trianed model after scoring. Scoring on cpu will be way too slow and dedicating a second gpu will be a nightmare to handle from the user standpoint

@anthdr
Copy link
Author

anthdr commented Dec 27, 2024

Tested how vram was impacted with this method:
Loading a comet model does not seem to directly load vram
self.comet_model = load_from_checkpoint(comet_model_path)
but after running prediction

            score = self.comet_model.predict(
                data, batch_size=64, gpus=1, num_workers=0, progress_bar=True
            )

This leaves a 300mib trace in vram.

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.

COMET scoring
3 participants