推理提供商文件
摘要
加入 Hugging Face 社群
並獲得增強的文件體驗
開始使用
摘要
摘要任務旨在生成文件的較短版本,同時保留其重要資訊。有些模型可以從原始輸入中提取文字,而其他模型可以生成全新的文字。
有關 `summarization` 任務的更多詳細資訊,請檢視其專用頁面!您將找到示例和相關材料。
推薦模型
- facebook/bart-large-cnn:一個在英文新聞文章上訓練的強大摘要模型。擅長生成事實性摘要。
- Falconsai/medical_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 | 字串 | 摘要後的文字。 |