Downloads · 30 days
0
abhinavv3/GPT-124m
GPT-124m is a machine learning model from abhinavv3. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A GPT-2-style large language model (LLM) repository.This implementation includes full support for distributed training, sharded datasets, benchmark evaluation, and efficient text generation.
Downloads · 30 days
0
Access
Public
Updated Jun 16, 2025
Repo size
12.2 MB
Likes
1
Public
Click a slice to open those files.
.pyc27.8 KB · 40%
From the Hugging Face model README
A GPT-2-style large language model (LLM) repository.This implementation includes full support for distributed training, sharded datasets, benchmark evaluation, and efficient text generation.
.npy files.torch.autocast.MEMGPT/
├── configs/
│ └── config.json # Model and training configuration
│
├── data/
│ ├── edu_fineweb/ # Sharded training data
│ │ ├── train_000001.npy
│ │ ├── train_000002.npy
│ │ └── test_000001.npy
│ ├── hellaswag/
│ │ └── hellaswag_val.jsonl
│ └── fineweb.py # Dataset sharding/processing logic
│
├── model_core/
│ ├── __init__.py
│ ├── attention.py # Self-attention module
│ ├── model.py # GPT2 model architecture
│ ├── dataloader.py # DataLoader_1 class
│ └── training.py # train_nanogpt function
│
├── scripts/
│ ├── train.py # Entry point to start training
│ ├── evaluate.py # Run evaluation
│ └── generate.py # Generate text from trained model
│
├── evaluation/
│ ├── __init__.py
│ ├── hellaswag.py # HellaSwag dataset preparation
│ └── val_hellaswag.py # HellaSwag scoring function
│
├── logs/
│ ├── log.txt # Training log file
│ └── model_xxxxx.pt # Checkpoint files
│
├── .gitignore
├── README.md
├── requirements.txt
Edit configs/config.json to configure your model and training setup.
Example:
{
"model": {
"block_size": 1024,
"vocab_size": 50304,
"n_layer": 12,
"n_head": 12,
"n_embd": 768
},
"training": {
"max_steps": 19073,
"log_dir": "log",
"total_batch_size": 524288,
"B": 64,
"T": 1024,
"max_lr": 0.0006,
"min_lr": 0.00006,
"warmup_steps": 715,
"weight_decay": 0.1,
"learning_rate": 0.0006
}
}
To start training the model:
python scripts/train.py
This script internally loads train_nanogpt() from model_core/training.py using the config in configs/config.json.
To run training across multiple GPUs using PyTorch DDP:
torchrun --nproc_per_node=NUM_GPUS scripts/train.py
Replace NUM_GPUS with the number of GPUs you want to use.
To evaluate on HellaSwag:
python scripts/evaluate.py
Make sure the hellaswag_val.jsonl file is available under data/hellaswag/.
To generate text from a trained model:
python scripts/generate.py
Make sure to adjust the generation script to point to the correct checkpoint under the logs/ directory.
Install required packages:
pip install -r requirements.txt
.npy sharded data is placed under data/edu_fineweb/.logs/.DataLoader_1 handles distributed data loading.bfloat16 autocasting for better training efficiency.MIT License. Feel free to modify and build upon this for research or commercial use.
Inspired by Andrej Karpathy's nanoGPT. Special thanks to the Andrej Karpathy Youtube tutorials and open-source AI community.