Skip to content

Commit

Permalink
empty cache when bert score calculation finished (#590)
Browse files Browse the repository at this point in the history
Co-authored-by: jeffrey <[email protected]>
  • Loading branch information
vkehfdl1 and jeffrey authored Jul 29, 2024
1 parent 52ec056 commit 56ea1b5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions autorag/evaluation/metric/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,8 @@ def bert_score(generation_gt: List[List[str]], generations: List[str],
df['bert_score'] = evaluator.compute(predictions=df['prediction'].tolist(),
references=df['reference'].tolist(),
lang=lang, nthreads=n_threads, batch_size=batch)['f1']

del evaluator
if torch.cuda.is_available():
torch.cuda.empty_cache()
return df.groupby(level=0)['bert_score'].max().tolist()

0 comments on commit 56ea1b5

Please sign in to comment.