Skip to contents

BERTScore recall, precision and F1 (Kamath Eq 8.7-8.9)

Usage

morie_kamath_ch8_bertscore_recall(x, xhat, normalize = FALSE)

morie_kamath_ch8_bertscore_precision(x, xhat, normalize = FALSE)

morie_kamath_ch8_bertscore_f1(P_BERT, R_BERT)

Arguments

x

Reference token embeddings.

xhat

Candidate embeddings.

normalize

Cosine instead of raw dot products.

P_BERT, R_BERT

Precision and recall.

Value

List with estimate, per_token, greedy_match.

Details

One greedy matcher serves the recall and precision Python modules exactly as km120 calls km119 with the arguments swapped: km119 -> morie_kamath_ch8_bertscore_recall, km120 -> morie_kamath_ch8_bertscore_precision, km121 -> morie_kamath_ch8_bertscore_f1. greedy_match is 0-BASED.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_kamath_ch8_bertscore_recall(V, V)
#> $estimate
#> [1] 36
#> 
#> $per_token
#> [1]  8 16 24 32 40 48 56 64
#> 
#> $greedy_match
#> [1] 7 7 7 7 7 7 7 7
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "BERTScore recall (Kamath Eq 8.7)"
#>