Instructions to use UIDUser-NSB/Gemma4-E4B-Text-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use UIDUser-NSB/Gemma4-E4B-Text-MLX with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("UIDUser-NSB/Gemma4-E4B-Text-MLX") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use UIDUser-NSB/Gemma4-E4B-Text-MLX with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "UIDUser-NSB/Gemma4-E4B-Text-MLX"
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": "UIDUser-NSB/Gemma4-E4B-Text-MLX" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use UIDUser-NSB/Gemma4-E4B-Text-MLX with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "UIDUser-NSB/Gemma4-E4B-Text-MLX"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "UIDUser-NSB/Gemma4-E4B-Text-MLX" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UIDUser-NSB/Gemma4-E4B-Text-MLX", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use UIDUser-NSB/Gemma4-E4B-Text-MLX 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 "UIDUser-NSB/Gemma4-E4B-Text-MLX"
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 UIDUser-NSB/Gemma4-E4B-Text-MLX
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use UIDUser-NSB/Gemma4-E4B-Text-MLX with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "UIDUser-NSB/Gemma4-E4B-Text-MLX"
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 "UIDUser-NSB/Gemma4-E4B-Text-MLX" \ --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"
Configuration Parsing Warning:In config.json: "num_experts" must be a number
Gemma 4 E4B Text for MLX (4-bit)
google/gemma-4-E4B-it as a text-only model for Apple's MLX, compressed to 4 bits. It runs on device on Apple silicon: Mac, and iPhone or iPad with 8 GB of memory.
Gemma 4 E4B can also read images and audio. This version keeps only the language model, so it is 4.2 GB instead of 5.2 GB and writes exactly the same text.
All credit for the model goes to Google. This repository only changes its file format.
At a glance
| Detail | Value |
|---|---|
| Base model | google/gemma-4-E4B-it (instruction-tuned) |
| Input and output | Text only |
| Version | 4-bit: weights compressed from 16 to 4 bits (affine, groups of 64) |
| Size | 4.2 GB (the multimodal 4-bit MLX version is 5.2 GB) |
| Model type | gemma4_text |
| Runtime | mlx-lm (Python) or mlx-swift-lm |
| License | Apache 2.0, the same as the original model |
Usage
pip install -U mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("UIDUser-NSB/Gemma4-E4B-Text-MLX")
messages = [{"role": "user", "content": "Summarize this meeting in three points: ..."}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False, enable_thinking=False)
print(generate(model, tokenizer, prompt=prompt, max_tokens=512))
Pass enable_thinking=False for a direct answer. Without it, Gemma 4 writes its reasoning first.
Check
With greedy decoding, this model and mlx-community/gemma-4-e4b-it-4bit (the multimodal version) write the same text for the same prompt.
How it was converted
- Source: google/gemma-4-E4B-it, revision
ee0ef6023621cff504d758262d4e04895a5af4a2. - Text only: the language model's weights are kept and renamed from
model.language_model.*tomodel.*. The vision and audio encoders and their embedders are removed. - Config:
model_typeisgemma4_text. The text model's settings (text_config) are also written at the top level, where mlx-lm and mlx-swift-lm read them for this model type. - Compression:
python -m mlx_lm convert -q --q-bits 4 --q-group-size 64with mlx-lm 0.32.0.
Credits
Gemma 4 by Google DeepMind. See the original model card for training data, evaluations, intended use and limitations.
- Downloads last month
- -
4-bit