AnyDecisionModel
A Swift package that returns typed probabilities, choices, and ordinal scores from language models, with local and API backends.
At a Glance
Swift package for typed decisions (probabilities, choices, scores) licensed under Apache License 2.0.
Engagement
Available On
Alternatives
Listed Nov 2026
About AnyDecisionModel
AnyDecisionModel is an open-source Swift package by mattt for getting typed decisions from language models: yes-or-no probabilities, choices among options, and scores on ordinal scales. Its API follows the model-and-session pattern of Apple's Foundation Models framework and AnyLanguageModel. The latest release listed is 0.7.0, under the Apache 2.0 license.
What It Is
AnyDecisionModel is a Swift library for asking questions about a piece of text or JSON state and receiving structured answers instead of free text. A DecisionSession holds one immutable state, and each question is independent of the others. Binary questions return a Double probability. Choice questions return a Choice with a value, a probability for each option, and a confidence value. Score questions return a Score with the expected level, per-level probabilities, and a confidence value.
Choices can be defined by conforming an enum to Choosable, optionally with option descriptions that tell the model when to select each one. Options can also be supplied at run time. Several questions can be sent in one batch call, which also returns token usage and local diagnostics.
Backends
Six backends are documented:
- MLX runs a small language model on Apple silicon and reads each decision from next-token probabilities in one forward pass.
- MLX decision heads run models with a trained decision head, such as Cloudflare's Clef.
- Core AI runs a Core AI model on macOS 27 and iOS 27.
- llama.cpp runs a GGUF model.
- Jev calls TypeSafe's Jev through the System One API, or any server implementing it.
- Ollama calls a System One model locally or in Ollama's cloud.
Without traits the package has no third-party dependencies and provides the core types plus the Jev and Ollama backends. The MLX, CoreAI, and Llama traits enable the local backends.
Calibration and confidence
Local backends accept a Calibration that applies a temperature to all answers and a bias to binary answers. Local confidence is the normalized complement of the entropy of the answer probabilities, which measures how concentrated the distribution is rather than whether the answer is correct. The MLX backend offers rotation debiasing to reduce position bias in choices, and optional prefix caching. Diagnostics report the share of next-token probability that fell on the answer labels.
Documented limitations
The README states that Jev and Ollama wire compatibility is tested against fixtures rather than live services, that calibration was fitted on two tasks with unknown transfer, and that typed output alone should not be relied on to resist injected instructions.
Community Discussions
Be the first to start a conversation about AnyDecisionModel
Share your experience with AnyDecisionModel, ask questions, or help others learn from your insights.
Pricing
Open Source
Swift package for typed decisions (probabilities, choices, scores) licensed under Apache License 2.0.
- Apache License 2.0 (OSI-approved)
- Core types plus Jev and Ollama backends without third-party dependencies
- Optional MLX, CoreAI and Llama traits for local backends
- Third-party services such as the Jev/System One API or Ollama cloud are separate external offerings
Capabilities
Key Features
- Typed binary probabilities, choices, and ordinal scores
- Model-and-session API patterned on Apple's Foundation Models framework
- Choosable enums with option descriptions
- Batch decisions in a single call with usage and diagnostics
- Six backends: MLX, MLX decision heads, Core AI, llama.cpp, Jev, Ollama
- Rotation debiasing for choice position bias
- Optional prefix caching
- Configurable calibration with temperature and binary bias
- Entropy-based confidence values and allowed-answer mass diagnostics
- Text and JSON session states
