Skip to content

Commit b1a346c

Browse files
committedAug 1, 2021
set all scores to zero for empty strings
1 parent 251764d commit b1a346c

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Automatic Evaluation Metric described in the paper [BERTScore: Evaluating Text G
77
- Support 8 SimCSE models
88
- Fix the support of scibert (to be compatible with transformers >= 4.0.0)
99
- Add scripts for reproducing some results in our paper (See this [folder](./reproduce))
10-
- Support fast tokenizers in huggingface transformers with `--use_fast_tokenizer`. Notably, you will get different scores because of the difference in the tokenizer implementations.
11-
- Updated to version 0.3.9
10+
- Support fast tokenizers in huggingface transformers with `--use_fast_tokenizer`. Notably, you will get different scores because of the difference in the tokenizer implementations ([#106](https://github.com/Tiiiger/bert_score/issues/106)).
11+
- Updated to version 0.3.10
1212
- Support 3 BigBird models
1313
- Fix bugs for mBART and T5
1414
- Support 4 mT5 models as requested ([#93](https://github.com/Tiiiger/bert_score/issues/93))

‎bert_score/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "0.3.9"
1+
__version__ = "0.3.10"
22
from .score import *
33
from .scorer import *

‎bert_score/utils.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,14 @@ def greedy_cos_idf(ref_embedding, ref_masks, ref_idf, hyp_embedding, hyp_masks,
463463

464464
if torch.any(hyp_zero_mask):
465465
print(
466-
"Warning: Empty candidate sentence detected; setting precision to be 0.", file=sys.stderr,
466+
"Warning: Empty candidate sentence detected; setting raw BERTscores to 0.", file=sys.stderr,
467467
)
468468
P = P.masked_fill(hyp_zero_mask, 0.0)
469+
R = R.masked_fill(hyp_zero_mask, 0.0)
469470

470471
if torch.any(ref_zero_mask):
471-
print("Warning: Empty reference sentence detected; setting recall to be 0.", file=sys.stderr)
472+
print("Warning: Empty reference sentence detected; setting raw BERTScores to 0.", file=sys.stderr)
473+
P = P.masked_fill(ref_zero_mask, 0.0)
472474
R = R.masked_fill(ref_zero_mask, 0.0)
473475

474476
F = F.masked_fill(torch.isnan(F), 0.0)

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name="bert_score",
6-
version='0.3.9',
6+
version='0.3.10',
77
author="Tianyi Zhang*, Varsha Kishore*, Felix Wu*, Kilian Q. Weinberger, and Yoav Artzi",
88
author_email="tzhang@asapp.com",
99
description="PyTorch implementation of BERT score",

0 commit comments

Comments
 (0)