Closed arturnn closed 6 months ago
FYI: I submitted a PR with proposed fixes in #178
Thanks @arturnn I will look into the PR asap!
@arturnn haven't had time yet, but its not forgotten.
Hi ! I just got a very similar error ('dict' object has no attribute 'scores', also highlighting pred.scores in the trace), but in my case there is no GPU on the machine I used.
The first time I got the error I specified gpus=0 (I thought it was the correct way to make it run on CPU), but then I removed the parameter and got the same error as well.
%env TOKENIZERS_PARALLELISM=false
issue_data = [
{
"src": "10 ε° 15 ειε―δ»₯ιε°ε",
"mt": "Can I receive my food in 10 to 15 minutes?",
"ref": "Can it be delivered between 10 to 15 minutes?"
},
{
"src": "Pode ser entregue dentro de 10 a 15 minutos?",
"mt": "Can you send it for 10 to 15 minutes?",
"ref": "Can it be delivered between 10 to 15 minutes?"
}
]
comet_model = load_from_checkpoint(download_model("Unbabel/wmt22-comet-da"))
comet_output = comet_model.predict(issue_data, batch_size=8)
print(model_output)
print(model_output.system_scores)
Ouput:
[...]
Predicting DataLoader 0: 100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 1/1 [00:00<00:00, 3.09it/s]
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[56], line 15
1 get_ipython().run_line_magic('env', 'TOKENIZERS_PARALLELISM=false')
3 issue_data = [
4 {
5 "src": "10 ε° 15 ειε―δ»₯ιε°ε",
(...)
13 }
14 ]
---> 15 comet_output = comet_model.predict(issue_data, batch_size=8)
16 # comet_output = comet_model.predict(test_dataset_comet, batch_size=8)
17 print(model_output)
File ~/.../venv-mt-models/lib/python3.10/site-packages/comet/models/base.py:652, in CometModel.predict(self, samples, batch_size, gpus, devices, mc_dropout, progress_bar, accelerator, num_workers, length_batching)
648 elif gpus > 1 and not trainer.is_global_zero:
649 # If we are not in the GLOBAL RANK we will return None
650 exit()
--> 652 scores = torch.cat([pred.scores for pred in predictions], dim=0).tolist()
653 if "metadata" in predictions[0]:
654 metadata = flatten_metadata([pred.metadata for pred in predictions])
File ~/.../venv-mt-models/lib/python3.10/site-packages/comet/models/base.py:652, in <listcomp>(.0)
648 elif gpus > 1 and not trainer.is_global_zero:
649 # If we are not in the GLOBAL RANK we will return None
650 exit()
--> 652 scores = torch.cat([pred.scores for pred in predictions], dim=0).tolist()
653 if "metadata" in predictions[0]:
654 metadata = flatten_metadata([pred.metadata for pred in predictions])
AttributeError: 'dict' object has no attribute 'scores'
I'm using unbabel-comet version 2.2.0 and Python 3.10, on Ubuntu 22.04
I ran into the same problem when using test cases on huggingface.
AttributeError: 'dict' object has no attribute 'scores'
Facing the same issue: AttributeError: 'dict' object has no attribute 'scores'
when running prediction on 1 GPU with the example from https://huggingface.co/Unbabel/wmt23-cometkiwi-da-xl. Looking forward to a fix!
I just publish a new release that should solve this.
π Bug
When trying to run scoring with COMET models via
comet-score
(although the issue is the same withcomet-mbr
when pre-scoring with qe models using multiple gpus) I get the following error. It works fine with--gpus 0
(running on cpu) or--gpus 1
. I tested it with wmt22-comet-da and wmt21-comet-mqm models.To Reproduce
Run
comet-score
command with--gpus
> 1 using the latest version of the package.Expected behaviour
Segment and system scores should be returned, as is the case with single gpu inference.
Environment
OS: Debian 11 (bullseye) Packaging: tried both conda (with python 3.11.6) and standard virtual environment with installation via pip (python 3.9.2) Version: latest master & current PyPI (2.2.0)