-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Text Analytics] Add support for abstractive summarization (#32402)
- Added `TextAnalyticsActions.AbstractSummaryActions` to perform abstractive summarization in a batch of actions. - Added `TextAnalyticsClient.StartAbstractSummary` and `StartAbstractSummaryAsync` to perform abstractive summarization on a collection of documents.
- Loading branch information
1 parent
2456bc8
commit df9d061
Showing
45 changed files
with
5,194 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 83 additions & 1 deletion
84
sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
sdk/textanalytics/Azure.AI.TextAnalytics/src/AbstractSummaryAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// A set of options used to configure abstractive summarization, including the model version to use, the maximum | ||
/// number of sentences that the resulting summary can have, and more. | ||
/// </summary> | ||
public class AbstractSummaryAction | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AbstractSummaryAction"/> class. | ||
/// </summary> | ||
public AbstractSummaryAction() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AbstractSummaryAction"/> class based on the given | ||
/// <see cref="AbstractSummaryOptions"/>. It sets the <see cref="ModelVersion"/>, | ||
/// <see cref="DisableServiceLogs"/>, and <see cref="MaxSentenceCount"/> properties. | ||
/// </summary> | ||
public AbstractSummaryAction(AbstractSummaryOptions options) | ||
{ | ||
ModelVersion = options.ModelVersion; | ||
DisableServiceLogs = options.DisableServiceLogs; | ||
MaxSentenceCount = options.MaxSentenceCount; | ||
} | ||
|
||
/// <summary> | ||
/// The version of the text analytics model that will be used to generate the result. To learn more about the | ||
/// supported model versions for each feature, see | ||
/// <see href="https://learn.microsoft.com/azure/cognitive-services/language-service/concepts/model-lifecycle"/>. | ||
/// </summary> | ||
public string ModelVersion { get; set; } | ||
|
||
/// <summary> | ||
/// Indicates whether the service logs your input text for 48 hours, which is solely to allow for | ||
/// troubleshooting, if needed. Setting this property to <c>true</c> disables input logging and may limit our | ||
/// ability to investigate any issues that occur. If not set, the service default is used. | ||
/// <para> | ||
/// Please see the Cognitive Services Compliance and Privacy notes at | ||
/// <see href="https://aka.ms/cs-compliance"/> for additional details, and the Microsoft Responsible AI | ||
/// principles at <see href="https://www.microsoft.com/ai/responsible-ai"/>. | ||
/// </para> | ||
/// </summary> | ||
public bool? DisableServiceLogs { get; set; } | ||
|
||
/// <summary> | ||
/// The name of this action. If not set, the service will generate one. | ||
/// </summary> | ||
public string ActionName { get; set; } | ||
|
||
/// <summary> | ||
/// The maximum number of sentences that the resulting summaries can have. If not set, the service default is | ||
/// used. | ||
/// </summary> | ||
public int? MaxSentenceCount { get; set; } | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
sdk/textanalytics/Azure.AI.TextAnalytics/src/AbstractSummaryActionResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.AI.TextAnalytics.Models; | ||
|
||
namespace Azure.AI.TextAnalytics | ||
{ | ||
/// <summary> | ||
/// A representation of the result of performing an <see cref="AbstractSummaryAction"/> on a given set of | ||
/// documents. | ||
/// </summary> | ||
public class AbstractSummaryActionResult : TextAnalyticsActionResult | ||
{ | ||
private readonly AbstractSummaryResultCollection _documentsResults; | ||
|
||
/// <summary> | ||
/// Initializes a successful <see cref="AbstractSummaryActionResult"/>. | ||
/// </summary> | ||
internal AbstractSummaryActionResult( | ||
AbstractSummaryResultCollection result, string actionName, DateTimeOffset completedOn) | ||
: base(actionName, completedOn) | ||
{ | ||
_documentsResults = result; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes an <see cref="AbstractSummaryActionResult"/> with an error. | ||
/// </summary> | ||
internal AbstractSummaryActionResult(string actionName, DateTimeOffset completedOn, Error error) | ||
: base(actionName, completedOn, error) { } | ||
|
||
/// <summary> | ||
/// The collection of results corresponding to each given document. | ||
/// </summary> | ||
public AbstractSummaryResultCollection DocumentsResults | ||
{ | ||
get | ||
{ | ||
if (HasError) | ||
{ | ||
throw new InvalidOperationException( | ||
$"Cannot access the results of this action, due to error {Error.ErrorCode}: {Error.Message}"); | ||
} | ||
return _documentsResults; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.