| hf_ez_sentence_similarity | R Documentation |
Calculate the semantic similarity between one text and a list of other sentences by comparing their embeddings.
hf_ez_sentence_similarity(
model_id = "sentence-transformers/all-MiniLM-L6-v2",
use_api = FALSE
)
model_id |
A model_id. Run hf_search_models(...) for model_ids. Defaults to 'sentence-transformers/all-MiniLM-L6-v2'. |
use_api |
Whether to use the Inference API to run the model (TRUE) or download and run the model locally (FALSE). Defaults to FALSE |
A sentence similarity object
https://huggingface.co/docs/api-inference/detailed_parameters#sentence-similarity-task
## Not run:
# Load the default model and use local inference
ez <- hf_ez_sentence_similarity()
ez$infer(
source_sentence = "That is a happy person",
sentences = list(
"That is a happy dog",
"That is a very happy person",
"Today is a sunny day"
)
)
# Use the API for inference.
ez <- hf_ez_sentence_similarity(use_api = TRUE)
ez$infer(
source_sentence = "That is a happy person",
sentences = list(
"That is a happy dog",
"That is a very happy person",
"Today is a sunny day"
)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.