Skip to main content

MagibuMizan

Typed probabilistic decisions from an open language model, without generating an answer string.

MagibuMizan presents a state and a typed question to a model, labels the possible answers A, B, C, …, and reads the next-token probability of each label. It reads every question with the options in normal and reversed order, averages the aligned probabilities, then optionally applies temperature scaling. The response contains a choice, a score, or a yes probability (noul).

The HTTP endpoint uses the request and answer fields of TypeSafe's /v1/systemone API within the limits below. MagibuMizan is an independent open-model implementation, not a TypeSafe or Jev model.

Install

Python 3.10 or newer is required. Install from PyPI:

pip install "magibumizan[mlx,server]"     # Apple Silicon
# or: pip install "magibumizan[cuda,server]" on an NVIDIA host

You can also install directly from this repository:

git clone https://github.com/magibu-ai/MagibuMizan.git
cd MagibuMizan
pip install ".[mlx,server]"     # Apple Silicon
# or: pip install ".[cuda,server]" on an NVIDIA host

The model weights are downloaded separately by the model library. The example Gemma 4 MLX checkpoint is about 15.6 GB. Check the model's own license before using it.

Python API

from magibumizan import MagibuMizan

mizan = MagibuMizan(
    "mlx-community/gemma-4-26B-A4B-it-qat-4bit",
    backend="mlx",
    temperature=2.5,
)
answers, input_tokens = mizan.answer(
    "Siparişim 10 gündür gelmedi, kargo takip numarası da çalışmıyor. Paramı geri istiyorum.",
    {
        "iade": {"type": "noul", "instructions": "Müşteri para iadesi istiyor mu?"},
        "konu": {
            "type": "choice",
            "instructions": "Talebin konusu nedir?",
            "criteria": {
                "kargo": "Teslimat ve kargo",
                "iade": "İade ve para geri ödemesi",
                "urun": "Ürün kusuru",
                "diger": "Diğer",
            },
        },
        "ofke": {
            "type": "score",
            "instructions": "Müşterinin sinirlilik düzeyi?",
            "criteria": ["Sakin", "Tedirgin", "Sinirli", "Çok sinirli"],
        },
    },
)
print(answers)

One local M2 Pro run of this example used 690 input tokens and took about 1.6 seconds after loading the model. The output selected iade, estimated noul=0.9974 for the refund request, and gave the frustration rubric a score of 2.444. Results and latency depend on the model and hardware.

noul may include optional criteria with true and false descriptions. choice takes 2–26 keyed options. score takes 2–10 ordered levels. state, instructions, and descriptions can be strings or JSON objects/arrays. Returned probabilities are unrounded and sum to approximately 1; confidence and score are rounded to four decimals.

HTTP API

MODEL=mlx-community/gemma-4-26B-A4B-it-qat-4bit \
TEMPERATURE=2.5 \
API_KEY=replace-with-a-secret \
uvicorn magibumizan.api:app --host 127.0.0.1 --port 8000
curl http://127.0.0.1:8000/v1/systemone \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer replace-with-a-secret' \
  -d '{"model":"jev-latest","state":"Hesabıma giremiyorum","questions":{"urgent":{"type":"noul","instructions":"Acil mi?"}}}'

MODEL selects the server's local model. A request's model field is accepted for client compatibility but does not change that selection. API_KEY is optional; set it before exposing the service. BACKEND overrides automatic selection (mlx on macOS, cuda elsewhere). MAX_QUESTIONS defaults to 10. GET /health reports readiness. MLX inference is processed serially in the server process.

The endpoint returns 401 for a missing or invalid API key, 422 for an invalid request, and 503 when local model inference fails. The server logs the underlying inference error.

Calibration and evaluation

temperature must be positive. The default 1.0 leaves the averaged distribution unscaled. 2.5 above is an estimate fitted to a Turkish MMLU subset with this 4-bit Gemma checkpoint; it is not a universal confidence guarantee. Fit and check a temperature on held-out examples from your own task before using probabilities to automate consequential decisions.

See BENCHMARKS.md for the evaluation method, model-specific accuracy, calibration results, dataset links, and limits of the comparisons.

Limits

  • The Turkish prompt and the listed temperature values were evaluated on Turkish tasks. Other languages and domains need their own evaluation.
  • Choice supports at most 26 options because labels are single letters. The TypeSafe API allows more.
  • Each question uses two model reads. The implementation does not share the state prefix between questions.
  • The CUDA path is experimental until an end-to-end NVIDIA smoke test is recorded for this release.
  • The package produces distributions over the supplied options; it cannot discover an omitted answer. Add an other or none option where appropriate.

Development

pip install ".[server,test]"
python -m unittest discover -s tests -v

MIT licensed. MagibuMizan is not affiliated with TypeSafe AI.

Release files for magibumizan 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for magibumizan 0.1.2
File Size Uploaded
magibumizan-0.1.2.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for magibumizan 0.1.2
File Interpreter ABI Platform
magibumizan-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 24.0 kB

Release files / magibumizan-0.1.2.tar.gz

Download URL magibumizan-0.1.2.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
424cb737676c23f6a0f21a5b4daeea03d4a55ce8592e46f32b97130bd43fe8f6
BLAKE2b-256 checksum
How to use checksums
0bb0c4067f7211c119b6237585fbd50ad9af1240759a1b42cec3d3b22483d255
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / magibumizan-0.1.2-py3-none-any.whl

Download URL magibumizan-0.1.2-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5660b224339197cca96232a6611dc91eaf6a21ad048bc7007f920dfff722e761
BLAKE2b-256 checksum
How to use checksums
a23bb6aece268af94c12fe1423cf14fc273faf4c2ae41a084ff562a173d6bb88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page