Downloads · 30 days
0
shubharthak/gpt2-124m-qa
gpt2-124m-qa is a question answering model from shubharthak. Use it when the input is a question plus a passage. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Nov 25, 2025
Repo size
2.1 GB
Likes
0
Public
Click a slice to open those files.
.pt2.1 GB · 100%
From the Hugging Face model README
This repository contains two trained checkpoints of a custom GPT-2 124M model:
model_09535.ptqa-sft_best.ptThis model was implemented using a from-scratch GPT-2 training pipeline, inspired by Andrej Karpathy’s engineering approach, but trained independently with different datasets and objectives.
model_09535.pt)| Feature | Details |
|---|---|
| Parameters | 124M |
| Layers | 12 |
| Heads | 12 |
| Hidden size | 768 |
| Sequence length | 1024 |
| Vocab size | 50304 |
| Dataset | Ultra-FineWeb Edu (educational, high-quality web text) |
| Purpose | General language modeling |
Goal: Build a clean GPT-2 Small from-scratch to understand and implement a full LLM training pipeline.
qa-sft_best.pt)| Feature | Details |
|---|---|
| Base | The pretrained model above |
| Method | Supervised Fine-Tuning (SFT) |
| Dataset | Custom JSONL Q&A dataset |
| Domain | Australian facts, general knowledge, definitions, reasoning |
| Use-case | QA-style interactive chatbot |
Demo available at:
👉 https://gpt2.devshubh.me
This model follows the GPT-2 Small architecture:
{"instruction": "...", "response": "..."}tiktokengit clone https://github.com/shubharthaksangharsha/karpathy
cd karpathy/chapter-9-sft-rhlf-dpo-gpt2-124m
import torch
from model import GPT
ckpt = torch.load("model_09535.pt", map_location="cpu")
model = GPT(config=ckpt['config'])
model.load_state_dict(ckpt['model'])
model.eval()
out = model.generate("Who is the prime minister of australia?", max_new_tokens=60)
print(out)
import torch
from model import GPT
ckpt = torch.load("qa-sft_best.pt", map_location="cpu")
model = GPT(config=ckpt['config'])
model.load_state_dict(ckpt['model'])
model.eval()
out = model.generate("What is the capital of Australia?", max_new_tokens=60)
print(out)
Because this is a Karpathy-format checkpoint, you cannot load it directly using:
AutoModelForCausalLM.from_pretrained(...)
Instead, load the state dict manually:
import torch
state = torch.load("model_09535.pt", map_location="cpu")
model = state["model"]
⚠️ A conversion script is required for full HF .from_pretrained() compatibility.
import torch
from model import GPT
from tokenizer import GPT2Tokenizer
tokenizer = GPT2Tokenizer()
ckpt = torch.load("qa-sft_best.pt")
model = GPT(config=ckpt['config'])
model.load_state_dict(ckpt['model'])
model.eval()
prompt = "Q: What is the capital of Australia?\nA:"
tokens = tokenizer.encode(prompt)
out = model.generate(tokens, max_new_tokens=60)
print(tokenizer.decode(out))
This work is based on Andrej Karpathy’s "Neural Networks: Zero to Hero" course and follows the same educational license.