Compartir a través de

如何使用对话摘要

重要

对话摘要仅适用于:

  • REST API
  • Python
  • C#

对话摘要特性

  • 章节标题和叙述(常规对话)旨在将对话汇总为章节标题,并汇总对话的内容。 此摘要特性适用于与任意数量的参与方展开的对话。

  • 问题和解决方法(侧重于呼叫中心)旨在汇总客户与客服代理之间的文本聊天日志。 此功能可以提供这些日志中存在的、在双方之间出现的问题和解决方法。

  • 叙述旨在总结对话的叙述内容。

  • “概况回顾”旨在将冗长的会议或对话压缩为简洁的一段摘要,以提供简明概述。

  • 后续任务旨在汇总会议期间出现的操作项和任务。

将数据发送到对话摘要问题和解决方法功能的示意图。

API 使用的 AI 模型由该服务提供,只需发送内容即可进行分析。

为便于导航,下面是指向每个服务相应部分的链接:

方面 部分
问题和解决方法 问题和解决方法
章节标题 章节标题
叙述 叙述
回顾和跟进 回顾和跟进

功能

对于每个请求,对话摘要 API 会使用自然语言处理技术将对话汇总为较短的摘要。 对话摘要可以汇总双方对话中讨论的问题和解决方法,或者将长对话汇总为章节和每个章节的简短叙述。

Azure AI 语言中提供了名为文本摘要的另一项功能,它更适合将文档汇总为简明摘要。 在决定是使用文本摘要还是使用对话摘要时,请考虑以下几点:

  • 输入格式:对话摘要可以同时对聊天文本和语音脚本进行操作,这两者包含说话人及其言语。 文本摘要可使用简单文本、Word、PDF 或 PowerPoint 格式进行操作。
  • 摘要的目的:例如,对话问题和解决方法摘要针对客户与客服代理之间的聊天返回问题原因和解决方法。

提交数据

注意

有关使用 Language Studio 设置要提交的对话文本格式的信息,请参阅 Language Studio 一文。

你将文档作为文本字符串提交到 API。 在收到请求时执行分析。 因为 API 是异步的,所以在发送 API 请求和接收结果之间可能存在延迟。 有关每分钟和每秒可以发送的请求大小和数量信息,请参阅下面的数据限制。

使用此功能时,API 结果在引入请求时的 24 小时内可用,并在响应中指示。 在此时间段后,结果将被清除,并且不再可用于检索。

将数据提交到对话摘要时,我们建议在每个请求中发送一个聊天日志,以改善延迟。

从文本聊天中获取摘要

可以根据需要使用对话问题和解决方法摘要来获取摘要。 若要查看使用文本聊天的示例,请参阅快速入门文章

从语音听录获取摘要

借助对话问题和解决方法摘要,你还可以使用语音服务的语音转文本功能从语音脚本获取摘要。 以下示例演示了一个简短的对话,你可以将该对话包括在 API 请求中。

"conversations":[
   {
      "id":"abcdefgh-1234-1234-1234-1234abcdefgh",
      "language":"en",
      "modality":"transcript",
      "conversationItems":[
         {
            "modality":"transcript",
            "participantId":"speaker",
            "id":"12345678-abcd-efgh-1234-abcd123456",
            "content":{
               "text":"Hi.",
               "lexical":"hi",
               "itn":"hi",
               "maskedItn":"hi",
               "audioTimings":[
                  {
                     "word":"hi",
                     "offset":4500000,
                     "duration":2800000
                  }
               ]
            }
         }
      ]
   }
]

获取章节标题

使用对话章节标题摘要可以从输入对话中获取章节标题。 下面提供了一个指导性的示例场景:

  1. 将下面的命令复制到文本编辑器中。 BASH 示例使用 \ 续行符。 如果你的控制台或终端使用不同的行继续符,请使用该字符。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-conversations/jobs?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
' 
{
  "displayName": "Conversation Task Example",
  "analysisInput": {
    "conversations": [
      {
        "conversationItems": [
          {
            "text": "Hello, you’re chatting with Rene. How may I help you?",
            "id": "1",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "Hi, I tried to set up wifi connection for Smart Brew 300 espresso machine, but it didn’t work.",
            "id": "2",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "I’m sorry to hear that. Let’s see what we can do to fix this issue. Could you please try the following steps for me? First, could you push the wifi connection button, hold for 3 seconds, then let me know if the power light is slowly blinking on and off every second?",
            "id": "3",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "Yes, I pushed the wifi connection button, and now the power light is slowly blinking.",
            "id": "4",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine? ",
            "id": "5",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "No. Nothing happened.",
            "id": "6",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "I’m very sorry to hear that. Let me see if there’s another way to fix the issue. Please hold on for a minute.",
            "id": "7",
            "role": "Agent",
            "participantId": "Agent_1"
          }
        ],
        "modality": "text",
        "id": "conversation1",
        "language": "en"
      }
    ]
  },
  "tasks": [
    {
      "taskName": "Conversation Task 1",
      "kind": "ConversationalSummarizationTask",
      "parameters": {
        "summaryAspects": [
          "chapterTitle"
        ]
      }
    }
  ]
}
'
  1. 必要时在命令中进行如下更改:

    • 将值 your-value-language-key 替换为你的值。
    • 将请求 URL 的第一部分 (your-language-resource-endpoint) 替换为你的终结点 URL。
  2. 打开命令提示符窗口(例如 BASH)。

  3. 将文本编辑器中的命令粘贴到命令提示符窗口,然后运行该命令。

  4. 从响应头获取 operation-location。 该值类似于以下 URL:

https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/12345678-1234-1234-1234-12345678?api-version=2023-11-15-preview
  1. 要获取请求的结果,请使用以下 cURL 命令。 请务必将 <my-job-id> 替换为从之前的 operation-location 响应头中收到的 GUID 值:
curl -X GET https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/<my-job-id>?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>"

章节标题摘要 JSON 响应示例:

{
    "jobId": "b01af3b7-1870-460a-9e36-09af28d360a1",
    "lastUpdatedDateTime": "2023-11-15T18:24:26Z",
    "createdDateTime": "2023-11-15T18:24:23Z",
    "expirationDateTime": "2023-11-16T18:24:23Z",
    "status": "succeeded",
    "errors": [],
    "displayName": "Conversation Task Example",
    "tasks": {
        "completed": 1,
        "failed": 0,
        "inProgress": 0,
        "total": 1,
        "items": [
            {
                "kind": "conversationalSummarizationResults",
                "taskName": "Conversation Task 1",
                "lastUpdateDateTime": "2023-11-15T18:24:26.3433677Z",
                "status": "succeeded",
                "results": {
                    "conversations": [
                        {
                            "summaries": [
                                {
                                    "aspect": "chapterTitle",
                                    "text": "\"Discussing the Problem of Smart Blend 300 Espresso Machine's Wi-Fi Connectivity\"",
                                    "contexts": [
                                        {
                                            "conversationItemId": "1",
                                            "offset": 0,
                                            "length": 53
                                        },
                                        {
                                            "conversationItemId": "2",
                                            "offset": 0,
                                            "length": 94
                                        },
                                        {
                                            "conversationItemId": "3",
                                            "offset": 0,
                                            "length": 266
                                        },
                                        {
                                            "conversationItemId": "4",
                                            "offset": 0,
                                            "length": 85
                                        },
                                        {
                                            "conversationItemId": "5",
                                            "offset": 0,
                                            "length": 119
                                        },
                                        {
                                            "conversationItemId": "6",
                                            "offset": 0,
                                            "length": 21
                                        },
                                        {
                                            "conversationItemId": "7",
                                            "offset": 0,
                                            "length": 109
                                        }
                                    ]
                                }
                            ],
                            "id": "conversation1",
                            "warnings": []
                        }
                    ],
                    "errors": [],
                    "modelVersion": "latest"
                }
            }
        ]
    }
}

对于长对话,模型可能会将其分段成多个内聚性的部分,并汇总每个段。 每个摘要还有一个冗长的 contexts 字段,它告诉我们从哪个输入对话范围生成了摘要。

获取叙述摘要

使用对话摘要还可以从输入对话中获取叙述摘要。 下面提供了一个指导性的示例场景:

  1. 将下面的命令复制到文本编辑器中。 BASH 示例使用 \ 续行符。 如果你的控制台或终端使用不同的行继续符,请使用该字符。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-conversations/jobs?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
' 
{
  "displayName": "Conversation Task Example",
  "analysisInput": {
    "conversations": [
      {
        "conversationItems": [
          {
            "text": "Hello, you’re chatting with Rene. How may I help you?",
            "id": "1",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "Hi, I tried to set up wifi connection for Smart Brew 300 espresso machine, but it didn’t work.",
            "id": "2",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "I’m sorry to hear that. Let’s see what we can do to fix this issue. Could you please try the following steps for me? First, could you push the wifi connection button, hold for 3 seconds, then let me know if the power light is slowly blinking on and off every second?",
            "id": "3",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "Yes, I pushed the wifi connection button, and now the power light is slowly blinking.",
            "id": "4",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine? ",
            "id": "5",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "No. Nothing happened.",
            "id": "6",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "I’m very sorry to hear that. Let me see if there’s another way to fix the issue. Please hold on for a minute.",
            "id": "7",
            "role": "Agent",
            "participantId": "Agent_1"
          }
        ],
        "modality": "text",
        "id": "conversation1",
        "language": "en"
      }
    ]
  },
  "tasks": [
    {
      "taskName": "Conversation Task 1",
      "kind": "ConversationalSummarizationTask",
      "parameters": {
        "summaryAspects": [
          "narrative"
        ]
      }
    }
  ]
}
'
  1. 必要时在命令中进行如下更改:

    • 将值 your-language-resource-key 替换为你的值。
    • 将请求 URL 的第一部分 (your-language-resource-endpoint) 替换为你的终结点 URL。
  2. 打开命令提示符窗口(例如 BASH)。

  3. 将文本编辑器中的命令粘贴到命令提示符窗口,然后运行该命令。

  4. 从响应头获取 operation-location。 该值类似于以下 URL:

https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/12345678-1234-1234-1234-12345678?api-version=2023-11-15-preview
  1. 若要获取请求的结果,请使用以下 cURL 命令。 请务必将 <my-job-id> 替换为从之前的 operation-location 响应头中收到的 GUID 值:
curl -X GET https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/<my-job-id>?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>"

叙述摘要 JSON 响应示例:

{
  "jobId": "d874a98c-bf31-4ac5-8b94-5c236f786754",
  "lastUpdatedDateTime": "2022-09-29T17:36:42Z",
  "createdDateTime": "2022-09-29T17:36:39Z",
  "expirationDateTime": "2022-09-30T17:36:39Z",
  "status": "succeeded",
  "errors": [],
  "displayName": "Conversation Task Example",
  "tasks": {
    "completed": 1,
    "failed": 0,
    "inProgress": 0,
    "total": 1,
    "items": [
      {
        "kind": "conversationalSummarizationResults",
        "taskName": "Conversation Task 1",
        "lastUpdateDateTime": "2022-09-29T17:36:42.895694Z",
        "status": "succeeded",
        "results": {
          "conversations": [
            {
              "summaries": [
                {
                  "aspect": "narrative",
                  "text": "Agent_1 helps customer to set up wifi connection for Smart Brew 300 espresso machine.",
                  "contexts": [
                    { "conversationItemId": "1", "offset": 0, "length": 53 },
                    { "conversationItemId": "2", "offset": 0, "length": 94 },
                    { "conversationItemId": "3", "offset": 0, "length": 266 },
                    { "conversationItemId": "4", "offset": 0, "length": 85 },
                    { "conversationItemId": "5", "offset": 0, "length": 119 },
                    { "conversationItemId": "6", "offset": 0, "length": 21 },
                    { "conversationItemId": "7", "offset": 0, "length": 109 }
                  ]
                }
              ],
              "id": "conversation1",
              "warnings": []
            }
          ],
          "errors": [],
          "modelVersion": "latest"
        }
      }
    ]
  }
}

对于长对话,模型可能会将其分段成多个内聚性的部分,并汇总每个段。 每个摘要还有一个冗长的 contexts 字段,它告诉我们从哪个输入对话范围生成了摘要。

获取概况回顾和后续任务摘要

通过对话摘要,还可以从输入对话中获取概况回顾和后续任务。 下面提供了一个指导性的示例场景:

  1. 将下面的命令复制到文本编辑器中。 BASH 示例使用 \ 续行符。 如果你的控制台或终端使用不同的行继续符,请使用该字符。
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-conversations/jobs?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
' 
{
  "displayName": "Conversation Task Example",
  "analysisInput": {
    "conversations": [
      {
        "conversationItems": [
          {
            "text": "Hello, you’re chatting with Rene. How may I help you?",
            "id": "1",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "Hi, I tried to set up wifi connection for Smart Brew 300 espresso machine, but it didn’t work.",
            "id": "2",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "I’m sorry to hear that. Let’s see what we can do to fix this issue. Could you please try the following steps for me? First, could you push the wifi connection button, hold for 3 seconds, then let me know if the power light is slowly blinking on and off every second?",
            "id": "3",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "Yes, I pushed the wifi connection button, and now the power light is slowly blinking.",
            "id": "4",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine? ",
            "id": "5",
            "role": "Agent",
            "participantId": "Agent_1"
          },
          {
            "text": "No. Nothing happened.",
            "id": "6",
            "role": "Customer",
            "participantId": "Customer_1"
          },
          {
            "text": "I’m very sorry to hear that. Let me see if there’s another way to fix the issue. Please hold on for a minute.",
            "id": "7",
            "role": "Agent",
            "participantId": "Agent_1"
          }
        ],
        "modality": "text",
        "id": "conversation1",
        "language": "en"
      }
    ]
  },
  "tasks": [
    {
      "taskName": "Conversation Task 1",
      "kind": "ConversationalSummarizationTask",
      "parameters": {
        "summaryAspects": [
          "recap",
          "follow-up tasks"
        ]
      }
    }
  ]
}
'
  1. 必要时在命令中进行如下更改:

    • 将值 your-language-resource-key 替换为你的值。
    • 将请求 URL 的第一部分 (your-language-resource-endpoint) 替换为你的终结点 URL。
  2. 打开命令提示符窗口(例如 BASH)。

  3. 将文本编辑器中的命令粘贴到命令提示符窗口,然后运行该命令。

  4. 从响应头获取 operation-location。 该值类似于以下 URL:

https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/12345678-1234-1234-1234-12345678?api-version=2023-11-15-preview
  1. 若要获取请求的结果,请使用以下 cURL 命令。 请务必将 <my-job-id> 替换为从之前的 operation-location 响应头中收到的 GUID 值:
curl -X GET https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/<my-job-id>?api-version=2023-11-15-preview \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>"

示例回顾和后续汇总 JSON 响应:

{
    "jobId": "e585d097-c19a-466e-8f99-a9646e55b1f5",
    "lastUpdatedDateTime": "2023-11-15T18:19:56Z",
    "createdDateTime": "2023-11-15T18:19:53Z",
    "expirationDateTime": "2023-11-16T18:19:53Z",
    "status": "succeeded",
    "errors": [],
    "displayName": "Conversation Task Example",
    "tasks": {
        "completed": 1,
        "failed": 0,
        "inProgress": 0,
        "total": 1,
        "items": [
            {
                "kind": "conversationalSummarizationResults",
                "taskName": "Conversation Task 1",
                "lastUpdateDateTime": "2023-11-15T18:19:56.1801785Z",
                "status": "succeeded",
                "results": {
                    "conversations": [
                        {
                            "summaries": [
                                {
                                    "aspect": "recap",
                                    "text": "The customer contacted the service agent, Rene, regarding an issue with setting up a wifi connection for their Smart Brew 300 espresso machine. The agent guided the customer through several steps, including pushing the wifi connection button and checking if the power light was blinking. However, the customer reported that no prompts were received in the Contoso Coffee app to connect with the machine. The agent then decided to look for another solution.",
                                    "contexts": [
                                        {
                                            "conversationItemId": "1",
                                            "offset": 0,
                                            "length": 53
                                        },
                                        {
                                            "conversationItemId": "2",
                                            "offset": 0,
                                            "length": 94
                                        },
                                        {
                                            "conversationItemId": "3",
                                            "offset": 0,
                                            "length": 266
                                        },
                                        {
                                            "conversationItemId": "4",
                                            "offset": 0,
                                            "length": 85
                                        },
                                        {
                                            "conversationItemId": "5",
                                            "offset": 0,
                                            "length": 119
                                        },
                                        {
                                            "conversationItemId": "6",
                                            "offset": 0,
                                            "length": 21
                                        },
                                        {
                                            "conversationItemId": "7",
                                            "offset": 0,
                                            "length": 109
                                        }
                                    ]
                                },
                                {
                                    "aspect": "Follow-Up Tasks",
                                    "text": "@Agent_1 will ask the customer to push the wifi connection button, hold for 3 seconds, then check if the power light is slowly blinking on and off every second."
                                },
                                {
                                    "aspect": "Follow-Up Tasks",
                                    "text": "@Agent_1 will ask the customer to check in the Contoso Coffee app if it prompts to connect with the machine."
                                },
                                {
                                    "aspect": "Follow-Up Tasks",
                                    "text": "@Agent_1 will investigate another way to fix the issue."
                                }
                            ],
                            "id": "conversation1",
                            "warnings": []
                        }
                    ],
                    "errors": [],
                    "modelVersion": "latest"
                }
            }
        ]
    }
}

对于长对话,模型可能会将其分段成多个内聚性的部分,并汇总每个段。 每个摘要还有一个冗长的 contexts 字段,它告诉我们从哪个输入对话范围生成了摘要。

获取对话问题和解决方法摘要结果

以下文本是你可能为对话问题和解决方法摘要提交的内容示例。 这只是一个示例,API 可以接受更长的输入文本。 有关详细信息,请参阅数据限制

代理:“您好,有什么可以帮您的吗?”

客户:“如何升级我的 Contoso 订阅?我已尝试了一整天。”

代理:“请按升级按钮,然后登录并按照说明进行操作”。

在收到请求后,将通过为 API 后端创建作业来执行摘要提取。 如果作业创建成功,将返回 API 的输出。 可在 24 小时内检索输出。 在此之后,将清除输出。 由于多语言和表情符号支持,响应可能包含文本偏移。 有关详细信息,请参阅如何处理偏移

在上面的示例中,API 可能会返回以下汇总句子:

总结的文本 方面
“客户想要升级其订阅。 客户不知道如何做。“ 问题
“客户需要按升级按钮,然后登录。” resolution

另请参阅