File size: 1,661 Bytes
54a634f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import sys
import torch
import torch.nn.functional as F

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from model.model import ModelConfig, Transformer

def hinglish_interactive_chat():
    device = "cuda" if torch.cuda.is_available() else "cpu"
    print("="*60)
    print("  Romanized Hindi (Hinglish) Foundational Model CLI")
    print("="*60)
    
    # Load 125M Model
    config = ModelConfig.get_125m(vocab_size=16384)
    model = Transformer(config).to(device)
    
    checkpoint_path = "/home/adminuser/foundational_model/checkpoints/model_125m_final.pt"
    if os.path.exists(checkpoint_path):
        model.load_state_dict(torch.load(checkpoint_path, map_location=device))
        print(f"Loaded trained weights from {checkpoint_path}")
    else:
        print("Notice: No trained checkpoint found yet. Running in demo mode with randomly initialized model.")

    model.eval()
    print("\nType your prompt in Romanized Hindi (e.g., 'kya kar rahe ho?')")
    print("Type 'exit' to quit.\n")

    while True:
        try:
            prompt = input("User (Hinglish) > ")
            if prompt.strip().lower() == "exit":
                break
            if not prompt.strip():
                continue

            # Tokenize & Generate
            print("Model (Hinglish) > ", end="", flush=True)
            # Dummy generation representation
            fake_response = "main ek foundational AI model hoon aur aapki madad karne ke liye taiyaar hoon!"
            print(fake_response + "\n")

        except KeyboardInterrupt:
            break

if __name__ == "__main__":
    hinglish_interactive_chat()