Instructions to use Kris0404/social-story-gemma4-e2b-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use Kris0404/social-story-gemma4-e2b-v3 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("Kris0404/social-story-gemma4-e2b-v3") 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 Kris0404/social-story-gemma4-e2b-v3 with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Kris0404/social-story-gemma4-e2b-v3"
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": "Kris0404/social-story-gemma4-e2b-v3" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use Kris0404/social-story-gemma4-e2b-v3 with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "Kris0404/social-story-gemma4-e2b-v3"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "Kris0404/social-story-gemma4-e2b-v3" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Kris0404/social-story-gemma4-e2b-v3", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use Kris0404/social-story-gemma4-e2b-v3 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 "Kris0404/social-story-gemma4-e2b-v3"
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 Kris0404/social-story-gemma4-e2b-v3
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use Kris0404/social-story-gemma4-e2b-v3 with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "Kris0404/social-story-gemma4-e2b-v3"
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 "Kris0404/social-story-gemma4-e2b-v3" \ --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"
social-story-gemma4-e2b-v3
LoRA fine-tune of mlx-community/Gemma4-E2B-IT-Text-int4 (text-only Gemma 4 E2B Instruct, 4-bit) trained to generate Carol-Gray-style social stories for autistic children. Fused, then quantized for both Python (mlx-lm) and Swift (mlx-swift-lm) on-device deployment.
Use case
Drop-in on-device text generation backend for the Mystoria iOS/iPadOS app (formerly Social Story Studio). Pairs with the v2-era prompt template — same system message and 8-rule user prompt — and emits valid JSON {title, pages: [{text, order}]}.
Training
- Base:
mlx-community/Gemma4-E2B-IT-Text-int4(Gemma 4 E2B Instruct, text-only, 4-bit) - Method: LoRA via
mlx_lm.lora - Hyperparameters: rank 8, scale 16, num_layers 26, lr 1e-5, batch 1 + grad-accum 4, max_seq 1024
- Iters: 2500
- Dataset: ~1,720 train / 152 valid / 153 test social stories generated and filtered to first-person, qualifier-rich, tentative-directive Carol Gray voice (10.2 / 10.4 methodology)
Eval (20-prompt grid: 5 ages × 4 topics)
| Metric | Rate |
|---|---|
| JSON valid | 100% |
| Schema correct (text/order) | 100% |
| Tier-1 Carol Gray pass | 70% |
| Descriptive:coaching ≥ 2:1 | 80% |
| Test loss | 0.447 (ppl 1.563) |
The 30% Tier-1 misses are all driven by the descriptive:coaching ratio on coaching-heavy topics (e.g. "making a new friend"). Every other sub-check (first-person, forbidden phrases, qualifiers, no-figurative-language, structure, positive framing, reading level, no-page-dupes) passes 100%.
Quantization (mixed precision for Swift compatibility)
Most weights are 4-bit (group_size=64, ~4.5 bits/weight). The per_layer_model_projection layer is kept in float16 because mlx-swift-lm 3.31.3's Gemma4Text.ScaledLinear is a plain Module and cannot dequantize at load time (the loader sees the packed (8960, 192) uint32 shape and rejects). Keeping that one layer in fp16 adds ~25 MB but lets the model load on iOS without a Swift-side patch.
Deployment
- Final size: ~2.5 GB on disk
- Loads via standard
mlx_lm.load(Python) andmlx-swift-lm≥ 3.31.3 (Swift) — both work without thesanitizepatch the originalmlx-community/Gemma4-*-Text-int4checkpoints needed - iOS users: clear any prior cache from a broken v3 download before loading this revision
Limitations
- The descriptive:coaching ratio fails on topics where every "I can try to..." sentence reads as coaching. Future work: more descriptive-first training data for action-oriented topics.
- On-device generation is text-only. Image generation in the app continues to run cloud-only.
- Downloads last month
- 22
4-bit