View source: R/word_embeddings-download.R
| download_embeddings_model2vec | R Documentation |
download_embeddings_model2vec() downloads the files of a
Model2Vec model, so they can be
read with read_embeddings_model2vec().
download_embeddings_model2vec(url, path = tempfile("model2vec-"))
url |
A string giving the URL of the folder that holds the model files.
For a model on the Hugging Face Hub this has the form
|
path |
A string giving the path to the folder to download the files into. The folder is created if it doesn't exist, and files in it with the same names are overwritten. Defaults to a new temporary folder, which is removed when the R session ends. |
Two files are downloaded: model.safetensors, which holds the vectors, and
vocab.txt, which holds the tokens. The files of a small model are about
30 MB, so the download can take a while. The downloaded files are not needed
once a recipe using the embeddings has been prepped.
The embeddings are tied to the tokenizer the model was trained with. See
vignette("static-embeddings", package = "textrecipes") for how to use a
downloaded model in a recipe.
The path to the folder holding the files, invisibly.
read_embeddings_model2vec() to read the downloaded files.
url <- paste0(
"https://huggingface.co/minishlab/potion-base-8M/resolve/",
"bf8b056651a2c21b8d2565580b8569da283cab23"
)
model_dir <- download_embeddings_model2vec(url)
embeddings <- read_embeddings_model2vec(model_dir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.