Run any model,on any backend

Open original

ZeroModels is a library that ports 100+ model families to pure Keras 3, letting you run the same code on JAX, PyTorch, or TensorFlow without needing transformers or torch at runtime. Models load from preconverted weights, upstream checkpoints converted on-the-fly, or any Hugging Face repo, with a consistent two-call interface (build model, run prediction).

  • 100+ model families (detectors, depth estimators, LLMs) work with identical code across three backends—switch backends by setting one environment variable before importing Keras
  • Large models load with aggressive quantization built-in: GPT-OSS 120B stays at 66GB using bfloat16 + packed MXFP4 experts instead of 130GB fp32, with int8/int4/fp8 quantization available as arguments
  • All outputs on model pages are measured from actually running the code snippets, not hand-written examples, so results are reproducible

ZeroModels is a library that ports over 100 model families into pure Keras 3, letting you run the same code across JAX, PyTorch, and TensorFlow without needing transformers or torch installed at runtime. The setup is straightforward: you load a model and its processor with `from_weights()`, then pass the processor output directly to the model. Everything stays synchronized—the processor's normalization and image resolution always match the checkpoint it came from, so you don't have to manage those details yourself. Switching between different model types (object detection, depth estimation, language models) requires no code changes beyond swapping the model class. The library handles weight loading flexibly. You can pull preconverted Keras weights from the zeromodels org on Hugging Face Hub, load a bare model name that gets converted on the fly from upstream checkpoints, or point to any compatible Hub repo using the `hf:` prefix. The architecture details automatically read from the repo config, including fine-tuning specifics like class counts. You can also load architecture-only versions with random initialization if you need that. Memory efficiency gets real attention here. Large models like GPT-OSS 120B load at bfloat16 with MoE experts staying packed in MXFP4 and dequantized on demand, keeping memory around 66 GB instead of 130 GB for full fp32. Weight-only quantization—int8, int4, fp8, or mxfp4—works as a simple argument to the same `from_weights()` call on any model. All outputs shown in the documentation come from actually running the code snippets on real images and audio, not hand-crafted examples.

Ask about this article