Run GLM-4.7-Flash with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs HuggingFace

kerasformers/glm-4.7-flash

Pure-Keras 3 conversion of zai-org/GLM-4.7-Flash for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX. GLM-4.7-Flash is a mixture-of-experts model (MLA + DeepSeekMoE) served as text -> text; weights are stored in bfloat16, with the mixture-of-experts router correction bias kept in float32 (matching the upstream mixed-precision checkpoint). See kf_config.json (weight_dtype + weight_dtype_overrides) for the exact layout.

For model details, license, and usage terms, see the upstream model card.

Paper: ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools (arXiv:2406.12793) · HF Papers

✨ Quick start

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

from kerasformers.models.glm4_moe_lite import Glm4MoeLiteTextGenerate, Glm4MoeLiteTokenizer

model = Glm4MoeLiteTextGenerate.from_weights("kerasformers/glm-4.7-flash")
tokenizer = Glm4MoeLiteTokenizer.from_weights("kerasformers/glm-4.7-flash")

messages = [{"role": "user", "content": "Name three prime numbers."}]
inputs = tokenizer(messages)
outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0]))

Load any GLM variant the same way with from_weights("kerasformers/<variant>"). Browse them all in the GLM collection.

Special Thanks

A huge thank you to the Zhipu AI / THUDM team for creating and releasing the GLM models.

License: mit (per the upstream model card).

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

Model tree for kerasformers/glm-4.7-flash

Finetuned
(75)
this model

Collection including kerasformers/glm-4.7-flash

Paper for kerasformers/glm-4.7-flash