| foundry_similarity | R Documentation |
Compute pairwise cosine similarity between all embeddings in a tibble. Useful for finding semantically similar texts.
foundry_similarity(data, text_col = "text", top_k = NULL, as_matrix = FALSE)
data |
A tibble from |
text_col |
Character. Name of the column containing text labels. Default: "text". |
top_k |
Integer. Optional maximum number of most-similar pairs to return. |
as_matrix |
Logical. If |
A tibble with columns:
Character. First text.
Character. Second text.
Numeric. Cosine similarity between -1 and 1.
# Toy vectors demonstrate local computation without calling Azure.
embeddings <- tibble::tibble(
text = c("Vector A", "Vector B", "Vector C"),
embedding = list(c(1, 0), c(1, 1), c(0, 1))
)
foundry_similarity(embeddings)
foundry_similarity(embeddings, top_k = 1)
foundry_similarity(embeddings, as_matrix = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.