Coder Social home page Coder Social logo

TypeError: comet.models.utils.Prediction is not a dataclasss. This is a subclass of ModelOutput and so must use the @dataclass decorator. about comet HOT 5 CLOSED

devrimcavusoglu avatar devrimcavusoglu commented on June 23, 2024
TypeError: comet.models.utils.Prediction is not a dataclasss. This is a subclass of ModelOutput and so must use the @dataclass decorator.

from comet.

Comments (5)

aRyBernAlTEglOTRO avatar aRyBernAlTEglOTRO commented on June 23, 2024 2

Hi @dmar1n, I think you can try adding the @dataclass(init=False) decorator to the classes of models.utils inheriting from Transformers' ModelOutput.

from comet.

dmar1n avatar dmar1n commented on June 23, 2024 2

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.

from comet.

lx0126z avatar lx0126z commented on June 23, 2024 1

try this:
pip install unbabel-comet==2.0.1 --force-reinstall --no-cache-dir

from comet.

dmar1n avatar dmar1n commented on June 23, 2024

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.

Traceback

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'

from comet.

ricardorei avatar ricardorei commented on June 23, 2024

I'll try to bump the package version in the next few weeks.

from comet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.