Skip to content

Conversation

@xiaolei373
Copy link
Collaborator

@xiaolei373 xiaolei373 commented Oct 21, 2025

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
Copy link

paddle-bot bot commented Oct 21, 2025

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
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
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
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
Collaborator

Choose a reason for hiding this comment

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

同上

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