Skip to content

Commit

Permalink
Made comet score more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelNiklaus committed Jan 13, 2025
1 parent f6b50b4 commit 7f36065
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions community_tasks/swiss_legal_evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,15 @@ def compute(
predictions = [response[0].result for response in responses]
sources = [kwargs["formatted_doc"].specific["source"] for kwargs["formatted_doc"] in formatted_docs]

data = [
{
"src": src,
"mt": pred if isinstance(pred, str) else pred[0],
"ref": gold,
}
for src, pred, gold in zip(sources, predictions, golds)
]
def unpack(x):
if isinstance(x, str):
return x
elif isinstance(x, (list, tuple)):
return unpack(x[0])
else:
raise ValueError(f"Unknown type {type(x)} of prediction {x}")

data = [{"src": src, "mt": unpack(pred), "ref": gold} for src, pred, gold in zip(sources, predictions, golds)]
model_output = self.model.predict(
data,
batch_size=self.batch_size,
Expand Down

0 comments on commit 7f36065

Please sign in to comment.