|
@@ -16,22 +16,11 @@ Dialog = List[Message]
|
|
|
|
|
|
B_INST, E_INST = "[INST]", "[/INST]"
|
|
|
B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
|
|
|
-DEFAULT_SYSTEM_PROMPT = """\
|
|
|
-You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|
|
|
-
|
|
|
-If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information."""
|
|
|
-
|
|
|
def format_tokens(dialogs, tokenizer):
|
|
|
prompt_tokens = []
|
|
|
for dialog in dialogs:
|
|
|
- if dialog[0]["role"] != "system":
|
|
|
- dialog = [
|
|
|
- {
|
|
|
- "role": "system",
|
|
|
- "content": DEFAULT_SYSTEM_PROMPT,
|
|
|
- }
|
|
|
- ] + dialog
|
|
|
- dialog = [
|
|
|
+ if dialog[0]["role"] == "system":
|
|
|
+ dialog = [
|
|
|
{
|
|
|
"role": dialog[1]["role"],
|
|
|
"content": B_SYS
|
|
@@ -47,7 +36,7 @@ def format_tokens(dialogs, tokenizer):
|
|
|
"starting with user and alternating (u/a/u/a/u...)"
|
|
|
)
|
|
|
"""
|
|
|
- Please verify that yout tokenizer support adding "[INST]", "[/INST]" to your inputs.
|
|
|
+ Please verify that your tokenizer support adding "[INST]", "[/INST]" to your inputs.
|
|
|
Here, we are adding it manually.
|
|
|
"""
|
|
|
dialog_tokens: List[int] = sum(
|