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.
"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
- Refer
train_gpt2.pyfor pre-training from scratch. - For Inference, Download weight huggingface and move it inside
hf_slm_translatefolder. Create a py venv if needed, thenpip install -r requirements.txt. Openinference.pychange your input prompt and run the file. - Note: You can avoid installing LigerKernel if you are only using the inference.
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 கி.மீ தூரத்திற்குள் வீசப்பட்டு நான்கு ஊதியங்களை விடுவித்தது. இந்தியாவின் முதல் தனியார் கட்ட ராக்கெட் ரிசார்ஓஸ் எர்ஸ்போம்ஸ் வரலாற்றை அடைய அல்லது நடுநிலையை அடைய ஒரு தனியார் கட்டமைக்கப்பட்டது. லைட்ரேட் ஏர்ஸ்போம்ஸ் வரலாறு. இந்த நிகழ்வில் ஒரு முதலீட்டாளர்கள் பல ஆண்டுகளாக பந்தயம் செய்திருந்தனர் என்பதை நிரூபித்தது: இந்திய ஸ்பேக் நிறுவனங்கள் உண்மையான வன்பொருனைக் கட்ட முடியும், வெறும் பிரிக்கங்களை சுருக்கிக் கொள்ள முடியாது.




