Closed devrimcavusoglu closed 12 months ago
Hi @devrimcavusoglu, I encountered the same problem and tentatively applied the same solution as in your PR (i.e. adding the @dataclass
decorator to the classes of models.utils
inheriting from Transformers' ModelOutput
, as indicated in the Transformers doc). However, in my case, this produces another error later, when training a unified metric model, because the Target
class is passed in the scores, and as a dataclass, it does not accept any non-initialized argument (not declared in the Target class definition). I'm not sure if this is an issue with Transformers or COMET, but any hints would be appreciated.
TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/opt/mt/anaconda3/envs/comet/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
data = fetcher.fetch(index)
File "/opt/mt/anaconda3/envs/comet/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 54, in fetch
return self.collate_fn(data)
File "/opt/mt/anaconda3/envs/comet/lib/python3.10/site-packages/comet/models/base.py", line 511, in <lambda>
collate_fn=lambda s: self.prepare_sample(s, stage="validate"),
File "/opt/mt/anaconda3/envs/comet/lib/python3.10/site-packages/comet/models/multitask/unified_metric.py", line 362, in prepare_sample
targets = Target(score=torch.tensor(scores, dtype=torch.float))
TypeError: Target.__init__() got an unexpected keyword argument 'score'
try this:
pip install unbabel-comet==2.0.1 --force-reinstall --no-cache-dir
Hi @dmar1n, I think you can try adding the @dataclass(init=False)
decorator to the classes of models.utils
inheriting from Transformers' ModelOutput
.
Thanks a lot, @aRyBernAlTEglOTRO, for the hint! I have run a quick test, and I can confirm this is actually solving the issue I explained above.
When possible, I will propose a PR with this change; otherwise, the changes implemented in 2.1 won't work for training a UniTE model, and maybe other models.
I'll try to bump the package version in the next few weeks.
@ricardorei @devrimcavusoglu The change is overrided.
I copied the old ModelOutput class from hugging face to utils. This error should not happen anymore
š Bug
unbabel-comet==2.1.0
Related CI: https://github.com/obss/jury/actions/runs/6409370286/job/17400400518Traceback