Downloads · 30 days
16
31% of all-time downloads
saiteja718/gpt-2
gpt-2 is a text generation model from saiteja718. Use it when you need the model to write or continue text. The card lists the license as mit.
A GPT-2–style causal language model built and trained entirely from scratch in PyTorch — no pre-trained weights, no HuggingFace Trainer. Every component (multi-head attention with KV-cache, transformer blocks, weight-…
Downloads · 30 days
16
31% of all-time downloads
All-time downloads
52
Public
Parameters
124M
498 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors498 MB · 99%
From the Hugging Face model README
A GPT-2–style causal language model built and trained entirely from scratch in PyTorch — no pre-trained weights, no HuggingFace Trainer. Every component (multi-head attention with KV-cache, transformer blocks, weight-tying) was implemented by hand.
| Hyperparameter | Value |
|---|---|
| Architecture | GPT-2 (decoder-only transformer) |
| Layers | 12 |
| Attention heads | 12 |
| d_model | 768 |
| FFN hidden dim | 3 072 |
| Context length | 1 024 tokens |
| Vocab size | 50 257 |
| Training steps | 150 000 |
| Tokens seen | ~9.8 B |
| Tokenizer | GPT-2 BPE (tiktoken) |
from transformers import AutoTokenizer
from model.hf_wrapper import GPT2ForCausalLM
model = GPT2ForCausalLM.from_pretrained("saiteja718/gpt2")
tokenizer = AutoTokenizer.from_pretrained("saiteja718/gpt2")
inputs = tokenizer("The capital of France is", return_tensors="pt")
logits = model(**inputs).logits
Clone the repo and run:
git clone https://huggingface.co/saiteja718/gpt2
cd gpt2
pip install torch transformers tiktoken
python3 gpt2_infer.py --interactive
Prompt: The capital of germany is
Output: The capital of germany is the country he first settled in, and soon the settlement
of the British colonies as a result of his military service...
If you use this model in your work, a shoutout is appreciated:
@misc{saiteja718-gpt2-scratch,
author = {saiteja718},
title = {GPT-2 Trained from Scratch},
year = {2025},
url = {https://huggingface.co/saiteja718/gpt2}
}