TextSummarize

TextSummarize[text]

generates a summary of text.

TextSummarize[text, spec]

summarizes the text according to the specification spec.

TextSummarize[texttopic,spec]

summarizes the part of text matching topic.

Details and Options

  • TextSummarize is used to condense textual information.
  • TextSummarize requires external service authentication, billing and internet connectivity.
  • Long strings are first split into smaller chunks, summarized independently (AKA mapped) and then combined (AKA reduced).
  • Possible values for text are:
  • "string"a plain string
    File["path"]individual file
    URL["url"]the text representation of "url"
    CloudObject[]a cloud object
    LocalObject[]a local object
    {obj1,obj2,}list of objects
  • Possible values for spec are:
  • "Description"paraphrased text in condensed form (default)
    "Extracts"key sentences from text
    "Keywords"keywords from text in order of importance
    "KeywordSummary"keywords from text in order of appearance
    "OneLineSummary"extremely condensed abstract
    "Rewrite"short version of text with the same style
    "Title"possible title for text
    "Topics"main topics in text
  • Additionally, custom values for spec can be specified using:
  • promptcustom specification description
    {promptmap,promptreduce}separate prompts for the map and reduce parts
  • The prompti support the following values:
  • LLMPrompt["name"]repository prompt
    StringTemplate[]templated text
    TemplateObject[]template for creating text
  • The topic specification is a free-form string. It can be used to select specific portions of text.
  • TextSummarize supports the following options:
  • InsertionFunctionAutomaticfunction or format to apply before inserting expressions
    CombinerFunctionStringJoinfunction to apply to combine pieces within a prompt
    AuthenticationAutomaticexplicit user ID and API key
    LLMEvaluator$LLMEvaluatorLLM configuration to use
    Method Automaticmethod details
  • The default InsertionFunction is TextString on a single chunk and StringRiffle[#, "\n\n"]& on a list of chunks.
  • Detailed options can be given using Method<|opt1val1|>. Possible values for opti are:
  • "ContextWindow"maximal length of the text chunks
    "ContextPadding"minimal overlap between chunks
    "SplitPattern"Automaticwhere to split long strings
  • The automatic "SplitPattern" tries to split text in paragraphs, newlines and words to create chunks smaller than "ContextWindow".
  • TextSummarize uses machine learning. Its methods, training sets and biases included therein may change and yield varied results in different versions of the Wolfram Language.

Examples

open allclose all

Basic Examples  (2)

Summarize the contents of a file:

Find the main keywords describing a piece of text:

Scope  (12)

Input Types  (4)

Summarize a string:

Summarize a file:

Summarize a URL:

Summarize a list of objects:

Summary Specification  (7)

Provide a succinct description of the text content:

Rewrite the text in a condensed form:

Invent a title for the provided text:

Summarize the text in a single sentence:

Find the main keywords to describe the text content:

Find the main keywords in the order they appear in the text:

Summarize the specified text by extracting the key sentences:

Topic Specification  (1)

Summarize the whole text:

Summarize only the part of the text matching a topic:

Options  (1)

Method  (1)

Long string with no newlines will be automatically split at whitespaces:

Define a custom split pattern to divide the chapters:

Compute the summary using the new text chunks:

Wolfram Research (2023), TextSummarize, Wolfram Language function, https://reference.wolfram.com/language/ref/TextSummarize.html.

Text

Wolfram Research (2023), TextSummarize, Wolfram Language function, https://reference.wolfram.com/language/ref/TextSummarize.html.

CMS

Wolfram Language. 2023. "TextSummarize." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TextSummarize.html.

APA

Wolfram Language. (2023). TextSummarize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TextSummarize.html

BibTeX

@misc{reference.wolfram_2024_textsummarize, author="Wolfram Research", title="{TextSummarize}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/TextSummarize.html}", note=[Accessed: 28-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_textsummarize, organization={Wolfram Research}, title={TextSummarize}, year={2023}, url={https://reference.wolfram.com/language/ref/TextSummarize.html}, note=[Accessed: 28-April-2024 ]}