[PR #11328] Add reranking in new engine (ollamarunner) #75802

Open
opened 2026-05-05 08:13:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/11328
Author: @404-9e1-520-e6dbd00d7
Created: 7/8/2025
Status: 🔄 Open

Base: mainHead: reranking-new-engine


📝 Commits (10+)

  • 6227d3f ollamarunner: add reranking support
  • 23d913f template: add reranking support
  • 8620567 server: add reranking support
  • d5a741b llm: add reranking support
  • 41adece api: add reranking support
  • c15baf0 docs: add reranking support
  • 1ba4734 ollamarunner: remove unnecessary tag replacement.
  • dd0461a docs: change example reranking template
  • 193990b ollamarunner: defer batch signal until full
  • 809e413 docs: change reranking template example (qwen)

📊 Changes

9 files changed (+494 additions, -9 deletions)

View changed files

📝 api/types.go (+27 -0)
📝 docs/api.md (+107 -0)
📝 docs/modelfile.md (+6 -0)
📝 docs/template.md (+4 -0)
📝 llm/server.go (+68 -0)
📝 runner/ollamarunner/runner.go (+159 -5)
📝 server/routes.go (+109 -0)
📝 server/sched_test.go (+5 -0)
📝 template/template.go (+9 -4)

📄 Description

Implements reranking: https://github.com/ollama/ollama/issues/3368
Implemented reranking in the new engine (ollamarunner), based on https://github.com/ollama/ollama/pull/11156

I tested it with this model: fanyx/Qwen3-Reranker-0.6B-Q8_0
With Modelfile:

FROM fanyx/Qwen3-Reranker-0.6B-Q8_0

TEMPLATE """[BOS]{{ .Query }}[EOS][SEP]{{ .Document }}[EOS]"""

And environment variable OLLAMA_NEW_ENGINE=1

However, it did not work with dengcao/Qwen3-Reranker-0.6B:Q8_0 (I got all zero output logits), maybe there are differences between the models that I'm not aware of, as mentioned by @halfcrazy..

I also did not find any other reranking models supported by the new engine (most seem based on bert which is not yet supported)

Looking forward to receive feedback.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/11328 **Author:** [@404-9e1-520-e6dbd00d7](https://github.com/404-9e1-520-e6dbd00d7) **Created:** 7/8/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `reranking-new-engine` --- ### 📝 Commits (10+) - [`6227d3f`](https://github.com/ollama/ollama/commit/6227d3f1a702ea43a121dddce80c0e90acc83b4f) ollamarunner: add reranking support - [`23d913f`](https://github.com/ollama/ollama/commit/23d913f26c407d154557f03e9402224306b381d3) template: add reranking support - [`8620567`](https://github.com/ollama/ollama/commit/862056767727f4fd43e7d80dcbbc414d2e48480c) server: add reranking support - [`d5a741b`](https://github.com/ollama/ollama/commit/d5a741bfe4451f37b9713495f9615fcc88b78472) llm: add reranking support - [`41adece`](https://github.com/ollama/ollama/commit/41adece1a3aa3db4a7205e9a3de309ff6549187b) api: add reranking support - [`c15baf0`](https://github.com/ollama/ollama/commit/c15baf08be8d287d177349fc0229b587cc434bda) docs: add reranking support - [`1ba4734`](https://github.com/ollama/ollama/commit/1ba47346704a3c288b5b1bb292c81174fc5ce093) ollamarunner: remove unnecessary tag replacement. - [`dd0461a`](https://github.com/ollama/ollama/commit/dd0461a23515bd7cf676b71d1631f8a975c19493) docs: change example reranking template - [`193990b`](https://github.com/ollama/ollama/commit/193990bc59a435e8de53844f33a21e7e63c512ea) ollamarunner: defer batch signal until full - [`809e413`](https://github.com/ollama/ollama/commit/809e4137c34590f3fec975ee851bd655cb3885fb) docs: change reranking template example (qwen) ### 📊 Changes **9 files changed** (+494 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+27 -0) 📝 `docs/api.md` (+107 -0) 📝 `docs/modelfile.md` (+6 -0) 📝 `docs/template.md` (+4 -0) 📝 `llm/server.go` (+68 -0) 📝 `runner/ollamarunner/runner.go` (+159 -5) 📝 `server/routes.go` (+109 -0) 📝 `server/sched_test.go` (+5 -0) 📝 `template/template.go` (+9 -4) </details> ### 📄 Description Implements reranking: https://github.com/ollama/ollama/issues/3368 Implemented reranking in the new engine (ollamarunner), based on https://github.com/ollama/ollama/pull/11156 I tested it with this model: `fanyx/Qwen3-Reranker-0.6B-Q8_0` With Modelfile: ``` FROM fanyx/Qwen3-Reranker-0.6B-Q8_0 TEMPLATE """[BOS]{{ .Query }}[EOS][SEP]{{ .Document }}[EOS]""" ``` And environment variable `OLLAMA_NEW_ENGINE=1` However, it did not work with `dengcao/Qwen3-Reranker-0.6B:Q8_0 ` (I got all zero output logits), maybe there are differences between the models that I'm not aware of, as mentioned by [@halfcrazy.](https://github.com/ollama/ollama/pull/11156#issuecomment-3018589644). I also did not find any other reranking models supported by the new engine (most seem based on bert which is not yet supported) Looking forward to receive feedback. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 08:13:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#75802