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 get_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<AiModel> model = AiModel::Create(AiModelType::Gpt4OMini)->WithApiKey(u"API_KEY");
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);
multiDocumentSummary->Save(ArtifactsDir + u"AI.AiSummarize.Multi.docx");
}Q: How do I choose which AI model to use for summarization?
A: Select a model from the AiModelType enumeration and create it with AiModel::Create. The supported families include OpenAI, Google (Gemini), and Anthropic (Claude). Choose a model available through your provider account.
Q: Can I summarize multiple documents in a single call?
A: Yes. Pass an array of Document objects to the Summarize method. It returns a single Document containing the combined summary.
Q: How can I control the length of the generated summary?
A: Set the SummaryLength property of SummarizeOptions to VeryShort, Short, Medium, Long, or VeryLong.
Q: What authentication is required for AI models?
A: Provide an API key for the selected OpenAI, Google, or Anthropic service via WithApiKey. OpenAI models also allow optional organization and project settings using WithOrganization and WithProject.
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.