Spaces:
Running
Running
Yarik
commited on
Commit
•
0f255f5
1
Parent(s):
833b3d3
Update space
Browse files
messagers/message_composer.py
CHANGED
@@ -102,12 +102,12 @@ class MessageComposer:
|
|
102 |
role = message["role"]
|
103 |
content = message["content"]
|
104 |
if role in self.inst_roles:
|
105 |
-
self.cached_str = f"[
|
106 |
elif role in self.answer_roles:
|
107 |
self.merged_str += f"<s> {self.cached_str} {content} </s>\n"
|
108 |
self.cached_str = ""
|
109 |
else:
|
110 |
-
self.cached_str = f"[
|
111 |
if self.cached_str:
|
112 |
self.merged_str += f"{self.cached_str}"
|
113 |
else:
|
@@ -187,14 +187,14 @@ class MessageComposer:
|
|
187 |
self.messages.append({"role": role, "content": content.strip()})
|
188 |
elif self.model in ["zephyr-7b-beta"]:
|
189 |
pair_pattern = (
|
190 |
-
r"<s>\s*\[INST\](?P<inst>[\s\S]*?)\[/
|
191 |
)
|
192 |
pair_matches = re.finditer(pair_pattern, self.merged_str, re.MULTILINE)
|
193 |
pair_matches_list = list(pair_matches)
|
194 |
|
195 |
self.messages = self.convert_pair_matches_to_messages(pair_matches_list)
|
196 |
|
197 |
-
inst_pattern = r"\[INST\](?P<inst>[\s\S]*?)\[/
|
198 |
inst_matches = re.finditer(inst_pattern, self.merged_str, re.MULTILINE)
|
199 |
inst_matches_list = list(inst_matches)
|
200 |
|
|
|
102 |
role = message["role"]
|
103 |
content = message["content"]
|
104 |
if role in self.inst_roles:
|
105 |
+
self.cached_str = f"[/USER] {content} [/ASSIST]"
|
106 |
elif role in self.answer_roles:
|
107 |
self.merged_str += f"<s> {self.cached_str} {content} </s>\n"
|
108 |
self.cached_str = ""
|
109 |
else:
|
110 |
+
self.cached_str = f"[/USER] {content} [/ASSIST]"
|
111 |
if self.cached_str:
|
112 |
self.merged_str += f"{self.cached_str}"
|
113 |
else:
|
|
|
187 |
self.messages.append({"role": role, "content": content.strip()})
|
188 |
elif self.model in ["zephyr-7b-beta"]:
|
189 |
pair_pattern = (
|
190 |
+
r"<s>\s*\[INST\](?P<inst>[\s\S]*?)\[/USER\][/ASSIST\](?P<answer>[\s\S]*?)</s>"
|
191 |
)
|
192 |
pair_matches = re.finditer(pair_pattern, self.merged_str, re.MULTILINE)
|
193 |
pair_matches_list = list(pair_matches)
|
194 |
|
195 |
self.messages = self.convert_pair_matches_to_messages(pair_matches_list)
|
196 |
|
197 |
+
inst_pattern = r"\[INST\](?P<inst>[\s\S]*?)\[/USER\][/ASSIST\]"
|
198 |
inst_matches = re.finditer(inst_pattern, self.merged_str, re.MULTILINE)
|
199 |
inst_matches_list = list(inst_matches)
|
200 |
|