テキスト要約は、ユーザーが読むには長すぎると考えられるコンテンツを短縮することを意図しています。 抽出要約と抽象要約の両方で、記事、論文、またはドキュメントが重要な文に要約されます。
抽出要約は、元のコンテンツ内で最も重要性または関連性の高い情報をまとめて表す文を抽出することで概要を生成します。
抽象要約: 主要なアイデアが表されている要約された文をドキュメントから生成することによって、概要を生成します。
クエリ指向要約: 要約するときにクエリを使用できます。
これらの各機能は、指定された特定の対象項目を集計できます。
API で使用される AI モデルは、サービスによって提供されます。 分析のためにコンテンツを送信するだけで済みます。
簡単に移動できるように、各サービスの対応するセクションへのリンクを次に示します。
| 特徴 | Section |
|---|---|
| 抽出 | 抽出要約 |
| 抽象 | 抽象的な要約 |
| クエリ指向 | クエリ指向要約 |
特徴
ヒント
これらの機能の使用を開始する場合は、 クイックスタートの記事 に従って作業を開始できます。 コードを記述しなくても、 Microsoft Foundry を使用してサンプル要求を行うこともできます。
抽出要約 API では、自然言語処理手法を使用して、非構造化テキスト ドキュメント内の重要な文が検索されます。 これらの文がまとめられて、ドキュメントの主要なアイデアが伝えられます。
抽出要約では、抽出された文と元のドキュメント内でのその位置と共に、システム応答の一部としてランク スコアが返されます。 ランク スコアは、ドキュメントの主要なアイデアに対して文がどの程度関係していると判断されるのかの指標です。 モデルでは、各文に対して 0 から 1 (両端を含む) のスコアが与えられ、要求ごとに最も高いスコアの文が返されます。 たとえば、3 文の要約を要求した場合、サービスからはスコアが最も高い 3 つの文が返されます。
Foundry Tools の Azure Language には、 キー フレーズ抽出という、キー情報を抽出できるもう 1 つの機能があります。 キー フレーズ抽出と抽出要約のどちらを決定する場合は、次の要因を考慮してください。
- キー フレーズ抽出からは語句が返されるのに対し、抽出要約からは文が返されます。
- 抽出要約からは文と共にランク スコアが返され、要求ごとに上位ランクの文が返されます。
- 抽出要約では、次の位置情報も返されます。
- オフセット: 抽出された各文の開始位置。
- 長さ: 抽出された各文の長さ。
データの処理方法を決定する (省略可能)
データの送信
ドキュメントをテキストの文字列として API に送信します。 要求が受信されると分析が実行されます。 API は非同期なので、API 要求を送信してから、結果を受信するまでに、遅延が発生する可能性があります。
この機能を使うと、API の結果は、応答で示される要求取り込み時刻から 24 時間利用できます。 この時間が経過すると、結果は消去され、取得できなくなります。
テキストの要約結果を取得する
言語検出から結果を取得するときは、結果をアプリケーションにストリーミングしたり、ローカル システム上のファイルに出力を保存したりできます。
以下は、要約のために送信するコンテンツの例です。これは、Microsoft ブログ記事「 統合 AI に対する包括的な表現」を使用して抽出されます。 この記事は一例にすぎません。 API では、長い入力テキストを受け取ることができます。 詳細については、データとサービスの制限に関する説明を参照してください。
マイクロソフトでは、既存の技術を超えてAIを進化させるために、より包括的で人間中心のアプローチを採用して学習と理解を深める探求を行っています。 Foundry Toolsの最高技術責任者として、私はこの探求を現実に変えるために素晴らしい科学者やエンジニアのチームと協力してきました。 私の役割では、人間の認知の3つの特性、すなわち一言語のテキスト(X)、聴覚または視覚の感覚信号(Y)、および多言語(Z)の関係を独自の視点で見ることを楽しんでいます。 3つの要素が交わるところに、魔法があります。これを図1で示されているようにXYZコードと呼びます。これは、より強力なAIを生み出すための共同表現で、人間とより自然に話し、聞き、見て、理解することができます。 私たちは、XYZ コードは、さまざまなモダリティと言語にまたがるクロスドメイン転移学習という長期的なビジョンを実現できると信じています。 目標は、今日の人間のように、幅広い下流のAIタスクをサポートするための表現を共同で学習できる事前学習済みモデルを持つことです。 過去 5 年間で、会話音声認識、機械翻訳、会話の質問回答、機械読解、画像キャプションのベンチマークで人間のパフォーマンスを達成しました。 この 5 つのブレークスルーにより、AI 機能の飛躍的な向上を目指す意欲的な志に向けた強いシグナルが得られ、人間の学習方法と理解方法に近い多感覚学習と多言語学習を実現しました。 私は、外部のナレッジ ソースを基にした下流の AI タスクにおいて、XYZコードはこの願望を実現するための基礎的な構成要素であると考えています。
ドキュメント要約 API 要求は、要求を受信した時点で API バックエンド用のジョブを作成することで処理されます。 ジョブが成功すると、API の出力が返されます。 出力は 24 時間取得できます。 この時間が過ぎると、出力は消去されます。 多言語と絵文字のサポートにより、応答にはテキスト オフセットが含まれる場合があります。 詳細については、オフセットを処理する方法を参照してください。
前の例を使用すると、API は次の要約文を返す場合があります。
抽出要約:
- "Microsoft では、学習と解釈に対してより包括的で人間中心のアプローチを行うことで、既存の手法を超えて AI を発展させることを目指しています。"
- "私たちは、XYZ コードは、さまざまなモダリティと言語にまたがるクロスドメイン転移学習という長期的なビジョンを実現できると信じています。"
- "目標は、さまざまなダウンストリーム AI タスクをサポートするために、現在人間が行っているのとほぼ同様の方法で、表現を共同で学習できる一連の事前トレーニング済みモデルを獲得することです。"
抽象要約:
- マイクロソフトは、学習と理解に対してより全体的で人間中心のアプローチを取っています。 私たちは、XYZ コードは、さまざまなモダリティと言語にまたがるクロスドメイン転移学習という長期的なビジョンを実現できると信じています。 過去5年間で、主要ベンチマークで人間のパフォーマンスを達成しました。
テキスト抽出の要約を試す
ドキュメントの抽出要約を使って、記事、論文、ドキュメントなどの要約を取得できます。 例については、クイックスタートの記事をご覧ください。
sentenceCount パラメータを使って、返される文の数を指定できます。既定値は 3 です。 範囲は 1 から 20 です。
また、sortby パラメーターを使うと、抽出された文が返されるときの順序を指定できます。値は Offset または Rank で、既定値は Offset です。
| パラメーターの値 | 説明 |
|---|---|
| 順位 | サービスによって決定された入力ドキュメントとの関連性に従って文を並べ替えます。 |
| オフセット | 入力ドキュメントで文が出現する元の順序を維持します。 |
テキストの抽象要約
次に示す例で、ドキュメントの抽象要約を開始できます。
- テキスト エディターに次のコマンドをコピーします。 BASH の例では、行連結文字として
\を使用します。 ご利用のコンソールまたはターミナルで異なる行連結文字が使われている場合は、その文字を代わりに使ってください。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-text/jobs?api-version=2023-04-01 \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
'
{
"displayName": "Text Abstractive Summarization Task Example",
"analysisInput": {
"documents": [
{
"id": "1",
"language": "en",
"text": "At Microsoft, we have been on a quest to advance AI beyond existing techniques, by taking a more holistic, human-centric approach to learning and understanding. As Chief Technology Officer of Foundry Tools, I have been working with a team of amazing scientists and engineers to turn this quest into a reality. In my role, I enjoy a unique perspective in viewing the relationship among three attributes of human cognition: monolingual text (X), audio or visual sensory signals, (Y) and multilingual (Z). At the intersection of all three, there's magic—what we call XYZ-code as illustrated in Figure 1—a joint representation to create more powerful AI that can speak, hear, see, and understand humans better. We believe XYZ-code enables us to fulfill our long-term vision: cross-domain transfer learning, spanning modalities and languages. The goal is to have pretrained models that can jointly learn representations to support a broad range of downstream AI tasks, much in the way humans do today. Over the past five years, we have achieved human performance on benchmarks in conversational speech recognition, machine translation, conversational question answering, machine reading comprehension, and image captioning. These five breakthroughs provided us with strong signals toward our more ambitious aspiration to produce a leap in AI capabilities, achieving multi-sensory and multilingual learning that is closer in line with how humans learn and understand. I believe the joint XYZ-code is a foundational component of this aspiration, if grounded with external knowledge sources in the downstream AI tasks."
}
]
},
"tasks": [
{
"kind": "AbstractiveSummarization",
"taskName": "Text Abstractive Summarization Task 1",
}
]
}
'
必要に応じて、コマンドに次の変更を加えます。
-
your-language-resource-key値をキーに置き換えます。 - 要求 URL (
your-language-resource-endpoint) の最初の部分を独自のエンドポイント URL に置き換えます。
-
コマンド プロンプト ウィンドウ (BASH など) を開きます。
テキスト エディターからコマンド プロンプト ウィンドウにコマンドを貼り付けて、コマンドを実行します。
operation-locationを応答ヘッダーから取得します。 値は次の URL のようになります。
https://<your-language-resource-endpoint>/language/analyze-text/jobs/12345678-1234-1234-1234-12345678?api-version=2022-10-01-preview
- 要求の結果を取得するには、次の cURL コマンドを使用します。
<my-job-id>を、前のoperation-location応答ヘッダーから受け取った数値 ID 値に必ず置き換えてください。
curl -X GET https://<your-language-resource-endpoint>/language/analyze-text/jobs/<my-job-id>?api-version=2022-10-01-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>"
抽象テキスト要約の例の JSON 応答
{
"jobId": "cd6418fe-db86-4350-aec1-f0d7c91442a6",
"lastUpdateDateTime": "2022-09-08T16:45:14Z",
"createdDateTime": "2022-09-08T16:44:53Z",
"expirationDateTime": "2022-09-09T16:44:53Z",
"status": "succeeded",
"errors": [],
"displayName": "Text Abstractive Summarization Task Example",
"tasks": {
"completed": 1,
"failed": 0,
"inProgress": 0,
"total": 1,
"items": [
{
"kind": "AbstractiveSummarizationLROResults",
"taskName": "Text Abstractive Summarization Task 1",
"lastUpdateDateTime": "2022-09-08T16:45:14.0717206Z",
"status": "succeeded",
"results": {
"documents": [
{
"summaries": [
{
"text": "Microsoft is taking a more holistic, human-centric approach to AI. We've developed a joint representation to create more powerful AI that can speak, hear, see, and understand humans better. We've achieved human performance on benchmarks in conversational speech recognition, machine translation, ...... and image captions.",
"contexts": [
{
"offset": 0,
"length": 247
}
]
}
],
"id": "1"
}
],
"errors": [],
"modelVersion": "latest"
}
}
]
}
}
| パラメータ | 説明 |
|---|---|
-X POST <endpoint> |
API にアクセスするためのエンドポイントを指定します。 |
-H Content-Type: application/json |
JSON データを送信するためのコンテンツ タイプ。 |
-H "Ocp-Apim-Subscription-Key:<key> |
API にアクセスするためのキーを指定します。 |
-d <documents> |
送信するドキュメントを含む JSON。 |
次の cURL コマンドは、BASH シェルから実行されます。 これらのコマンドは、実際のリソース名、リソース キー、JSON の値に合わせて編集してください。
クエリ ベース要約
クエリベースのテキスト要約 API は、既存のテキスト要約 API を拡張するものです。
最大の違いは、要求本文内の (querytasks>parameters> の下の) 新しい query フィールドです。
ヒント
クエリ ベースの要約では、使用しているクエリ ベースの要約の種類に基づいて、長さの制御の利用方法にいくつかの違いがあります。
- クエリ ベースの抽出要約では、sentenceCount を指定することで長さの制御をサポートします。
- クエリ ベースの抽象要約では、長さの制御はサポートされていません。
次が要求の例です。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-text/jobs?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
'
{
"displayName": "Text Extractive Summarization Task Example",
"analysisInput": {
"documents": [
{
"id": "1",
"language": "en",
"text": "At Microsoft, we have been on a quest to advance AI beyond existing techniques, by taking a more holistic, human-centric approach to learning and understanding. As Chief Technology Officer of Foundry Tools, I have been working with a team of amazing scientists and engineers to turn this quest into a reality. In my role, I enjoy a unique perspective in viewing the relationship among three attributes of human cognition: monolingual text (X), audio or visual sensory signals, (Y) and multilingual (Z). At the intersection of all three, there's magic—what we call XYZ-code as illustrated in Figure 1—a joint representation to create more powerful AI that can speak, hear, see, and understand humans better. We believe XYZ-code enables us to fulfill our long-term vision: cross-domain transfer learning, spanning modalities and languages. The goal is to have pretrained models that can jointly learn representations to support a broad range of downstream AI tasks, much in the way humans do today. Over the past five years, we have achieved human performance on benchmarks in conversational speech recognition, machine translation, conversational question answering, machine reading comprehension, and image captioning. These five breakthroughs provided us with strong signals toward our more ambitious aspiration to produce a leap in AI capabilities, achieving multi-sensory and multilingual learning that is closer in line with how humans learn and understand. I believe the joint XYZ-code is a foundational component of this aspiration, if grounded with external knowledge sources in the downstream AI tasks."
}
]
},
"tasks": [
{
"kind": "AbstractiveSummarization",
"taskName": "Query-based Abstractive Summarization",
"parameters": {
"query": "XYZ-code",
"summaryLength": "short"
}
}, {
"kind": "ExtractiveSummarization",
"taskName": "Query_based Extractive Summarization",
"parameters": {
"query": "XYZ-code"
}
}
]
}
'
要約の長さの制御
抽象要約で summaryLength パラメーターを使用する
summaryLength を指定しない場合、モデルによって要約の長さが決定されます。
summaryLength パラメーターについては、次の 3 つの値が受け取られます。
- oneSentence: 約 80 個のトークンを含む、ほぼ 1 つの文の概要を生成します。
- short: 約 120 個のトークンを含む、ほぼ 2 ~ 3 文の要約を生成します。
- medium: 約 170 個のトークンを含む、ほぼ 4 ~ 6 文の要約を生成します。
- long: 約 210 個のトークンを含む、ほぼ 7 文以上の要約を生成します。
要求の例を次に示します。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-text/jobs?api-version=2023-04-01 \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
'
{
"displayName": "Text Abstractive Summarization Task Example",
"analysisInput": {
"documents": [
{
"id": "1",
"language": "en",
"text": "At Microsoft, we have been on a quest to advance AI beyond existing techniques, by taking a more holistic, human-centric approach to learning and understanding. As Chief Technology Officer of Foundry Tools, I have been working with a team of amazing scientists and engineers to turn this quest into a reality. In my role, I enjoy a unique perspective in viewing the relationship among three attributes of human cognition: monolingual text (X), audio or visual sensory signals, (Y) and multilingual (Z). At the intersection of all three, there's magic—what we call XYZ-code as illustrated in Figure 1—a joint representation to create more powerful AI that can speak, hear, see, and understand humans better. We believe XYZ-code enables us to fulfill our long-term vision: cross-domain transfer learning, spanning modalities and languages. The goal is to have pretrained models that can jointly learn representations to support a broad range of downstream AI tasks, much in the way humans do today. Over the past five years, we have achieved human performance on benchmarks in conversational speech recognition, machine translation, conversational question answering, machine reading comprehension, and image captioning. These five breakthroughs provided us with strong signals toward our more ambitious aspiration to produce a leap in AI capabilities, achieving multi-sensory and multilingual learning that is closer in line with how humans learn and understand. I believe the joint XYZ-code is a foundational component of this aspiration, if grounded with external knowledge sources in the downstream AI tasks."
}
]
},
"tasks": [
{
"kind": "AbstractiveSummarization",
"taskName": "Length controlled Abstractive Summarization",
"parameters": {
"summaryLength": "short"
}
}
]
}
'
抽出要約で sentenceCount パラメーターを使用する
sentenceCount パラメーターには、出力文の望ましい数を示す 1 から 20 の値を入力できます。
要求の例を次に示します。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-text/jobs?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
'
{
"displayName": "Text Extractive Summarization Task Example",
"analysisInput": {
"documents": [
{
"id": "1",
"language": "en",
"text": "At Microsoft, we have been on a quest to advance AI beyond existing techniques, by taking a more holistic, human-centric approach to learning and understanding. As Chief Technology Officer of Foundry Tools, I have been working with a team of amazing scientists and engineers to turn this quest into a reality. In my role, I enjoy a unique perspective in viewing the relationship among three attributes of human cognition: monolingual text (X), audio or visual sensory signals, (Y) and multilingual (Z). At the intersection of all three, there's magic—what we call XYZ-code as illustrated in Figure 1—a joint representation to create more powerful AI that can speak, hear, see, and understand humans better. We believe XYZ-code enables us to fulfill our long-term vision: cross-domain transfer learning, spanning modalities and languages. The goal is to have pretrained models that can jointly learn representations to support a broad range of downstream AI tasks, much in the way humans do today. Over the past five years, we have achieved human performance on benchmarks in conversational speech recognition, machine translation, conversational question answering, machine reading comprehension, and image captioning. These five breakthroughs provided us with strong signals toward our more ambitious aspiration to produce a leap in AI capabilities, achieving multi-sensory and multilingual learning that is closer in line with how humans learn and understand. I believe the joint XYZ-code is a foundational component of this aspiration, if grounded with external knowledge sources in the downstream AI tasks."
}
]
},
"tasks": [
{
"kind": "ExtractiveSummarization",
"taskName": "Length controlled Extractive Summarization",
"parameters": {
"sentenceCount": "5"
}
}
]
}
'
サービスとデータの制限
分単位および秒単位で送信できる要求のサイズと数については、サービスの制限に関する記事を参照してください。