Instructions to use zeromodels/gpt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use zeromodels/gpt 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/gpt 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/gpt") - Notebooks
- Google Colab
- Kaggle
Run GPT with Keras 3: JAX, PyTorch, or TensorFlow
kerasformers/gpt
Paper: Improving Language Understanding by Generative Pre-Training (Radford et al., 2018)
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.
Pure-Keras 3 conversion of openai-community/openai-gpt for
kerasformers. One implementation runs unmodified on
TensorFlow / Torch / JAX.
Quick start
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from kerasformers.models.gpt import GptTextGenerate, GptTokenizer
model = GptTextGenerate.from_weights("kerasformers/gpt")
tokenizer = GptTokenizer.from_weights("kerasformers/gpt")
inputs = tokenizer("the meaning of life is")
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0]))
Tips
- Set
KERAS_BACKENDbefore importing Keras / kerasformers. - Context length is 512 tokens; this is a base completion model, not instruction-tuned.
- See the GPT docs and 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.
- Downloads last month
- 37
Model tree for zeromodels/gpt
Base model
openai-community/openai-gpt