Skip to content
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

Use system message in chat instruct #4648

Merged
merged 1 commit into from
Nov 18, 2023

Conversation

jordanbtucker
Copy link
Contributor

Checklist:

This PR allows instruction templates to insert their system message into the context of the prompt in chat-instruct mode.

As an example, before this change, the constructed prompt with the Llama-v2 instruction template in chat-instruct mode would look like this:

[INST] <<SYS>>
<|system-message|>
<</SYS>>

Continue the chat dialogue below. Write a single reply for the character "AI".

The following is a conversation with an AI Large Language Model. The AI has been trained to answer questions, provide recommendations, and help with decision making. The AI follows user requests. The AI thinks outside the box.
AI: How can I help you today?
You: Write a hello world program in Python.
 [/INST] AI:

Note that verbatim string <|system-message|> is provided to the tokenizer instead of the system message itself.

With this change, the constructed prompt with Llama-v2 instruction template in chat-instruct mode looks like this:

[INST] <<SYS>>
Answer the questions.
<</SYS>>

Continue the chat dialogue below. Write a single reply for the character "AI".

The following is a conversation with an AI Large Language Model. The AI has been trained to answer questions, provide recommendations, and help with decision making. The AI follows user requests. The AI thinks outside the box.
AI: How can I help you today?
You: Write a hello world program in Python.
 [/INST] AI:

The system message in the Llama-v2 instruction template is "Answer the questions." and it is now correctly included in the prompt.

These examples use the Llama-v2 instruction template, but the changes apply to any instruction template that has the string <|system-message|> in its Context field. If the Custom system message field is not empty, its contents will be used instead of the System message field.

@oobabooga
Copy link
Owner

Thank you! I missed that completely.

@oobabooga oobabooga merged commit baab894 into oobabooga:dev Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants