Enhance OpenAI Compatible Provider Support Rerank #6167

Closed
opened 2026-02-21 18:14:21 -05:00 by yindo · 2 comments
Owner

Originally created by @ziyu4huang on GitHub (Oct 20, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Although OpenAI doesn't currently have a standard rerank implementation, llama.cpp already supports reranking, primarily through the Jina API. I believe we could first make the OpenAI provider compatible with it. Previously, I did something similar in LocalAI (see #9159 for reference).

However, I noticed there are still issues with score normalization.

I plan to experiment by adding rerank functionality within the OpenAI provider and testing different approaches to score normalization.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @ziyu4huang on GitHub (Oct 20, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Although OpenAI doesn't currently have a standard rerank implementation, llama.cpp already supports reranking, primarily through the Jina API. I believe we could first make the OpenAI provider compatible with it. Previously, I did something similar in LocalAI (see #9159 for reference). However, I noticed there are still issues with score normalization. I plan to experiment by adding rerank functionality within the OpenAI provider and testing different approaches to score normalization. ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [X] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 18:14:21 -05:00
yindo closed this issue 2026-02-21 18:14:21 -05:00
Author
Owner

@ziyu4huang commented on GitHub (Oct 20, 2024):

I have test use llama.cpp bge-m3

run script

ziyu4huang@ziyu4huang-X570-AORUS-ELITE:~/proj/wolfox$ cat  run_llama_cpp_rerank_m3.sh
gguf_file=/mnt/data/proj/gguf/bge-reranker-v2-m3-Q4_K_M.gguf
llama_path=$(realpath ../llama.cpp/build_hip)
#${llama_path}/bin/llama-server --host 0.0.0.0 --port 9901 -c 9128 -ub 2048 -ub 2048 -ngl 99 -m $gguf_file --reranking "$@"
${llama_path}/bin/llama-server --host 0.0.0.0 --port 9901 -ub 1024 -ngl 99 -m $gguf_file --reranking "$@"


llama output

slot update_slots: id  0 | task 69 | tokenizing prompt, len = 2
slot update_slots: id  0 | task 69 | prompt tokenized, n_ctx_slot = 8192, n_keep = 0, n_prompt_tokens = 484
slot update_slots: id  0 | task 69 | kv cache rm [0, end)
slot update_slots: id  0 | task 69 | prompt processing progress, n_past = 484, n_tokens = 484, progress = 1.000000
slot update_slots: id  0 | task 69 | prompt done, n_past = 484, n_tokens = 484
slot      release: id  0 | task 69 | stop processing: n_past = 484, truncated = 0
srv  update_slots: all slots are idle
request: POST /rerank 172.21.0.7 200


@ziyu4huang commented on GitHub (Oct 20, 2024): I have test use llama.cpp bge-m3 run script ``` ziyu4huang@ziyu4huang-X570-AORUS-ELITE:~/proj/wolfox$ cat run_llama_cpp_rerank_m3.sh gguf_file=/mnt/data/proj/gguf/bge-reranker-v2-m3-Q4_K_M.gguf llama_path=$(realpath ../llama.cpp/build_hip) #${llama_path}/bin/llama-server --host 0.0.0.0 --port 9901 -c 9128 -ub 2048 -ub 2048 -ngl 99 -m $gguf_file --reranking "$@" ${llama_path}/bin/llama-server --host 0.0.0.0 --port 9901 -ub 1024 -ngl 99 -m $gguf_file --reranking "$@" ``` llama output ``` slot update_slots: id 0 | task 69 | tokenizing prompt, len = 2 slot update_slots: id 0 | task 69 | prompt tokenized, n_ctx_slot = 8192, n_keep = 0, n_prompt_tokens = 484 slot update_slots: id 0 | task 69 | kv cache rm [0, end) slot update_slots: id 0 | task 69 | prompt processing progress, n_past = 484, n_tokens = 484, progress = 1.000000 slot update_slots: id 0 | task 69 | prompt done, n_past = 484, n_tokens = 484 slot release: id 0 | task 69 | stop processing: n_past = 484, truncated = 0 srv update_slots: all slots are idle request: POST /rerank 172.21.0.7 200 ```
Author
Owner

@ziyu4huang commented on GitHub (Oct 20, 2024):

Screenshot from 2024-10-20 13-19-18

It works on HitTest

@ziyu4huang commented on GitHub (Oct 20, 2024): ![Screenshot from 2024-10-20 13-19-18](https://github.com/user-attachments/assets/ffd66274-89ef-4672-aa34-2e24f0d297aa) It works on HitTest
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6167