| hf_similarity | R Documentation |
Compute cosine similarity between all pairs of embeddings. Numeric embeddings with consistent dimensions use vectorized matrix operations for better performance on larger result sets; invalid, zero-length, zero-norm, or dimension-mismatched pairs return 'NA_real_'.
hf_similarity(embeddings, text_col = "text")
embeddings |
A tibble with an 'embedding' column (from hf_embed). |
text_col |
Character string. Name of the text column. Default: "text". |
A tibble with columns: text_1, text_2, similarity.
## Not run:
sentences <- c("I love cats", "I adore felines", "Dogs are great")
embeddings <- hf_embed(sentences)
similarities <- hf_similarity(embeddings)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.