Downloads · 30 days
0
Shreyaj-pseudo/shreyaj-mini-gpt-shakespeare
shreyaj-mini-gpt-shakespeare is a text generation model from Shreyaj-pseudo. Use it when you need the model to write or continue text. The card lists the license as mit.
MiniGPT Shakespeare is a small decoder-only Transformer trained from scratch on the complete works of William Shakespeare. It generates Shakespeare-style dialogue at the character level.
Downloads · 30 days
0
Access
Public
Updated Feb 25, 2026
Repo size
79.7 MB
Likes
0
Public
Click a slice to open those files.
.pt79.7 MB · 100%
From the Hugging Face model README
MiniGPT Shakespeare is a small decoder-only Transformer trained from scratch on the complete works of William Shakespeare.
It generates Shakespeare-style dialogue at the character level.
This project demonstrates building and training a GPT-style language model from scratch using PyTorch.
MiniGPT Shakespeare is a lightweight autoregressive language model trained to predict the next character in Shakespeare’s text corpus.
The model learns formatting patterns such as speaker tags (e.g., ROMEO:, KING RICHARD III:) and generates structured play-like dialogue.
This model is intended for:
The model can be:
This model is not suitable for:
It is a small experimental research model.
Users should:
Evaluation was performed on held-out segments of the Shakespeare corpus not seen during training.
Evaluation focuses on:
The model demonstrates successful learning of Shakespearean formatting and stylistic structure.
Generation quality improves steadily as training loss decreases, with significant coherence emerging below ~1.6 loss.
Carbon emissions can be estimated using the Machine Learning Impact calculator:
https://mlco2.github.io/impact#compute
The model predicts the next character given previous context.
This model is an independent educational implementation inspired by:
Radford et al., Improving Language Understanding by Generative Pre-Training.
This project was built as a learning exercise to understand:
Shreyaj
For questions, suggestions, or collaboration inquiries, please contact via GitHub.
import torch
from model import MiniGPT
from config import device
from dataset import stoi, itos
from huggingface_hub import hf_hub_download
checkpoint_path = hf_hub_download(
repo_id="Shreyaj-pseudo/shreyaj-mini-gpt-shakespeare",
filename="MODEL_NAME",
local_dir="./downloaded_model" # exact filename you want
)
checkpoint = torch.load(checkpoint_path, map_location=device)
model = MiniGPT().to(device)
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Generate text
def generate(prompt, max_new_tokens="TOKEN_NUMBER"):
context = torch.tensor(
[stoi[c] for c in prompt], dtype=torch.long
).unsqueeze(0).to(device)
output = model.generate(context, max_new_tokens=max_new_tokens)
return ''.join([itos[i] for i in output[0].tolist()])
print(generate("ROMEO:"))