Skip to content

Commit 64dca78

Browse files
Merge pull request #202338 from aahill/python-update
summarization for python
2 parents cf4ffa2 + ca365a1 commit 64dca78

File tree

4 files changed

+186
-11
lines changed

4 files changed

+186
-11
lines changed

articles/cognitive-services/language-service/summarization/how-to/conversation-summarization.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,56 @@ The AI models used by the API are provided by the service, you just have to send
2626

2727
The conversation summarization API uses natural language processing techniques to locate key issues and resolutions in text-based chat logs. Conversation summarization will return issues and resolutions found from the text input.
2828

29-
There's another feature in Azure Cognitive Service for Language, [document summarization](../overview.md?tabs=document-summarization), that can summarize sentences from large documents. When you're deciding between document summarization and conversation summarization, consider the following points:
29+
There's another feature in Azure Cognitive Service for Language named [document summarization](../overview.md?tabs=document-summarization) that can summarize sentences from large documents. When you're deciding between document summarization and conversation summarization, consider the following points:
3030
* Extractive summarization returns sentences that collectively represent the most important or relevant information within the original content.
3131
* Conversation summarization returns summaries based on full chat logs including a reason for the chat (a problem), and the resolution. For example, a chat log between a customer and a customer service agent.
3232

3333
## Submitting data
3434

3535
You submit documents to the API as strings of text. Analysis is performed upon receipt of the request. Because the API is [asynchronous](../../concepts/use-asynchronously.md), there may be a delay between sending an API request and receiving the results. For information on the size and number of requests you can send per minute and second, see the data limits below.
3636

37-
When using this feature, the API results are available for 24 hours from the time the request was ingested, and is indicated in the response. After this time period, the results are purged and are no longer available for retrieval.
37+
When you use this feature, the API results are available for 24 hours from the time the request was ingested, and is indicated in the response. After this time period, the results are purged and are no longer available for retrieval.
3838

3939
When you submit data to conversation summarization, we recommend sending one chat log per request, for better latency.
40-
40+
41+
### Get summaries from text chats
42+
43+
You can use conversation summarization to get summaries from 2-person chats between customer service agents, and customers. To see an example using text chats, see the [quickstart article](../quickstart.md).
44+
45+
### Get summaries from speech transcriptions
46+
47+
Conversation summarization also enables you to get summaries from speech transcripts by using the [Speech service's speech-to-text feature](../../../Speech-Service/call-center-transcription.md). The following example shows a short conversation that you might include in your API requests.
48+
49+
```json
50+
"conversations":[
51+
{
52+
"id":"abcdefgh-1234-1234-1234-1234abcdefgh",
53+
"language":"En",
54+
"modality":"transcript",
55+
"conversationItems":[
56+
{
57+
"modality":"transcript",
58+
"participantId":"speaker",
59+
"id":"12345678-abcd-efgh-1234-abcd123456",
60+
"content":{
61+
"text":"Hi.",
62+
"lexical":"hi",
63+
"itn":"hi",
64+
"maskedItn":"hi",
65+
"audioTimings":[
66+
{
67+
"word":"hi",
68+
"offset":4500000,
69+
"duration":2800000
70+
}
71+
]
72+
}
73+
}
74+
]
75+
}
76+
]
77+
```
78+
4179
## Getting conversation summarization results
4280

4381
When you get results from language detection, you can stream the results to an application or save the output to a file on the local system.
@@ -52,7 +90,7 @@ The following text is an example of content you might submit for summarization.
5290

5391
Summarization is performed upon receipt of the request by creating a job for the API backend. If the job succeeded, the output of the API will be returned. The output will be available for retrieval for 24 hours. After this time, the output is purged. Due to multilingual and emoji support, the response may contain text offsets. See [how to process offsets](../../concepts/multilingual-emoji-support.md) for more information.
5492

55-
Using the above example, the API might return the following summarized sentences:
93+
In the above example, the API might return the following summarized sentences:
5694

5795
|Summarized text | Aspect |
5896
|---------|----|

articles/cognitive-services/language-service/summarization/includes/quickstarts/python-sdk.md

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,32 @@ ms.custom: ignite-fall-2021
3131

3232
After installing Python, you can install the client library with:
3333

34+
# [Document summarization](#tab/document-summarization)
35+
36+
```console
37+
pip install azure-ai-textanalytics==5.2.0b4
38+
```
39+
40+
# [Conversation summarization](#tab/conversation-summarization)
41+
3442
```console
35-
pip install azure-ai-textanalytics==5.2.0b1
43+
pip install azure-ai-language-conversations==1.1.0b1
3644
```
3745

46+
---
47+
3848
> [!div class="nextstepaction"]
3949
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=PYTHON&Pillar=Language&Product=Summarization&Page=quickstart&Section=Set-up-the-environment" target="_target">I ran into an issue</a>
4050
51+
4152
## Code example
4253

4354
Create a new Python file and copy the below code. Remember to replace the `key` variable with the key for your resource, and replace the `endpoint` variable with the endpoint for your resource.
4455

4556
[!INCLUDE [find the key and endpoint for a resource](../../../includes/find-azure-resource-info.md)]
4657

58+
# [Document summarization](#tab/document-summarization)
59+
4760
```python
4861
key = "paste-your-key-here"
4962
endpoint = "paste-your-endpoint-here"
@@ -108,3 +121,119 @@ sample_extractive_summarization(client)
108121
Summary extracted:
109122
The extractive summarization feature uses natural language processing techniques to locate key sentences in an unstructured text document. This feature is provided as an API for developers. They can use it to build intelligent solutions based on the relevant information extracted to support various use cases.
110123
```
124+
125+
# [Conversation summarization](#tab/conversation-summarization)
126+
127+
```python
128+
129+
key = "paste-your-key-here"
130+
endpoint = "paste-your-endpoint-here"
131+
132+
import os
133+
from azure.core.credentials import AzureKeyCredential
134+
from azure.ai.language.conversations import ConversationAnalysisClient
135+
136+
client = ConversationAnalysisClient(endpoint, AzureKeyCredential(key))
137+
with client:
138+
poller = client.begin_conversation_analysis(
139+
task={
140+
"displayName": "Analyze conversations from xxx",
141+
"analysisInput": {
142+
"conversations": [
143+
{
144+
"conversationItems": [
145+
{
146+
"text": "Hello, you’re chatting with Rene. How may I help you?",
147+
"id": "1",
148+
"role": "Agent",
149+
"participantId": "Agent_1"
150+
},
151+
{
152+
"text": "Hi, I tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn’t work.",
153+
"id": "2",
154+
"role": "Customer",
155+
"participantId": "Customer_1"
156+
},
157+
{
158+
"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?",
159+
"id": "3",
160+
"role": "Agent",
161+
"participantId": "Agent_1"
162+
},
163+
{
164+
"text": "Yes, I pushed the wifi connection button, and now the power light is slowly blinking.",
165+
"id": "4",
166+
"role": "Customer",
167+
"participantId": "Customer_1"
168+
},
169+
{
170+
"text": "Great. Thank you! Now, please check in your Contoso Coffee app. Does it prompt to ask you to connect with the machine?",
171+
"id": "5",
172+
"role": "Agent",
173+
"participantId": "Agent_1"
174+
},
175+
{
176+
"text": "No. Nothing happened.",
177+
"id": "6",
178+
"role": "Customer",
179+
"participantId": "Customer_1"
180+
},
181+
{
182+
"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.",
183+
"id": "7",
184+
"role": "Agent",
185+
"participantId": "Agent_1"
186+
}
187+
],
188+
"modality": "text",
189+
"id": "conversation1",
190+
"language": "en"
191+
},
192+
]
193+
},
194+
"tasks": [
195+
{
196+
"taskName": "analyze 1",
197+
"kind": "ConversationalSummarizationTask",
198+
"parameters": {
199+
"summaryAspects": ["Issue, Resolution"]
200+
}
201+
}
202+
]
203+
}
204+
)
205+
206+
# view result
207+
result = poller.result()
208+
task_result = result["tasks"]["items"][0]
209+
print("... view task status ...")
210+
print("status: {}".format(task_result["status"]))
211+
resolution_result = task_result["results"]
212+
if resolution_result["errors"]:
213+
print("... errors occured ...")
214+
for error in resolution_result["errors"]:
215+
print(error)
216+
else:
217+
conversation_result = resolution_result["conversations"][0]
218+
if conversation_result["warnings"]:
219+
print("... view warnings ...")
220+
for warning in conversation_result["warnings"]:
221+
print(warning)
222+
else:
223+
summaries = conversation_result["summaries"]
224+
print("... view task result ...")
225+
print("issue: {}".format(summaries[0]["text"]))
226+
print("resolution: {}".format(summaries[1]["text"]))
227+
228+
```
229+
230+
> [!div class="nextstepaction"]
231+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=PYTHON&Pillar=Language&Product=Summarization&Page=quickstart&Section=Code-example" target="_target">I ran into an issue</a>
232+
233+
### Output
234+
235+
```console
236+
issue: Customer tried to set up wifi connection for Smart Brew 300 coffee machine, but it didn't work
237+
resolution: Asked customer to try the following steps | Asked customer for the power light | Helped customer to connect to the machine
238+
```
239+
---

articles/cognitive-services/language-service/summarization/includes/regional-availability.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ manager: nitinme
55
ms.service: cognitive-services
66
ms.subservice: language-service
77
ms.topic: include
8-
ms.date: 06/14/2022
8+
ms.date: 06/21/2022
99
ms.author: aahi
1010
ms.custom: references_regions
1111
---
1212

1313
> [!NOTE]
14-
> This feature is only available through Language resources in the following regions:
15-
> * North Europe
16-
> * East US
17-
> * UK South
14+
> For document summarization and conversation summarization:
15+
> * These features are only available through Language resources in the following regions:
16+
> * North Europe
17+
> * East US
18+
> * UK South
19+
>
20+
> For conversation summarization only:
21+
> * To use conversation summarization, you must [submit an online request and have it approved](https://aka.ms/applyforconversationsummarization/).
22+
> * Conversation summarization is only available using:
23+
> * REST API
24+
> * Python

articles/cognitive-services/language-service/summarization/quickstart.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ If you want to clean up and remove a Cognitive Services subscription, you can de
6262

6363
## Next steps
6464

65-
* [Summarization overview](overview.md)
65+
* [How to call document summarization](./how-to/document-summarization.md)
66+
* [How to call conversation summarization](./how-to/conversation-summarization.md)

0 commit comments

Comments
 (0)