Upload code/build_sft_v16_dataset.py with huggingface_hub
Browse files1 unmodified line23456783 unmodified lines12131415161718192021222352 unmodified lines7677787980818217 unmodified lines100101102103104105106109 unmodified lines216217218219220221222150 unmodified lines3733743753763773783793803813823833843853863873883893903913923933943956 unmodified lines402403404405406407408409410411412413414257 unmodified lines6726736746756766776781 unmodified line# π ViuAI Sarus-500M β SFT v16 Master Dataset Builder (~88,500+ Samples)# ==============================================================================# 9 BALANCED DOMAINS:# 0. π General Knowledge, History, Geography, Polity, ISRO & Quizzes (~18k)# 1. π» Core Coding, Python, Web Dev, SQL, Git & Linux Debugging (~16k)# 2. π’ Math & Arithmetic Step-by-Step Logic (~9k)# 3. π§ Logical Reasoning & Deductive Puzzles (~6k)3 unmodified lines# 7. π° Personal Finance, Fitness & Wellness Awareness (~5k)# 8. π 100% AUTHENTIC Sarus Identity (from final_viuai_dataset_identity.json) (~2.2k)## KEY FEATURES:# β’ ZERO SYNTHETIC IDENTITY: 100% authentic ViuAI identity dataset used.# β’ AUTO CLOUD SYNC: Automatically downloads authentic raw data files from HF on Cloud.# β’ OVERFLOW FIX: Labels stored as np.int32 (supports vocab > 32767 and -100).# β’ DEDUP FIX: Handcrafted anchor packs bypass dedup so 15x reinforcement works.# β’ 2048 NATIVE CONTEXT: Strict EOT_ID preservation.# ==============================================================================import os52 unmodified linesprint("=" * 85)print("π ViuAI Sarus-500M β SFT v16 Master Dataset Builder (~88,500+ Scale)")print(" 100% Authentic ViuAI Identity | Auto Cloud Sync | int32 Overflow Fix")print("=" * 85)17 unmodified linesprint(f"π Found Local Authentic Raw Data Directory: {resolved}")return resolved# Auto-Download from Hugging Face Hub if on Cloud / Kagglecloud_dest = os.path.join(PROJECT_ROOT, "data", "raw_data")os.makedirs(cloud_dest, exist_ok=True)print(f"\nπ Local dataset not found. Auto-downloading authentic raw datasets from Hugging Face Hub ({DATA_REPO_ID}/raw_data)...")109 unmodified lines# ------------------------------------------------------------------------------# 5. Handcrafted Core Anchor Packs (Empathy, Recipes, Coding, Math, GK)# ------------------------------------------------------------------------------def get_empathy_and_chitchat_pack():150 unmodified linesreturn [{"instruction": inst, "thinking": th, "response": resp, "language": "english", "domain": "math_logic"} for inst, th, resp in items]def get_gk_polity_pack():items = [("Who is known as the Father of the Indian Constitution?","Identify the primary architect of the Constitution of India: Dr. B.R. Ambedkar.","**Dr. B. R. Ambedkar** (Bhimrao Ramji Ambedkar) is known as the **Father of the Indian Constitution**. He served as the Chairman of the Drafting Committee (Praroop Samiti) which prepared the final draft of the Constitution of India."),("What was the objective and significance of ISRO's Chandrayaan-3 mission?","Explain ISRO's Chandrayaan-3 lunar mission: objective (soft landing on south pole), key payloads (Vikram lander, Pragyan rover), and historic achievement on 23 August 2023.","**Chandrayaan-3** was India's historic lunar exploration mission by ISRO:\n\n""β’ **Historic Milestone**: On **23 August 2023**, India became the first country in the world to successfully soft-land a spacecraft on the **Lunar South Pole**.\n""β’ **Key Components**: **Vikram Lander** and **Pragyan Rover**.\n""β’ **Primary Objectives**: Demonstrate safe landing, deploy rover for mobility, and conduct in-situ chemical and thermal analysis of lunar surface.\n""β’ **National Space Day**: 23 August is now officially celebrated as **National Space Day** in India."),("Bharat ka sabse lamba national highway kaunsa hai?","Identify the longest national highway in India: NH 44 (Srinagar to Kanyakumari).","Bharat ka sabse lamba National Highway **NH 44** (National Highway 44) hai. Yeh **Srinagar (Jammu & Kashmir)** se shuru hokar **Kanyakumari (Tamil Nadu)** tak jata hai, aur iski kul lambai lagbhag **3,745 kilometers** hai."),]return [{"instruction": inst, "thinking": th, "response": resp, "language": "hinglish", "domain": "gk_polity_history"} for inst, th, resp in items]6 unmodified linesprint("\nπ¦ Step 2/5: Building Balanced Multi-Domain Master Pool...")master_pool = []# 1. Inject Handcrafted Core Anchor Packsprint(" -> Ingesting 15x Reinforcement Handcrafted Anchor Packs (Empathy, Food, Code, Math, GK)...")for pack in [get_empathy_and_chitchat_pack(), get_authentic_recipes_pack(),get_coding_essentials_pack(), get_math_logic_pack(), get_gk_polity_pack()]:for rep in range(15):for item in pack:master_pool.append(dict(item))# 2. Authentic Clean Datasets (Local or Cloud Auto-Downloaded)if local_data_dir and os.path.exists(local_data_dir):257 unmodified linesf.write(json.dumps(row, ensure_ascii=False) + "\n")print(f" π Saved JSONL: {jsonl_file} ({len(jsonl_rows):,} rows)")# Save NPY (uint16 for tokens, int32 for labels [FIX for overflow], uint32 for offsets, uint8 for domains)tok_arr = np.array(token_list, dtype=np.uint16)lbl_arr = np.array(label_list, dtype=np.int32)off_arr = np.array(offsets, dtype=np.uint32)1 unmodified line23456783 unmodified lines1213141516171819202122232452 unmodified lines7778798081828317 unmodified lines101102103104105106109 unmodified lines216217218219220221222150 unmodified lines3733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724736 unmodified lines480481482483484485486487488489490491492493494257 unmodified lines7527537547557567577581 unmodified line# π ViuAI Sarus-500M β SFT v16 Master Dataset Builder (~88,500+ Samples)# ==============================================================================# 9 BALANCED DOMAINS:# 0. π General Knowledge, Updated 2023-2026 Current Affairs, History & Polity (~18k)# 1. π» Core Coding, Python, Web Dev, SQL, Git & Linux Debugging (~16k)# 2. π’ Math & Arithmetic Step-by-Step Logic (~9k)# 3. π§ Logical Reasoning & Deductive Puzzles (~6k)3 unmodified lines# 7. π° Personal Finance, Fitness & Wellness Awareness (~5k)# 8. π 100% AUTHENTIC Sarus Identity (from final_viuai_dataset_identity.json) (~2.2k)## NEW FEATURE:# β’ π UPDATED CONTEMPORARY GK PACK (2023-2026 Milestones):# - Chandrayaan-3, Aditya-L1, Gaganyaan, National Space Day# - T20 World Cup 2024 Champions (India), Paris Olympics 2024 (Neeraj, Manu Bhaker)# - New Parliament Building, Sengol, Atal Setu (MTHL), Vande Bharat# - G20 Summit New Delhi, BNS (Bharatiya Nyaya Sanhita), Women's Reservation Bill# - Global UPI (France, UAE, Singapore, Nepal), Ayodhya Ram Mandir# ==============================================================================import os52 unmodified linesprint("=" * 85)print("π ViuAI Sarus-500M β SFT v16 Master Dataset Builder (~88,500+ Scale)")print(" 100% Authentic Identity | Updated Contemporary GK (2023-2026) | int32 Overflow Fix")print("=" * 85)17 unmodified linesprint(f"π Found Local Authentic Raw Data Directory: {resolved}")return resolvedcloud_dest = os.path.join(PROJECT_ROOT, "data", "raw_data")os.makedirs(cloud_dest, exist_ok=True)print(f"\nπ Local dataset not found. Auto-downloading authentic raw datasets from Hugging Face Hub ({DATA_REPO_ID}/raw_data)...")109 unmodified lines# ------------------------------------------------------------------------------# 5. Handcrafted Core Anchor Packs (Empathy, Recipes, Coding, Math, Contemporary GK)# ------------------------------------------------------------------------------def get_empathy_and_chitchat_pack():150 unmodified linesreturn [{"instruction": inst, "thinking": th, "response": resp, "language": "english", "domain": "math_logic"} for inst, th, resp in items]# ------------------------------------------------------------------------------# π UPDATED CONTEMPORARY GK & CURRENT AFFAIRS PACK (2023-2026)# ------------------------------------------------------------------------------def get_updated_contemporary_gk_pack():"""High-density updated contemporary GK facts (Space, Sports, Governance, Infrastructure & Tech)."""items = [# 1. Chandrayaan-3 & Space Day("Chandrayaan-3 kab land hua tha aur iski kya uplabdhi thi?","Explain Chandrayaan-3 landing date (23 August 2023), landing site (Shiv Shakti Point at South Pole), and historic world achievement.","**Chandrayaan-3** Bharat ka ek aitihasik antariksh mission tha:\n\n""β’ **Landing Date**: **23 August 2023** ko shaam 6:04 baje ISRO ne safalta-purvak landing ki.\n""β’ **Vishwa Record**: Bharat Chandrama ke **South Pole (Dakshini Dhruva)** par soft landing karne wala **duniya ka pehla desh** bana.\n""β’ **Shiv Shakti Point**: Landing point ka naam **'Shiv Shakti'** rakha gaya.\n""β’ **National Space Day**: Is uplabdhi ke samman me har saal 23 August ko Bharat me **'National Space Day'** manaya jata hai."),# 2. Aditya-L1 Mission("ISRO ka Aditya-L1 mission kya hai aur ye kaha sthit hai?","Explain ISRO Aditya-L1 solar mission: launch in Sept 2023, placement at Sun-Earth Lagrange Point 1 (L1), and scientific objectives.","**Aditya-L1** Bharat ka **pehla Solar Observatory mission** hai jise ISRO ne Surya ka adhyayan (study) karne ke liye bheja hai:\n\n""β’ **Location**: Yeh prithvi se lagbhag **15 lakh kilometers** door Sun-Earth system ke **Lagrange Point 1 (L1)** ke halo orbit me sthit hai.\n""β’ **Fayda**: L1 point par sthit hone ki wajah se bina kisi grahan (eclipse) ke Surya ko 24x7 lagatar observe kiya ja sakta hai.\n""β’ **Objectives**: Solar flares, coronal mass ejections (CME) aur space weather ka deep analysis karna."),# 3. T20 World Cup 2024("ICC Men's T20 World Cup 2024 kisne jeeta aur captain kaun the?","State winner of ICC T20 World Cup 2024: India, defeating South Africa in Barbados under Rohit Sharma's captaincy.","**ICC Men's T20 World Cup 2024** ka khitab **Bharat (India)** ne jeeta:\n\n""β’ **Final Match**: 29 June 2024 ko Bridgetown (Barbados) me Bharat ne South Africa ko 7 runs se haraya.\n""β’ **Captain**: **Rohit Sharma** ki kaptani me Bharat ne ye trophy jeeti.\n""β’ **Player of the Final**: **Virat Kohli** (76 runs).\n""β’ **Player of the Tournament**: **Jasprit Bumrah** (15 wickets, economy 4.17).\n""β’ Yeh Bharat ka **doosra T20 World Cup** khitab tha (pehla 2007 me MS Dhoni ki kaptani me jeeta tha)."),# 4. Paris Olympics 2024("Paris Olympics 2024 me Bharat ke pramukh medals kaunse the?","Summarize India's achievements in Paris 2024 Olympics: Neeraj Chopra (Silver), Manu Bhaker (2 Bronze medals), Hockey team (Bronze).","**Paris Olympics 2024** me Bharat ke pramukh itihaasik pal:\n\n""β’ **Neeraj Chopra**: Men's Javelin Throw me **Silver Medal** jeeta (89.45m throw ke sath).\n""β’ **Manu Bhaker**: Ek hi Olympics me **2 medals** (10m Air Pistol Individual & 10m Mixed Team with Sarabjot Singh) jeetne wali azaad Bharat ki pehli athlete bani.\n""β’ **Indian Hockey Team**: PR Sreejesh ki shandar goalkeeping ke sath **Bronze Medal** jeeta.\n""β’ **Aman Sehrawat**: Wrestling (57kg) me Bronze jeetkar sabse kam umar ke Indian Olympic medalist bane."),# 5. G20 Summit New Delhi 2023("Bharat me huye G20 Summit 2023 ka theme aur pramukh faisla kya tha?","Explain G20 New Delhi Summit 2023: theme 'Vasudhaiva Kutumbakam' (One Earth, One Family, One Future), venue Bharat Mandapam, and historic inclusion of African Union (AU).","**G20 Summit 2023** Bharat ki adhyakshata (presidency) me New Delhi ke **Bharat Mandapam** me aayojit hua tha:\n\n""β’ **Theme**: **'Vasudhaiva Kutumbakam'** ya **'One Earth Β· One Family Β· One Future'**.\n""β’ **Aitihasik Faisla**: **African Union (AU)** ko G20 ka permanent member banaya gaya (jisse ye G21 ban gaya).\n""β’ **IMEC**: India-Middle East-Europe Economic Corridor ka ailaan kiya gaya."),# 6. New Parliament Building & Sengol("Bharat ke naye Sansad Bhavan (New Parliament House) ki kya visheshataen hain?","Describe India's New Parliament Building: triangular design by Bimal Patel, Lok Sabha (Peacock theme), Rajya Sabha (Lotus theme), and installation of Sengol.","Bharat ka **Naya Sansad Bhavan (New Parliament House)** New Delhi me sthit hai:\n\n""β’ **Shape & Architect**: Yeh triangular (tribhujaakar) shape me bana hai, jiske architect **Bimal Patel** hain (Central Vista Project).\n""β’ **Lok Sabha Chamber**: Rashtriya pakshi **Mor (Peacock)** theme par aadharit hai (888 seating capacity).\n""β’ **Rajya Sabha Chamber**: Rashtriya phool **Kamal (Lotus)** theme par aadharit hai (384 seating capacity).\n""οΏ½οΏ½ **Sengol**: Lok Sabha Speaker ki seat ke paas aitihasik **'Sengol'** (nyay aur shasan ka prateek) sthapit kiya gaya hai."),# 7. Atal Setu (MTHL)("Atal Setu (Mumbai Trans Harbour Link) kya hai aur iski lambai kitni hai?","Explain Atal Setu (MTHL): longest sea bridge in India, connecting Sewri in Mumbai to Chirle in Navi Mumbai, length ~21.8 km.","**Atal Setu (Mumbai Trans Harbour Link - MTHL)** Bharat ka **sabse lamba samundri pul (longest sea bridge)** hai:\n\n""β’ **Lambai**: Lagbhag **21.8 kilometers** (jisme se 16.5 km samundar ke upar hai).\n""β’ **Connectivity**: Yeh South Mumbai ke **Sewri** ko Navi Mumbai ke **Chirle** se jodta hai.\n""β’ **Fayda**: 2 ghante ka travel time ghat kar sirf 15-20 minute ho gaya hai."),# 8. New Criminal Laws (Bharatiya Nyaya Sanhita - BNS)("Bharat me naye kanoon BNS, BNSS aur BSA kab lagu huye aur unhone kinhe replace kiya?","Explain implementation of 3 new criminal laws on 1 July 2024: BNS replacing IPC, BNSS replacing CrPC, and BSA replacing Indian Evidence Act.","Bharat me **1 July 2024** se 3 naye criminal kanoon lagu huye hain jinhone colonial daur ke kanoonon ko replace kiya:\n\n""1. **Bharatiya Nyaya Sanhita (BNS, 2023)**: Isne British-era **Indian Penal Code (IPC, 1860)** ko replace kiya.\n""2. **Bharatiya Nagarik Suraksha Sanhita (BNSS, 2023)**: Isne **Code of Criminal Procedure (CrPC, 1973)** ko replace kiya.\n""3. **Bharatiya Sakshya Adhiniyam (BSA, 2023)**: Isne **Indian Evidence Act (1872)** ko replace kiya."),# 9. Women's Reservation Bill (Nari Shakti Vandan Adhiniyam)("Nari Shakti Vandan Adhiniyam (Women's Reservation Bill) kya hai?","Explain 106th Constitutional Amendment Act (Nari Shakti Vandan Adhiniyam): 33% reservation for women in Lok Sabha and State Legislative Assemblies.","**Nari Shakti Vandan Adhiniyam (106th Constitutional Amendment Act)** ek aitihasik kanoon hai:\n\n""β’ **Uddeshya**: Lok Sabha aur rajyon ki Vidhan Sabhao (State Legislative Assemblies) me mahilaon ke liye **33% (one-third) seats reserve** karna.\n""β’ **Significance**: Naye Sansad Bhavan me pass hone wala yeh **pehla aitihasik bill** tha."),# 10. UPI Global Expansion("Bharat ka UPI (Unified Payments Interface) kin-kin deshon me chal raha hai?","List foreign countries supporting Indian UPI payments: France, UAE, Singapore, Sri Lanka, Mauritius, Nepal, Bhutan.","Bharat ka digital payment system **UPI (Unified Payments Interface)** ab kai deshon me globally accept hota hai:\n\n""β’ **Major Countries**: France (Eiffel Tower par live), UAE (Dubai/Abu Dhabi), Singapore (PayNow-UPI link), Sri Lanka, Mauritius, Nepal, aur Bhutan.\n""β’ **Fayda**: Indian tourists aur travellers bina currency exchange kiye seedha apne Indian bank apps (PhonePe, GPay, Paytm) se QR code scan karke payment kar sakte hain."),# 11. Chess Grandmaster D. Gukesh("D. Gukesh ne chess me kya itihaas racha?","Explain D. Gukesh's historic achievement: winning FIDE Candidates Tournament 2024 at age 17 to become youngest challenger in World Chess Championship history.","**Dommaraju Gukesh (D. Gukesh)** ne 2024 me FIDE Candidates Tournament jeet kar itihaas racha:\n\n""β’ **Record**: Sirf **17 saal ki umar** me World Chess Championship ke sabse young challenger bane (Viswanathan Anand ke baad Candidates jeetne wale doosre Indian).\n""β’ Unhone 45th Chess Olympiad 2024 me Bharat ko historic Gold medal dilane me bhi leading role nibhaya."),]return [{"instruction": inst, "thinking": th, "response": resp, "language": "hinglish", "domain": "gk_polity_history"} for inst, th, resp in items]6 unmodified linesprint("\nπ¦ Step 2/5: Building Balanced Multi-Domain Master Pool...")master_pool = []# 1. Inject Handcrafted Core Anchor Packs (including Updated Contemporary GK)print(" -> Ingesting 15x Reinforcement Handcrafted Anchor Packs (Empathy, Food, Code, Math, Updated GK)...")for pack in [get_empathy_and_chitchat_pack(), get_authentic_recipes_pack(),get_coding_essentials_pack(), get_math_logic_pack(), get_gk_polity_pack(),get_updated_contemporary_gk_pack()]:for rep in range(15):for item in pack:master_pool.append(dict(item))print(f" Reinforced {len(master_pool):,} clean anchor samples (with 2023-2026 Updated GK).")# 2. Authentic Clean Datasets (Local or Cloud Auto-Downloaded)if local_data_dir and os.path.exists(local_data_dir):257 unmodified linesf.write(json.dumps(row, ensure_ascii=False) + "\n")print(f" π Saved JSONL: {jsonl_file} ({len(jsonl_rows):,} rows)")# Save NPY (uint16 for tokens, int32 for labels, uint32 for offsets, uint8 for domains)tok_arr = np.array(token_list, dtype=np.uint16)lbl_arr = np.array(label_list, dtype=np.int32)off_arr = np.array(offsets, dtype=np.uint32)
code/build_sft_v16_dataset.py+110-30