Skip to content

Commit c1620d9

Browse files
cccclaifacebook-github-bot
authored andcommitted
Add qwen2.5 for llama app (pytorch#13988)
Summary: Generate qwen2.5 0.5b model and run on the app Differential Revision: D81751900
1 parent dbac09c commit c1620d9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/demo-apps/apple_ios/LLaMA/LLaMA/Application/ContentView.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct ContentView: View {
8585
enum ModelType {
8686
case llama
8787
case llava
88+
case qwen2
8889
case qwen3
8990
case phi4
9091

@@ -94,11 +95,14 @@ struct ContentView: View {
9495
return .llama
9596
} else if filename.hasPrefix("llava") {
9697
return .llava
98+
} else if filename.hasPrefix("qwen2") {
99+
return .qwen2
97100
} else if filename.hasPrefix("qwen3") {
98101
return .qwen3
99102
} else if filename.hasPrefix("phi4") {
100103
return .phi4
101104
}
105+
102106
print("Unknown model type in path: \(path). Model filename should start with one of: llama, llava, qwen3, or phi4")
103107
exit(1)
104108
}
@@ -346,15 +350,15 @@ struct ContentView: View {
346350
}
347351

348352
switch modelType {
349-
case .llama, .qwen3, .phi4:
353+
case .llama, .qwen2, .qwen3, .phi4:
350354
runnerHolder.llamaRunner = runnerHolder.llamaRunner ?? LLaMARunner(modelPath: modelPath, tokenizerPath: tokenizerPath)
351355
case .llava:
352356
runnerHolder.llavaRunner = runnerHolder.llavaRunner ?? LLaVARunner(modelPath: modelPath, tokenizerPath: tokenizerPath)
353357
}
354358

355359
guard !shouldStopGenerating else { return }
356360
switch modelType {
357-
case .llama, .qwen3, .phi4:
361+
case .llama, .qwen2, .qwen3, .phi4:
358362
if let runner = runnerHolder.llamaRunner, !runner.isLoaded() {
359363
var error: Error?
360364
let startLoadTime = Date()
@@ -468,6 +472,8 @@ struct ContentView: View {
468472
} else {
469473
let prompt: String
470474
switch modelType {
475+
case .qwen2:
476+
prompt = String(format: Constants.llama3PromptTemplate, text)
471477
case .qwen3:
472478
let basePrompt = String(format: Constants.qwen3PromptTemplate, text)
473479
// If thinking mode is enabled for Qwen, don't skip the <think></think> special tokens

0 commit comments

Comments
 (0)