hf_ez_zero_shot_classification: Perform Text Classification with No Context Required

View source: R/ez.R

hf_ez_zero_shot_classificationR Documentation

Perform Text Classification with No Context Required

Description

This task is super useful to try out classification with zero code, you simply pass a sentence/paragraph and the possible labels for that sentence, and you get a result.

Usage

hf_ez_zero_shot_classification(
  model_id = "facebook/bart-large-mnli",
  use_api = FALSE
)

Arguments

model_id

A model_id. Run hf_search_models(...) for model_ids. Defaults to 'facebook/bart-large-mnli'.

use_api

Whether to use the Inference API to run the model (TRUE) or download and run the model locally (FALSE). Defaults to FALSE

Value

A zero shot classification object

See Also

https://huggingface.co/docs/api-inference/detailed_parameters#zero-shot-classification-task

Examples

## Not run: 
# Load the default model
ez <- hf_ez_zero_shot_classification()

# Classify the string
ez$infer(
  string = paste(
    "Hi, I recently bought a device from your company but it is not working",
    "as advertised and I would like to get reimbursed!"
  ),
  candidate_labels = c("refund", "legal", "faq")
)

## End(Not run)

huggingfaceR documentation built on Aug. 30, 2026, 1:06 a.m.