Skip to content

Conversation

@adumrewal
Copy link
Contributor

Fix the sample code for on-going conversation with codellama instruct model. Line 260 should not have suffix append instruction instead it should be a simple value assignment.

Existing code:

system = "System prompt"
user_1 = "user_prompt_1"
answer_1 = "answer_1"
user_2 = "user_prompt_2"
answer_2 = "answer_2"
user_3 = "user_prompt_3"

prompt  = f"<<SYS>>\\n{system}\\n<</SYS>>\\n\\n{user_1}"
prompt += f"<s>[INST] {prompt.strip()} [/INST] {answer_1.strip()} </s>"
prompt += f"<s>[INST] {user_2.strip()} [/INST] {answer_2.strip()} </s>"
prompt += f"<s>[INST] {user_3.strip()} [/INST]"

inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")

Results in:

<<SYS>>
{system}
<</SYS>>

{user_1}<s>[INST] <<SYS>>
{system}
<</SYS>>

{user_1} [/INST] {answer_1.strip()} </s><s>[INST] {user_2.strip()} [/INST] {answer_2.strip()} </s><s>[INST] {user_3.strip()} [/INST]

Expected correct output:

<s>[INST] <<SYS>>
{system}
<</SYS>>

{user_1} [/INST] {answer_1.strip()} </s><s>[INST] {user_2.strip()} [/INST] {answer_2.strip()} </s><s>[INST] {user_3.strip()} [/INST]

Fix the sample code for on-going conversation with codellama instruct model. Line 260 should not have suffix append instruction instead it should be a simple value assignment.
Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! 🙌

While checking this I saw that the escaped newlines in the first prompt initialization are not required, would you agree?

Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix, thanks a lot!

@pcuenca pcuenca merged commit 6dcf174 into huggingface:main Feb 8, 2024
@adumrewal
Copy link
Contributor Author

Thank you @pcuenca for the additional comments and these amazing blog posts! 🔥

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