LLM Learning Hub

workspace/llm-course/home

Reranking

Reranking takes an initial set of retrieved documents and re-scores them with a more powerful cross-encoder model that jointly reads query and document, improving precision over bi-encoder retrieval.

What is Reranking?

Reranking takes an initial set of retrieved documents and re-scores them with a more powerful cross-encoder model that jointly reads query and document, improving precision over bi-encoder retrieval.

Reranking takes an initial set of retrieved documents and re-scores them with a more powerful cross-encoder model that jointly reads query and document, improving precision over bi-encoder retrieval.

Where is it used?

Cohere Rerank, `BAAI/bge-reranker-large`, and `cross-encoder/ms-marco-MiniLM-L-6-v2` are used in LangChain `ContextualCompressionRetriever` and LlamaIndex `CohereRerank` nodes.

How to build it

Load `CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')`, call `model.rank(query, retrieved_docs)` to get scores, sort docs by score, and keep the top-3 for prompt context.