Back to directory

swift-litert-lm

A Swift package that runs Google's Gemma 4 model on iPhone through the LiteRT-LM runtime on the Metal GPU, with text, image and audio input, and a second mode that plugs the same runtime into Apple's Foundation Models API as a custom backend.

swift-litert-lm

swift-litert-lm puts two interfaces on top of Google's official LiteRT-LM runtime. Its "easy mode" is a single LiteRTChat(.gemma4_E2B) call that downloads the model on first run and streams a Gemma 4 chat response token by token on the Metal GPU, measured at roughly 50 tokens per second on an iPhone 17 Pro.

Its "FM mode" instead exposes LiteRTLanguageModel as a backend for Apple's Foundation Models API, introduced in iOS 27 to accept third-party models conforming to its LanguageModel protocol; through a LanguageModelSession, it supports the same respond/streamResponse calls, @Generable guided generation, and tool calling as Apple's own on-device and Private Cloud Compute models, along with image, audio and video understanding that Apple's system model does not offer.

It installs as a single Swift Package Manager dependency and requires no other setup beyond adding the package and calling one of these two entry points.

More in Inference

See all 770
  • OpenDecision

    deepanwadhwa.github.io

    An open-source Python package that answers typed questions about application state or documents using a local natural-language-inference model, returning structured choice, score, yes/no or evidence-relation values instead of free text.

  • Lifeboat

    iterate.ai

    A local inference server that puts an OpenAI- and Anthropic-compatible API in front of open-weight language models running on hardware you control, from a laptop to a GPU cluster.

  • Claude S40

    github.com

    An unofficial Claude chat client for 2007-era Nokia Series 40 phones, built as a Java ME app plus a small Go relay server, with web search, reading mode and saved chats.