langchain.document_transformers.long_context_reorder.LongContextReorder¶

class langchain.document_transformers.long_context_reorder.LongContextReorder[source]¶

Bases: BaseDocumentTransformer, BaseModel

Lost in the middle: Performance degrades when models must access relevant information in the middle of long contexts. See: https://arxiv.org/abs//2307.03172

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

async atransform_documents(documents: Sequence[Document], **kwargs: Any) Sequence[Document][source]¶

Asynchronously transform a list of documents.

Parameters

documents – A sequence of Documents to be transformed.

Returns

A list of transformed Documents.

transform_documents(documents: Sequence[Document], **kwargs: Any) Sequence[Document][source]¶

Reorders documents.

model Config[source]¶

Bases: object

Configuration for this pydantic object.

arbitrary_types_allowed = True¶

Examples using LongContextReorder¶