Instructions to use netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit with MLX:
# Make sure mlx-vlm is installed # pip install --upgrade mlx-vlm from mlx_vlm import load, generate from mlx_vlm.prompt_utils import apply_chat_template from mlx_vlm.utils import load_config # Load the model model, processor = load("netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit") config = load_config("netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit") # Prepare input image = ["http://images.cocodataset.org/val2017/000000039769.jpg"] prompt = "Describe this image." # Apply chat template formatted_prompt = apply_chat_template( processor, config, prompt, num_images=1 ) # Generate output output = generate(model, processor, formatted_prompt, image) print(output) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent
How to use netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
gemma-4-31B-it-LayerFit-MLX-2.5bit
google/gemma-4-31B-it, Google's 31B dense model with image input, for Apple Silicon, built with LayerFitβ’: a per-layer search that spends the bits where the model needs them most. 14.1 GB on disk, text and image input.
| Build | Size | Suggested Mac memory |
|---|---|---|
| netprojects/gemma-4-31B-it-LayerFit-MLX-4bit | 18.4 GB | 24 GB (tight) or 32 GB |
| netprojects/gemma-4-31B-it-LayerFit-MLX-3bit | 14.6 GB | 24 GB |
| netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit (this build) | 14.1 GB | 16 GB (tight) or 24 GB |
LayerFit: same size, closer to the original
A standard quant gives every layer the same bits. LayerFit measures how much each part of the model suffers at low bits (attention, the experts and MLP of every layer, the embeddings), then fills the same size budget where it helps most. After the search, the scales were polished by distillation from bf16 (DWQ, same bits and format).
| Build (same test: chat replies, our harness) | Text weights* | Top-1 vs bf16 | Error (KL) | GSM8K |
|---|---|---|---|---|
| LayerFit 2.5-bit (this build) | 12.9 GB | 87.1% | 0.3219 | 20/20 |
| Standard 2.5-bit (same bits everywhere, same size) | 12.9 GB | 77.5% | 0.9041 | 20/20 |
| unsloth/gemma-4-31b-it-UD-MLX-3bit | 19.5 GB | 90.6% | 0.1851 | 20/20 |
*Text weights = language-model weights, the same measure for every row. The download is larger because it also holds the bf16 vision tower and embeddings.
Held-out check on text the search and tuning never saw (real chat replies from ultrachat test_sft, GSM8K items 20-69):
| Held-out test (new chats + GSM8K 50) | Text weights* | Top-1 vs bf16 | Error (KL) | GSM8K |
|---|---|---|---|---|
| LayerFit 2.5-bit (this build) | 12.9 GB | 87.8% | 0.1728 | 47/50 |
| unsloth/gemma-4-31b-it-UD-MLX-3bit | 19.5 GB | 91.5% | 0.0801 | 47/50 |
| bf16 original (reference) | 100% | 0 | 47/50 |
*Text weights = language-model weights, the same measure for every row. The download is larger because it also holds the bf16 vision tower and embeddings.
Our harness: language-model weights against our bf16 MLX conversion, chat-template text, top-1 agreement and KL on the reply tokens,
GSM8K with thinking off. Public builds were scored on the same tokens. The exact recipe is in layerfit-recipe.json.
Measured on a MacBook Pro M5 Max, 29 November 2026.
Use
pip install -U mlx-vlm
python -m mlx_vlm.generate --model netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit --max-tokens 2048 \
--prompt "Write a Python function that checks if a string is a palindrome."
OpenAI-compatible server:
python -m mlx_vlm.server --model netprojects/gemma-4-31B-it-LayerFit-MLX-2.5bit --port 8080
- Images: add
--image path/to/file.pngtomlx_vlm.generate. - See the original card for thinking mode, sampling settings and the published benchmark scores.
Tested with mlx-vlm 0.7.11 on a MacBook Pro M5 Max.
Licence
Apache-2.0, as google/gemma-4-31B-it. LICENSE is the licence text; NOTICE describes the conversion.
Built by Paris Michalas, NetProjects. LayerFitβ’ is a NetProjects trademark. Not affiliated with Google.
- Downloads last month
- 6
Quantized