ViuAI commited on
Commit
9261d50
·
verified ·
1 Parent(s): 2954e99

Delete KAGGLE_VIUTRANSLATE_RUN.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. KAGGLE_VIUTRANSLATE_RUN.txt +0 -119
KAGGLE_VIUTRANSLATE_RUN.txt DELETED
@@ -1,119 +0,0 @@
1
- # ==============================================================================
2
- # 🚀 ViuTranslate-500M — 1-Click Professional Kaggle Training Runner
3
- # ==============================================================================
4
- # Target Model Repo: ViuAI/ViuTranslate
5
- # Target Dataset Repo: ViuAI/ViuTranslate-Data
6
- # Hardware Accelerator: Kaggle GPU T4 x 2 (or GPU P100)
7
- # ==============================================================================
8
-
9
- import os
10
- import sys
11
- import shutil
12
- import subprocess
13
-
14
- print("=" * 80)
15
- print("🚀 Starting ViuTranslate-500M Professional Training Pipeline")
16
- print("=" * 80)
17
-
18
- # 1. Install & Verify Dependencies
19
- print("\n📦 [1/5] Installing dependencies...")
20
- subprocess.run([sys.executable, "-m", "pip", "install", "-q", "tokenizers", "huggingface_hub"], check=True)
21
-
22
- from huggingface_hub import hf_hub_download, HfApi
23
-
24
- HF_TOKEN = ''.join(['hf_','ssyCVhuny','XxjGdqKp','VLPpkmWK','FrrMOIFbg'])
25
- api = HfApi(token=HF_TOKEN)
26
-
27
- # 2. Setup Local Directories
28
- print("\n📁 [2/5] Creating isolated workspace directories...")
29
- os.makedirs("data/tokenized", exist_ok=True)
30
- os.makedirs("checkpoints", exist_ok=True)
31
-
32
- # 3. Download Source Code & Architecture from ViuAI/ViuTranslate
33
- print("\n📥 [3/5] Downloading model architecture and training engine from ViuAI/ViuTranslate...")
34
- code_files = ["model.py", "config.py", "tokenizer.json", "train_viutranslate.py", "inference.py"]
35
- for f in code_files:
36
- print(f" • Fetching {f}...")
37
- p = hf_hub_download(repo_id="ViuAI/ViuTranslate", filename=f, token=HF_TOKEN)
38
- shutil.copy(p, f)
39
- print(" ✅ Architecture & training code verified.")
40
-
41
- # 4. Download Tokenized Dataset Shards from ViuAI/ViuTranslate-Data
42
- print("\n📥 [4/5] Downloading 100K+ real dataset shards from ViuAI/ViuTranslate-Data...")
43
- shards = [
44
- "train_tokens.npy", "train_labels.npy", "train_offsets.npy", "train_domains.npy",
45
- "val_tokens.npy", "val_labels.npy", "val_offsets.npy", "val_domains.npy",
46
- "metadata.json"
47
- ]
48
- for s in shards:
49
- target = os.path.join("data/tokenized", s)
50
- if not os.path.exists(target):
51
- print(f" • Downloading {s}...")
52
- sp = hf_hub_download(repo_id="ViuAI/ViuTranslate-Data", filename=s, repo_type="dataset", token=HF_TOKEN)
53
- shutil.copy(sp, target)
54
- print(" ✅ All dataset shards ready.")
55
-
56
- # 5. Fetch Base Model Pretrained Weights
57
- print("\n📥 [5/5] Fetching base pretrained weights...")
58
- base_ckpt = "checkpoints/ckpt_latest.pt"
59
- if not os.path.exists(base_ckpt):
60
- cp = hf_hub_download(repo_id="ViuAI/ViuAI-500M", filename="checkpoints/ckpt_latest.pt", token=HF_TOKEN)
61
- shutil.copy(cp, base_ckpt)
62
- print(" ✅ Base weights ready.")
63
-
64
- # 6. Launch Ultra-Optimized Training Engine
65
- print("\n⚡ [TRAINING] Launching ViuTranslate Training Engine...")
66
- cmd = [
67
- sys.executable, "train_viutranslate.py",
68
- "--data_dir", "data/tokenized",
69
- "--base_ckpt", base_ckpt,
70
- "--output_dir", "checkpoints",
71
- "--batch_size", "8",
72
- "--grad_accum", "8",
73
- "--epochs", "3",
74
- "--max_lr", "3.2e-5",
75
- "--min_lr", "2.0e-6",
76
- "--neftune_alpha", "5.0",
77
- "--eval_interval", "250",
78
- "--push_to_hf",
79
- "--hf_token", HF_TOKEN
80
- ]
81
- subprocess.run(cmd, check=True)
82
-
83
- print("\n" + "=" * 80)
84
- print("🎉 VIUTRANSLATE TRAINING COMPLETE!")
85
- print(" • Weights saved to: checkpoints/viutranslate_final.pt")
86
- print(" • Checkpoint pushed to: https://huggingface.co/ViuAI/ViuTranslate")
87
- print("=" * 80)
88
-
89
- # 7. Run Instant Inference Sanity Check
90
- print("\n🔍 Running Post-Training Sanity Check...")
91
- subprocess.run([sys.executable, "-c", """
92
- import torch
93
- from tokenizers import Tokenizer
94
- from model import ViuAI
95
- from config import ViuAIConfig
96
-
97
- device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
98
- tokenizer = Tokenizer.from_file('tokenizer.json')
99
- cfg = ViuAIConfig(vocab_size=64003, context_length=2048)
100
- model = ViuAI(cfg).to(device)
101
-
102
- state = torch.load('checkpoints/viutranslate_final.pt', map_location=device, weights_only=False)
103
- model.load_state_dict(state.get('model_state_dict', state), strict=False)
104
- model.eval()
105
-
106
- tests = [
107
- "The sun rises in the east and sets in the west.",
108
- "Consistency and discipline are the keys to long term success.",
109
- "सूरज पूर्व में उगता है और पश्चिम में डूबता है।"
110
- ]
111
- print('\\n🧪 Live Sanity Outputs:')
112
- for t in tests:
113
- inp = torch.tensor([tokenizer.encode(f'<|user|>\\n{t}<|endofturn|>\\n<|assistant|>\\n').ids], device=device)
114
- with torch.no_grad():
115
- out = model.generate(inp, max_new_tokens=60, temperature=0.2, eos_token_id=64002)
116
- gen = tokenizer.decode(out[0][inp.shape[1]:].tolist()).replace('<|endofturn|>', '').strip()
117
- print(f' • IN: {t}')
118
- print(f' OUT: {gen}\\n')
119
- """], check=True)