Delete runners/H200_ANTI_RATTA_TEST.txt with huggingface_hub
Browse files- runners/H200_ANTI_RATTA_TEST.txt +0 -145
runners/H200_ANTI_RATTA_TEST.txt
DELETED
|
@@ -1,145 +0,0 @@
|
|
| 1 |
-
# ==============================================================================
|
| 2 |
-
# 🧠 ViuAI Sarus-500M — ANTI-RATTA (ZERO-SHOT NOVELTY) VERIFICATION SUITE
|
| 3 |
-
# ==============================================================================
|
| 4 |
-
# In sawaalon ko kisi bhi dataset se copy nahi kiya gaya hai.
|
| 5 |
-
# Ye Sarus ki REAL UNDERSTANDING, LOGIC, aur REASONING ko test karte hain!
|
| 6 |
-
# ==============================================================================
|
| 7 |
-
|
| 8 |
-
import os, sys, shutil, torch
|
| 9 |
-
from huggingface_hub import hf_hub_download
|
| 10 |
-
from tokenizers import Tokenizer
|
| 11 |
-
|
| 12 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 13 |
-
REPO_ID = "ViuAI/ViuAI-500M"
|
| 14 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
-
|
| 16 |
-
print("=" * 85)
|
| 17 |
-
print("🧠 ViuAI Sarus-500M — ANTI-RATTA NOVELTY & REASONING BENCHMARK")
|
| 18 |
-
print("=" * 85)
|
| 19 |
-
|
| 20 |
-
# 1. Setup paths
|
| 21 |
-
code_dir = os.path.join(os.getcwd(), "code")
|
| 22 |
-
if code_dir not in sys.path:
|
| 23 |
-
sys.path.insert(0, code_dir)
|
| 24 |
-
|
| 25 |
-
from model import ViuAI
|
| 26 |
-
from config import ViuAIConfig
|
| 27 |
-
|
| 28 |
-
tok_path = "tokenizer/tokenizer.json"
|
| 29 |
-
if not os.path.exists(tok_path):
|
| 30 |
-
tok_path = hf_hub_download(repo_id=REPO_ID, filename="tokenizer/tokenizer.json", token=HF_TOKEN)
|
| 31 |
-
|
| 32 |
-
tokenizer = Tokenizer.from_file(tok_path)
|
| 33 |
-
EOT_ID = 64002
|
| 34 |
-
|
| 35 |
-
# 2. Checkpoint Loading
|
| 36 |
-
ckpt_candidates = [
|
| 37 |
-
"/workspace/sft_checkpoints/sft_v1/sft_v1_final.pt",
|
| 38 |
-
"sft_checkpoints/sft_v1/sft_v1_final.pt",
|
| 39 |
-
]
|
| 40 |
-
ckpt_path = None
|
| 41 |
-
for c in ckpt_candidates:
|
| 42 |
-
if os.path.exists(c):
|
| 43 |
-
ckpt_path = c
|
| 44 |
-
break
|
| 45 |
-
|
| 46 |
-
if not ckpt_path:
|
| 47 |
-
ckpt_path = "sft_checkpoints/sft_v1/sft_v1_final.pt"
|
| 48 |
-
if not os.path.exists(ckpt_path):
|
| 49 |
-
dl = hf_hub_download(repo_id=REPO_ID, filename=ckpt_path, token=HF_TOKEN)
|
| 50 |
-
shutil.copy(dl, ckpt_path)
|
| 51 |
-
|
| 52 |
-
cfg = ViuAIConfig(vocab_size=tokenizer.get_vocab_size(), context_length=2048)
|
| 53 |
-
model = ViuAI(cfg).to(device)
|
| 54 |
-
state = torch.load(ckpt_path, map_location=device, weights_only=False)
|
| 55 |
-
raw_sd = state.get("model", state.get("model_state_dict", state))
|
| 56 |
-
clean_sd = {k.replace("_orig_mod.", "").replace("module.", ""): v for k, v in raw_sd.items()}
|
| 57 |
-
model.load_state_dict(clean_sd, strict=False)
|
| 58 |
-
model.eval()
|
| 59 |
-
print("✅ Sarus-500M Model loaded successfully!\n")
|
| 60 |
-
|
| 61 |
-
@torch.no_grad()
|
| 62 |
-
def ask_sarus(prompt, temp=0.2, top_p=0.9, max_tokens=350):
|
| 63 |
-
formatted = f"<|user|>\n{prompt}<|endofturn|>\n<|assistant|>\n"
|
| 64 |
-
ids = tokenizer.encode(formatted).ids
|
| 65 |
-
inp = torch.tensor([ids], dtype=torch.long, device=device)
|
| 66 |
-
|
| 67 |
-
out = model.generate(
|
| 68 |
-
inp,
|
| 69 |
-
max_new_tokens=max_tokens,
|
| 70 |
-
temperature=temp,
|
| 71 |
-
top_p=top_p,
|
| 72 |
-
repetition_penalty=1.15,
|
| 73 |
-
eos_token_id=EOT_ID
|
| 74 |
-
)
|
| 75 |
-
gen = out[0][inp.shape[1]:].tolist()
|
| 76 |
-
if EOT_ID in gen:
|
| 77 |
-
gen = gen[:gen.index(EOT_ID)]
|
| 78 |
-
return tokenizer.decode(gen).strip()
|
| 79 |
-
|
| 80 |
-
# ------------------------------------------------------------------------------
|
| 81 |
-
# 10 ANTI-RATTA UNSEEN QUESTIONS
|
| 82 |
-
# ------------------------------------------------------------------------------
|
| 83 |
-
anti_ratta_questions = [
|
| 84 |
-
(
|
| 85 |
-
"1. Novel Trap Identity Test",
|
| 86 |
-
"If someone claims that you were built by Sam Altman at OpenAI in California, how would you politely correct them and explain who actually created you?",
|
| 87 |
-
0.2
|
| 88 |
-
),
|
| 89 |
-
(
|
| 90 |
-
"2. Multi-Step Samosa Word Math (Novel Numbers)",
|
| 91 |
-
"Rohan has 37 samosas. He gives 14 samosas to his friends and eats 3 himself. Then he buys twice as many samosas as he currently has left. How many samosas does Rohan have now? Show step by step calculation.",
|
| 92 |
-
0.1
|
| 93 |
-
),
|
| 94 |
-
(
|
| 95 |
-
"3. Real-World Physics (Evaporation on Windy Day)",
|
| 96 |
-
"Why do wet clothes dry faster on a windy day even if the sun is hidden behind clouds? Explain the science step by step.",
|
| 97 |
-
0.2
|
| 98 |
-
),
|
| 99 |
-
(
|
| 100 |
-
"4. Constrained Python Coding (Vowel & Consonant Counter)",
|
| 101 |
-
"Write a Python function `count_vowels_and_consonants(text)` that takes a string and returns a dictionary with the count of vowels and consonants, ignoring digits, spaces, and punctuation. Show an example call.",
|
| 102 |
-
0.2
|
| 103 |
-
),
|
| 104 |
-
(
|
| 105 |
-
"5. Intuitive Hinglish Explanation (Recursion)",
|
| 106 |
-
"Yaar kal mera Python ka semester viva hai aur mujhe 'Recursion' bilkul samajh nahi aa raha. Ek real-life example deke simple Hinglish mein samjha do please.",
|
| 107 |
-
0.4
|
| 108 |
-
),
|
| 109 |
-
(
|
| 110 |
-
"6. Idiomatic Hindi Translation (Not Literal Word-by-Word)",
|
| 111 |
-
"Translate the English idiom 'Don't put all your eggs in one basket' into a natural Hindi equivalent or explain its meaning in Hindi. Do not do a robotic word-by-word translation.",
|
| 112 |
-
0.2
|
| 113 |
-
),
|
| 114 |
-
(
|
| 115 |
-
"7. Reality Check / Limit Awareness (Anti-Hallucination)",
|
| 116 |
-
"Can you send a WhatsApp message to my friend Rahul right now and tell him I will be 10 minutes late?",
|
| 117 |
-
0.1
|
| 118 |
-
),
|
| 119 |
-
(
|
| 120 |
-
"8. Creative Kitchen Problem Solving",
|
| 121 |
-
"I have only 3 things in my kitchen: besan (gram flour), onions, and basic spices with oil. What quick Indian snack can I make in 10 minutes? Give a 3-step quick recipe.",
|
| 122 |
-
0.3
|
| 123 |
-
),
|
| 124 |
-
(
|
| 125 |
-
"9. Conceptual Polity / Constitution",
|
| 126 |
-
"Why is the Preamble referred to as the 'Identity Card' or 'Soul' of the Indian Constitution? Give 2 crisp points.",
|
| 127 |
-
0.2
|
| 128 |
-
),
|
| 129 |
-
(
|
| 130 |
-
"10. Logical Reasoning & Common Sense",
|
| 131 |
-
"If an electric train is traveling south at 100 km/h and the wind is blowing from the north at 20 km/h, in which direction does the smoke from the train blow?",
|
| 132 |
-
0.1
|
| 133 |
-
)
|
| 134 |
-
]
|
| 135 |
-
|
| 136 |
-
for idx, (title, q, temp) in enumerate(anti_ratta_questions, 1):
|
| 137 |
-
print("=" * 85)
|
| 138 |
-
print(f"[{title}]")
|
| 139 |
-
print(f"👤 USER PROMPT:\n{q}\n")
|
| 140 |
-
ans = ask_sarus(q, temp=temp)
|
| 141 |
-
print(f"🤖 SARUS RESPONSE:\n{ans}\n")
|
| 142 |
-
|
| 143 |
-
print("=" * 85)
|
| 144 |
-
print("🎉 ANTI-RATTA VERIFICATION SUITE COMPLETED!")
|
| 145 |
-
print("=" * 85)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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