-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[OAI refactor] Add rerank and score serving #7399
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
[OAI refactor] Add rerank and score serving #7399
Conversation
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.
Summary of Changes
Hello @woodx9, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces dedicated serving capabilities for "rerank" and "score" functionalities, integrating them into the existing OpenAI-like serving framework. It defines the necessary request and response protocols for reranking and establishes new service handlers to manage the lifecycle of these requests, from validation and internal conversion to processing and response formatting. This work refactors and expands the serving infrastructure to support these new types of requests, building upon a recent serving_base
update.
Highlights
- New Rerank and Score Serving: Introduces new, dedicated serving handlers (
OpenAIServingRerank
andOpenAIServingScore
) to manage reranking and scoring requests, respectively, integrating them into the existing OpenAI-like serving framework. - Rerank Protocol Definition: Defines new protocol models (
V1RerankReqInput
andRerankResponse
) inprotocol.py
for handling rerank requests and their corresponding responses, including query, documents, scores, and metadata. - Internal Request Conversion Logic: Implements specific
_convert_to_internal_request
logic for both rerank (adapting toEmbeddingReqInput
for cross-encoder processing) and score (passing requests directly to a specialized scoring method). - Request Validation and Response Formatting: Each new serving handler includes logic for validating incoming requests and formatting the processed results into the appropriate OpenAI-like response structure, including sorting rerank results by score.
- Alignment with Serving Base: The changes align the rerank and score serving implementations with a common
serving_base
pattern, as indicated by the PR's motivation to update serving due toserving_base
changes.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This PR refactors the serving layer to add support for rerank and score endpoints. The changes introduce new serving handlers and update the protocol definitions. The method signatures and return types of the new handlers do not match the OpenAIServingBase
abstract class, which will lead to runtime errors. A new request protocol model should inherit from Pydantic's BaseModel
for consistency and to leverage FastAPI's features.
…nvert internal request
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
- We should only capture ValueError from tokenizer_manager and wrap it as a 400. - Get model from request to build ScoringResponse
ac3774e
to
6b76595
Compare
Co-authored-by: Chang Su <[email protected]>
Co-authored-by: Chang Su <[email protected]>
Motivation
update score and rerank serving due to serving_base update
base on #7351
Modifications
Checklist