Text Generation
Keras
PyTorch
JAX
TensorFlow
English
Chinese
zeromodels
glm
glm4_moe_lite
glm-4.7
mixture-of-experts
Instructions to use zeromodels/glm-4.7-flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use zeromodels/glm-4.7-flash with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/glm-4.7-flash") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
8321abb verified | pipeline_tag: text-generation | |
| license: mit | |
| base_model: zai-org/GLM-4.7-Flash | |
| library_name: zeromodels | |
| language: | |
| - en | |
| - zh | |
| tags: | |
| - keras | |
| - zeromodels | |
| - glm | |
| - glm4_moe_lite | |
| - glm-4.7 | |
| - mixture-of-experts | |
| - text-generation | |
| - pytorch | |
| - jax | |
| - tf | |
| # Run GLM-4.7-Flash with Keras 3: JAX, PyTorch, or TensorFlow | |
| [](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/glm4_moe_lite/) [](https://huggingface.co/collections/zeromodels/glm-6a82b8f9f753e8dcae3ff3f7) | |
| # zeromodels/glm-4.7-flash | |
| Pure-**Keras 3** conversion of [`zai-org/GLM-4.7-Flash`](https://huggingface.co/zai-org/GLM-4.7-Flash) for [zeromodels](https://github.com/IMvision12/ZeroModels). 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 `zm_config.json` (`weight_dtype` + `weight_dtype_overrides`) for the exact layout. | |
| For model details, license, and usage terms, see the upstream [model card](https://huggingface.co/zai-org/GLM-4.7-Flash). | |
| Paper: [ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools (arXiv:2406.12793)](https://arxiv.org/abs/2406.12793) · [HF Papers](https://huggingface.co/papers/2406.12793) | |
| ## ✨ Quick start | |
| ```python | |
| import os | |
| os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow" | |
| from zeromodels.models.glm4_moe_lite import Glm4MoeLiteTextGenerate, Glm4MoeLiteTokenizer | |
| model = Glm4MoeLiteTextGenerate.from_weights("zeromodels/glm-4.7-flash") | |
| tokenizer = Glm4MoeLiteTokenizer.from_weights("zeromodels/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("zeromodels/<variant>")`. Browse them all in the [GLM collection](https://huggingface.co/collections/zeromodels/glm-6a82b8f9f753e8dcae3ff3f7). | |
| ## 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). | |