-
Notifications
You must be signed in to change notification settings - Fork 661
[Feature] support reward model #5301
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
Changes from 27 commits
16b9399
d8a0f52
1c2a228
63df44b
7cca89f
a0c81e3
af3b93b
fa45a91
766e58b
8868d8e
3a289c9
921e04d
0a07749
dd6cb23
3df2899
8023a66
d0c4151
a775f9a
ab0b6aa
b777746
c83a9e0
0751d21
0b692d0
6f1b431
4d7f4fb
817ede4
6f59f5b
243e6c1
87d4d45
4a8bf03
778feca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,175 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [简体中文](../zh/features//pooling_models.md) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Pooling Models | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FastDeploy also supports pooling models, such as embedding models. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| In FastDeploy, pooling models implement the `FdModelForPooling` interface. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| These models use a `Pooler` to extract the final hidden states of the input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| before returning them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Model Runner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Run a model in pooling mode via the option `--runner pooling`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !!! tip<br> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| There is no need to set this option in the vast majority of cases as Fastdeploy can automatically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| detect the appropriate model runner via `--runner auto`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ### Model Conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FastDeploy can adapt models for various pooling tasks via the option `--convert <type>`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| If `--runner pooling` has been set (manually or automatically) but the model does not implement the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `FdModelForPooling` interface, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| vLLM will attempt to automatically convert the model according to the architecture names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| shown in the table below. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | Architecture | `--convert` | Supported pooling tasks | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |-------------------------------------------------|-------------|---------------------------------------| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | `*ForTextEncoding`, `*EmbeddingModel`, `*Model` `*ForProcessRewardModel` | `embed` | `embed` | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | `*ForTextEncoding`, `*EmbeddingModel`, `*Model` `*ForProcessRewardModel` | `embed` | `embed` | | |
| | `*ForTextEncoding`, `*EmbeddingModel`, `*Model`, `*ForProcessRewardModel` | `embed` | `embed` | |
Copilot
AI
Dec 1, 2025
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.
Inconsistent formatting: Items should have a space after the number and period (e.g., "1. " instead of "1.") for proper markdown rendering.
| 1.LastPool(PoolingType.LAST) | |
| Purpose:Extracts the hidden state of the last token in each sequence | |
| 2.AllPool(PoolingType.ALL) | |
| Purpose:Returns the hidden states of all tokens in each sequence | |
| 3.CLSPool(PoolingType.CLS) | |
| Purpose:Returns the hidden state of the first token in each sequence (CLS token) | |
| 4.MeanPool(PoolingType.MEAN) | |
| 1. LastPool(PoolingType.LAST) | |
| Purpose:Extracts the hidden state of the last token in each sequence | |
| 2. AllPool(PoolingType.ALL) | |
| Purpose:Returns the hidden states of all tokens in each sequence | |
| 3. CLSPool(PoolingType.CLS) | |
| Purpose:Returns the hidden state of the first token in each sequence (CLS token) | |
| 4. MeanPool(PoolingType.MEAN) |
Copilot
AI
Dec 1, 2025
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.
Inconsistent formatting: The list items are shown in square brackets [Embeddings API] and [Reward API] when they should be bullet points or properly formatted as a list. Also, the descriptions should maintain parallel structure.
| [Embeddings API], supports text and multi-modal inputs | |
| [Reward API], scores specific content | |
| - Embeddings API: Supports text and multi-modal inputs | |
| - Reward API: Scores specific content |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,168 @@ | ||||||||||||||||||||||
| [English](../../features/pooling_models.md) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Pooling Models | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| FastDeploy也支持pooling模型,例如嵌入(embedding)模型。 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 在FastDeploy中,池化模型通过`FdModelForPooling`接口。这些模型使用一个`Pooler`来提取输入的最终隐藏状态并返回。 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Configuration | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Model Runner | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 通过`--runner pooling`选项以池化模型运行模型。 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| !!! 提示<br> | ||||||||||||||||||||||
| 在绝大多数情况下无需手动设置该选项,因此Fastdeploy可以通过--runner auto(默认值)自动检测合适的runner。 | ||||||||||||||||||||||
|
Comment on lines
+15
to
+16
|
||||||||||||||||||||||
| !!! 提示<br> | |
| 在绝大多数情况下无需手动设置该选项,因此Fastdeploy可以通过--runner auto(默认值)自动检测合适的runner。 | |
| !!! 提示 | |
| 在绝大多数情况下无需手动设置该选项,因此FastDeploy可以通过--runner auto(默认值)自动检测合适的runner。 |
Copilot
AI
Dec 1, 2025
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.
Missing comma between *Model and **ForProcessRewardModel. It should be a comma-separated list. Also, **ForProcessRewardModel should be *ForProcessRewardModel (single asterisk for consistency).
| | `*ForTextEncoding`, `*EmbeddingModel`, `*Model` `**ForProcessRewardModel` | `embed` | `embed` | | |
| | `*ForTextEncoding`, `*EmbeddingModel`, `*Model`, `*ForProcessRewardModel` | `embed` | `embed` | |
Copilot
AI
Dec 1, 2025
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.
Typo: "显示" should be "显式" (explicitly), and "制定" should be "指定" (specify).
| 你可以显示设置`--convert <type>`来制定模型转换方式。 | |
| 你可以显式设置`--convert <type>`来指定模型转换方式。 |
Copilot
AI
Dec 1, 2025
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.
The admonition syntax is incorrect. The exclamation marks should not have a space between them and "提示". It should be !!! 提示 without a trailing <br> tag.
Copilot
AI
Dec 1, 2025
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.
Typo: "优于" should be "优先于" (takes priority over). The current text says "superior to" but should say "takes priority over".
| 加载[Sentence Transformers](https://huggingface.co/sentence-transformers)模型时,其`modules.json`配置优于默认值,也可以通过@default_pooling_type("LAST")在模型组网时指定。 | |
| 加载[Sentence Transformers](https://huggingface.co/sentence-transformers)模型时,其`modules.json`配置优先于默认值,也可以通过@default_pooling_type("LAST")在模型组网时指定。 |
Copilot
AI
Dec 1, 2025
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.
Inconsistent formatting: Items 1 and 2 use "1." and "2." numbering, while the pattern should continue with "3." and "4." for consistency. The formatting shows "3.CLSPool" and "4.MeanPool" without proper spacing.
| 3.CLSPool(PoolingType.CLS) | |
| 作用:返回每个序列的第一个token(CLS token)的隐藏状态 | |
| 4.MeanPool(PoolingType.MEAN) | |
| 3. CLSPool(PoolingType.CLS) | |
| 作用:返回每个序列的第一个token(CLS token)的隐藏状态 | |
| 4. MeanPool(PoolingType.MEAN) |
Copilot
AI
Dec 1, 2025
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.
Grammar and formatting issue: "API的端点" should be "API端点" (redundant 的). Also, the list should use proper bullet points format with dashes, and there should be proper spacing after colons in Chinese text.
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.
Typo: "vLLM" should be "FastDeploy" - this appears to be copy-paste error from another codebase.