Yarik commited on
Commit
9125999
β€’
1 Parent(s): 0f255f5

Update space

Browse files
apis/chat_api.py CHANGED
@@ -61,6 +61,13 @@ class ChatAPIApp:
61
  "created": 1700000000,
62
  "owned_by": "TheBloke",
63
  },
 
 
 
 
 
 
 
64
  ],
65
  }
66
  return self.available_models
 
61
  "created": 1700000000,
62
  "owned_by": "TheBloke",
63
  },
64
+ {
65
+ "id": "starchat2-15b-v0.1",
66
+ "description": "[HuggingFaceH4/starchat2-15b-v0.1]: https://huggingface.co/HuggingFaceH4/starchat2-15b-v0.1",
67
+ "object": "model",
68
+ "created": 1700000000,
69
+ "owned_by": "TheBloke",
70
+ },
71
  ],
72
  }
73
  return self.available_models
messagers/message_composer.py CHANGED
@@ -9,6 +9,7 @@ class MessageComposer:
9
  "mixtral-8x7b",
10
  "mistral-7b",
11
  "zephyr-7b-beta",
 
12
  "nous-mixtral-8x7b",
13
  ]
14
 
@@ -110,6 +111,17 @@ class MessageComposer:
110
  self.cached_str = f"[/USER] {content} [/ASSIST]"
111
  if self.cached_str:
112
  self.merged_str += f"{self.cached_str}"
 
 
 
 
 
 
 
 
 
 
 
113
  else:
114
  self.merged_str = "\n".join(
115
  [
@@ -201,6 +213,17 @@ class MessageComposer:
201
  self.append_last_instruction_to_messages(
202
  inst_matches_list, pair_matches_list
203
  )
 
 
 
 
 
 
 
 
 
 
 
204
  else:
205
  self.messages = [
206
  {
 
9
  "mixtral-8x7b",
10
  "mistral-7b",
11
  "zephyr-7b-beta",
12
+ "starchat2-15b-v0.1",
13
  "nous-mixtral-8x7b",
14
  ]
15
 
 
111
  self.cached_str = f"[/USER] {content} [/ASSIST]"
112
  if self.cached_str:
113
  self.merged_str += f"{self.cached_str}"
114
+ elif self.model in ["starchat2-15b-v0.1"]:
115
+ self.merged_str_list = []
116
+ for message in self.messages:
117
+ role = message["role"]
118
+ content = message["content"]
119
+ if role not in ["system", "user", "assistant"]:
120
+ role = self.default_role
121
+ message_line = f"<|im_start|>{role}\n{content}<|im_end|>"
122
+ self.merged_str_list.append(message_line)
123
+ self.merged_str_list.append("<|im_start|>assistant")
124
+ self.merged_str = "\n".join(self.merged_str_list)
125
  else:
126
  self.merged_str = "\n".join(
127
  [
 
213
  self.append_last_instruction_to_messages(
214
  inst_matches_list, pair_matches_list
215
  )
216
+ elif self.model in ["starchat2-15b-v0.1"]:
217
+ message_pattern = r"<\|im_start\|>(?P<role>system|user|assistant)[\s\n]*(?P<content>[\s\S]*?)<\|im_end\|>"
218
+ message_matches = re.finditer(
219
+ message_pattern, self.merged_str, flags=re.MULTILINE | re.IGNORECASE
220
+ )
221
+ message_matches_list = list(message_matches)
222
+ logger.note(f"message_matches_list: {message_matches_list}")
223
+ for match in message_matches_list:
224
+ role = match.group("role")
225
+ content = match.group("content")
226
+ self.messages.append({"role": role, "content": content.strip()})
227
  else:
228
  self.messages = [
229
  {
networks/message_streamer.py CHANGED
@@ -13,6 +13,8 @@ class MessageStreamer:
13
  "mistral-7b": "mistralai/Mistral-7B-Instruct-v0.2", # 65.71, fast
14
  "nous-mixtral-8x7b": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
15
  "zephyr-7b-beta": "HuggingFaceH4/zephyr-7b-beta", # ❌ Too Slow
 
 
16
  # "llama-70b": "meta-llama/Llama-2-70b-chat-hf", # ❌ Require Pro User
17
  # "codellama-34b": "codellama/CodeLlama-34b-Instruct-hf", # ❌ Low Score
18
  # "falcon-180b": "tiiuae/falcon-180B-chat", # ❌ Require Pro User
@@ -23,13 +25,15 @@ class MessageStreamer:
23
  "mistral-7b": "</s>",
24
  "nous-mixtral-8x7b": "<|im_end|>",
25
  "zephyr-7b-beta": "</s>",
26
-
27
  }
28
  TOKEN_LIMIT_MAP = {
29
  "mixtral-8x7b": 32768,
30
  "mistral-7b": 32768,
31
  "nous-mixtral-8x7b": 32768,
32
  "zephyr-7b-beta": 4096,
 
 
33
  }
34
  TOKEN_RESERVED = 100
35
 
 
13
  "mistral-7b": "mistralai/Mistral-7B-Instruct-v0.2", # 65.71, fast
14
  "nous-mixtral-8x7b": "NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
15
  "zephyr-7b-beta": "HuggingFaceH4/zephyr-7b-beta", # ❌ Too Slow
16
+ "starchat2-15b-v0.1": "HuggingFaceH4/starchat2-15b-v0.1", # ❌ Too Slow
17
+
18
  # "llama-70b": "meta-llama/Llama-2-70b-chat-hf", # ❌ Require Pro User
19
  # "codellama-34b": "codellama/CodeLlama-34b-Instruct-hf", # ❌ Low Score
20
  # "falcon-180b": "tiiuae/falcon-180B-chat", # ❌ Require Pro User
 
25
  "mistral-7b": "</s>",
26
  "nous-mixtral-8x7b": "<|im_end|>",
27
  "zephyr-7b-beta": "</s>",
28
+ "starchat2-15b-v0.1": "</s>",
29
  }
30
  TOKEN_LIMIT_MAP = {
31
  "mixtral-8x7b": 32768,
32
  "mistral-7b": 32768,
33
  "nous-mixtral-8x7b": 32768,
34
  "zephyr-7b-beta": 4096,
35
+ "starchat2-15b-v0.1": 8192,
36
+
37
  }
38
  TOKEN_RESERVED = 100
39