Function er_compare_embeddings computes the similarity between two or more embeddings.

er_compare_embeddings(
  embeddings,
  metric = "cosine",
  comparison_metric = "spearman"
)

Arguments

embeddings

a list of embedding matrices.

metric

a character string specifying the type of similarity used to produce similarity matrices from each embedding. One of c("cosine","arccos","pearson","spearman"). Default is "cosine".

comparison_metric

a character string specifying the type of similarity used to compare similarity matrices. One of c("cosine","arccos","pearson","spearman"). Default is "spearman".

Value

The function returns a tibble containing for every pair of embeddings the representational similarities overall (based on the lower triangle) and per row (text).

References

Wulff, D. U., Aeschbach, S., Hussain, Z., & Mata, R. (2024). embeddeR. In preparation.

Examples

if (FALSE) {
# get embedding
embedding_1 <- embed(neo$text)
embedding_2 <- embed(neo$text, model = "distilbert-base-uncased")

# compute similarity
compare_embeddings(list(embedding_1, embedding_2))
}