Inference Providers documentation
Summarization
Summarization
Summarization is the task of producing a shorter version of a document while preserving its important information. Some models can extract text from the original input, while other models can generate entirely new text.
For more details about the summarization
task, check out its dedicated page! You will find examples and related materials.
Recommended models
- facebook/bart-large-cnn: A strong summarization model trained on English news articles. Excels at generating factual summaries.
- Falconsai/medical_summarization: A summarization model trained on medical articles.
Explore all available models and find the one that suits you best here.
Using the API
Copied
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="hf-inference",
api_key="hf_xxxxxxxxxxxxxxxxxxxxxxxx",
)
result = client.summarization(
inputs="The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.",
model="facebook/bart-large-cnn",
)
API specification
Request
Headers | ||
---|---|---|
authorization | string | Authentication header in the form 'Bearer: hf_****' when hf_**** is a personal user access token with “Inference Providers” permission. You can generate one from your settings page. |
Payload | ||
---|---|---|
inputs* | string | The input text to summarize. |
parameters | object | |
clean_up_tokenization_spaces | boolean | Whether to clean up the potential extra spaces in the text output. |
truncation | enum | Possible values: do_not_truncate, longest_first, only_first, only_second. |
generate_parameters | object | Additional parametrization of the text generation algorithm. |
Response
Body | ||
---|---|---|
summary_text | string | The summarized text. |