summarize method
Contents
[
Hide
]summarize(source_document, options)
Generates a summary of the specified document, with options to adjust the length of the summary.
def summarize(self, source_document: aspose.words.Document, options: aspose.words.ai.SummarizeOptions):
...
| Parameter | Type | Description |
|---|---|---|
| source_document | Document | |
| options | SummarizeOptions |
summarize(source_documents, options)
Generates a summary for an array of documents, with options to adjust the length of the summary.
def summarize(self, source_documents: List[aspose.words.Document], options: aspose.words.ai.SummarizeOptions):
...
| Parameter | Type | Description |
|---|---|---|
| source_documents | List[Document] | |
| options | SummarizeOptions |
Examples
Shows how to summarize documents with a local model, so the content never leaves the machine.
# Aspose.LLM is a separate package with its own license. You should set it directly,
# the same way as for any other Aspose product.
first_doc = aw.Document(file_name=MY_DIR + "Big document.docx")
second_doc = aw.Document(file_name=MY_DIR + "Document.docx")
# Disposing the model releases the local model and its native resources.
with aw.ai.AsposeLlmModel("Qwen25_3BPresetCpu") as model:
summarize_options = aw.ai.SummarizeOptions()
summarize_options.summary_length = aw.ai.SummaryLength.SHORT
summary = model.summarize(source_document=first_doc, options=summarize_options)
summary.save(file_name=ARTIFACTS_DIR + "AI.AsposeLlmSummarize.One.docx")
summarize_options.summary_length = aw.ai.SummaryLength.MEDIUM
combined_summary = model.summarize(source_documents=[first_doc, second_doc], options=summarize_options)
combined_summary.save(file_name=ARTIFACTS_DIR + "AI.AsposeLlmSummarize.Multiple.docx")
See Also
- module aspose.words.ai
- class AsposeLlmModel