Skip to content

[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

Merged
merged 4 commits into from
Jun 20, 2025

Conversation

woodx9
Copy link
Contributor

@woodx9 woodx9 commented Jun 20, 2025

Motivation

update score and rerank serving due to serving_base update
base on #7351

Modifications

Checklist

@woodx9 woodx9 requested a review from zhaochenyang20 as a code owner June 20, 2025 18:18
Copy link

@gemini-code-assist gemini-code-assist bot left a 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 and OpenAIServingScore) to manage reranking and scoring requests, respectively, integrating them into the existing OpenAI-like serving framework.
  • Rerank Protocol Definition: Defines new protocol models (V1RerankReqInput and RerankResponse) in protocol.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 to EmbeddingReqInput 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 to serving_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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@CatherineSue CatherineSue changed the title refactor rerank and score serving base on #7351: update convert inter… [OAI refactor] Add rerank and score serving Jun 20, 2025
woodx9 and others added 4 commits June 20, 2025 21:40
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
@CatherineSue CatherineSue force-pushed the feat/refactor_rerank_score_serving branch from ac3774e to 6b76595 Compare June 20, 2025 21:40
@zhyncs zhyncs merged commit cfb2fb5 into sgl-project:main Jun 20, 2025
4 of 48 checks passed
whybeyoung pushed a commit to whybeyoung/sglang that referenced this pull request Jun 24, 2025
yilian49 pushed a commit to yilian49/sglang that referenced this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants