| hf_embed_umap | R Documentation |
Reduce embedding dimensions to 2D using UMAP for visualization. Requires the 'uwot' package to be installed.
hf_embed_umap(
text,
model = hf_default_model("embed"),
token = NULL,
endpoint_url = NULL,
n_neighbors = 15,
min_dist = 0.1,
...
)
text |
Character vector of text(s) to embed and reduce. |
model |
Character string. Model ID for generating embeddings. Default: "BAAI/bge-small-en-v1.5". |
token |
Character string or NULL. API token for authentication. |
endpoint_url |
Character string or NULL. A custom Inference Endpoint URL. |
n_neighbors |
Integer. UMAP n_neighbors parameter. Default: 15. |
min_dist |
Numeric. UMAP min_dist parameter. Default: 0.1. |
... |
Additional arguments passed to uwot::umap(). |
A tibble with columns: text, umap_1, umap_2
## Not run:
# Reduce and visualize
library(ggplot2)
texts <- c("cat", "dog", "kitten", "puppy", "car", "truck")
coords <- hf_embed_umap(texts)
ggplot(coords, aes(umap_1, umap_2, label = text)) +
geom_text() +
theme_minimal()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.