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 when the first release is available:

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.

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.0

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.0
File Size Uploaded
magibumizan-0.1.0.tar.gz 13.0 kB Details

Built distribution (wheel)

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

Total release size: 22.6 kB

Release files / magibumizan-0.1.0.tar.gz

Download URL magibumizan-0.1.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4fea49ed656780e4af7c934414c076896477b7cdb5ade4e7d7a2f271724be1e7
BLAKE2b-256 checksum
How to use checksums
a8ed720c8dadb118ab8462c65624436ef738ae2b5208d28c87912e8b4946660a
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.0-py3-none-any.whl

Download URL magibumizan-0.1.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ed092274377656127939007c5e143b1af661dd8997fc85d559e7065214ec356
BLAKE2b-256 checksum
How to use checksums
4ae2f15d49884dface401ad186d2fa1fc195bc5aabb2f943fc0ec09da3861fe3
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

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

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