Downloads · 30 days
17
6% of all-time downloads
achavan1211/harrypotter-gpt-bpe
harrypotter-gpt-bpe is a text generation model from achavan1211. Use it when you need the model to write or continue text. It is set up for generic.
A from-scratch decoder-only Transformer (~12.3M parameters) trained on the Harry Potter series (books 1-7). Built with raw PyTorch (not transformers) — see model.py.
Downloads · 30 days
17
6% of all-time downloads
All-time downloads
293
Public
Repo size
58.6 MB
Likes
0
Public
Click a slice to open those files.
.bin58.6 MB · 100%
From the Hugging Face model README
A from-scratch decoder-only Transformer (~12.3M parameters) trained on the Harry Potter series (books 1-7). Built with raw PyTorch (not transformers) — see model.py.
tokenizers), vocab 2000Custom PyTorch model. See model.py (architecture), config.json (hyperparameters), and tokenizer.json (BPE tokenizer).
import json, torch
from tokenizers import Tokenizer
from huggingface_hub import hf_hub_download
from model import GPTLanguageModel
repo = "achavan1211/harrypotter-gpt-bpe"
cfg = json.load(open(hf_hub_download(repo, "config.json")))
tokenizer = Tokenizer.from_file(hf_hub_download(repo, "tokenizer.json"))
model = GPTLanguageModel(**cfg)
model.load_state_dict(torch.load(hf_hub_download(repo, "pytorch_model.bin"), map_location="cpu"))
model.eval()
ctx = torch.tensor([tokenizer.encode("
").ids])
print(tokenizer.decode(model.generate(ctx, max_new_tokens=500)[0].tolist()))