-
Notifications
You must be signed in to change notification settings - Fork 13.3k
server / ranking : add sorting and management of top_n #16403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I don't think the change is backwards compatible - would it work if the request does not include |
no it won't work if no top_n, I can change it to make it back compatible |
Yes, it should remain backward compatible. |
adding a test case is also required for this type of change |
What king of test case? one bash script in comment to test many cases ? |
all results here is a script to make some test ```script URL=${1:-http://127.0.0.1:8181} curl "$URL/v1/rerank" -H "Content-Type: application/json" \ -d '{ "model": "M", "query": "What is the recipe to make bread ?", "return_text" : true, "texts" : true, "top_n": 6, "documents": [ "voici la recette pour faire du pain, il faut de la farine de l eau et du levain et du sel", "it is a bear", "bread recipe : floor, water, yest, salt", "The giant panda (Ailuropoda melanoleuca), sometimes called a panda bear or simply panda, is a bear species endemic to China.", "here is the ingedients to bake bread : 500g floor, 350g water, 120g fresh refresh yest, 15g salt", "recipe to make cookies : floor, eggs, water, chocolat", "here is the recipe to make bread : 500g floor, 350g water, 120g fresh refresh yest, 15g salt", "il fait tres beau aujourd hui", "je n ai pas faim, je ne veux pas manger", "je suis a paris" ] }' | jq ```
here is one script to test the reranking
|
You should add a server test: https://github.com/ggml-org/llama.cpp/tree/master/tools/server/tests |
you need this ?
|
return; | ||
} | ||
|
||
int top_n = documents.size(); // no top_n will return all the documents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work?
int top_n = documents.size(); // no top_n will return all the documents | |
int top_n = json_value(body, "top_n", (int)documents.size()); |
results = json::array(); | ||
int count = 0; | ||
for (const auto & elem : elements) { | ||
if (++count > top_n) break; | ||
results.push_back(elem); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is probably redundant, as you can simply resize()
the elements
vector
server / ranking : add sorting and management of top_n
exemple output for
top_n = 4
:or