ONNX CPU
Uses onnxruntime and provides the portable fallback for ONNX checkpoints.
A common Python runtime for Laya checkpoints using ONNX Runtime on Windows, Linux, and macOS, with an MLX backend for supported Apple Silicon systems.
Backend selection considers both the providers available on the machine and the weight format present in the checkpoint directory.
Uses onnxruntime and provides the portable fallback for ONNX checkpoints.
Uses onnxruntime-gpu when the CUDA execution provider is available.
Uses onnxruntime-directml and selects the DirectML provider when present.
Loads compatible model.safetensors checkpoints through MLX on supported systems.
The ONNX CPU, CUDA, and DirectML packages are alternative distributions. Choose the one appropriate to the environment rather than installing them together.
python -m pip install ".[cpu]"
python -m pip install ".[gpu-cuda]"
python -m pip install ".[gpu-directml]"
python -m pip install ".[mlx]"
git clone https://github.com/abusuraihsakhri/laya-universal.git
cd laya-universal
python -m pip install ".[cpu]"
Point the runtime at a compatible local checkpoint or a supported Hugging Face model repository, then submit typed question definitions.
import laya_universal as laya
questions = {
"department": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {
"billing": "invoices, charges, refunds",
"technical": "bugs, outages, integrations",
"sales": "pricing, plans, purchases",
},
}
}
agent = laya.load("./laya-onnx")
result = agent.predict("I was charged twice.", questions)
print(result["answers"]["department"])
These constraints come from the current source implementation and should be considered when integrating the package.
model.safetensors; incompatible formats are rejected with an explicit error.
encoder.onnx when present. Otherwise provide a separate embedding function or re-export the checkpoint.
python -m pip install -e ".[cpu,dev]",
then run python -m pip check,
python -m ruff check laya_universal tests, python -m pytest -v,
and python -m build.