File size: 1,003 Bytes
46bb8ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
import torch

# 1. تحميل الإعدادات
with open('config.json', 'r') as f:
    config = json.load(f)

# 2. تحميل القاموس
with open('tokenizer_config.json', 'r', encoding='utf-8') as f:
    tokenizer_data = json.load(f)
    stoi = tokenizer_data['stoi']
    itos = {i: ch for ch, i in stoi.items()}

def encode(s): return [stoi.get(c, stoi[" "]) for c in s]
def decode(l): return "".join([itos.get(i, "") for i in l])

# 3. إنشاء النموذج
model = MedicalMasterAI(config)

# 4. تجربة النص العشوائي الذي أرسلته
random_string = "LنIBkيظقcظزSرoIeD!OxMعه*kDNO]وzOبXقآلt(بdأfk."
encoded_ids = encode(random_string)
print(f"Encoded IDs: {encoded_ids}")
print(f"Decoded Text: {decode(encoded_ids)}")

# محاكاة مرور البيانات عبر النموذج
input_tensor = torch.tensor([encoded_ids])
with torch.no_grad():
    logits = model(input_tensor)
    print(f"Output shape (Batch, Seq, Vocab): {logits.shape}")