| hf_classify_zero_shot | R Documentation |
Classify text into custom categories without training a model. The model determines which labels best describe the input text.
hf_classify_zero_shot(
text,
labels,
model = hf_default_model("zero_shot"),
multi_label = FALSE,
token = NULL,
endpoint_url = NULL,
...
)
text |
Character vector of text(s) to classify. |
labels |
Character vector of candidate labels/categories. |
model |
Character string. Model ID from Hugging Face Hub. Default: "facebook/bart-large-mnli" |
multi_label |
Logical. If TRUE, allows multiple labels per text. Default: FALSE (single label per text). |
token |
Character string or NULL. API token for authentication. |
endpoint_url |
Character string or NULL. A custom Inference Endpoint URL. |
... |
Additional arguments (currently unused). |
A tibble with columns: text, label, score (sorted by score descending)
## Not run:
# Classify into custom categories
hf_classify_zero_shot(
"I just bought a new laptop",
labels = c("technology", "sports", "politics", "food")
)
# Multi-label classification
hf_classify_zero_shot(
"This laptop is great for gaming",
labels = c("technology", "gaming", "entertainment"),
multi_label = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.