Spaces:
Running
Running
Update dialogues.py
Browse files- dialogues.py +3 -5
dialogues.py
CHANGED
@@ -132,9 +132,9 @@ class DialogueTemplate(ModelHubMixin):
|
|
132 |
return cls.from_dict(data=data)
|
133 |
|
134 |
|
135 |
-
# Default template
|
136 |
default_template = DialogueTemplate(
|
137 |
-
system="Below is a dialogue between a human user and an AI assistant. The assistant
|
138 |
)
|
139 |
|
140 |
# Supporting other templates
|
@@ -151,13 +151,11 @@ SUPPORTED_DIALOGUE_TEMPLATES = {
|
|
151 |
"alpaca": alpaca_template,
|
152 |
}
|
153 |
|
154 |
-
|
155 |
def get_dialogue_template(template: str) -> DialogueTemplate:
|
156 |
if template not in SUPPORTED_DIALOGUE_TEMPLATES:
|
157 |
raise ValueError(f"Template {template} is not supported!")
|
158 |
return SUPPORTED_DIALOGUE_TEMPLATES[template].copy()
|
159 |
|
160 |
-
|
161 |
def prepare_dialogue(example, dialogue_template, is_train=True):
|
162 |
if "messages" in example and example["messages"] is not None:
|
163 |
dialogue_template.messages = example["messages"]
|
@@ -170,7 +168,7 @@ def prepare_dialogue(example, dialogue_template, is_train=True):
|
|
170 |
dialogue_template.messages = [{"role": "user", "content": example["prompt"]}]
|
171 |
else:
|
172 |
raise ValueError(
|
173 |
-
f"Could not format example as dialogue! Require either `messages` or `[prompt, completion]` or `[prompt]` keys but found {list(example.keys())}"
|
174 |
)
|
175 |
if is_train:
|
176 |
example["text"] = dialogue_template.get_training_prompt()
|
|
|
132 |
return cls.from_dict(data=data)
|
133 |
|
134 |
|
135 |
+
# Default template with programming specialization
|
136 |
default_template = DialogueTemplate(
|
137 |
+
system="Below is a dialogue between a human user and an AI assistant. The assistant specializes in computer programming and coding, and will assist with coding questions, debugging, code optimization, algorithm design, and more. The assistant is knowledgeable in various programming languages like Python, JavaScript, and C++.",
|
138 |
)
|
139 |
|
140 |
# Supporting other templates
|
|
|
151 |
"alpaca": alpaca_template,
|
152 |
}
|
153 |
|
|
|
154 |
def get_dialogue_template(template: str) -> DialogueTemplate:
|
155 |
if template not in SUPPORTED_DIALOGUE_TEMPLATES:
|
156 |
raise ValueError(f"Template {template} is not supported!")
|
157 |
return SUPPORTED_DIALOGUE_TEMPLATES[template].copy()
|
158 |
|
|
|
159 |
def prepare_dialogue(example, dialogue_template, is_train=True):
|
160 |
if "messages" in example and example["messages"] is not None:
|
161 |
dialogue_template.messages = example["messages"]
|
|
|
168 |
dialogue_template.messages = [{"role": "user", "content": example["prompt"]}]
|
169 |
else:
|
170 |
raise ValueError(
|
171 |
+
f"Could not format example as dialogue! Require either `messages` or `[prompt, completion]` or `[prompt]` keys but found {list(example.keys())}."
|
172 |
)
|
173 |
if is_train:
|
174 |
example["text"] = dialogue_template.get_training_prompt()
|