See our collection for all GPT-OSS versions.

Run GPT-OSS with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs

kerasformers/gpt-oss-20b

GPT-OSS is OpenAI's open-weight mixture-of-experts LLM family: top-k routed experts, learned per-head attention sinks, alternating sliding-window / full causal attention, and YaRN-scaled rotary positions. The experts ship in MXFP4 (4-bit), which is why the checkpoint is compact.

For more details on the model, please see OpenAI's original model card.

Pure-Keras 3 conversion of openai/gpt-oss-20b for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX. The MoE experts are stored in MXFP4 exactly as OpenAI ships them (uint8 nibble blocks + e8m0 scales), matching the official footprint and dequantized on the fly at run time on every backend (including CPU).

Quick start

import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from kerasformers.models.gpt_oss import GptOssGenerate, GptOssTokenizer

model = GptOssGenerate.from_weights("kerasformers/gpt-oss-20b")
tokenizer = GptOssTokenizer.from_weights("kerasformers/gpt-oss-20b")

inputs = tokenizer([
    {"role": "user", "content": "Explain rotary embeddings in one sentence."}
])
outputs = model.generate(**inputs, max_new_tokens=64)
print(tokenizer.decode(outputs[0]))

Load any GPT-OSS variant the same way with from_weights("kerasformers/<variant>"):

Variant Hub Weights
gpt-oss-20b kerasformers/gpt-oss-20b MXFP4 MoE
gpt-oss-120b kerasformers/gpt-oss-120b MXFP4 MoE

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • The experts stay 4-bit (MXFP4) in memory; weight-only, so it saves memory, not compute. Community / upstream safetensors also work via the hf: prefix, e.g. GptOssGenerate.from_weights("hf:openai/gpt-oss-20b").
  • See the GPT-OSS docs.

Special Thanks

A huge thank you to the OpenAI GPT-OSS authors for creating and releasing these models under Apache 2.0.

License: Apache 2.0.

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kerasformers/gpt-oss-20b

Finetuned
(544)
this model

Collection including kerasformers/gpt-oss-20b