Esegui Gemma con MLX

MLX è un framework di array per il machine learning su Apple Silicon.

Avvio rapido

Installa dal Python Package Index (PyPI)

pip install mlx mlx-lm mlx-vlm

Comando di esempio:

# Text Generation
mlx_lm.generate --model mlx-community/gemma-4-e2b-it-4bit --prompt "Who are you?"

# Vision Task
mlx_vlm.generate --model mlx-community/gemma-4-e2b-it-4bit --prompt "Describe this image." --image <path_to_image>

Puoi avviare il server con:

mlx_vlm.server --port 8080

# Preload a model at startup (Hugging Face repo or local path)
mlx_vlm.server --model mlx-community/gemma-4-e2b-it-4bit

In questo modo viene creato un server che ti consente di accedere al modello con l'endpoint compatibile con OpenAI (http://localhost:8080/v1).

Per ulteriori informazioni e istruzioni su come utilizzare MLX con Gemma, consulta il repository ufficiale: