Skip to content

How-ToGPU

How to Run a Reranker Model Locally with llama.cpp's llama-server

A reranker makes local document chat pick better passages by scoring each one against your question. Using the official llama.cpp server documentation, we show how to run a small reranking model with llama-server, send it queries and fix the most common error.

By , Systems & Technical Editor

4 min read

How to Run a Reranker Model Locally with llama.cpp's llama-server

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.

Step 3: Pick the request format your app expects

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.

Step 4: Fix "input too large" errors

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.

The bottom line

Running a reranker locally takes one extra llama-server command: load a reranking GGUF such as ggml-org's 0.64GB Qwen3-Reranker-0.6B build, add --rerank, and send the query and candidate passages to /v1/rerank. It's one of the cheapest ways to make a local document chat pick better passages, as it needs very little memory. Just remember the endpoint isn't OpenAI-compatible, and raise --ubatch-size if long passages fail with encoder rerankers such as bge-reranker-v2-m3.

Sources

  1. 01ggml-org, llama.cpp server README
  2. 02ggml-org, Qwen3-Reranker-0.6B-Q8_0-GGUF on Hugging Face
  3. 03Qwen, Qwen3-Reranker-0.6B model card on Hugging Face
  4. 04Sentence Transformers documentation, Retrieve & Re-Rank
  5. 05Open WebUI documentation, Retrieval Augmented Generation (RAG)

About the author

Marcus Thorne

Systems & Technical Editor

Marcus writes Forge PC's step-by-step build, troubleshooting and system optimisation guides. His background spans Windows kernel and power-state diagnostics, UEFI/BIOS configuration, NVMe storage arrays, ATX 3.1 power delivery and running local AI and LLM workloads on consumer graphics cards.

More from Marcus Thorne

Read next

How to Spot a Fake Graphics Card Before and After You Buy

How-To

How to Spot a Fake Graphics Card Before and After You Buy

Fake graphics cards are usually old GPUs with edited firmware that report as newer models. Here's how to check a listing against official specs before you buy, then confirm a card with GPU-Z's [FAKE] detection, memory and bus-width checks and a stress test after it arrives.

Marcus Thorne4 min

DXVK 3.2 Brings Present Timing for Smoother Frame Pacing on Linux

News

DXVK 3.2 Brings Present Timing for Smoother Frame Pacing on Linux

DXVK 3.2, the Vulkan translation layer behind most Direct3D 8-11 games on Linux and Proton, adds present timing for steadier frame pacing on Wayland and Gamescope, rewrites Reflex support, improves VRAM eviction and fixes a list of games, per the official release notes.

Eleanor Shaw4 min

Embedding vs Reranker Models: Which Does Your Local RAG Setup Need?

Versus

Embedding vs Reranker Models: Which Does Your Local RAG Setup Need?

Embedding models and rerankers both judge how relevant a passage is to your question, but they do very different jobs in a local RAG setup. We explain how each works, what it costs in speed and memory, and when a reranker is worth adding.

Callum Reid4 min