Instructions to use zeromodels/glm-4-9b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use zeromodels/glm-4-9b with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use zeromodels/glm-4-9b 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-9b") - Notebooks
- Google Colab
- Kaggle
| pipeline_tag: text-generation | |
| license: other | |
| license_name: glm-4 | |
| license_link: https://huggingface.co/THUDM/glm-4-9b/main/LICENSE | |
| base_model: zai-org/glm-4-9b-hf | |
| library_name: kerasformers | |
| language: | |
| - en | |
| - zh | |
| tags: | |
| - keras | |
| - kerasformers | |
| - glm | |
| - glm-4 | |
| - text-generation | |
| - pytorch | |
| - jax | |
| - tf | |
| # Run GLM-4 with Keras 3: JAX, PyTorch, or TensorFlow | |
| [](https://github.com/IMvision12/KerasFormers) [](https://imvision12.github.io/KerasFormers/glm/) [](https://huggingface.co/collections/kerasformers/glm-6a82b8f9f753e8dcae3ff3f7) | |
| # kerasformers/glm-4-9b | |
| Pure-**Keras 3** conversion of [`zai-org/glm-4-9b-hf`](https://huggingface.co/zai-org/glm-4-9b-hf) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**. This is a **GLM-4-9B** checkpoint served as **text -> text**; weights are stored in **bfloat16**. | |
| For model details, license, and usage terms, see the upstream [model card](https://huggingface.co/zai-org/glm-4-9b-hf). | |
| 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 kerasformers.models.glm import GlmTextGenerate, GlmTokenizer | |
| model = GlmTextGenerate.from_weights("kerasformers/glm-4-9b") | |
| tokenizer = GlmTokenizer.from_weights("kerasformers/glm-4-9b") | |
| 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](https://huggingface.co/collections/kerasformers/glm-6a82b8f9f753e8dcae3ff3f7). | |
| ## Special Thanks | |
| A huge thank you to the Zhipu AI / THUDM team for creating and releasing the GLM models. | |
| License: glm-4 ([link](https://huggingface.co/THUDM/glm-4-9b/main/LICENSE)). | |