hf_summarize: Summarize Text

View source: R/text-tasks.R

hf_summarizeR Documentation

Summarize Text

Description

Condense longer text into a shorter summary using a summarization model via the Hugging Face Inference Providers API. Accepts a character vector and returns one row per input, composing naturally with dplyr pipelines.

Usage

hf_summarize(
  text,
  model = hf_default_model("summarize"),
  min_length = NULL,
  max_length = NULL,
  token = NULL,
  endpoint_url = NULL,
  ...
)

Arguments

text

Character vector of text(s) to summarize.

model

Character string. Model ID from the Hugging Face Hub. Append '":provider"' to select an inference provider. Default: "facebook/bart-large-cnn".

min_length

Integer or NULL. Minimum length of the summary in tokens. Default: NULL (model default).

max_length

Integer or NULL. Maximum length of the summary in tokens. Default: NULL (model default).

token

Character string or NULL. API token for authentication.

endpoint_url

Character string or NULL. A custom Inference Endpoint URL. When provided, requests are sent to this URL instead of the public Inference API.

...

Additional arguments (currently unused).

Value

A tibble with columns: text, summary.

See Also

https://huggingface.co/docs/inference-providers/tasks/summarization

Examples

## Not run: 
hf_summarize("Long article text goes here ...", max_length = 60)

library(dplyr)
articles |>
  mutate(tldr = hf_summarize(body)$summary)

## End(Not run)

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