AnyDecisionModel

A Swift package by Mattt for getting typed decisions from a model, such as a probability, a choice or a score, instead of generated text. One interface covers several backends, including MLX, Core AI, Ollama, llama.cpp and Gemini.

View on GitHub ↗
Stars
★ 63
Last commit
25 Nov 2026
Maintenance
Active
Licence
Apache-2.0
Category
On-device AI SDKs · Cloud-capable
GitHub
mattt/AnyDecisionModel

Overview

AnyDecisionModel asks a model a classification-style question and returns a typed answer: the probability of a statement, a choice among options, or a score. The README says each decision is read from the next-token probabilities of the allowed answers, rather than parsed from generated text. The README's example classifies a support ticket by urgency, department and frustration.

One protocol sits in front of several backends. Some run on device and some call out to a local or hosted service. Local backends accept a Calibration setting (a temperature and a bias value) to tune confidence, and the Core AI backend has a prefix caching option. The README includes a Limitations section, which is worth reading before you rely on a score.

AnyDecisionModel is licensed under the Apache License 2.0.

Features

  • Typed results through probability(of:), choice and score, with batch calls.
  • Backends listed in the README: Jev, Ollama, System One, Gemini, MLX (including Liquid d1 and MLX decision heads), Core AI and llama.cpp. MLX, Core AI and llama.cpp are enabled through SwiftPM package traits.
  • A Calibration setting for local backends, and prefix caching on the Core AI backend (in the source and tests).
  • Errors through a DecisionError type. The README describes an unreleased 0.11 in which this becomes a struct and the Jev and Ollama models are deprecated, so check which version you are reading about.

Requirements

  • Swift 6.2 and macOS or iOS 26 or later.
  • A model for the backend you choose. Some backends need a local server or an API key.
  • The latest release is 0.10.0, from 18 Nov 2026, and the README is ahead of it.

Install

  1. Add .package(url: "https://github.com/mattt/AnyDecisionModel.git", from: "0.10.0") to Package.swift, then add the AnyDecisionModel product and any backend traits you need.

Example

Ask a small local model whether a support message is about billing, with a DecisionSession and probability(of:), and route it to the right queue when the probability is high. Or call choice to pick between three categories and act on the winner.

Works with

Not stated by the source

Listed in

Read the code before you install anything. SwiftAgents doesn't review or endorse the tools listed here. Active: a commit in the last 90 days. Slowing: last commit within the past year. Stale: older than a year, or archived.

Report a correction

More in this category