hf_ez_summarization: Summarize a Text

View source: R/ez.R

hf_ez_summarizationR Documentation

Summarize a Text

Description

This task is well known to summarize longer text into shorter text. Be careful, some models have a maximum length of input. That means that the summary cannot handle full books for instance. Be careful when choosing your model.

Usage

hf_ez_summarization(model_id = "facebook/bart-large-cnn", use_api = FALSE)

Arguments

model_id

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

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 summarization object

See Also

https://huggingface.co/docs/api-inference/detailed_parameters#summarization-task

Examples

## Not run: 
# Load the default model and use local inference
ez <- hf_ez_fill_summarization()
ez$infer(string = "The tower is 324 metres (1,063 ft) tall, about the same \cr
height as an 81-storey building, and the tallest structure in Paris. Its base \cr
is square, measuring 125 metres (410 ft) on each side. During its construction, \cr
the Eiffel Tower surpassed the Washington Monument to become the tallest man-made \cr
structure in the world, a title it held for 41 years until the Chrysler Building \cr
in New York City was finished in 1930. It was the first structure to reach a height \cr
of 300 metres. Due to the addition of a broadcasting aerial at the top of the \cr
tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). \cr
Excluding transmitters, the Eiffel Tower is the second tallest free-standing \cr
structure in France after the Millau Viaduct.",
min_length = 10, max_length = 100)

# Load a specific model and use the api for inference.
ez <- hf_ez_summarization(model_id = 'xlm-roberta-base', use_api = TRUE)
ez$infer(string = "huggingface is the <mask>!")

## End(Not run)

farach/huggingfaceR documentation built on Feb. 4, 2023, 10:31 p.m.