Executar o Gemma com o MLX

O MLX é uma estrutura de matriz para machine learning em silício da Apple.

Início rápido

Instalar no índice de pacotes do Python (PyPI)

pip install mlx mlx-lm mlx-vlm

Exemplo de comando:

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

Você pode iniciar o servidor com:

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

Isso cria um servidor que permite acessar o modelo com o endpoint compatível com a OpenAI (http://localhost:8080/v1).

Para mais informações e instruções sobre como usar o MLX com o Gemma, consulte o repositório oficial: