Skip to contents

Classify text into custom categories without training a model. The model determines which labels best describe the input text.

Usage

hf_classify_zero_shot(
  text,
  labels,
  model = "facebook/bart-large-mnli",
  multi_label = FALSE,
  token = NULL,
  ...
)

Arguments

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.

...

Additional arguments (currently unused).

Value

A tibble with columns: text, label, score (sorted by score descending)

Examples

if (FALSE) { # \dontrun{
# 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
)
} # }