| hf_summarize | R Documentation |
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.
hf_summarize(
text,
model = hf_default_model("summarize"),
min_length = NULL,
max_length = NULL,
token = NULL,
endpoint_url = NULL,
...
)
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). |
A tibble with columns: text, summary.
https://huggingface.co/docs/inference-providers/tasks/summarization
## Not run:
hf_summarize("Long article text goes here ...", max_length = 60)
library(dplyr)
articles |>
mutate(tldr = hf_summarize(body)$summary)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.