Instructions to use zeromodels/gpt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/gpt with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/gpt") - Keras
How to use zeromodels/gpt with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://zeromodels/gpt") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
b5e34cf verified |
Download README.md from zeromodels/gpt: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/zeromodels/gpt/resolve/main/README.md
- Command line
-
hf download hf://zeromodels/gpt/README.md
-
curl -L -o README.md https://huggingface.co/zeromodels/gpt/resolve/main/README.md
2.38 kB
| pipeline_tag: text-generation | |
| license: mit | |
| base_model: openai-community/openai-gpt | |
| library_name: zeromodels | |
| language: | |
| - en | |
| tags: | |
| - keras | |
| - zeromodels | |
| - gpt | |
| - openai-gpt | |
| - text-generation | |
| - pytorch | |
| - jax | |
| - tf | |
| # Run GPT with Keras 3: JAX, PyTorch, or TensorFlow | |
| [](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/gpt/) | |
| # zeromodels/gpt | |
| Paper: [Improving Language Understanding by Generative Pre-Training (Radford et al., 2018)](https://cdn.openai.com/research-covers/language-unsupervised/language_understanding_paper.pdf) | |
| GPT (the original GPT-1) is OpenAI's first generative pre-trained transformer: a | |
| 12-layer decoder-only model with learned position embeddings (512-token context), | |
| `gelu_new` activations, and a byte-pair-encoding tokenizer, trained on BookCorpus. | |
| This is the **117M** base completion model (no chat template). | |
| For more details, see the upstream [model card](https://huggingface.co/openai-community/openai-gpt). | |
| Pure-**Keras 3** conversion of [`openai-community/openai-gpt`](https://huggingface.co/openai-community/openai-gpt) for | |
| [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on | |
| **TensorFlow / Torch / JAX**. | |
| ## Quick start | |
| ```python | |
| import os | |
| os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow" | |
| from zeromodels.models.gpt import GptTextGenerate, GptTokenizer | |
| model = GptTextGenerate.from_weights("zeromodels/gpt") | |
| tokenizer = GptTokenizer.from_weights("zeromodels/gpt") | |
| inputs = tokenizer("the meaning of life is") | |
| outputs = model.generate(**inputs, max_new_tokens=40) | |
| print(tokenizer.decode(outputs[0])) | |
| ``` | |
| ## Tips | |
| - Set `KERAS_BACKEND` **before** importing Keras / zeromodels. | |
| - Context length is 512 tokens; this is a base completion model, not | |
| instruction-tuned. | |
| - See the [GPT docs](https://imvision12.github.io/ZeroModels/gpt/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/). | |
| - Upstream safetensors still work via the `hf:` prefix, e.g. | |
| `GptTextGenerate.from_weights("hf:openai-community/openai-gpt")`. | |
| ## Special Thanks | |
| A huge thank you to the OpenAI GPT authors for creating and releasing this model. | |
| License: MIT, inherited from the upstream OpenAI GPT release. | |