推理提供商文档

摘要

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

摘要

摘要任务旨在生成文档的较短版本,同时保留其重要信息。有些模型可以从原始输入中提取文本,而其他模型可以生成全新的文本。

有关 `summarization` 任务的更多详细信息,请查看其专用页面!您将找到示例和相关材料。

推荐模型

在这里探索所有可用模型,找到最适合您的模型。

使用 API

import os
from huggingface_hub import InferenceClient

client = InferenceClient(
    provider="hf-inference",
    api_key=os.environ["HF_TOKEN"],
)

result = client.summarization(
    "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 规范

请求

标头
授权 字符串 认证头部的格式为 `Bearer: hf_****`,其中 `hf_****` 是具有“Inference Providers”权限的个人用户访问令牌。您可以从您的设置页面生成一个。
有效负载
inputs* 字符串 要进行摘要的输入文本。
参数 对象
        clean_up_tokenization_spaces 布尔值 是否清理文本输出中可能存在的额外空格。
        truncation 枚举 可能的值:do_not_truncate, longest_first, only_first, only_second。
        generate_parameters 对象 文本生成算法的额外参数设置。

响应

正文
summary_text 字符串 摘要后的文本。
< > 在 GitHub 上更新