Text Generation
MLX
Safetensors
English
Arabic
Central Kurdish
gemma4_text
gemma4
text-only
4-bit precision
conversational
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"
|
Download README.md from UIDUser-NSB/Gemma4-E4B-Text-MLX: direct link, hf CLI and curl.
- Browser
- Download file 2.7 kB
-
https://huggingface.co/UIDUser-NSB/Gemma4-E4B-Text-MLX/resolve/main/README.md
- Command line
-
hf download hf://UIDUser-NSB/Gemma4-E4B-Text-MLX/README.md
-
curl -L -o README.md https://huggingface.co/UIDUser-NSB/Gemma4-E4B-Text-MLX/resolve/main/README.md
2.7 kB
| license: apache-2.0 | |
| library_name: mlx | |
| pipeline_tag: text-generation | |
| base_model: | |
| - google/gemma-4-E4B-it | |
| tags: | |
| - mlx | |
| - gemma4 | |
| - text-only | |
| - 4-bit | |
| language: | |
| - en | |
| - ar | |
| - ckb | |
| # Gemma 4 E4B Text for MLX (4-bit) | |
| [google/gemma-4-E4B-it](https://huggingface.co/google/gemma-4-E4B-it) as a **text-only** model for Apple's [MLX](https://github.com/ml-explore/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](https://github.com/ml-explore/mlx-lm) (Python) or [mlx-swift-lm](https://github.com/ml-explore/mlx-swift-lm) | | |
| | License | Apache 2.0, the same as the original model | | |
| ## Usage | |
| ```bash | |
| pip install -U mlx-lm | |
| ``` | |
| ```python | |
| 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](https://huggingface.co/mlx-community/gemma-4-e4b-it-4bit) (the multimodal version) write the same text for the same prompt. | |
| ## How it was converted | |
| 1. **Source:** google/gemma-4-E4B-it, revision `ee0ef6023621cff504d758262d4e04895a5af4a2`. | |
| 2. **Text only:** the language model's weights are kept and renamed from `model.language_model.*` to `model.*`. The vision and audio encoders and their embedders are removed. | |
| 3. **Config:** `model_type` is `gemma4_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. | |
| 4. **Compression:** `python -m mlx_lm convert -q --q-bits 4 --q-group-size 64` with mlx-lm 0.32.0. | |
| ## Credits | |
| Gemma 4 by Google DeepMind. See the [original model card](https://huggingface.co/google/gemma-4-E4B-it) for training data, evaluations, intended use and limitations. | |