Kettei takes the same decide call as OneHot, model included, and gives the answer in the same shape. You need no API key, your requests stay on the Mac, and each call is free.
ippon, Sqwish’s open-source runtime for decision models, runs the model on the Mac’s GPU. The client installs it for you.
What you need
- A Mac with Apple silicon (M1 or later).
- Python 3.11 or newer, running natively on Apple silicon. A Python that runs under Rosetta can’t use the GPU. To check, run
python3 -c "import platform; print(platform.machine())". It printsarm64when Python runs natively. - Space on disk and in memory for the model. ippon’s models table gives the size of each model and precision.
Install
mac extra installs ippon and MLX, Apple’s array library, beside the client. On other computers the extra installs nothing more. To run Kettei on Linux or Windows, see Linux and Windows.
Make a first call
This loads Kettei Core, asks one yes-or-no question and prints the probability of yes.with block frees the model’s memory at its end. Without with, call kettei.close().
The decisions take the same kinds and fields as on the API. Decision types and Write decisions explain them.
Choose Kettei Core or Kettei Dot
- Use Kettei Core for the best answers. It is the model that the API answers with when a request names no
model. - Use Kettei Dot when speed or memory counts most. It is smaller and faster than Kettei Core.
Kettei() with no name loads Kettei Dot. ippon’s benchmarks give the time of a call on each model.
Choose a precision
precision sets how the model is stored and computed in memory.
A name with
:q8, such as Kettei("kettei-core:q8"), does the same as precision="q8". Use 8-bit weights when the model does not fit your Mac’s memory. Their probabilities are further from the creators’ reference, past ippon’s bound on some requests, such as Kettei Core’s questions with the most options. The top answer stayed the same in every request ippon checked.
ippon checks each model against its creators’ code. ippon’s accuracy page gives how closely the probabilities match at each precision.
Move between your Mac and the API
Kettei and OneHot take the same request and give the answer in the same shape, so one piece of code can use either. This example uses the Mac when SQWISH_LOCAL is set, and the API when it is not.
Kettei takes model too, so shared code can keep it. A Kettei answers only for the model that it loaded. It refuses the other Kettei size with invalid_request, and a name that it does not run with not_found, such as a typo, kettei-chub or kettei-fat.
The answer’s model is the name that the API uses, such as kettei-core.
The API may apply a default temperature, and its answer’s temperature names it. A model on your Mac applies none unless the request gives one. To get comparable probabilities in both places, send the same temperature in each request. Temperature explains it.
Share one model
OneKettei can be shared by the threads of a program, and it answers their calls one at a time.
To serve many callers at once, or callers in other programs and languages, run the model as a local server. The ippon command installs with the client.
http://127.0.0.1:8000/v1/decide, with no key.
Licences
The weights download under the Kettei Community Model License. When you download or use the model, you accept that licence. Nothing asks you to confirm it, so scripts and agents never wait for input.Errors
A refused request or a model that can’t run raisesKetteiError, with a code and a message. Where the API refuses the same request, the code is the API’s code.
When ippon is not installed, loading a model raises
ImportError with the command to install it.
Linux and Windows
On Linux and Windows,Kettei runs Kettei Core and Kettei Dot with PyTorch, on an NVIDIA GPU when the computer has one.
device chooses where the model runs. "auto" (the default) uses CUDA when it is available and the CPU when it is not. "cpu", "cuda" and "cuda:N" ask for one. PyTorch runs the weights as published, so precision and the :q8 names are for Macs only. On a Mac, device takes "auto" or "mlx".