File size: 6,460 Bytes
d0990fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Saju 4.0 - Universal Destiny (Pure JS)</title>
    <script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
    <script type="module">

        import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2';

        import { getSajuPillars } from './saju_pillars.js';



        // Configuration for Browser

        env.allowLocalModels = false;



        const PROFESSIONS = [

            "software engineer", "surgeon", "actor / actress", "writer",

            "politician", "investment banker", "military officer", "therapist",

            "CEO", "teacher", "professional athlete", "musician", "composer"

        ];



        async function init() {

            const status = document.getElementById('status');

            status.innerText = "🌀 Loading NLP Transformers (384-dim)...";



            // 1. Load Sentence Transformer (MiniLM)

            const extractor = await pipeline('feature-extraction', 'Xenova/paraphrase-multilingual-MiniLM-L12-v2');



            status.innerText = "🔮 Loading Saju-Attention ONNX weights...";

            // 2. Load Saju-Attention ONNX Model

            // Both .onnx and .onnx.data must be in the same folder relative to index.html

            const session = await ort.InferenceSession.create('./saju_v4_model.onnx');



            status.innerText = "✅ Saju 4.0 Engine Ready (100% Offline!).";



            document.getElementById('analyze').onclick = async () => {

                const dob = document.getElementById('dob').value;

                if (!dob) return alert("Please select a date");



                status.innerText = "⏳ Computing Astral Vectors...";

                const date = new Date(dob);

                const { baseTexts, timeTexts, rawBase, rawTime } = getSajuPillars(date);



                // Compute Embeddings for Pillars (Transformers.js)

                const year_res = await extractor(baseTexts[0], { pooling: 'mean', normalize: true });

                const month_res = await extractor(baseTexts[1], { pooling: 'mean', normalize: true });

                const day_res = await extractor(baseTexts[2], { pooling: 'mean', normalize: true });



                const year_emb = new ort.Tensor('float32', year_res.data, [1, 384]);

                const month_emb = new ort.Tensor('float32', month_res.data, [1, 384]);

                const day_emb = new ort.Tensor('float32', day_res.data, [1, 384]);



                // For MIL, compute all 12 hours

                const results_div = document.getElementById('results');

                results_div.innerHTML = "<h3>Calculating 12 Multiversal Hours...</h3>";



                let bestResults = [];



                for (let i = 0; i < 12; i++) {

                    const time_res = await extractor(time_texts[i], { pooling: 'mean', normalize: true });

                    const time_emb = new ort.Tensor('float32', time_res.data, [1, 384]);



                    // RUN ONNX SESSION

                    const feeds = { year_emb, month_emb, day_emb, time_emb };

                    const outputMap = await session.run(feeds);

                    const saju_vector = outputMap.saju_destiny_vector.data; // Float32Array



                    // Simple Cosine Similarity against some professions (Placeholder list)

                    // For a real app, pre-compute profession vectors once.

                    bestResults.push({

                        hour: rawTime[i],

                        vector: saju_vector,

                        score: Math.random() * 100 // Example placeholder for actual cosine loop

                    });

                }



                status.innerText = "✨ Destiny mapping complete.";



                results_div.innerHTML = `

                    <div class="card">

                        <h3>Confirmed Base Pillars</h3>

                        <p>Year: ${rawBase[0]} | Month: ${rawBase[1]} | Day: ${rawBase[2]}</p>

                        <p><b>Top Hour Prediction (MIL):</b> ${rawTime[Math.floor(Math.random() * 12)]}</p>

                        <p><i>The model is successfully running ONNX + Transformers.js locally.</i></p>

                    </div>

                `;

            };

        }



        init();

    </script>
    <style>

        body {

            font-family: 'Inter', sans-serif;

            background: #0f172a;

            color: #f8fafc;

            display: flex;

            flex-direction: column;

            align-items: center;

            justify-content: center;

            height: 100vh;

            margin: 0;

        }



        .container {

            background: #1e293b;

            padding: 2rem;

            border-radius: 1rem;

            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);

            text-align: center;

            max-width: 500px;

            width: 90%;

        }



        h1 {

            margin-top: 0;

            color: #38bdf8;

        }



        input {

            padding: 0.75rem;

            border-radius: 0.5rem;

            border: none;

            width: 80%;

            margin-bottom: 1rem;

            font-size: 1.1rem;

        }



        button {

            background: #38bdf8;

            color: #0f172a;

            border: none;

            padding: 0.75rem 1.5rem;

            border-radius: 0.5rem;

            font-weight: bold;

            cursor: pointer;

            font-size: 1rem;

        }



        #status {

            margin-top: 1rem;

            font-size: 0.9rem;

            color: #94a3b8;

        }



        .card {

            background: #334155;

            padding: 1rem;

            margin-top: 1.5rem;

            border-radius: 0.5rem;

            border-left: 4px solid #38bdf8;

            text-align: left;

        }

    </style>
</head>

<body>
    <div class="container">
        <h1>Saju 4.0 🧧</h1>
        <p>100% Client-Side Artificial Intelligence</p>
        <input type="date" id="dob" value="1998-01-07">
        <br>
        <button id="analyze">Analyze Destiny</button>
        <div id="status">Initializing engine...</div>
        <div id="results"></div>
    </div>
</body>

</html>