-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
[Frontend] Add LLM.reward specific to reward models #21720
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
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
be054e2
+ reward
noooop f33d084
+ fix
noooop 5025a2f
+ warning
noooop 3bf071e
+ reward
noooop 332ffea
fix
noooop 6dc06a0
fix
noooop 8ed7dc9
fix
noooop 26d6f8c
+ encoder_config check
noooop 6e69ae8
fix
noooop 900ffcc
+ check if "embed" in self.supported_tasks
noooop 5bbaa22
fix
noooop 4faeee5
fix
noooop 731cb1b
fix
noooop 8d10bd1
fix
noooop 1a95259
fix
noooop 9c51ced
fix
noooop e31e002
fix
noooop 2991926
fix
noooop 9619439
fix
noooop 3cc8f80
fix
noooop a056ad8
fix
noooop cc82767
fix
noooop d9732d3
fix
noooop f9a7e35
Merge branch 'vllm-project:main' into llm_reward
noooop 5a5907b
Merge branch 'vllm-project:main' into llm_reward
noooop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
|
|
||
| from argparse import Namespace | ||
|
|
||
| from vllm import LLM, EngineArgs | ||
| from vllm.utils import FlexibleArgumentParser | ||
|
|
||
|
|
||
| def parse_args(): | ||
| parser = FlexibleArgumentParser() | ||
| parser = EngineArgs.add_cli_args(parser) | ||
| # Set example specific arguments | ||
| parser.set_defaults( | ||
| model="internlm/internlm2-1_8b-reward", | ||
| runner="pooling", | ||
| enforce_eager=True, | ||
| max_model_len=1024, | ||
| trust_remote_code=True, | ||
| ) | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| def main(args: Namespace): | ||
| # Sample prompts. | ||
| prompts = [ | ||
| "Hello, my name is", | ||
| "The president of the United States is", | ||
| "The capital of France is", | ||
| "The future of AI is", | ||
| ] | ||
|
|
||
| # Create an LLM. | ||
| # You should pass runner="pooling" for reward models | ||
| llm = LLM(**vars(args)) | ||
|
|
||
| # Generate rewards. The output is a list of PoolingRequestOutput. | ||
| outputs = llm.reward(prompts) | ||
|
|
||
| # Print the outputs. | ||
| print("\nGenerated Outputs:\n" + "-" * 60) | ||
| for prompt, output in zip(prompts, outputs): | ||
| rewards = output.outputs.data | ||
| rewards_trimmed = ( | ||
| (str(rewards[:16])[:-1] + ", ...]") if len(rewards) > 16 else rewards | ||
| ) | ||
| print(f"Prompt: {prompt!r} \nReward: {rewards_trimmed} (size={len(rewards)})") | ||
| print("-" * 60) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| args = parse_args() | ||
| main(args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.