Skip to content

jskoiz/yemma

Repository files navigation

Yemma 4 logo

yemma.chat

MIT License iOS 17+ Xcode 26+ On-device inference Apple and Gemma 4 runtimes

AI that lives on your iPhone.
Good for notes, writing, questions, and image help. Private by design, on device, and honest about what local AI does best.

What it's good for · Screenshots · Structure · Runtime Selection · Optional Gemma Bundle · Build

This repo contains the iOS app, landing page, and brand assets.

On eligible iPhones running iOS 26 or newer with Apple Intelligence available, Yemma uses SystemLanguageModel.default for zero-download text chat. Gemma 4 is an explicit optional 4.2 GB download for text and image chat, and the local choice for older or Apple Intelligence-ineligible devices. Yemma never downloads Gemma automatically. There is no cloud inference, no account, and no telemetry.

What it's good for

  • Quick rewrites and everyday writing help
  • Personal notes and thinking out loud
  • Everyday questions answered on-device
  • Image explanations and visual help
  • Offline use — planes, commutes, anywhere without signal
  • Low-friction, no-account AI when you just need a hand

Yemma is not trying to replace frontier cloud models. Where you need deep reasoning, broad world knowledge, or giant workflows, cloud AI is still better. Where you want something local, private, and always available, Yemma is a good fit.

Features

  • Streaming chat with markdown rendering, image attachments, and conversation history
  • Zero-download text chat through Apple Foundation Models on eligible iOS 26+ Apple Intelligence devices
  • Explicit optional Gemma 4 download (~4.2 GB) for text and image inference via MLXVLM
  • Resumable background Gemma download and strict local bundle validation
  • Configurable response style, temperature, and response limits
  • Light / Dark / System appearance modes
  • Built-in diagnostics, debug probes, and simulator mock mode

Screenshots

Advanced settings for inference tuning Debug scenarios for markdown and formatting tests Diagnostics event log and runtime details
Advanced controls
Temperature, context window, flash attention, response length.
Debug probes
Markdown and renderer test scenarios.
Diagnostics
Event log, copyable logs, runtime metadata.

Structure

  • ContentView.swift — root state machine (onboarding vs chat)
  • LLMService.swift — runtime selection, generation, streaming, and MLX lifecycle
  • AppleFoundationModelRuntime.swift — iOS 26 availability, Apple transcript shaping, and snapshot streaming
  • MLXModelSupport.swift — model directory validation and Gemma 4 asset contract checks
  • ModelDownloader.swift — optional Gemma download, resume, cleanup, and local validation
  • ConversationStore.swift — chat history persistence
  • ChatMessage.swift — app-owned message, user, and attachment value types
  • YemmaPromptPlanner.swift — prompt shaping for the chat experience
  • Gemma4SmokeAutomation.swift — smoke checks for the shipped model path
  • ChatSidebarView.swift / AdvancedSettingsView.swift — preferences, runtime tuning, diagnostics, and debug probes
  • DebugInferenceScenario.swift — debug prompt and renderer scenarios
  • Appearance.swift — theme system
  • website/ — landing page and brand assets

Runtime Selection

  • Simulator: deterministic mock replies; neither real runtime is invoked.
  • Eligible iOS 26+ Apple Intelligence device: Apple Foundation Models is the zero-download initial runtime for text chat.
  • iOS 17-25 or Apple Intelligence-ineligible device: Gemma 4 is the initial runtime choice, but its 4.2 GB download begins only when the user starts setup.
  • Images: choose the optional Gemma 4 runtime. Yemma's Apple runtime is text-only.
  • Apple Intelligence off, model not ready, or unsupported language: Yemma explains the unavailable state and lets the user enable Apple Intelligence or explicitly choose Gemma.

Both runtimes operate on device. Real inference requires a physical iPhone; Simulator builds keep using mock replies.

Gemma 4 MLX Port

Yemma originally ran Gemma 4 through two separate GGUF assets: a text model plus a standalone mmproj vision projector. The current MLX integration replaces that with one Swift-native multimodal bundle and one runtime container.

The important distinction is that MLX Swift already provided the general model-loading, tokenizer, and VLM infrastructure. The missing work was Gemma 4 support on the Swift side, plus Yemma-specific integration around download, validation, prompt shaping, and runtime lifecycle.

Validated upstream baseline:

  • mlx-swift-lm at 3.31.3 for Gemma 4 model, processor, and parity fixes
  • mlx-swift-examples at 31b6cf6 for app-side smoke validation and request-shaping patterns

How the optional Gemma integration works:

  • Yemma4.xcodeproj declares MLX, MLXLMCommon, MLXVLM, Hub, and Tokenizers, so the runtime stays inside Swift instead of bridging through llama.cpp or Objective-C++ vision code.
  • After the user selects Gemma and starts setup, ModelDownloader pulls mlx-community/gemma-4-e2b-it-4bit using *.safetensors, *.json, and *.jinja patterns instead of downloading a text GGUF and a second mmproj file.
  • ModelDirectoryValidator proves the downloaded bundle is structurally usable by checking required metadata files, processor config, tokenizer files, weight shards, and safetensors index references before the app accepts setup as complete.
  • Gemma4MLXSupport enforces the Gemma 4 multimodal asset contract in Swift by cross-checking processor and model values like soft-token budgets, patch size, and pooling kernel size. It also normalizes a known compatibility gap when a bundle is missing a top-level pad_token_id.
  • LLMService converts each conversation turn into structured Chat.Message and UserInput values with optional image URLs, then calls context.processor.prepare(input:) so MLX performs the image and text preprocessing directly inside the same runtime path as inference.
  • The current implementation uses VLMModelFactory.shared._load(...) to load the entire Gemma 4 VLM from one local directory, so text generation and image understanding live in one ModelContainer instead of separate GGUF and projector runtimes.
  • Yemma still adds app-side stability logic around the MLX runtime, including prompt shaping, smoke checks, and output filtering for noisy hidden-channel and control-token responses.

What that buys us:

  • no standalone mmproj download
  • no Objective-C++ multimodal bridge
  • one optional model bundle to download, validate, load, unload, and delete
  • one Swift runtime path for both text-only and image-assisted turns

Optional Gemma 4 Bundle

  • Download source: mlx-community/gemma-4-e2b-it-4bit
  • Approximate first-download size: 4.2 GB
  • Downloaded file classes: safetensors weights, tokenizer/config JSON, processor config, and chat template files
  • Runtime contract: config.json, tokenizer.json, tokenizer_config.json, processor_config.json or preprocessor_config.json, plus one or more readable .safetensors weight files and any referenced safetensors index entries

Yemma does not download this bundle automatically. After the user chooses Gemma and completes setup, Yemma can load, unload, and run it entirely on device.

Build

  1. Open Yemma4.xcodeproj; it is the sole build graph and owns the pinned SwiftPM dependencies.
  2. Use Xcode 26 or newer with an iOS 26 SDK. The deployment target remains iOS 17 and the app and test targets currently compile in Swift 5 language mode.
  3. Run ./scripts/local_validation.sh for simulator tests plus an unsigned Release compile for a generic iOS device.
  4. Run on a physical iPhone for real Apple Foundation Models or Gemma inference.
  5. Use ./scripts/sim_run.sh only when you also want to install and launch the mocked simulator app.
  6. Use ./scripts/device_startup_probe.sh when you need a clean first-launch timing probe on an already installed device build.

Lint (optional, not a build dependency): with SwiftLint installed, run swiftlint lint --config .swiftlint.yml --quiet.

Release

App Store Connect deployment via asc-cli.

License

MIT. See LICENSE.

About

Gemma 4 right on your iPhone.

Resources

License

Stars

4 stars

Watchers

1 watching

Forks

Contributors