Skip to content

Repository files navigation

GPT2-from-scratch-Pytorch

Just a simple implementation of GPT2 architecture guided from Sebastian Raschka book. A 58M parameter model, pretrained on 6-million tokens of Tamil and English corpus and further finetuned on english, tamil translation pairs. Used Liger kernel for faster training and memory efficient. trained on mixed precision bfloat16.

Model Config:

"vocab_size": 64000, "context_len": 1024, "embed_dim": 256, "num_heads": 8, "attn_dim": 512, "ffn_dim": 256 * 4, # embed_dim x multiplier "num_layers": 12, "dropout": 0.1, "qkv_bias": False

Usage:

  1. Refer train_gpt2.py for pre-training from scratch.
  2. For Inference, Download weight huggingface and move it inside hf_slm_translate folder. Create a py venv if needed, then pip install -r requirements.txt. Open inference.py change your input prompt and run the file.
  3. Note: You can avoid installing LigerKernel if you are only using the inference.

Training Vals:

Finetuning Vals (translation: en -> ta):

Evals:

This is my first pretrain a lot of problems were occured, the attention map looks decent and slightly overfitted scores of few area, but for a 58M model it does a below average job on translation thus not even suitable for BLEU Eval. sharing a below example of model translation:

Input: Translate the below English text to Tamil: New Delhi: On July 18, a seven-storey rocket lifted off from Sriharikota. Vikram-1 climbed into a 450 km orbit and released four payloads. It was India's first privately built rocket to reach orbit. Skyroot Aerospace had just made history. The moment mattered beyond the launch pad. It proved something investors had been betting on for years: Indian spacetech companies can build real hardware, not just pitch decks.

Generated: டெல்லி: ஜூலை 18 அன்று ஸ்ரீஹரிகோட்டாவிலிருந்து ஏழு காலமான ராக்கெட் உடைந்து 450 கி.மீ தூரத்திற்குள் வீசப்பட்டு நான்கு ஊதியங்களை விடுவித்தது. இந்தியாவின் முதல் தனியார் கட்ட ராக்கெட் ரிசார்ஓஸ் எர்ஸ்போம்ஸ் வரலாற்றை அடைய அல்லது நடுநிலையை அடைய ஒரு தனியார் கட்டமைக்கப்பட்டது. லைட்ரேட் ஏர்ஸ்போம்ஸ் வரலாறு. இந்த நிகழ்வில் ஒரு முதலீட்டாளர்கள் பல ஆண்டுகளாக பந்தயம் செய்திருந்தனர் என்பதை நிரூபித்தது: இந்திய ஸ்பேக் நிறுவனங்கள் உண்மையான வன்பொருனைக் கட்ட முடியும், வெறும் பிரிக்கங்களை சுருக்கிக் கொள்ள முடியாது.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages