LocalAI
LocalAI copied to clipboard
fix(reranker): llama-cpp sort score desc, crop top_n
Description
This PR fixes #7189
Notes for Reviewers
After applying the fix I see the right reranker output:
curl -X POST http://localhost:8080/v1/rerank \
-H "Content-Type: application/json" \
-d '{
"query": "What are the benefits of exercise?",
"documents": [
"Regular exercise can improve cardiovascular health.",
"Eating a balanced diet is important for overall well-being.",
"Exercise helps in weight management and builds muscle strength.",
"Reading books can expand your knowledge and vocabulary."
],
"model": "jina-reranker-v1-tiny-en",
"top_n": 2
}'
{
"model": "jina-reranker-v1-tiny-en",
"usage": {
"total_tokens": 41,
"prompt_tokens": 41
},
"results": [
{
"index": 2,
"document": {
"text": "Exercise helps in weight management and builds muscle strength."
},
"relevance_score": 0.07032939791679382
},
{
"index": 0,
"document": {
"text": "Regular exercise can improve cardiovascular health."
},
"relevance_score": 0.059670690447092056
}
]
}
is there are tests, which I can assert behavior for this backend?
Signed commits
- [v] Yes, I signed my commits.
Deploy Preview for localai ready!
| Name | Link |
|---|---|
| Latest commit | 7d199e7f3bf6152b213bc89d5c29939ef26fa76e |
| Latest deploy log | https://app.netlify.com/projects/localai/deploys/691175fd7fcc920008755536 |
| Deploy Preview | https://deploy-preview-7211--localai.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
Description
This PR fixes #7189
Notes for Reviewers
After applying the fix I see the right reranker output:
curl -X POST http://localhost:8080/v1/rerank \ -H "Content-Type: application/json" \ -d '{ "query": "What are the benefits of exercise?", "documents": [ "Regular exercise can improve cardiovascular health.", "Eating a balanced diet is important for overall well-being.", "Exercise helps in weight management and builds muscle strength.", "Reading books can expand your knowledge and vocabulary." ], "model": "jina-reranker-v1-tiny-en", "top_n": 2 }' { "model": "jina-reranker-v1-tiny-en", "usage": { "total_tokens": 41, "prompt_tokens": 41 }, "results": [ { "index": 2, "document": { "text": "Exercise helps in weight management and builds muscle strength." }, "relevance_score": 0.07032939791679382 }, { "index": 0, "document": { "text": "Regular exercise can improve cardiovascular health." }, "relevance_score": 0.059670690447092056 } ] }
This is great, thanks for opening up a PR!
is there are tests, which I can assert behavior for this backend?
we have tests here that could be likely extended: https://github.com/mudler/LocalAI/blob/bf77c11b6591731c68d6142a68f5eada7c4c5c2d/tests/e2e-aio/e2e_test.go#L286