Unbabel / COMET

A Neural Framework for MT Evaluation
https://unbabel.github.io/COMET/html/index.html
Apache License 2.0
453 stars 72 forks source link

wmt20-comet-qe-da do not work under huggingface guides (possible version conflicts) #129

Open Yaoming95 opened 1 year ago

Yaoming95 commented 1 year ago

🐛 Bug

wmt20-comet-qe-da do not work under huggingface guides I followed https://huggingface.co/Unbabel/wmt20-comet-qe-da,

model_path = download_model("wmt20-comet-qe-da") # where I removed Unbabel according to https://github.com/Unbabel/COMET/issues/125 since I use comet 1.1.3
model = load_from_checkpoint(model_path)
data = [
    {
        "src": "The output signal provides constant sync so the display never glitches.",
        "mt": "Das Ausgangssignal bietet eine konstante Synchronisation, so dass die Anzeige nie stört."
    },
    {
        "src": "Kroužek ilustrace je určen všem milovníkům umění ve věku od 10 do 15 let.",
        "mt": "Кільце ілюстрації призначене для всіх любителів мистецтва у віці від 10 до 15 років."
    },
    {
        "src": "Mandela then became South Africa's first black president after his African National Congress party won the 1994 election.",
        "mt": "その後、1994年の選挙でアフリカ国民会議派が勝利し、南アフリカ初の黒人大統領となった。"
    }
]
model_output = model.predict(data, batch_size=8, gpus=1)
print (model_output)

The output is


LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
Predicting DataLoader 0:   0%|                                                                               | 0/1 [00:00<?, ?it/s]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/comet/models/base.py", line 578, in predict
    self, dataloaders=dataloader, return_predictions=True
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1026, in predict
    self._predict_impl, model, dataloaders, datamodule, return_predictions, ckpt_path
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 723, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1072, in _predict_impl
    results = self._run(model, ckpt_path=self.ckpt_path)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1236, in _run
    results = self._run_stage()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1322, in _run_stage
    return self._run_predict()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1381, in _run_predict
    return self.predict_loop.run()
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/base.py", line 204, in run
    self.advance(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/dataloader/prediction_loop.py", line 102, in advance
    dataloader_iter, self.current_dataloader_idx, dl_max_batches, self.num_dataloaders, self.return_predictions
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/base.py", line 204, in run
    self.advance(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/epoch/prediction_epoch_loop.py", line 104, in advance
    self._predict_step(batch, batch_idx, dataloader_idx)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/loops/epoch/prediction_epoch_loop.py", line 132, in _predict_step
    predictions = self.trainer._call_strategy_hook("predict_step", *step_kwargs.values())
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/trainer/trainer.py", line 1765, in _call_strategy_hook
    output = fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pytorch_lightning/strategies/strategy.py", line 360, in predict_step
    return self.model.predict_step(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/comet/models/base.py", line 400, in predict_step
    return self(**batch)["score"].view(-1)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1118, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() missing 4 required positional arguments: 'src_input_ids', 'src_attention_mask', 'mt_input_ids', and 'mt_attention_mask'

The code used to work a few weeks ago. Are there conflicts among the recent updates?

Yaoming95 commented 1 year ago

The conflicts may happen between comet 1.1.2 and pytorch_lightning 1.6.3

When I downgrade to comet 1.0.0 and pytorch_lightning 1.3.5, everything work in normal

ricardorei commented 1 year ago

Hi @Yaoming95, I can investigate this a but further but is there any particular reason you're using version 1.1.2?

Yaoming95 commented 1 year ago

Hi @Yaoming95, I can investigate this a but further but is there any particular reason you're using version 1.1.2?

hi @ricardorei, thanks for your attention. Not for some particular reason about COMET, but just because of some compatibility problems, my working environment has to be Python 3.7 currently, which could not support COMET 2.0 . (As you can see in the Error Information)