Skip to content

Commit 70974aa

Browse files
authored
LlamaDemo Android add Qwen 3 prompt format (#10624)
Format the raw prompt
1 parent 22d2558 commit 70974aa

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ModelType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ public enum ModelType {
1414
LLAMA_3_2,
1515
LLAVA_1_5,
1616
LLAMA_GUARD_3,
17+
QWEN_3,
1718
}

examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/ModelUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static int getModelCategory(ModelType modelType, BackendType backendType)
2929
case LLAMA_3:
3030
case LLAMA_3_1:
3131
case LLAMA_3_2:
32+
case QWEN_3:
3233
default:
3334
return TEXT_MODEL;
3435
}

examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/PromptFormat.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public static String getSystemPromptTemplate(ModelType modelType) {
2525
+ "<|eot_id|>";
2626
case LLAVA_1_5:
2727
return "USER: ";
28+
case QWEN_3:
29+
return "<|im_start|>system\n" + "You are a helpful assistant.\n" + "<|im_end|>\n";
2830
default:
2931
return SYSTEM_PLACEHOLDER;
3032
}
@@ -42,6 +44,14 @@ public static String getUserPromptTemplate(ModelType modelType) {
4244
+ "<|start_header_id|>assistant<|end_header_id|>";
4345

4446
case LLAVA_1_5:
47+
case QWEN_3:
48+
return "<|im_start|>user\n"
49+
+ USER_PLACEHOLDER
50+
+ "<|im_end|>\n"
51+
+ "<|im_start|>assistant\n"
52+
+ "<think>\n"
53+
+ "\n"
54+
+ "</think>\n\n\n";
4555
default:
4656
return USER_PLACEHOLDER;
4757
}
@@ -69,6 +79,8 @@ public static String getStopToken(ModelType modelType) {
6979
return "<|eot_id|>";
7080
case LLAVA_1_5:
7181
return "</s>";
82+
case QWEN_3:
83+
return "<|endoftext|>";
7284
default:
7385
return "";
7486
}

0 commit comments

Comments
 (0)