FlashrankRerank#

class langchain_community.document_compressors.flashrank_rerank.FlashrankRerank[source]#

Bases: BaseDocumentCompressor

Document compressor using Flashrank interface.

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

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param client: Ranker [Required]#

Flashrank client to use for compressing documents

param model: str | None = None#

Model to use for reranking.

param prefix_metadata: str = ''#

Prefix for flashrank_rerank metadata keys

param score_threshold: float = 0.0#

Minimum relevance threshold to return.

param top_n: int = 3#

Number of documents to return.

async acompress_documents(documents: Sequence[Document], query: str, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None) Sequence[Document]#

Async compress retrieved documents given the query context.

Parameters:
Returns:

The compressed documents.

Return type:

Sequence[Document]

compress_documents(documents: Sequence[Document], query: str, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None) Sequence[Document][source]#

Compress retrieved documents given the query context.

Parameters:
Returns:

The compressed documents.

Return type:

Sequence[Document]

Examples using FlashrankRerank