Skip to contents

1 - exact WMD / max pair cost. The transport LP is the same core the Eq 8.10 module uses, so the two cannot drift.

Usage

morie_kamath_moverscore(
  hypothesis_embeddings,
  reference_embeddings,
  weights_h = NULL,
  weights_r = NULL,
  metric = "euclidean",
  normalizer = NULL
)

morie_kamath_word_movers_distance(cost, p, q, max_iter = 10000)

Arguments

hypothesis_embeddings, reference_embeddings

Token embedding rows.

weights_h, weights_r

Optional weights (normalised to sum to 1).

metric

"euclidean" or "cosine".

normalizer

Optional divisor.

cost

Cost matrix.

p, q

Marginals.

max_iter

Guard.

Value

List with estimate, wmd, normalizer.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_kamath_moverscore(V, V)
#> $estimate
#> [1] 1
#> 
#> $score
#> [1] 1
#> 
#> $wmd
#> [1] 0
#> 
#> $normalizer
#> [1] 7
#> 
#> $metric
#> [1] "euclidean"
#> 
#> $n_hypothesis
#> [1] 8
#> 
#> $n_reference
#> [1] 8
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "MoverScore = 1 - exact WMD / normalizer"
#>