Add compatibility w/ JinaAI Reranker API and Cohere Rerank API#797
Add compatibility w/ JinaAI Reranker API and Cohere Rerank API#797alvarobartt wants to merge 13 commits intomainfrom
Conversation
|
Hey guys @vrdn-23, @rowan-fan, as you were both interested in the "OpenAI" compatible routes for text ranking models, namely JinaAI Reranker API and Cohere Rerank API, I invite you both to review + test this PR to see if the current fits your needs 🤗 The PR implements both routes under For an easier review please check https://github.com/huggingface/text-embeddings-inference/pull/797/files/d25c565d502720eb95767883cb9ee56743ecab57..1190ce2e3d6808110d55f49087cd4ad028b8748b which only contains the changes related to the implementation of both routes, without the formatting fixes applied by the |
|
Awesome! Thanks a lot @alvarobartt . I'll be sure to take a look at this early next week! <3 |
| pub(crate) struct RerankResponse(pub Vec<Rank>); | ||
|
|
||
| #[derive(Deserialize, ToSchema)] | ||
| pub(crate) struct JinaAIRerankRequest { |
There was a problem hiding this comment.
it would be great if users, could add their prompt_template etc to the query, do you think we could fit it into one of these templates?
Option: String<{query}{document}> that can be formatted with stringfmt crate. What do you think?
What does this PR do?
This PR adds the routes for re-ranking for JinaAI Reranker API (v1) @
/v1/rerankand Cohere Rerank API (v2) @/v2/rerank.Also this PR includes
uuidwith--features v4as a dependency, required to generate the IDs that one can encounter when using either JinaAI Reranker API (included in the error messages) or Cohere Rerank API (included in both the response and the errors).Warning
The implementations are aligned with their counterparts on both JinaAI and Cohere, but there's some considerations:
JinaAI Reranker API
Run any
text-rankingmodel from https://huggingface.co/models?pipeline_tag=text-ranking&sort=trending as:Then run the inference via
requestsin Python (or your preferred alternative):The Python snippet above has been copied from https://jina.ai/reranker/.
Cohere Rerank API
Run any
text-rankingmodel from https://huggingface.co/models?pipeline_tag=text-ranking&sort=trending as:Then run the inference via Python with Cohere Python SDK as:
The Python snippet above has been copied from https://docs.cohere.com/reference/rerank.
Before submitting
instasnapshots?Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.