Skip to content

[Feature] support reward api - #4518

Merged
Jiang-Jia-Jun merged 2 commits into
PaddlePaddle:developfrom
xiaolei373:support_reward
Oct 28, 2025
Merged

Jiang-Jia-Jun merged 2 commits into
PaddlePaddle:developfrom
xiaolei373:support_reward

Conversation

@xiaolei373

@xiaolei373 xiaolei373 commented Oct 21, 2025

Copy link
Copy Markdown
Collaborator

Motivation

支持reward接口,给指定的内容打分

Modifications

Usage or Command

本 PR 增加了一个多模态 chat/reward 接口请求示例。

示例请求如下:

curl --location 'http://xxxx/v1/chat/reward' \
--header 'Content-Type: application/json' \
--data '{
  "model": "",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "https://xxx/a.png"
          }
        }
      ]
    },
    {
      "role": "assistant",
      "content": [
        {
          "type": "text",
          "text": "图里有几个人"
        }
      ]
    }
  ],
  "user": "user-123",
  "chat_template": null,
  "chat_template_kwargs": {
    "custom_var": "value"
  },
  "mm_processor_kwargs": {
    "image_size": 224
  }
}'

Accuracy Tests

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@paddle-bot

paddle-bot Bot commented Oct 21, 2025

Copy link
Copy Markdown

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label Oct 21, 2025
@xiaolei373
xiaolei373 requested a review from sunlei1024 October 21, 2025 09:06
@xiaolei373 xiaolei373 changed the title [feature] support reward api [Feature] support reward api Oct 21, 2025
@Jiang-Jia-Jun
Jiang-Jia-Jun merged commit 14e7d88 into PaddlePaddle:develop Oct 28, 2025
23 of 27 checks passed
@staticmethod
def from_base(pooling_output: PoolingOutput):
pooled_data = pooling_output.data
# if pooled_data.ndim != 1:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

GENERATION_TASKS = get_args(GenerationTask)

PoolingTask = Literal["encode", "embed"]
PoolingTask = Literal["encode", "embed", "reward"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里reward哪里用到了吗?



class ChatRewardRequest(BaseModel):
model: Optional[str] = None # 指定模型,例如 "default" 或支持 embedding 的 chat 模型

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成英文注释



class ChatRewardData(BaseModel):
index: Optional[int] = None # 数据索引(可选)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
Co-authored-by: SunLei <sunlei5788@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants