If you've set up a local "chat with your documents" system, you've probably seen it pull in the wrong passages: chunks that share a few words with your question but don't answer it. A reranker fixes much of that. It takes the shortlist your embedding search returns and scores each passage against the question, so the best matches go to the chat model first. llama.cpp's llama-server can run reranking models on your own PC and offers a reranking endpoint for this. This guide follows the official llama-server README and the model pages on Hugging Face.
What you need
llama.cpp installed. On Windows, our guide to running llama.cpp on Windows covers the Llama app, winget and the pre-built downloads, plus choosing the right GPU build.
A reranking model in GGUF format. These are separate from chat models and embedding models. A good first choice is ggml-org's Qwen3-Reranker-0.6B Q8_0 build, a single file of about 0.64GB (639,153,184 bytes on Hugging Face's file list), made from Alibaba's Qwen3-Reranker-0.6B. The llama-server README names BAAI's bge-reranker-v2-m3 as another example of a model the endpoint needs.
An existing retrieval step, such as an embedding model. If you haven't set one up yet, see how to use embedding models with Ollama and our best local embedding models.
Rerankers are small next to chat models: the Qwen3 rerankers come in 0.6B, 4B and 8B sizes, and the 0.6B file above takes well under 1GB, so it fits alongside a chat model on most graphics cards.
Step 1: Start llama-server with reranking turned on
The README lists the --rerank (or --reranking) option as "enable reranking endpoint on server", and it's off by default. You can also set it with the LLAMA_ARG_RERANKING environment variable. The simplest way to get the model is to let llama-server download it from Hugging Face with -hf:
llama-server -hf ggml-org/Qwen3-Reranker-0.6B-Q8_0-GGUF --rerank --port 8012
On Windows the program is llama-server.exe. If you've already downloaded a GGUF, use -m with the file path instead of -hf. We've used port 8012 to match the README's reranking examples and to keep it apart from any chat server you already run. The README lists the default as 9931, so leave --port out if you prefer that. GPU offload (-ngl) defaults to auto, so you don't normally need to set it.
The README says the endpoint needs a reranker model and either --reranking or the combination --embedding --pooling rank. Ordinary chat models won't give useful scores.
Step 2: Send a test query
llama-server answers on /reranking, with /rerank, /v1/rerank and /v1/reranking as aliases. With the server running, send a question and a few candidate passages. This is the README's own example (on Windows, use a tool such as Git Bash or WSL for this curl syntax):
curl http://127.0.0.1:8012/v1/rerank \
-H "Content-Type: application/json" \
-d '{"query": "What is machine learning?", "texts": ["Machine learning is a subset of artificial intelligence.", "A python is a large snake."], "return_text": true}'
The reply lists each passage's position in your list (index) with a score. According to the README, results are sorted from best to worst match, and the score is a match probability between 0 and 1, so in this example the machine learning sentence should come back first with a much higher score than the snake.
The README is clear that this endpoint is not OpenAI-compatible. It accepts two formats, chosen by which key holds the passages:
texts uses the TEI format (as in the example above) and returns a bare list of index and score pairs, plus the text if you set return_text: true.
documents uses the Jina format, which returns an object with model, object, usage and a results list of index and relevance_score pairs. This format also supports images with multimodal rerankers such as Qwen3-VL-Reranker.
Both accept top_n to return only the best few passages; by default you get them all. If your RAG app or script has a "Jina-compatible" or "TEI" reranker option, point it at http://127.0.0.1:8012 and pick the matching format. The README notes the Jina-style format might change in future, so check it after updating llama.cpp.
The README has one important note on size. A bidirectional-encoder reranker such as bge-reranker-v2-m3 must fit the whole prompt, meaning the query plus the passage, within the physical batch size, --ubatch-size (-ub), which defaults to 512. If you see errors with long passages, raise it, for example to -ub 2048. Causal decoder rerankers such as Qwen3-VL-Reranker don't have this limit. Keeping your document chunks reasonably short helps either way.
Where it fits in a local RAG setup
A typical pipeline, as described in the Sentence Transformers documentation, retrieves a shortlist (its example uses 100 candidates) with a fast embedding search, then has the reranker score each one against the query and passes only the top few to the chat model. Our embedding vs reranker comparison explains why you'd use both rather than either one alone. Qwen's model card also lists 4B and 8B versions of the reranker if you want to trade speed for accuracy. If you already run several models through one server, see running multiple models with the llama-server router.
If you'd rather not write any code, Open WebUI's documentation says its hybrid search combines BM25 keyword search with re-ranking powered by a CrossEncoder, and can be switched on in Settings > Documents in the admin section without re-indexing your knowledge bases. Our Open WebUI knowledge base guide covers that route.