Create matrix of embedding similarities
get_similarity_matrix.Rd
Create a matrix of pairwise similarities between each string in strings_A
and strings_B
.
Value
A matrix of cosine similarities between the embeddings of strings_A and the embeddings of strings_B
Examples
embeddings <- get_embeddings(c('UPS', 'USPS', 'Postal Service'))
get_similarity_matrix(embeddings)
#> UPS USPS Postal Service
#> UPS 1.0000002 0.7534348 0.6256223
#> USPS 0.7534348 0.9999999 0.8407916
#> Postal Service 0.6256223 0.8407916 1.0000000
get_similarity_matrix(embeddings, 'Postal Service')
#> UPS USPS Postal Service
#> Postal Service 0.6256223 0.8407916 1
get_similarity_matrix(embeddings, 'Postal Service', c('UPS', 'USPS'))
#> UPS USPS
#> Postal Service 0.6256223 0.8407916