File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,8 @@ class LLMEvaluator {
159
159
160
160
/// This controls which model loads. `phi3_5_4bit` is one of the smaller ones, so this will fit on
161
161
/// more devices.
162
- let modelConfiguration = ModelConfiguration . phi3_5_4bit
162
+ // let modelConfiguration = ModelConfiguration.phi3_5_4bit
163
+ let modelConfiguration = ModelConfiguration . mistral7B4bit
163
164
164
165
/// parameters controlling the output
165
166
let generateParameters = GenerateParameters ( temperature: 0.6 )
@@ -212,11 +213,9 @@ class LLMEvaluator {
212
213
do {
213
214
let modelContainer = try await load ( )
214
215
215
- // augment the prompt as needed
216
- let prompt = modelConfiguration. prepare ( prompt: prompt)
217
-
218
- let promptTokens = await modelContainer. perform { _, tokenizer in
219
- tokenizer. encode ( text: prompt)
216
+ let messages = [ [ " role " : " user " , " content " : prompt] ]
217
+ let promptTokens = try await modelContainer. perform { _, tokenizer in
218
+ try tokenizer. applyChatTemplate ( messages: messages)
220
219
}
221
220
222
221
// each time you generate you will get something new
Original file line number Diff line number Diff line change @@ -130,7 +130,8 @@ extension ModelConfiguration {
130
130
131
131
public static let mistral7B4bit = ModelConfiguration (
132
132
id: " mlx-community/Mistral-7B-Instruct-v0.3-4bit " ,
133
- defaultPrompt: " Describe the Swift language. "
133
+ defaultPrompt: " Describe the Swift language. " ,
134
+ extraEOSTokens: [ " <|im_end|> " ] // !! This doesn't seem to work
134
135
) { prompt in
135
136
" <s>[INST] \( prompt) [/INST] "
136
137
}
You can’t perform that action at this time.
0 commit comments