From c49dd73c2867c676580bda0ec7b51ed5e08e1649 Mon Sep 17 00:00:00 2001 From: David Koski Date: Fri, 1 Mar 2024 16:10:34 -0800 Subject: [PATCH] swift-format, circleci setup --- .circleci/config.yml | 1 + Applications/LLMEval/ContentView.swift | 8 +++++--- Libraries/LLM/Models.swift | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a145b10..ecd2e9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,6 +38,7 @@ jobs: xcodebuild -skipPackagePluginValidation -scheme llm-tool xcodebuild -skipPackagePluginValidation -scheme mnist-tool xcodebuild -skipPackagePluginValidation -scheme MNISTTrainer + xcodebuild -skipPackagePluginValidation -scheme LLMEval workflows: build_and_test: diff --git a/Applications/LLMEval/ContentView.swift b/Applications/LLMEval/ContentView.swift index e6d59ca..806264e 100644 --- a/Applications/LLMEval/ContentView.swift +++ b/Applications/LLMEval/ContentView.swift @@ -2,9 +2,9 @@ import LLM import MLX +import Metal import SwiftUI import Tokenizers -import Metal struct ContentView: View { @@ -62,9 +62,11 @@ class LLMEvaluator { func load() async throws -> (LLMModel, LLM.Tokenizer) { switch loadState { case .idle: - let (model, tokenizer) = try await LLM.load(configuration: modelConfiguration) { [modelConfiguration] progress in + let (model, tokenizer) = try await LLM.load(configuration: modelConfiguration) { + [modelConfiguration] progress in DispatchQueue.main.sync { - self.output = "Downloading \(modelConfiguration.id): \(Int(progress.fractionCompleted * 100))%" + self.output = + "Downloading \(modelConfiguration.id): \(Int(progress.fractionCompleted * 100))%" } } loadState = .loaded(model, tokenizer) diff --git a/Libraries/LLM/Models.swift b/Libraries/LLM/Models.swift index 960ec8d..7d390b6 100644 --- a/Libraries/LLM/Models.swift +++ b/Libraries/LLM/Models.swift @@ -54,7 +54,8 @@ public struct ModelConfiguration { extension ModelConfiguration { - public static let mistral7B4bit = ModelConfiguration(id: "mlx-community/Mistral-7B-v0.1-hf-4bit-mlx") + public static let mistral7B4bit = ModelConfiguration( + id: "mlx-community/Mistral-7B-v0.1-hf-4bit-mlx") public static let codeLlama13b4bit = ModelConfiguration( id: "mlx-community/CodeLlama-13b-Instruct-hf-4bit-MLX", @@ -67,7 +68,8 @@ extension ModelConfiguration { "
 " + prompt.replacingOccurrences(of: "", with: "") + " "
     }
 
-    public static let phi4bit = ModelConfiguration(id: "mlx-community/phi-2-hf-4bit-mlx") { prompt in
+    public static let phi4bit = ModelConfiguration(id: "mlx-community/phi-2-hf-4bit-mlx") {
+        prompt in
         "Instruct: \(prompt). Output: "
     }