Skip to content

Commit

Permalink
fix basic prompts (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
sceuick authored Aug 21, 2024
1 parent 914dc62 commit a8c668f
Showing 1 changed file with 44 additions and 53 deletions.
97 changes: 44 additions & 53 deletions common/prompt-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,101 +33,92 @@ function getOrderHolder(format: string, holder: string) {

export const formatHolders: Record<string, Record<string, string>> = {
Alpaca: {
preamble: neat`Below is an instruction that describes a task. Write a response that appropriately completes the request.\n
Write {{char}}'s next reply in a fictional roleplay chat between {{char}} and {{user}}`,
history: neat`Then the roleplay chat between {{user}} and {{char}} begins.
system_prompt: `### System:\n{{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}}`,
history: neat`Then the roleplay chat between "{{user}}" and "{{char}}" begins.
{{#each msg}}{{#if .isbot}}### Response:\n{{.name}}: {{.msg}}{{/if}}{{#if .isuser}}### Instruction:\n{{.name}}: {{.msg}}{{/if}}
{{/each}}`,
post: `### Response:\n{{post}}`,
system_prompt: `{{#if system_prompt}}### Instruction:\n{{system_prompt}}{{/if}}`,
ujb: `{{#if ujb}}({{ujb}}){{/if}}`,
},
Vicuna: {
preamble: neat`Below is an instruction that describes a task. Write a response that appropriately completes the request.\n
Write {{char}}'s next reply in a fictional roleplay chat between {{char}} and {{user}}`,
history: neat`Then the roleplay chat between {{user}} and {{char}} begins.
system_prompt: neat`{{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}}`,
history: neat`Then the roleplay chat between "{{user}}" and "{{char}}" begins.
{{#each msg}}{{#if .isbot}}ASSISTANT:\n{{.name}}: {{.msg}}{{/if}}{{#if .isuser}}USER:\n{{.name}}: {{.msg}}{{/if}}
{{/each}}`,
post: `ASSISTANT: {{post}}`,
system_prompt: `{{#if system_prompt}}SYSTEM: {{system_prompt}}{{/if}}`,
ujb: `{{#if ujb}}({{ujb}}){{/if}}`,
},
Mistral: {
preamble: neat`Below is an instruction that describes a task. Write a response that appropriately completes the request.\n
Write {{char}}'s next reply in a fictional roleplay chat between {{char}} and {{user}}`,
history: neat`Then the roleplay chat between {{user}} and {{char}} begins.
system_prompt: neat`[INST] {{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}} [/INST]`,
history: neat`Then the roleplay chat between "{{user}}" and "{{char}}" begins.
{{#each msg}}{{#if .isbot}}\n{{.name}}: {{.msg}}{{/if}}{{#if .isuser}}[INST] {{.name}}: {{.msg}} [/INST]{{/if}}
{{/each}}`,
post: `{{post}}`,
system_prompt: `{{#if system_prompt}}[INST] {{system_prompt}} [/INST]{{/if}}`,
ujb: `{{#if ujb}}[INST] {{ujb}} [/INST]{{/if}}`,
},
Metharme: {
preamble: neat`Below is an instruction that describes a task. Write a response that appropriately completes the request.\n
Write {{char}}'s next reply in a fictional roleplay chat between {{char}} and {{user}}`,
history: neat`Then the roleplay chat between {{user}} and {{char}} begins.
system_prompt: `<|system|>{{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}}`,
history: neat`Then the roleplay chat between "{{user}}" and "{{char}}" begins.
{{#each msg}}{{#if .isbot}}<|model|>{{/if}}{{#if .isuser}}<|user|>{{/if}}{{.name}}: {{.msg}}
{{/each}}`,
post: `<|model|>{{post}}`,
system_prompt: `{{#if system_prompt}}<|system|>{{system_prompt}}{{/if}}`,
},
ChatML: {
preamble: neat`<|im_start|>system
Below is an instruction that describes a task. Write a response that appropriately completes the request.\n
Write {{char}}'s next reply in a fictional roleplay chat between {{char}} and {{user}}<|im_end|>`,
scenario: neat`{{#if scenario}}<|im_start|>system
The scenario of the conversation: {{scenario}}<|im_end|>{{/if}}`,
memory: neat`{{#if memory}}<|im_start|>system
{{char}}'s memories:
{{memory}}<|im_end|>{{/if}}`,
personality: neat`{{#if personality}}<|im_start|>system
{{char}}'s personality:\n{{personality}}<|im_end|>{{/if}}`,
impersonating: neat`{{#if impersonating}}<|im_start|>system
{{user}}'s personality:\n{{impersonating}}<|im_end|>{{/if}}`,
chat_embed: neat`{{#if chat_embed}}<|im_start|>system
Relevant past conversation history
{{chat_embed}}<|im_end|>{{/if}}`,
example_dialogue: neat`{{#if example_dialogue}}<|im_start|>system
How {{char}} speaks:
{{example_dialogue}}<|im_end|>{{/if}}`,
history: neat`<|im_start|>system
Then the roleplay chat between {{user}} and {{char}} begins.<|im_end|>
system_prompt: neat`<|im_start|>system
{{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}}<|im_end|>`,
scenario: neat`{{#if scenario}}The scenario of the conversation:\n{{scenario}}\n{{/if}}`,
memory: neat`{{#if memory}}"{{char}}'s" memories:\n{{memory}}\n{{/if}}`,
personality: neat`{{#if personality}}{{char}}'s personality:\n{{personality}}\n{{/if}}`,
impersonating: neat`{{#if impersonating}}{{user}}'s personality:\n{{impersonating}}\n{{/if}}`,
chat_embed: neat`{{#if chat_embed}}Relevant past conversation history:\n{{chat_embed}}\n{{/if}}`,
example_dialogue: neat`{{#if example_dialogue}}How "{{char}}" speaks:\n{{example_dialogue}}\n{{/if}}`,
history: neat`Then the roleplay chat between {{user}} and {{char}} begins.
{{#each msg}}<|im_start|>{{#if .isbot}}assistant{{/if}}{{#if .isuser}}user{{/if}}
{{.name}}: {{.msg}}<|im_end|>{{/each}}`,
post: neat`<|im_start|>assistant
{{post}}`,
system_prompt: neat`{{#if system_prompt}}<|im_start|>system
{{system_prompt}}<|im_end|>{{/if}}`,
ujb: neat`{{#if ujb}}<|im_start|>system
{{ujb}}<|im_end|>{{/if}}`,
},
Llama3: {
system_prompt: neat`<|begin_of_text|><|start_header_id|>system
{{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}}<|eot_id|>`,
scenario: neat`{{#if scenario}}The scenario of the conversation:\n{{scenario}}\n{{/if}}`,
memory: neat`{{#if memory}}"{{char}}'s" memories:\n{{memory}}\n{{/if}}`,
personality: neat`{{#if personality}}"{{char}}'s" personality:\n{{personality}}\n{{/if}}`,
impersonating: neat`{{#if impersonating}}"{{user}}'s" personality:\n{{impersonating}}\n{{/if}}`,
chat_embed: neat`{{#if chat_embed}}Relevant past conversation history:\n{{chat_embed}}\n{{/if}}`,
example_dialogue: neat`{{#if example_dialogue}}How "{{char}}" speaks:\n{{example_dialogue}}\n{{/if}}`,
history: neat`Then the roleplay chat between "{{user}}" and "{{char}}" begins.
{{#each msg}}<|start_header_id|>{{#if .isbot}}assistant{{/if}}{{#if .isuser}}user{{/if}}
{{.name}}: {{.msg}}<|eot_id|>{{/each}}`,
post: neat`<|start_header_id|>assistant
{{post}}`,
ujb: neat`{{#if ujb}}<|im_start|>system
{{ujb}}<|im_end|>{{/if}}`,
},
'Pyg/Simple:': {
preamble: '',
history: `Start of the conversation:\n\n{{history}}`,
scenario: `{{#if scenario}}Scenario: {{scenario}}{{/if}}`,
},
}

const fallbackHolders: Record<string, string> = {
system_prompt: `{{#if system_prompt}}{{system_prompt}}{{/if}}`,
scenario: `{{#if scenario}}The scenario of the conversation: {{scenario}}{{/if}}`,
personality: `{{#if personality}}{{char}}'s personality:\n{{personality}}{{/if}}`,
memory: `{{#if memory}}{{char}}'s memories:\n{{memory}}{{/if}}`,
ujb: `{{#if ujb}}{{ujb}}{{/if}}`,
example_dialogue: `{{#if example_dialogue}}How {{char}} speaks:\n{{example_dialogue}}{{/if}}`,
impersonating: `{{#if impersonating}}{{user}}'s personality:
{{impersonating}}{{/if}}`,
system_prompt: neat`{{#if system_prompt}}{{value}}{{#else}}Write "{{char}}'s" next reply in a fictional roleplay chat between "{{char}}" and "{{user}}"{{/else}}{{/if}}`,
scenario: `{{#if scenario}}The scenario of the conversation:\n{{scenario}}\n{{/if}}`,
personality: `{{#if personality}}"{{char}}'s" personality:\n{{personality}}\n{{/if}}`,
memory: `{{#if memory}}"{{char}}'s" memories:\n{{memory}}\n{{/if}}`,
ujb: `{{#if ujb}}({{ujb}}) {{/if}}`,
example_dialogue: `{{#if example_dialogue}}How "{{char}}" speaks:\n{{example_dialogue}}\n{{/if}}`,
impersonating: `{{#if impersonating}}"{{user}}'s" personality:\n{{impersonating}}\n{{/if}}`,
history: `{{history}}`,
post: `{{post}}`,
chat_embed: `{{#if chat_embed}}Relevant past conversation history
{{chat_embed}}
{{/if}}`,
user_embed: `{{#if user_embed}}Relevant information to the conversation
{{user_embed}}
{{/if}}`,
chat_embed: `{{#if chat_embed}}Relevant past conversation history:\n{{chat_embed}}\n{{/if}}`,
user_embed: `{{#if user_embed}}Relevant information to the conversation:\n{{user_embed}}\n{{/if}}`,
}

0 comments on commit a8c668f

Please sign in to comment.