04. FlashRank Reranker

FlashRank Existing search and retrieval Ultra-light and ultra-fast Python library to add a seam to the pipeline. SoTA cross-encoders Based on.

This laptop is compressed documents and retrieval for flashrank Shows how to use.

Preferences

Copy

# installation
# !pip install -qU flashrank

Copy

def pretty_print_docs(docs):
    print(
        f"\n{'-' * 100}\n".join(
            [
                f"Document {i+1}:\n\n{d.page_content}\nMetadata: {d.metadata}"
                for i, d in enumerate(docs)
            ]
        )
    )

FlashrankRerank

Load the data above a simple example and generate retriever.

Copy

Copy

Now the basics retriever for ContextualCompressionRetriever Wrapped up, FlashrankRerank Let's use it as a compressor.

Copy

Copy

Copy

Compare results after reranker is applied.

Copy

Copy

Last updated