lvwerra HF staff commited on
Commit
8123a8e
1 Parent(s): 6130ccf

Update Space (evaluate main: c447fc8e)

Browse files
Files changed (2) hide show
  1. comet.py +4 -23
  2. requirements.txt +1 -1
comet.py CHANGED
@@ -34,9 +34,6 @@ predictions['scores']
34
  ```
35
  """
36
 
37
- from dataclasses import dataclass
38
- from typing import Optional
39
-
40
  import comet # From: unbabel-comet
41
  import datasets
42
  import torch
@@ -109,29 +106,15 @@ Examples:
109
  """
110
 
111
 
112
- @dataclass
113
- class COMETConfig(evaluate.info.Config):
114
-
115
- name: str = "default"
116
-
117
- gpus: Optional[int] = None
118
- progress_bar: bool = False
119
-
120
-
121
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
122
  class COMET(evaluate.Metric):
123
-
124
- CONFIG_CLASS = COMETConfig
125
- ALLOWED_CONFIG_NAMES = None
126
-
127
- def _info(self, config):
128
 
129
  return evaluate.MetricInfo(
130
  description=_DESCRIPTION,
131
  citation=_CITATION,
132
  homepage="https://unbabel.github.io/COMET/html/index.html",
133
  inputs_description=_KWARGS_DESCRIPTION,
134
- config=config,
135
  features=datasets.Features(
136
  {
137
  "sources": datasets.Value("string", id="sequence"),
@@ -153,12 +136,10 @@ class COMET(evaluate.Metric):
153
  else:
154
  self.scorer = comet.load_from_checkpoint(comet.download_model(self.config_name))
155
 
156
- def _compute(self, sources, predictions, references):
157
- if self.config.gpus is None:
158
  gpus = 1 if torch.cuda.is_available() else 0
159
- else:
160
- gpus = self.config.gpus
161
  data = {"src": sources, "mt": predictions, "ref": references}
162
  data = [dict(zip(data, t)) for t in zip(*data.values())]
163
- scores, mean_score = self.scorer.predict(data, gpus=gpus, progress_bar=self.config.progress_bar)
164
  return {"mean_score": mean_score, "scores": scores}
 
34
  ```
35
  """
36
 
 
 
 
37
  import comet # From: unbabel-comet
38
  import datasets
39
  import torch
 
106
  """
107
 
108
 
 
 
 
 
 
 
 
 
 
109
  @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
110
  class COMET(evaluate.Metric):
111
+ def _info(self):
 
 
 
 
112
 
113
  return evaluate.MetricInfo(
114
  description=_DESCRIPTION,
115
  citation=_CITATION,
116
  homepage="https://unbabel.github.io/COMET/html/index.html",
117
  inputs_description=_KWARGS_DESCRIPTION,
 
118
  features=datasets.Features(
119
  {
120
  "sources": datasets.Value("string", id="sequence"),
 
136
  else:
137
  self.scorer = comet.load_from_checkpoint(comet.download_model(self.config_name))
138
 
139
+ def _compute(self, sources, predictions, references, gpus=None, progress_bar=False):
140
+ if gpus is None:
141
  gpus = 1 if torch.cuda.is_available() else 0
 
 
142
  data = {"src": sources, "mt": predictions, "ref": references}
143
  data = [dict(zip(data, t)) for t in zip(*data.values())]
144
+ scores, mean_score = self.scorer.predict(data, gpus=gpus, progress_bar=progress_bar)
145
  return {"mean_score": mean_score, "scores": scores}
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- git+https://github.com/huggingface/evaluate@e4a2724377909fe2aeb4357e3971e5a569673b39
2
  unbabel-comet
3
  torch
 
1
+ git+https://github.com/huggingface/evaluate@c447fc8eda9c62af501bfdc6988919571050d950
2
  unbabel-comet
3
  torch