SummarizeChain class abstract

Chain for summarizing documents.

There are two methods to summarize documents:

  • stuff uses the StuffDocumentsChain to combine all the documents into a single string, then prompts the model to summarize that string. This method is limited by the context length limit of the model.
  • mapReduce uses the MapReduceDocumentsChain to summarize each document individually, then combines the results into a single summary.

Constructors

SummarizeChain.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

mapReduce({required BaseLanguageModel<Object, LanguageModelOptions, LanguageModelResult<Object>> llm, String inputKey = SummarizeChain.defaultInputKey, String outputKey = SummarizeChain.defaultOutputKey, BasePromptTemplate mapPrompt = _promptTemplate, String mapDocumentPromptVar = MapReduceDocumentsChain.defaultLlmChainDocumentPromptVar, BasePromptTemplate combinePrompt = _promptTemplate, BaseLanguageModel<Object, LanguageModelOptions, LanguageModelResult<Object>>? combineLlm, BasePromptTemplate combineDocumentPrompt = StuffDocumentsChain.defaultDocumentPrompt, String combineDocumentPromptVar = StuffDocumentsChain.defaultLlmChainStuffedDocumentPromptVar, String combineDocumentSeparator = StuffDocumentsChain.defaultDocumentSeparator, int combineInputMaxTokens = ReduceDocumentsChain.defaultTokenMax, BasePromptTemplate? collapsePrompt, BaseLanguageModel<Object, LanguageModelOptions, LanguageModelResult<Object>>? collapseLlm, BasePromptTemplate collapseDocumentPrompt = StuffDocumentsChain.defaultDocumentPrompt, String collapseDocumentPromptVar = StuffDocumentsChain.defaultLlmChainStuffedDocumentPromptVar, String collapseDocumentSeparator = StuffDocumentsChain.defaultDocumentSeparator, bool returnIntermediateSteps = false}) MapReduceDocumentsChain
The mapReduce method uses the MapReduceDocumentsChain to summarize each document individually, then combines the results into a single summary.
stuff({required BaseLanguageModel<Object, LanguageModelOptions, LanguageModelResult<Object>> llm, String inputKey = SummarizeChain.defaultInputKey, String outputKey = SummarizeChain.defaultOutputKey, BasePromptTemplate promptTemplate = _promptTemplate, BasePromptTemplate documentPrompt = StuffDocumentsChain.defaultDocumentPrompt, String stuffedDocumentPromptVar = StuffDocumentsChain.defaultLlmChainStuffedDocumentPromptVar, String documentSeparator = StuffDocumentsChain.defaultDocumentSeparator}) StuffDocumentsChain
The stuff method uses the StuffDocumentsChain to combine all the documents into a single string, then prompts the model to summarize that string. This method is limited by the context length limit of the llm.

Constants

defaultInputKey → const String
Default input key for the summarization chain where to place the documents to summarize.
defaultOutputKey → const String
Default output key for the summarization chain where to place the summary.