R/api_huggingface_embeddings.R
api_huggingface_embeddings.Rd
Retrieves embeddings for text data using Hugging Face's API. It can process a batch of texts or a single query. Mostly for demo purposes.
api_huggingface_embeddings(
tif,
text_hierarchy,
api_token,
api_url = NULL,
query = NULL,
dims = 384,
batch_size = 250,
sleep_duration = 1,
verbose = TRUE
)
A data frame containing text data.
A character vector indicating the columns used to create row names.
Token for accessing the Hugging Face API.
The URL of the Hugging Face API endpoint (default is all-MiniLM-L6-v2).
An optional single text query for which embeddings are required.
The dimension of the output embeddings.
Number of rows in each batch sent to the API.
Duration in seconds to pause between processing batches.
A boolean specifying whether to include progress bar
A matrix containing embeddings, with each row corresponding to a text input.
if (FALSE) { # \dontrun{
tif <- data.frame(doc_id = c('1'), text = c("Hello world."))
embeddings <- api_huggingface_embeddings(tif,
text_hierarchy = 'doc_id',
api_token = api_token)
} # }