Skip to content

Commit 3319d1c

Browse files
authored
Conversation templates for Qwen and StableLM (mlc-ai#285)
- Adds qwen - Adds stablels-3b - Adds stablelm-2 - Fixes chatml not able to be extended with config json
1 parent 780fe2c commit 3319d1c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/conversation.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ export function getConversation(conv_template: string, conv_config?: Partial<Con
234234
stop_str: "<|im_end|>",
235235
add_bos: false,
236236
stop_tokens: [2],
237+
...conv_config,
237238
});
238239
} else if (conv_template == "phi-2") {
239240
return new Conversation({
@@ -247,6 +248,43 @@ export function getConversation(conv_template: string, conv_config?: Partial<Con
247248
stop_tokens: [50256],
248249
...conv_config,
249250
});
251+
} else if (conv_template == "qwen") {
252+
return new Conversation({
253+
system: "<|im_start|>system A conversation between a user and an LLM-based AI assistant. The " +
254+
"assistant gives helpful and honest answers.<|im_end|> ",
255+
roles: ["<|im_start|>user", "<|im_start|>assistant"],
256+
offset: 0,
257+
seps: ["", ""],
258+
separator_style: "Two",
259+
stop_str: "<|im_end|>",
260+
add_bos: false,
261+
stop_tokens: [2],
262+
...conv_config,
263+
});
264+
} else if (conv_template == "stablelm-2") {
265+
return new Conversation({
266+
system: "",
267+
roles: ["<|user|>", "<|assistant|>"],
268+
offset: 0,
269+
seps: ["<|endoftext|>", "<|endoftext|>"],
270+
separator_style: "Two",
271+
stop_str: "<|endoftext|>",
272+
add_bos: false,
273+
stop_tokens: [100257],
274+
...conv_config,
275+
});
276+
} else if (conv_template == "stablelm-3b") {
277+
return new Conversation({
278+
system: "",
279+
roles: ["<|user|>", "<|assistant|>"],
280+
offset: 0,
281+
seps: ["<|endoftext|>", "<|endoftext|>"],
282+
separator_style: "Two",
283+
stop_str: "<|endoftext|>",
284+
add_bos: true,
285+
stop_tokens: [0],
286+
...conv_config,
287+
});
250288
} else if (conv_template == "empty") {
251289
// A dummy template for non-language models; should never be actually used
252290
return new Conversation({

0 commit comments

Comments
 (0)