> For the complete documentation index, see [llms.txt](https://docs.zenml.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zenml.io/user-guides/llmops-guide/reranking.md).

# Reranking for better retrieval

Add reranking to your RAG inference for better retrieval performance.

Rerankers are a crucial component of retrieval systems that use LLMs. They help\
improve the quality of the retrieved documents by reordering them based on\
additional features or scores. In this section, we'll explore how to add a\
reranker to your RAG inference pipeline in ZenML.

In previous sections, we set up the overall workflow, from data ingestion and\
preprocessing to embeddings generation and retrieval. We then set up some basic\
evaluation metrics to assess the performance of our retrieval system. A reranker\
is a way to squeeze a bit of extra performance out of the system by reordering\
the retrieved documents based on additional features or scores.

![](https://3621652509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F75OYotLPi8TviSrtZTJZ%2Fuploads%2Fgit-blob-cd59ef6831c8834b60984ecd59ddc55549d5b6e0%2Freranking-workflow.png?alt=media)

As you can see, reranking is an optional addition we make to what we've already\
set up. It's not strictly necessary, but it can help improve the relevance and\
quality of the retrieved documents, which in turn can lead to better responses\
from the LLM. Let's dive in!

<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zenml.io/user-guides/llmops-guide/reranking.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
