glm-4-9b-chat / README.md
IMvision12's picture
Super-squash branch 'main' using huggingface_hub
e76ba17
|
Raw
History Blame Contribute Delete
2.38 kB
metadata
pipeline_tag: text-generation
license: other
license_name: glm-4
license_link: https://huggingface.co/THUDM/glm-4-9b-chat-hf/blob/main/LICENSE
base_model: zai-org/glm-4-9b-chat-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

GitHub Docs HuggingFace

kerasformers/glm-4-9b-chat

Pure-Keras 3 conversion of zai-org/glm-4-9b-chat-hf for 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.

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.glm import GlmTextGenerate, GlmTokenizer

model = GlmTextGenerate.from_weights("kerasformers/glm-4-9b-chat")
tokenizer = GlmTokenizer.from_weights("kerasformers/glm-4-9b-chat")

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: glm-4 (link).