Downloads · 30 days
34
40% of all-time downloads
zeromodels/gpt2
gpt2 is a text generation model from zeromodels. Use it when you need the model to write or continue text. It is set up for zeromodels. The card lists the license as mit.
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/gpt2/)
Downloads · 30 days
34
40% of all-time downloads
All-time downloads
86
Public
Repo size
498 MB
Likes
0
Public
Click a slice to open those files.
.h5498 MB · 100%
From the Hugging Face model README
Paper: Language Models are Unsupervised Multitask Learners (Radford et al., 2019)
GPT-2 is OpenAI's decoder-only transformer language model trained on WebText:
learned absolute position embeddings, pre-LayerNorm blocks, gelu_new
activations, a tied output head, and a byte-level BPE tokenizer. This is the
124M variant, a base completion model (no chat template).
For more details, see the upstream model card.
Pure-Keras 3 conversion of openai-community/gpt2 for
zeromodels. One implementation runs unmodified on
TensorFlow / Torch / JAX.
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from zeromodels.models.gpt2 import GPT2TextGenerate, GPT2Tokenizer
model = GPT2TextGenerate.from_weights("zeromodels/gpt2")
tokenizer = GPT2Tokenizer.from_weights("zeromodels/gpt2")
inputs = tokenizer("The meaning of life is")
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0]))
All GPT-2 sizes load the same way with from_weights("zeromodels/<variant>"):
| Variant | Hub | Params |
|---|---|---|
gpt2 | zeromodels/gpt2 | 124M |
gpt2_medium | zeromodels/gpt2_medium | 355M |
gpt2_large | zeromodels/gpt2_large | 774M |
gpt2_xl | zeromodels/gpt2_xl | 1.5B |
KERAS_BACKEND before importing Keras / zeromodels.hf: prefix, e.g.
GPT2TextGenerate.from_weights("hf:openai-community/gpt2").A huge thank you to the OpenAI GPT-2 authors for creating and releasing these models.
License: MIT, inherited from the upstream OpenAI GPT-2 release.