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

Question: Why are special tokens added to the prompt being sent to replicate? #124

Open
hershalb opened this issue Jun 14, 2024 · 0 comments

Comments

@hershalb
Copy link

hershalb commented Jun 14, 2024

In Replicate, the Llama-3-8b-instruct model takes in a "system_prompt" and "prompt_template" param. The replicate docs mentioned that system_prompt is prepended to the text being sent, and I'm assuming the prompt_template is also used to format the prompt data since there's a default value that includes the special tokens. Is there a reason this application is formatting the prompt to also use these special tokens? I guess I'm just a little confused how this is being handled by Replicate behind the scenes.

For example, for the message "Can you tell me about the story of David and Goliath" the front-end sends:

{
  system_prompt: "You are a helpful assistant.",
  prompt: "<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a helpful assistant.<|eot_id|>
<|start_header_id|>user<|end_header_id|>

Can you tell me about the story of David and Goliath<|eot_id|>"
}

The default "prompt_template" seems to be:

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

{system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|>

{prompt}<|eot_id|><|start_header_id|>assistant<|end_header_id|>

So, behind the scenes, it seems like what gets passed to the model becomes:

<|begin_of_text|><|start_header_id|>system<|end_header_id|>

You are a helpful assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>

<|begin_of_text|><|start_header_id|>system<|end_header_id|>
You are a helpful assistant.<|eot_id|>
<|start_header_id|>user<|end_header_id|>

Can you tell me about the story of David and Goliath<|eot_id|><|eot_id|><|start_header_id|>assistant<|end_header_id|>

since the prompt and system_prompt are possibly directly passed into the prompt template. Is this a correct understanding?

@hershalb hershalb changed the title Question: Why are the messages being pre-formatted before being sent to replicate? Question: Why are special tokens added to the prompt being sent to replicate? Jun 14, 2024
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

No branches or pull requests

1 participant