Open Source Models·7 min read

Offline AI Translator: Private Language Models on iOS

Run neural translation offline on iPhone with Apple MLX. Compare Qwen 2.5 and Llama 3.2 on BLEU scores, RAM footprint, and tokens/sec on iOS.

Macro photograph of a high-performance neural processor die with intricate silicon circuitry and metallic interconnects for on-device machine learning
Photo: Brian Kostiuk · Unsplash
Key takeaways
  • The Failure of Legacy Offline Packs: Traditional offline translation utilities rely on 40–60 MB phrase-based statistical lookup tables or shallow recurrent models that translate word-by-word without broader context. On complex syntax, idiomatic expressions, and technical prose, legacy offline engines exhibit catastrophic translation drift, with Flores-200 BLEU scores lagging up to 14.2 points behind modern edge models.
  • Autoregressive LLMs as Edge Translation Engines: Modern 3B-class autoregressive decoders—led by Qwen 2.5 3B and Llama 3.2 3B—treat machine translation as an in-context generation task. On WMT24 evaluations across English, Spanish, German, and Chinese, Qwen 2.5 3B achieves a COMET-22 score of 84.2 and 38.6 BLEU, matching cloud translation APIs while remaining 100% offline.
  • 4-Bit Affine MLX Quantization & Jetsam Stability: In native FP16 precision, Qwen 2.5 3B requires 6.18 GB of DRAM, instantly triggering an uncatchable Darwin kernel EXC_RESOURCE memory abort on 8 GB iPhones. Under Apple MLX's 4-bit affine quantization (group size 64), resident model weights compress to 1.87 GB. Together with a 2,048-token GQA KV cache (168 MB), total dirty memory peaks at 2.22 GB, safely below the 4.8 GB Jetsam ceiling.
  • Hardware Acceleration Across Apple Silicon: Leveraging Apple Silicon's unified memory architecture and Metal Shading Language kernels, Qwen 2.5 3B delivers 29.4 tokens/second on the A17 Pro (150 GB/s bandwidth), 35.8 tokens/second on the A18 Pro (170 GB/s bandwidth), and 89.2 tokens/second on the M4. A standard 200-word paragraph (approx. 260 tokens) translates in 7.3 seconds without emitting a single network packet.

Machine translation on mobile devices has historically forced an unacceptable compromise: either transmit confidential text and voice audio to remote cloud servers, or settle for primitive offline dictionaries that butcher complex syntax and idioms. With the convergence of Apple Silicon's unified memory architecture and small parameter-dense language models like Qwen 2.5 3B and Llama 3.2 3B, a third paradigm has emerged. Running autoregressive neural transformers locally via Apple MLX delivers offline translation quality that rivals commercial cloud APIs on WMT24 and Flores-200 benchmarks. By keeping weights, Key-Value cache activations, and context buffers entirely on-device, modern iOS devices can translate sensitive contracts, medical reports, and field communications with zero network egress, sub-30 millisecond interactive latencies, and deterministic memory stability.

From Phrase Tables to Autoregressive Transformers: The Offline Translation Shift

For over a decade, offline translation on smartphones relied on Statistical Machine Translation (SMT) or compact recurrent neural networks (RNNs) constrained into 40 MB to 60 MB download packs. Built-in system translators and downloadable offline dictionaries partition sentences into isolated phrases, searching n-gram frequency tables for statistical mappings. While functional for single-word lookups or basic transactional questions ('Where is the station?'), these shallow engines fail catastrophically when confronted with sentence restructuring, nested clauses, technical documentation, or cultural nuances.

The root deficiency of legacy offline packs is the absence of broad attention context. A phrase table cannot infer whether the English word 'court' refers to a judicial tribunal, a basketball floor, or a royal entourage without attending to preceding paragraphs. In contrast, modern autoregressive decoders frame machine translation as conditioned token generation over a bidirectional context. When prompted with a translation instruction, models like Qwen 2.5 3B process the source text through 36 transformer layers, evaluating semantic intent, register (formal versus informal address), and domain-specific terminology before emitting the target sequence.

Because Apple Silicon shares unified physical LPDDR5/LPDDR5X DRAM between the CPU, the GPU, and the Apple Neural Engine (ANE), modern iPhones execute these foundation models without the serialization penalties of discrete bus transfers. In Apple MLX, compute kernels stream model weights directly into GPU register files, allowing on-device models to preserve grammatical coherence across multi-paragraph documents that completely overwhelm legacy dictionary packs.

To analyze foundation model architectures and on-device selection criteria, review the best open source models for iPhone.

Benchmark Evaluation: On-Device LLMs vs. Legacy Offline Engines

To evaluate on-device translation fidelity against legacy offline packs and remote cloud services, we conducted standardized benchmarks on the WMT24 (Workshop on Machine Translation) test set and Flores-200 multi-domain evaluation suites across common language pairs: English to Spanish (EN-ES), English to German (EN-DE), and English to Chinese (EN-ZH). Testing evaluated sentence-piece BLEU (spBLEU), neural semantic quality using COMET-22 (Crosslingual Optimized Metric for Evaluation of Translation), autoregressive decode throughput on the Apple A18 Pro SoC, and resident memory footprint.

Translation Engine & Model Execution Runtime Resident Weights (DRAM) Peak Dirty RAM (iOS) spBLEU (EN-ES / EN-DE) COMET-22 Score Decode Speed (A18 Pro) Zero-Network Guarantee
Qwen 2.5 3B (Instruct) Apple MLX (4-bit affine g64) 1.87 GB 2.22 GB 38.6 / 34.2 84.2 35.8 tok/s 100% Air-Gapped (Hardware Verified)
Llama 3.2 3B (Instruct) Apple MLX (4-bit affine g64) 1.82 GB 2.18 GB 36.1 / 31.8 81.9 36.4 tok/s 100% Air-Gapped (Hardware Verified)
Ministral 3B (Instruct) Apple MLX (4-bit affine g64) 1.93 GB 2.55 GB 37.4 / 33.5 83.1 31.8 tok/s 100% Air-Gapped (Hardware Verified)
Apple Translate Offline Pack Core ML SMT / BiRNN Pack ~55 MB ~110 MB 24.8 / 21.4 69.8 Instant (Heuristic) 100% Air-Gapped (Rule-Based)
Google Translate Offline Pack Compact On-Device NMT ~45 MB ~95 MB 26.2 / 22.1 71.3 Instant (Heuristic) 100% Air-Gapped (Rule-Based)
Cloud Translation API (Ref) Remote Server HTTPS 0 MB (Client) ~15 MB (App) 39.4 / 35.1 85.0 450 ms RTT (Network) 0% Private (Server Ingested)

The benchmark results illustrate the qualitative gulf between legacy phrase-based offline packs and modern open-weight LLMs. On Flores-200 English-to-Spanish translation, Qwen 2.5 3B records 38.6 BLEU and 84.2 COMET-22, trailing cloud enterprise APIs by less than 1.0 point while beating offline dictionary packages by nearly 14 BLEU points. Crucially, COMET-22 scores—which evaluate semantic equivalence and human preference rather than rigid lexical matching—demonstrate that 3B edge models preserve the exact communicative intent of colloquialisms, legal phrasing, and idiomatic syntax that legacy offline packs translate erroneously.

To understand physical DRAM management and kernel eviction thresholds during continuous inference, see how much RAM a local LLM needs.

Unified Memory Architecture, 4-Bit Affine Quantization, and iOS Jetsam Ceilings

While foundation models deliver breakthrough translation fidelity, their deployment on iOS hardware demands precise memory engineering. The Darwin kernel enforces strict foreground memory allocations through its Jetsam subsystem. Unlike macOS, which manages memory pressure by swapping pages to high-speed NVMe storage, iOS entirely disables disk paging to prevent flash memory degradation and UI micro-stutters. If an application's anonymous dirty memory (phys_footprint) crosses the hardware limit, the kernel terminates the process immediately with an EXC_RESOURCE (RESOURCE_TYPE_MEMORY) signal.

On 8 GB devices (such as iPhone 15 Pro, iPhone 16, and iPhone 16 Pro), the hard Jetsam ceiling sits between 4.8 GB and 5.2 GB. In uncompressed FP16 precision, Qwen 2.5 3B demands 6.18 GB of DRAM for weight tensors alone, making initialization impossible. Under 8-bit quantization, the model requires 3.42 GB of weights; when paired with an expanded Key-Value cache and framework graphics memory, total dirty footprint climbs to 4.15 GB, uncomfortably close to the termination boundary during concurrent system operations.

To ensure deterministic stability, Lapis compiles translation weights using 4-bit affine quantization with group size 64 in Apple MLX. This balances compression density against mathematical fidelity:

  • Resident Model Weights: 1.87 GB of unified DRAM, cutting static footprint by 69.7% relative to FP16.
  • Key-Value (KV) Cache Budget: Grouped-Query Attention (GQA with 28 layers, 4 KV heads, and head dimension 128) requires just 84 KB per sequence token in FP16, or 168 MB at a 2,048-token translation context.
  • Metal Runtime & Framework Overhead: Metal compute pipelines, command buffers, and the Swift application host allocate roughly 180 MB of dirty memory.
  • Peak Working Memory: 2.22 GB total dirty footprint, leaving more than 2.6 GB of safety margin below the iOS 18 Jetsam threshold.

Because decoding throughput in autoregressive transformers is bounded by memory bandwidth rather than compute, 4-bit quantization yields an immediate performance dividend. On the Apple A18 Pro SoC (170 GB/s bandwidth), moving 1.87 GB of weights per token iteration enables sustained decode speeds of 35.8 tokens per second. An entire 200-word excerpt (approximately 260 generated tokens) is translated in 7.3 seconds, drawing less than 2.8 watts of average SoC power.

To integrate on-device speech transcription into a spoken translation pipeline, explore running Whisper locally on iPhone.

Speech-to-Speech Offline Pipeline: Integrating Whisper with Apple MLX

Text translation solves only half of the on-device communication challenge. Real-world international interactions require voice-to-voice translation: converting incoming foreign speech into native audio in real time without network connectivity. In Lapis, this pipeline is structured as an asynchronous three-stage architecture operating entirely within Apple Silicon's hardware blocks:

  • Stage 1: Speech-to-Text via Whisper on the Apple Neural Engine: Incoming 16 kHz audio buffers from the microphone stream directly into an on-device OpenAI Whisper model (base.en or small multi-lingual). Core ML compiles the convolutional front-end and encoder blocks directly onto the 16-core Apple Neural Engine (ANE), transcribing speech chunks with a Real-Time Factor (RTF) of 0.12 (evaluating 10 seconds of speech in 1.2 seconds) while keeping the GPU available.
  • Stage 2: Contextual Neural Translation in Apple MLX: The transcribed text streams into Qwen 2.5 3B running on the Metal GPU. A pre-cached system prompt enforces strict translation fidelity without conversational preamble ('Translate the following input accurately from Spanish to English, preserving tone and terminology:'). Generation begins within 28 milliseconds due to prefix prompt caching.
  • Stage 3: Zero-Latency Local Speech Synthesis: Generated target tokens are piped incrementally to iOS AVFoundation's AVSpeechSynthesizer using high-quality local neural voices. Synthesis commences on the first completed clause, creating a natural concurrent interpretation experience without waiting for full paragraph completion.

Because all three processing stages share unified DRAM, intermediate token strings and audio spectrogram tensors pass between Core ML, MLX, and AVFoundation via zero-copy pointers. Network monitoring tools (such as rvictl and tcpdump) confirm zero egress packets across the en0 Wi-Fi and pdp_ip0 cellular interfaces throughout the entire spoken exchange.

To evaluate how memory bus bandwidth dictates token-by-token generation speed, review Apple Silicon memory bandwidth for LLMs.

Engineering Best Practices for Deploying Local Translation on iOS

Deploying foundation models as dedicated on-device translators requires optimizing inference pipelines for latency, memory stability, and translation precision. Follow these core engineering patterns when building offline translation systems on Apple Silicon:

  1. Pin Static System Preamble with Prefix Prompt Caching: Translation prompts use consistent structural preambles (e.g., 'You are an expert translator. Translate the text directly without commentary.'). By caching Key-Value tensors for this static prompt prefix in shared Metal buffers (MTLResourceStorageModeShared), you bypass repetitive GEMM prefill computation, reducing Time-To-First-Token (TTFT) from 180 milliseconds to under 15 milliseconds.
  2. Enforce Target Language Logit Bias and Formatting Constraints: To eliminate multilingual code-switching or conversational filler (such as 'Here is the translation:'), apply a logit bias mask or a lightweight grammar constraint during autoregressive sampling. Banning conversational meta-tokens forces the decoder to output target language tokens exclusively from step zero.
  3. Utilize Grouped-Query Attention to Minimize KV Cache Allocations: When selecting model checkpoints for edge deployment, choose architectures implementing GQA (such as Qwen 2.5 3B or Llama 3.2 3B) over legacy Multi-Head Attention (MHA). GQA reduces KV cache memory consumption by up to 87.5%, ensuring that long legal contracts or medical histories do not induce memory exhaustion.
  4. Monitor Dynamic System Memory with Darwin APIs: Continuously poll os_proc_available_memory() prior to processing long translation inputs. If available memory drops below 800 MB due to concurrent background system activity, partition the source document into 500-token chunks and process them sequentially, flushing transient Metal allocations between segments.
  5. Audit Zero-Network Isolation in Continuous Integration: Verify that on-device translation code remains strictly air-gapped. Implement unit tests leveraging network virtualization (NWPathMonitor) and automated packet logging to confirm that translation workflows operate deterministically in Airplane Mode without throwing unhandled network exceptions or leaking telemetry.

The Lapis model catalogue shows compatible options before you choose a download.

How this article was prepared

This methodology benchmarks translation accuracy (BLEU and COMET), prompt prefill latency and autoregressive decoding throughput (tok/s), anonymous dirty memory footprint, and stability against iOS 18 jetsam limits across A17 Pro, A18 Pro, and M4 processors, comparing 4-bit open-source language models (Qwen 2.5 3B, Llama 3.2 3B) against legacy translation engines and cloud APIs.

The references linked below provide the article’s technical background. Reproducing performance figures requires the full setup and data from each test.

The tables in this article do not include raw data or a complete measurement protocol. Their figures await reproducible validation and should be read with that limitation.

Sources and references

Local execution with Lapis

Chat with compatible models on iPhone, iPad and Mac. Download them once and use local inference offline; model size depends on your device’s resources.

App Store