Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support custom system message template #2069

Closed
wants to merge 8 commits into from
Closed

Conversation

zeyugao
Copy link
Contributor

@zeyugao zeyugao commented Jul 25, 2023

Why are these changes needed?

It makes the conversation class more adaptable, allowing for further customization of the chat.

conv = get_conv_template("llama-2")
conv.set_system_msg("You are a helpful, respectful and honest assistant.")
conv.append_message(conv.roles[0], "Hello!")
conv.append_message(conv.roles[1], "Hi!")
conv.append_message(conv.roles[0], "How are you?")
conv.append_message(conv.roles[1], None)
print(conv.get_prompt())

Results in

<s>[INST] <<SYS>>
You are a helpful, respectful and honest assistant.
<</SYS>>

Hello![/INST] Hi! </s><s>[INST] How are you? [/INST]

Related issue number (if applicable)

Checks

  • I've run format.sh to lint the changes in this PR.
  • I've included any doc changes needed.
  • I've made sure the relevant tests are passing (if applicable).

@sarathkondeti
Copy link

conv.system is overwritten when inferencing from other modules/files.

For example in openai_api_server : https://github.com/lm-sys/FastChat/blob/4e2c942b8d785eb5e2aef1d0df2150e756f381ab/fastchat/serve/openai_api_server.py#L252C18-L252C18

Now, they need to use conv.system --> conv.system_msg.

@zeyugao zeyugao changed the title Support custom system message Support custom system message template Jul 26, 2023
@zeyugao
Copy link
Contributor Author

zeyugao commented Jul 26, 2023

@sarathkondeti That's true. I would try to fix it.

However, it appears there's an issue with the templates. I am unfamiliar with how each model is aligned with SFT. Hence, I'm uncertain whether the system prompt is fully predetermined, as with Stanford Alpaca, partially fixed, like Llama 2, or can be arbitrarily set, akin to one_shot and zero_shot during the fine-tuning process. This necessitates further investigation.

Replace all `.system =` with `.set_system_msg`
@laidybug
Copy link
Contributor

@sarathkondeti That's true. I would try to fix it.

However, it appears there's an issue with the templates. I am unfamiliar with how each model is aligned with SFT. Hence, I'm uncertain whether the system prompt is fully predetermined, as with Stanford Alpaca, partially fixed, like Llama 2, or can be arbitrarily set, akin to one_shot and zero_shot during the fine-tuning process. This necessitates further investigation.

In my testing I've been able to arbitrarily change the system message and get useful results that are obviously influenced by it.

@zeyugao
Copy link
Contributor Author

zeyugao commented Aug 2, 2023

@merrymercy Sorry for that, it seems that I cannot allow the editing by maintainers due to the limitation from GitHub (https://github.com/orgs/community/discussions/5634) cause this pr is from a organisation instead of individual account. I didn't expect this problem.

It seems that you have created a new PR for that, so it is just fine to close this one for further modification.

@zeyugao zeyugao closed this Aug 2, 2023
@merrymercy
Copy link
Member

@zeyugao Hi, thanks for the contributions!
It has been merged by #2135. You are added as a co-author.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants