Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Summarizing documents is a valuable tool for content review, quick insights, or preparing abstracts. Aspose.Words supports document summarization using AI‑powered models, making it easier to process long text. This feature, available in the Aspose.Words.AI namespace, integrates advanced generative language models from OpenAI and Google, as well as Claude’s anthropic generative language models. The list of supported models is available in the AiModelType enumeration.
You can specify various options for summarizing document content. Use the Summarize method to generate a summary of your document. You can also set summary length using the SummaryLength property.
With Aspose.Words, implementing document summarization is straightforward. The following code example shows how to summarize a document using GPT‑4o model:
void AiSummarize()
{
auto firstDoc = MakeObject<Document>(MyDir + u"Big document.docx");
auto secondDoc = MakeObject<Document>(MyDir + u"Document.docx");
SharedPtr<IAiModelText> model = System::ExplicitCast<OpenAiModel>(MakeObject<AiModel>()->Create(AiModelType::Gpt4OMini)->WithApiKey(u"API_KEY"))->WithOrganization(u"Organization")->WithProject(u"Project");
auto options = MakeObject<SummarizeOptions>();
options->set_SummaryLength(SummaryLength::Short);
auto firstDocumentSummary = model->Summarize(firstDoc, options);
firstDocumentSummary->Save(ArtifactsDir + u"AI.AiSummarize.One.docx");
System::ArrayPtr<System::SharedPtr<Document>> documents = System::MakeArray<System::SharedPtr<Document>>(2);
documents[0] = firstDoc;
documents[1] = secondDoc;
options->set_SummaryLength(SummaryLength::Long);
auto multiDocumentSummary = model->Summarize(documents, options);
firstDocumentSummary->Save(ArtifactsDir + u"AI.AiSummarize.Multi.docx");
}
Q: How do I choose which AI model to use for summarization?
A: The AI model is selected via the AiModelType enumeration when creating the model instance, e.g., AiModelType::Gpt4OMini for OpenAI’s GPT‑4o Mini or AiModelType::GoogleGemini for Google’s Gemini. Choose the model that best fits your accuracy, latency, and cost requirements.
Q: Can I summarize multiple documents in a single call?
A: Yes. Pass an array of Document objects to the Summarize method. The same SummarizeOptions (including SummaryLength) will be applied to each document, and the method returns a collection of summary documents.
Q: How can I control the length of the generated summary?
A: Set the SummaryLength property of SummarizeOptions to Short, Medium, Long, or a custom value using Custom. This determines how concise or detailed the AI‑generated summary will be.
Q: What authentication is required for OpenAI or Google models?
A: For OpenAI models, provide an API key via WithApiKey, and optionally specify organization and project using WithOrganization and WithProject. For Google models, supply the appropriate credentials (API key or service account) using the corresponding WithApiKey or credential methods defined in the SDK.
Q: Is it possible to summarize a document without using AI models?
A: The Summarize API is built on AI models, so it requires an AI provider. For simple text extraction or keyword summarization, you would need to implement custom logic using other Aspose.Words features such as DocumentVisitor or manual text processing.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.