Skip to content

Commit

Permalink
phi3 template, fixed carsh when EOS option is on
Browse files Browse the repository at this point in the history
  • Loading branch information
guinmoon committed Apr 25, 2024
1 parent d6fef7c commit fb4702e
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 29 deletions.
4 changes: 4 additions & 0 deletions LLMFarm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
15C08A662BA3705D000A1BE0 /* ModelSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15C08A652BA3705D000A1BE0 /* ModelSelector.swift */; };
15C08A682BA5976A000A1BE0 /* MessageImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15C08A672BA5976A000A1BE0 /* MessageImage.swift */; };
15C08A6A2BA5CB2C000A1BE0 /* MobileVLM.json in Resources */ = {isa = PBXBuildFile; fileRef = 15C08A692BA5CB2C000A1BE0 /* MobileVLM.json */; };
15D81B002BDAC0E900C3B5CE /* phi3.json in Resources */ = {isa = PBXBuildFile; fileRef = 15D81AFF2BDAC0E900C3B5CE /* phi3.json */; };
15D8FE902AF80D7600B5C90D /* FineTuneView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15D8FE8F2AF80D7600B5C90D /* FineTuneView.swift */; };
15E086C42AEAC69B006459DE /* FineTuneModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15E086C32AEAC69B006459DE /* FineTuneModel.swift */; };
15E415D42A18A2980057A15E /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15E415D32A18A2980057A15E /* main.swift */; };
Expand Down Expand Up @@ -178,6 +179,7 @@
15C08A652BA3705D000A1BE0 /* ModelSelector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModelSelector.swift; sourceTree = "<group>"; };
15C08A672BA5976A000A1BE0 /* MessageImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageImage.swift; sourceTree = "<group>"; };
15C08A692BA5CB2C000A1BE0 /* MobileVLM.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = MobileVLM.json; sourceTree = "<group>"; };
15D81AFF2BDAC0E900C3B5CE /* phi3.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = phi3.json; sourceTree = "<group>"; };
15D8FE8F2AF80D7600B5C90D /* FineTuneView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FineTuneView.swift; sourceTree = "<group>"; };
15E086C32AEAC69B006459DE /* FineTuneModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FineTuneModel.swift; sourceTree = "<group>"; };
15E415D12A18A2970057A15E /* ModelTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ModelTest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -254,6 +256,7 @@
158172B72BC5B1460078DCDA /* llama chat 2 7B (2).json */,
158172BD2BC5B1470078DCDA /* llama chat 2 7B.json */,
158172B52BC5B1460078DCDA /* phi2.json */,
15D81AFF2BDAC0E900C3B5CE /* phi3.json */,
158172B92BC5B1470078DCDA /* RWKV-4 Raven Eng.json */,
158172B82BC5B1470078DCDA /* StableLM-3B-4E1T.json */,
158172B42BC5B1460078DCDA /* tinyllama.json */,
Expand Down Expand Up @@ -577,6 +580,7 @@
158172CA2BC5B1480078DCDA /* llama chat 2 7B.json in Resources */,
15F210892A191B1B0021F414 /* Preview Assets.xcassets in Resources */,
15F210852A191B1B0021F414 /* Assets.xcassets in Resources */,
15D81B002BDAC0E900C3B5CE /* phi3.json in Resources */,
1532BF7E2AA113D5006DC514 /* MagicPrompt-Stable-Diffusion.json in Resources */,
158172C12BC5B1480078DCDA /* tinyllama.json in Resources */,
158172C52BC5B1480078DCDA /* StableLM-3B-4E1T.json in Resources */,
Expand Down
27 changes: 17 additions & 10 deletions LLMFarm/Chats/LLMTextInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,26 @@ public struct LLMTextInput: View {
HStack(alignment: .bottom) {
if self.show_attachment_btn{
if img_cahce_path != nil && platformImage != nil{
HStack{
#if os(macOS)
Image(nsImage:platformImage!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 30,maxHeight: 40)
Image(nsImage:platformImage!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 30,maxHeight: 40)
#else
Image(uiImage:platformImage!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 30,maxHeight: 40)
Image(uiImage:platformImage!)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 30,maxHeight: 40)
.clipShape(Circle())
#endif
// image!

// image!
}
.cornerRadius(20) /// make the background rounded
.overlay( /// apply a rounded border
RoundedRectangle(cornerRadius: 5)
.stroke(.gray, lineWidth: 1)
)
}
Group {
attachButton
Expand Down
2 changes: 1 addition & 1 deletion LLMFarm/Lib/FileHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ func create_chat(_ in_options:Dictionary<String, Any>,edit_chat_dialog:Bool = fa
continue
}
if key != "lora_adapters" && key != "model" && key != "clip_model"
&& key != "title" && key != "icon"{
&& key != "title" && key != "icon" && key != "model_settings_template"{
options[key] = value
}
}
Expand Down
57 changes: 40 additions & 17 deletions LLMFarm/Settings/downloadable_models.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,46 @@

]
},
{
"name": "Phi 2 2.7B",
"models": [
{
"file_name": "phi-2.Q4_K_M.gguf",
"url": "https://huggingface.co/TheBloke/phi-2-GGUF/resolve/main/phi-2.Q4_K_M.gguf?download=true",
"size": "1.48",
"Q": "Q4_K_M"
},
{
"url": "https://huggingface.co/ggml-org/models/resolve/main/phi-2/ggml-model-q8_0.gguf?download=true",
"file_name": "phi-2-q8_0.gguf",
"size": "",
"Q": "Q8_0"
}
]
},
{
"name": "Phi 3 mini 128k instruct",
"models": [
{
"file_name": "Phi-3-mini-128k-instruct.IQ4_NL.gguf",
"url": "https://huggingface.co/PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed/resolve/main/Phi-3-mini-128k-instruct.IQ4_NL.gguf?download=true",
"size": "1.48",
"Q": "IQ4_NL"
},
{
"url": "https://huggingface.co/PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed/resolve/main/Phi-3-mini-128k-instruct.IQ3_S.gguf?download=true",
"file_name": "Phi-3-mini-128k-instruct.IQ3_S.gguf",
"size": "",
"Q": "IQ3_S"
},
{
"url": "https://huggingface.co/PrunaAI/Phi-3-mini-128k-instruct-GGUF-Imatrix-smashed/resolve/main/Phi-3-mini-128k-instruct.Q5_K_M.gguf?download=true",
"file_name": "Phi-3-mini-128k-instruct.Q5_K_M.gguf",
"size": "",
"Q": "Q5_K_M"
}
]
},
{
"name": "MobileVLM 1.7B",
"models": [
Expand Down Expand Up @@ -85,23 +125,6 @@
}
]
},
{
"name": "Phi 2 2.7B",
"models": [
{
"file_name": "phi-2.Q4_K_M.gguf",
"url": "https://huggingface.co/TheBloke/phi-2-GGUF/resolve/main/phi-2.Q4_K_M.gguf?download=true",
"size": "1.48",
"Q": "Q4_K_M"
},
{
"url": "https://huggingface.co/ggml-org/models/resolve/main/phi-2/ggml-model-q8_0.gguf?download=true",
"file_name": "phi-2-q8_0.gguf",
"size": "",
"Q": "Q8_0"
}
]
},
{
"name": "ORCA mini 3B",
"models": [
Expand Down
27 changes: 27 additions & 0 deletions LLMFarm/model_setting_templates/phi3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"add_eos_token" : false,
"mlock" : false,
"repeat_penalty" : 1.1000000238418579,
"mirostat_tau" : 5,
"temp" : 0.89999997615814209,
"warm_prompt" : "\n\n\n",
"mmap" : true,
"grammar" : "<None>",
"parse_special_tokens" : true,
"use_metal" : true,
"model_inference" : "llama",
"repeat_last_n" : 64,
"prompt_format" : "<|user|>\n{{prompt}}<|end|>\n<|assistant|>\n",
"reverse_prompt" : "<|end|>",
"n_batch" : 512,
"typical_p" : 1,
"top_k" : 40,
"add_bos_token" : true,
"mirostat" : 0,
"top_p" : 0.94999998807907104,
"numberOfThreads" : 0,
"template_name" : "Phi 3",
"context" : 1024,
"mirostat_eta" : 0.10000000149011612,
"tfs_z" : 1
}
2 changes: 1 addition & 1 deletion llmfarm_core.swift

0 comments on commit fb4702e

Please sign in to comment.