Clearer syntax for instruction-following characters

This commit is contained in:
oobabooga 2023-05-03 22:50:39 -03:00
parent 9c77ab4fc2
commit 0e6d17304a
10 changed files with 38 additions and 28 deletions

View File

@ -1,4 +1,4 @@
name: "### Response:" user: "### Instruction:"
your_name: "### Instruction:" bot: "### Response:"
context: "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"
turn_template: "<|user|>\n<|user-message|>\n\n<|bot|>\n<|bot-message|>\n\n" turn_template: "<|user|>\n<|user-message|>\n\n<|bot|>\n<|bot-message|>\n\n"
context: "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n"

View File

@ -1,4 +1,4 @@
name: "答:" user: "[Round <|round|>]\n问:"
your_name: "[Round <|round|>]\n问:" bot: "答:"
context: ""
turn_template: "<|user|><|user-message|>\n<|bot|><|bot-message|>\n" turn_template: "<|user|><|user-message|>\n<|bot|><|bot-message|>\n"
context: ""

View File

@ -1,4 +1,4 @@
name: "GPT:" user: "USER:"
your_name: "USER:" bot: "GPT:"
context: "BEGINNING OF CONVERSATION: "
turn_template: "<|user|> <|user-message|> <|bot|><|bot-message|></s>" turn_template: "<|user|> <|user-message|> <|bot|><|bot-message|></s>"
context: "BEGINNING OF CONVERSATION: "

View File

@ -1,4 +1,4 @@
name: "### Assistant" user: "### Human"
your_name: "### Human" bot: "### Assistant"
context: "You are LLaVA, a large language and vision assistant trained by UW Madison WAIV Lab. You are able to understand the visual content that the user provides, and assist the user with a variety of tasks using natural language. Follow the instructions carefully and explain your answers in detail.\n### Human: \nHi!\n### Assistant: \nHi there! How can I help you today?\n"
turn_template: "<|user|>\n<|user-message|>\n<|bot|>\n<|bot-message|>\n" turn_template: "<|user|>\n<|user-message|>\n<|bot|>\n<|bot-message|>\n"
context: "You are LLaVA, a large language and vision assistant trained by UW Madison WAIV Lab. You are able to understand the visual content that the user provides, and assist the user with a variety of tasks using natural language. Follow the instructions carefully and explain your answers in detail.\n### Human: \nHi!\n### Assistant: \nHi there! How can I help you today?\n"

View File

@ -1,3 +1,3 @@
name: "<|assistant|>" user: "<|prompter|>"
your_name: "<|prompter|>" bot: "<|assistant|>"
turn_template: "<|user|><|user-message|><|endoftext|><|bot|><|bot-message|><|endoftext|>" turn_template: "<|user|><|user-message|><|endoftext|><|bot|><|bot-message|><|endoftext|>"

View File

@ -1,3 +1,3 @@
name: "Alice:" user: "Bob:"
your_name: "Bob:" bot: "Alice:"
turn_template: "<|user|> <|user-message|>\n\n<|bot|> <|bot-message|>\n\n" turn_template: "<|user|> <|user-message|>\n\n<|bot|> <|bot-message|>\n\n"

View File

@ -1,4 +1,4 @@
name: "### Assistant:" user: "### Human:"
your_name: "### Human:" bot: "### Assistant:"
context: "A chat between a human and an assistant.\n\n"
turn_template: "<|user|> <|user-message|>\n<|bot|> <|bot-message|>\n" turn_template: "<|user|> <|user-message|>\n<|bot|> <|bot-message|>\n"
context: "A chat between a human and an assistant.\n\n"

View File

@ -1,4 +1,4 @@
name: "ASSISTANT:" user: "USER:"
your_name: "USER:" bot: "ASSISTANT:"
context: "A chat between a user and an assistant.\n\n"
turn_template: "<|user|> <|user-message|>\n<|bot|> <|bot-message|></s>\n" turn_template: "<|user|> <|user-message|>\n<|bot|> <|bot-message|></s>\n"
context: "A chat between a user and an assistant.\n\n"

View File

@ -4,11 +4,12 @@ The following fields may be defined:
| Field | Description | | Field | Description |
|-------|-------------| |-------|-------------|
| `name` | The character's name. | | `name` or `bot` | The character's name. |
| `your_name` or `user` (optional) | Your name. This overwrites what you had previously written in the `Your name` field in the interface. |
| `context` | A string that appears at the top of the prompt. It usually contains a description of the character's personality. | | `context` | A string that appears at the top of the prompt. It usually contains a description of the character's personality. |
| `greeting` (optional) | The character's opening message when a new conversation is started. | | `greeting` (optional) | The character's opening message when a new conversation is started. |
| `example_dialogue` (optional) | A few example messages to guide the model. | | `example_dialogue` (optional) | A few example messages to guide the model. |
| `your_name` (optional) | Your name. This overwrites what you had previously written in the `Your name` field in the interface. | | `turn_template` (optional) | Used to define where the spaces and new line characters should be in Instruct mode. See the characters in `characters/instruction-following` for examples. |
#### Special tokens #### Special tokens

View File

@ -455,9 +455,18 @@ def load_character(character, name1, name2, mode):
file_contents = open(filepath, 'r', encoding='utf-8').read() file_contents = open(filepath, 'r', encoding='utf-8').read()
data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents) data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents)
name2 = data['name'] if 'name' in data else data['char_name']
if 'your_name' in data and data['your_name'] != '': # Finding the bot's name
name1 = data['your_name'] for k in ['name', 'bot', '<|bot|>', 'char_name']:
if k in data and data[k] != '':
name2 = data[k]
break
# Find the user name (if any)
for k in ['your_name', 'user', '<|user|>']:
if k in data and data[k] != '':
name1 = data[k]
break
else: else:
name1 = shared.settings['name1'] name1 = shared.settings['name1']