Full bf16 weights, no quantization applied.
1pip install mlx-vlm
2
3# Apply fix
4git clone https://github.com/FakeRocket543/mlx-gemma4.git
5cp mlx-gemma4/mlx_vlm_patches/models/gemma4/language.py \
6 $(python -c "import mlx_vlm; print(mlx_vlm.__path__[0])")/models/gemma4/
1from mlx_vlm import load, generate
2
3model, processor = load("FakeRockert543/gemma-4-e4b-it-MLX-bf16")
4tokenizer = processor.tokenizer
5
6messages = [{"role": "user", "content": [
7 {"type": "image", "url": "photo.jpg"},
8 {"type": "text", "text": "Describe this image in detail."},
9]}]
10prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
11out = generate(model, processor, prompt, ["photo.jpg"],
12 max_tokens=200, repetition_penalty=1.2, temperature=0.7)
13print(out.text)
1messages = [{"role": "user", "content": [
2 {"type": "audio", "url": "speech.wav"},
3 {"type": "text", "text": "What is the speaker saying? What is their emotional tone?"},
4]}]
5prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
6out = generate(model, processor, prompt, audio=["speech.wav"],
7 max_tokens=200, repetition_penalty=1.2, temperature=0.1)
8print(out.text)
1messages = [{"role": "user", "content": "What is the capital of France?"}]
2prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
3out = generate(model, processor, prompt, max_tokens=100, temperature=0.0)
4print(out.text)
Fixed source files are included in the
GitHub repo.
1git clone https://github.com/FakeRocket543/mlx-gemma4.git
2cd mlx-gemma4
3python convert_gemma4.py E4B bf16
All 12 variants validated on 10 images + 12 audio samples + 3 chat prompts. Full results:
GitHub.