Skip to contents

With pre-normalised embeddings, R = mean_i max_j x_i' xhat_j, P = mean_j max_i x_i' xhat_j and F = 2PR/(P+R); idf weights re-weight the recall sum.

Usage

Bertscore(reference, candidate, idf = NULL)

Arguments

reference

Reference token embeddings, k x d.

candidate

Candidate token embeddings, l x d.

idf

Importance weight per reference token, or NULL.

Value

List with P, R, F, recallmatch, precmatch, k, l, d.

References

Zhang, Kishore, Wu, Weinberger and Artzi (2020), ICLR; arXiv:1904.09675, Sect. 3. Read from the ar5iv rendering.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Bertscore(V, V)
#> $P
#> [1] 1
#> 
#> $R
#> [1] 1
#> 
#> $F
#> [1] 1
#> 
#> $recallmatch
#> [1] 1 1 1 1 1 1 1 1
#> 
#> $precmatch
#> [1] 1 1 1 1 1 1 1 1
#> 
#> $k
#> [1] 8
#> 
#> $l
#> [1] 8
#> 
#> $d
#> [1] 1
#> 
#> $method
#> [1] "BERTScore greedy cosine matching (Zhang et al. 2020)"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"