Exécuter Gemma avec MLX

MLX est un framework de tableaux pour le machine learning sur les processeurs Apple.

Démarrage rapide

Installer à partir de l'index de packages Python (PyPI)

pip install mlx mlx-lm mlx-vlm

Exemple de commande :

# 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>

Vous pouvez démarrer le serveur avec :

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

Cela crée un serveur qui vous permet d'accéder à votre modèle avec le point de terminaison compatible avec OpenAI (http://localhost:8080/v1).

Pour obtenir plus d'informations et savoir comment utiliser MLX avec Gemma, consultez le dépôt officiel :