mlx-swift-examples icon indicating copy to clipboard operation
mlx-swift-examples copied to clipboard

Error: Unsupported model type: gemma3n

Open seungjun-green opened this issue 9 months ago • 6 comments

If I try to use gemma-3n model using swift-mlx-examples package I get following error:

Error: Unsupported model type: gemma3n

I installed the package and run the code with below simple code. It all worked well with different version of model such as SmolLM-135M-Instruct-4bit but keep failing when I try to use mlx-community/gemma-3n-E2B-it-lm-bf16 or mlx-community/gemma-3n-E4B-it-lm-bf16

import SwiftUI
import MLXVLM
import MLXLMCommon

struct ContentView: View {
    @State private var isLoading = false

    var body: some View {
        VStack(spacing: 20) {
            if isLoading {
                ProgressView("Processing...")
            }

            Button("Process") {
                Task {
                    await process()
                }
            }
            .padding()
        }
        .padding()
    }

    func process() async {
        isLoading = true
        defer { isLoading = false }

        do {
            let model = try await loadModel(id: "mlx-community/SmolLM-135M-Instruct-4bit")
            let session = ChatSession(model)
            
            print(try await session.respond(to: "What are two things to see in San Francisco?"))

        } catch {
            print("Error: \(error.localizedDescription)")
        }
    }
}

seungjun-green avatar Jul 23 '25 13:07 seungjun-green

I wonder if you are using the tag of mlx-swift-examples (mlx-libraries) or main? This code isn't in a tag yet.

davidkoski avatar Jul 23 '25 14:07 davidkoski

I was using the tag version not the main. Using main the gemma3n works very well. Sorry for asking stupid question. Thanks for the great work!

seungjun-green avatar Jul 24 '25 02:07 seungjun-green

No worries -- it isn't always clear what to do!

davidkoski avatar Jul 24 '25 02:07 davidkoski

Sorry for the confusion. Last time I tested gemma3n in a wrong way(passed other model name to the id argument). When tested correctly, it does not produce Error: Unsupported model type: gemma3n error but generating the response never stops. Could you check this issue please?

seungjun-green avatar Jul 25 '25 11:07 seungjun-green

Sorry for the confusion. Last time I tested gemma3n in a wrong way(passed other model name to the id argument). When tested correctly, it does not produce Error: Unsupported model type: gemma3n error but generating the response never stops. Could you check this issue please?

Hi mate, could you please provide me with a flow for running an LLM locally within our own app? I’ve been trying but haven’t been able to get it working. Could you share part of your code or explain how you did it? It would be really helpful.

shashankb-cc avatar Sep 15 '25 10:09 shashankb-cc

Sorry for my late reply, Here is an example iOS app I built which runs gemma-3n models on iPhone. https://github.com/seungjun-green/FoodLen

seungjun-green avatar Oct 01 '25 06:10 seungjun-green