-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Chat method for offline llm #5049
Chat method for offline llm #5049
Conversation
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.
Great first step
- Let's call it just
chat
because generate_chat has duplicated meaning. Chat method is generating. - Let's also support just a string or list of string for simplicity. We will apply it as a single turn conversation in this case. We should also take a parameter specifying the global system prompt. This is done for usability and it's simple to adopt the chat method.
- Let's add support for specifying custom chat template via a string. This is supported in online api server.
- Please add a good example script in the examples directory showcase the many different ways the chat method can be used with string comments.
This should also fix #1582. I have edited the OP accordingly. |
Let's leave out Also, I would rename |
vllm/entrypoints/llm.py
Outdated
messages = [{ | ||
'role': | ||
'system', | ||
'content': | ||
global_system_prompt or default_system_prompt | ||
}, { |
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.
some model (like Mixtral) doesn't support system prompt
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.
Should I remove the default_system_prompt, and only include a system prompt when it is explicitly passed in?
Or Is there a method or property I can check to see if a model supports system prompts? Thank you for your guidance!
hi @nunjunj kindly want to check if you may want to continue on this PR? Thanks |
Yes, I am working on some merge conflicts and it should be done in a couple
of days.
…On Tue, Jul 9, 2024 at 2:56 AM ning.zhang ***@***.***> wrote:
hi @nunjunj <https://github.com/nunjunj> kindly want to check if you may
want to continue on this PR? Thanks
—
Reply to this email directly, view it on GitHub
<#5049 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZLBZ7VMFFVUCPMM6WR3T2DZLLVG3AVCNFSM6AAAAABIIWS5SCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJVGA4DKOBWHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
examples/offline_inference_chat.py
Outdated
# str and list[str] inputs are treated as text completions, similar to LLM.generate(), | ||
message = "Entropy is" | ||
outputs = llm.chat( | ||
message, | ||
sampling_params=sampling_params, | ||
use_tqdm=False, | ||
) | ||
print_outputs(outputs) | ||
|
||
messages = [ | ||
"Relativity is a theory about", "Bangkok is a city in", | ||
"One of the best programming languages is" | ||
] | ||
outputs = llm.chat( | ||
messages, | ||
sampling_params=sampling_params, | ||
use_tqdm=False, | ||
) | ||
print_outputs(outputs) |
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.
I'm unsure if llm.chat
should accept unformatted text completions. It is possible users will use this and be unaware that no chat templating is happening even though they are using the chat
interface. I believe HF's apply_chat_template fails if a non-dictionary is passed in, so we may want to follow that lead.
Hello @nunjunj just want to kindly ping and circle back to see if there may be any update on this feature. Thanks |
e26dc5d
to
c49532c
Compare
7fcc1bf
to
7530495
Compare
You may consider using the utilities in |
7530495
to
7fcc1bf
Compare
Also, please avoid unnecessarily editing whitespace. |
a8f42d2
to
c4ca2f3
Compare
7b7b481
to
f54c406
Compare
f54c406
to
c64cc8c
Compare
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.
LGTM now, thanks for implementing this! We can address multi-modal support in a future PR.
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.
LGTM as well!
Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: Cyrus Leung <[email protected]> Co-authored-by: DarkLight1337 <[email protected]>
Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: Cyrus Leung <[email protected]> Co-authored-by: DarkLight1337 <[email protected]>
Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: Cyrus Leung <[email protected]> Co-authored-by: DarkLight1337 <[email protected]>
Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: Cyrus Leung <[email protected]> Co-authored-by: DarkLight1337 <[email protected]>
Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: Cyrus Leung <[email protected]> Co-authored-by: DarkLight1337 <[email protected]> Signed-off-by: Alvant <[email protected]>
Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: nunjunj <[email protected]> Co-authored-by: Cyrus Leung <[email protected]> Co-authored-by: DarkLight1337 <[email protected]>
Apply chat template for the offline LLM class. Adding new method generate_chat(), which generates chat responses for the input messages.
FIX #1582
FIX #3718
FIX #6191
FIX #6416
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!