See our collection for all Qwen2 versions.

Run Qwen2 with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs Collection

kerasformers/qwen2-57b-a14b-instruct

Qwen2-57B-A14B is Alibaba's Qwen2 mixture-of-experts LLM: a fine-grained top-k router over 64 experts plus a shared expert, on the standard Qwen2 backbone (grouped-query attention with q/k/v bias, SwiGLU, RMSNorm, rotary positions). 57B total parameters, ~14B active per token.

For more details on the model, please see the upstream model card.

Pure-Keras 3 conversion of Qwen/Qwen2-57B-A14B-Instruct for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX. The mixture-of-experts banks are stored fused (the hub layout) and routed on every backend.

This is an instruct (chat-tuned) checkpoint; load Qwen2MoeTokenizer so the chat template is applied.

Quick start

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

from kerasformers.models.qwen2_moe import Qwen2MoeGenerate, Qwen2MoeTokenizer

model = Qwen2MoeGenerate.from_weights("kerasformers/qwen2-57b-a14b-instruct")
tokenizer = Qwen2MoeTokenizer.from_weights("kerasformers/qwen2-57b-a14b-instruct")

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 Qwen2 variant the same way with from_weights("kerasformers/<variant>"):

Variant Hub Type
qwen2-0.5b kerasformers/qwen2-0.5b base
qwen2-0.5b-instruct kerasformers/qwen2-0.5b-instruct instruct
qwen2-1.5b kerasformers/qwen2-1.5b base
qwen2-1.5b-instruct kerasformers/qwen2-1.5b-instruct instruct
qwen2-7b kerasformers/qwen2-7b base
qwen2-7b-instruct kerasformers/qwen2-7b-instruct instruct
qwen2-72b kerasformers/qwen2-72b base
qwen2-72b-instruct kerasformers/qwen2-72b-instruct instruct
qwen2-57b-a14b kerasformers/qwen2-57b-a14b MoE base
qwen2-57b-a14b-instruct kerasformers/qwen2-57b-a14b-instruct MoE instruct
qwen1.5-moe-a2.7b kerasformers/qwen1.5-moe-a2.7b MoE base
qwen1.5-moe-a2.7b-chat kerasformers/qwen1.5-moe-a2.7b-chat MoE chat

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • Prefer Qwen2MoeTokenizer.from_weights(...) so the chat template matches.
  • Larger checkpoints: try load_dtype="bfloat16" or quantization="int8".
  • Experts are stored fused; loading is weight-only bf16 (saves memory, not compute).
  • See Loading Weights and the Qwen2-MoE docs.
  • Community / upstream safetensors still work via the hf: prefix, e.g. Qwen2MoeGenerate.from_weights("hf:Qwen/Qwen2-57B-A14B-Instruct").

Special Thanks

A huge thank you to the Qwen team at Alibaba for creating and releasing these models.

License: Apache 2.0.

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

Model tree for kerasformers/qwen2-57b-a14b-instruct

Finetuned
(3)
this model

Collection including kerasformers/qwen2-57b-a14b-instruct