-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
KevinMusgrave
committed
Jan 29, 2024
1 parent
72c7103
commit 207555c
Showing
3 changed files
with
40 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
CHAT_ML_TEMPLATE = """ | ||
{% for message in messages %} | ||
{% if message['role'] == 'user' %} | ||
{{'<|im_start|>user\n' + message['content'].strip() + '<|im_end|>' }} | ||
{% elif message['role'] == 'system' %} | ||
{{'<|im_start|>system\n' + message['content'].strip() + '<|im_end|>' }} | ||
{% elif message['role'] == 'assistant' %} | ||
{{'<|im_start|>assistant\n' + message['content'] + '<|im_end|>' }} | ||
{% endif %} | ||
{% endfor %} | ||
""" | ||
|
||
ASSISTANT_PROMPT = "<|im_start|>assistant" | ||
|
||
EOS_TOKEN = "<|im_end|>" | ||
|
||
|
||
def get_chat_format(element): | ||
system_prompt = ( | ||
"You are a helpful programmer assistant that excels at SQL. " | ||
"When prompted with a task and a definition of an SQL table, you " | ||
"respond with a SQL query to retrieve information from the table. " | ||
"Don't explain your reasoning, only provide the SQL query." | ||
) | ||
user_prompt = "Task: {instruction}\nSQL table: {input}\nSQL query: " | ||
|
||
return [ | ||
{"role": "system", "content": system_prompt}, | ||
{"role": "user", "content": user_prompt.format_map(element)}, | ||
{"role": "assistant", "content": element["response"]}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters