A class that uses an LLM chain to extract relevant parts of documents. It extends the BaseDocumentCompressor class.

Hierarchy (view full)

Constructors

Properties

getInput: ((query: string, doc: DocumentInterface) => Record<string, unknown>) = defaultGetInput
llmChain: LLMChain<string, any>

Methods

  • Creates a new instance of LLMChainExtractor from a given LLM, prompt template, and getInput function.

    Parameters

    • llm: BaseLanguageModelInterface

      The BaseLanguageModel instance used for document extraction.

    • Optionalprompt: any

      The PromptTemplate instance used for document extraction.

    • OptionalgetInput: ((query: string, doc: DocumentInterface) => Record<string, unknown>)

      A function used for constructing the chain input from the query and a Document.

        • (query, doc): Record<string, unknown>
        • Parameters

          • query: string
          • doc: DocumentInterface

          Returns Record<string, unknown>

    Returns LLMChainExtractor

    A new instance of LLMChainExtractor.