Create matrix of embedding similarities
get_similarity_matrix.Rd
Create a matrix of pairwise similarities between each string in strings_A
and strings_B
.
Arguments
- embeddings
A matrix of text embeddings
- strings_A
A string vector
- strings_B
A string vector
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.7530467 0.6254707
#> USPS 0.7530467 1.0000000 0.8408279
#> Postal Service 0.6254707 0.8408279 1.0000000
get_similarity_matrix(embeddings, 'Postal Service')
#> UPS USPS Postal Service
#> Postal Service 0.6254707 0.8408279 1
get_similarity_matrix(embeddings, 'Postal Service', c('UPS', 'USPS'))
#> UPS USPS
#> Postal Service 0.6254707 0.8408279