@misterscan/sesi 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -34
- package/bin/sesi.js +163 -38
- package/dist/ai-runtime.d.ts.map +1 -1
- package/dist/ai-runtime.js +22 -4
- package/dist/ai-runtime.js.map +1 -1
- package/dist/builtins.d.ts +1 -0
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +257 -17
- package/dist/builtins.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/dist/interpreter.d.ts +17 -1
- package/dist/interpreter.d.ts.map +1 -1
- package/dist/interpreter.js +256 -98
- package/dist/interpreter.js.map +1 -1
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +8 -4
- package/dist/lexer.js.map +1 -1
- package/dist/parser.d.ts +2 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +76 -32
- package/dist/parser.js.map +1 -1
- package/dist/sesi.bundled.js +87 -20
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +33 -1
- package/dist/types.js.map +1 -1
- package/docs/ARCHITECTURE.md +26 -9
- package/docs/BUILTINS.md +111 -13
- package/docs/COMPARISON.md +7 -9
- package/docs/{DISTRIBUTED_SYSTEMS.md → CONCURRENCY.md} +11 -11
- package/docs/IMAGE_GENERATION.md +13 -14
- package/docs/IMPLEMENTATION_SUMMARY.md +141 -84
- package/docs/QUICKSTART.md +81 -28
- package/docs/README.md +140 -34
- package/docs/{SYSTEMS_REASONING.md → REASONING.md} +107 -109
- package/docs/ROADMAP.md +44 -44
- package/docs/SKILLS.md +56 -28
- package/docs/SPECIFICATION.md +25 -18
- package/docs/sesi_ai_chronicles.md +96 -209
- package/examples/07_prompts.sesi +1 -1
- package/examples/08_model_call.sesi +1 -1
- package/examples/09_structured_output.sesi +1 -1
- package/examples/10_code_generation.sesi +1 -1
- package/examples/13_data_pipeline.sesi +1 -1
- package/examples/14_folder_explainer.sesi +2 -2
- package/examples/15_image_generation.sesi +1 -1
- package/examples/16_modules.sesi +27 -27
- package/examples/19_search_web.sesi +4 -0
- package/examples/20_model_aliases.sesi +22 -0
- package/examples/21_custom_tools.sesi +27 -0
- package/examples/22_reasoning_plus_custom_tools.sesi +19 -0
- package/main/orchestrator.sesi +2 -2
- package/main/sesi_db_chatbot.sesi +7 -3
- package/main/tests/test_grounding.sesi +2 -0
- package/package.json +6 -6
|
@@ -1,209 +1,96 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## 📖 Executive Summary
|
|
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
|
-
The
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* **The
|
|
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
|
-
## 🧠 Neural Network Mathematics & Backpropagation Pipeline
|
|
101
|
-
|
|
102
|
-
Sesi AI uses a **10x3 Single-Layer Feedforward Neural Network Classifier** to distribute semantic probability.
|
|
103
|
-
|
|
104
|
-
### 1. Vectorization Space (Bag-of-Words)
|
|
105
|
-
The input text is tokenized, stripped of punctuation, and mapped against a **10-Feature Vocabulary**:
|
|
106
|
-
$$\mathcal{V} = [\text{"synthesizer"}, \text{"vinyl"}, \text{"record"}, \text{"wood"}, \text{"gears"}, \text{"clock"}, \text{"compiler"}, \text{"framework"}, \text{"memory"}, \text{"offline"}]$$
|
|
107
|
-
|
|
108
|
-
Each string produces a 10-dimensional one-hot representation vector $\mathbf{x} \in \mathbb{R}^{10}$, where:
|
|
109
|
-
$$x_i = \begin{cases} 1.0 & \text{if } \mathcal{V}_i \in \text{input\_tokens} \\ 0.0 & \text{otherwise} \end{cases}$$
|
|
110
|
-
|
|
111
|
-
### 2. Forward Pass Mathematical Calculations
|
|
112
|
-
The 3 output classes correspond directly to our conversational domains:
|
|
113
|
-
$$\mathcal{C} = [\text{"audio"}, \text{"mechanical"}, \text{"systems"}]$$
|
|
114
|
-
|
|
115
|
-
For each class $c \in \{0, 1, 2\}$, the raw activation value $y_c$ is calculated against class biases $\mathbf{b} \in \mathbb{R}^3$ and weights $\mathbf{W} \in \mathbb{R}^{3 \times 10}$:
|
|
116
|
-
$$y_c = b_c + \sum_{i=1}^{10} x_i \cdot W_{c, i}$$
|
|
117
|
-
|
|
118
|
-
To calculate normalized probability distributions $\mathbf{p} \in \mathbb{R}^3$ without overflow on limited custom interpreters, we implement a **Softmax activation function**:
|
|
119
|
-
$$p_c = \frac{e^{y_c}}{\sum_{j=0}^{2} e^{y_j}}$$
|
|
120
|
-
|
|
121
|
-
### 3. Backpropagation Gradient Updates
|
|
122
|
-
Natively programmed in Sesi, the network is trained using **Mean Squared Error (MSE) loss** combined with Sigmoid/Softmax derivatives to adjust weights and biases over thousands of epochs:
|
|
123
|
-
$$\mathbf{W}_{c, i} \leftarrow \mathbf{W}_{c, i} - \eta \cdot \frac{\partial \mathcal{L}}{\partial W_{c, i}}$$
|
|
124
|
-
Where $\eta$ represents the optimized learning rate (`0.30` - `0.45`).
|
|
125
|
-
|
|
126
|
-
The final calibrated parameters are stored in **[`main/response_classifier_weights.json`](file:///c:/Users/owner/Documents/Sesi/main/response_classifier_weights.json)**:
|
|
127
|
-
```json
|
|
128
|
-
{
|
|
129
|
-
"weights": [
|
|
130
|
-
[18.51, 18.35, 20.76, -16.23, 0.08, -0.03, -15.94, -16.59, 0.42, -15.24],
|
|
131
|
-
[-16.51, -16.25, -18.64, 17.02, -0.11, -0.27, -17.95, -18.82, 0.23, -17.17],
|
|
132
|
-
[-16.76, -16.51, -18.92, -15.86, -0.35, -0.24, 18.66, 19.53, -0.40, 17.88]
|
|
133
|
-
],
|
|
134
|
-
"biases": [-1.884, -0.418, -0.128]
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## 🔗 The Win95 Netscape Navigator Dialectic Portal (V4)
|
|
141
|
-
|
|
142
|
-
### 1. Visual Aesthetics & Window Layout
|
|
143
|
-
The Netscape Portal (**[`retro_chat.html`](file:///c:/Users/owner/Documents/Sesi/main/retro_chat.html)**) implements a beautiful, glassmorphic-inspired Win95 desktop layout:
|
|
144
|
-
* A Win95 Teal desktop background (`#008080`).
|
|
145
|
-
* A fully beveled Netscape Navigator program frame with Linear Gradient title bars, menu panels (`File`, `Edit`, `View`), beveled location input fields, and standard back/forward button controls.
|
|
146
|
-
* A high-contrast, black-and-green IRC chat log console.
|
|
147
|
-
* Real-time color-coded neural tag flags: `[NEURAL: audio]` in vibrant green, `[NEURAL: mechanical]` in bright yellow, and `[NEURAL: systems]` in deep cyan.
|
|
148
|
-
|
|
149
|
-
### 2. The Graph-Loop Repetition Vulnerability
|
|
150
|
-
During early iterations of Markov dialogue walkers, characters would routinely fall into **infinite graph loops**. Because standard bigrams only evaluate a 1-word lookahead, the generator maintains no global semantic context. If the walker selects a common word pair (e.g. `"...how the..."`), the walk can jump back onto an identical path, repeating:
|
|
151
|
-
> *"You should hear how the retro chiptune audio loop plays... You should hear how the retro chiptune..."*
|
|
152
|
-
|
|
153
|
-
### 3. Engineering the Unbreakable Decoding Filters
|
|
154
|
-
To guarantee loop-free, natural prose, we designed and integrated modern LLM-grade decoding constraints natively into the walker:
|
|
155
|
-
1. **Extended Sliding Lookback (Size 15):** The walker maintains a history of the last 15 generated tokens. If a candidate word resides within this sliding window, it is instantly penalized and rejected.
|
|
156
|
-
2. **Strict Bigram Blocking (`No-Repeat-N-Gram` Size 2):** The walker tracks every transition pair `(w1 -> w2)` generated in the current sentence. If a proposed transition `current_word -> candidate` has **already occurred anywhere** in the history array, that candidate is completely banned and the walker selects an alternative.
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## 📻 The Natively Neural-Empathetic Terminal Chat REPL (V4)
|
|
161
|
-
|
|
162
|
-
The terminal chat portal (**[`main/terminal_chat.py`](file:///c:/Users/owner/Documents/Sesi/main/terminal_chat.py)**) provides an interactive, robust, and highly aesthetic command-line gateway.
|
|
163
|
-
|
|
164
|
-
### 1. Interactive Selection Directory
|
|
165
|
-
On launch, the REPL prints a beautiful, double-beveled ASCII table listing all 20 specialized experts with their native age and categorized domains. The operator can input index `[0-19]` to dial in a secure offline connection to their desired persona.
|
|
166
|
-
|
|
167
|
-
### 2. HSL-Aligned Terminal Dials & Probability Bars
|
|
168
|
-
Upon every conversational turn, the REPL prints a visually outstanding probability progress bar detailing the exact softmax confidence distribution:
|
|
169
|
-
```ansi
|
|
170
|
-
[ NEURAL RESPONSE CLASSIFICATION ]
|
|
171
|
-
[ AUDIO ████████████████ (100.0%) ]
|
|
172
|
-
[ MECH ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ( 0.0%) ]
|
|
173
|
-
[ SYSTEM ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ( 0.0%) ]
|
|
174
|
-
[ ROUTING COGNITIVE FLOW -> AUDIO CLASS ]
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### 3. Cognitive Brain Morphing & Dynamic Empathy Bridges
|
|
178
|
-
* **Dynamic Morphing:** If you are talking to a `systems` specialist but type an `audio` focused comment, the specialist **instantly morphs their transition matrices** to access the audio corpus, mirroring your cognitive focus.
|
|
179
|
-
* **Empathetic Mismatch Bridges:** The specialist uses the mismatch to formulate a gorgeous technical analogy bridging their native specialty to your predicted domain (e.g. systems compiler pointers compared to mechanical gear leverages).
|
|
180
|
-
* **Loop-Free Prefix Variation:** To prevent prefix monotony, we engineered a dynamic dictionary mapping relationship pairs to pools of **3-4 random prefix variations**, selecting a fresh one on every conversational turn!
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## 📂 Mapping the Sesi AI Codebase
|
|
185
|
-
|
|
186
|
-
The architecture is divided logically across modular scripts, databases, and UI assets:
|
|
187
|
-
|
|
188
|
-
### 1. Dynamic Code Files
|
|
189
|
-
* **[`main/terminal_chat.py`](file:///c:/Users/owner/Documents/Sesi/main/terminal_chat.py) [NEW V4]:** The interactive python terminal REPL gateway. Integrates dynamic prefix variations, HSL colored probability bars, cognitive brain morphing, and loop-free bigram blocking.
|
|
190
|
-
* **[`main/retro_chat_generator.sesi`](file:///c:/Users/owner/Documents/Sesi/main/retro_chat_generator.sesi) [NEW V4]:** Compiles the offline 3-category Markov brains, performs real-time neural inference loops in Sesi, runs the strict bigram-blocking walker, and writes the Win95 Netscape HTML portal.
|
|
191
|
-
* **[`main/nn_personas_trainer.sesi`](file:///c:/Users/owner/Documents/Sesi/main/nn_personas_trainer.sesi) [NEW]:** Trains a multi-class neural network on conversational sentences to zero-shot classify all 20 character bios.
|
|
192
|
-
* **[`main/nn_sentences_trainer.sesi`](file:///c:/Users/owner/Documents/Sesi/main/nn_sentences_trainer.sesi) [NEW]:** Inversely trains on character bios to zero-shot classify all 300 dialog sentences.
|
|
193
|
-
|
|
194
|
-
### 2. Calibrated Neural Synapses & Data Layers
|
|
195
|
-
* **[`main/response_classifier_weights.json`](file:///c:/Users/owner/Documents/Sesi/main/response_classifier_weights.json):** The calibrated 10x3 weights and 3x1 biases file.
|
|
196
|
-
* **[`main/personas.json`](file:///c:/Users/owner/Documents/Sesi/main/personas.json):** Roster of all 20 specialized expert character profiles.
|
|
197
|
-
* **[`main/varied_responses.json`](file:///c:/Users/owner/Documents/Sesi/main/varied_responses.json):** The 300 varied conversational sentences corpus (100 audio, 100 mechanical, 100 systems).
|
|
198
|
-
|
|
199
|
-
### 3. Display Portals
|
|
200
|
-
* **[`main/retro_chat.html`](file:///c:/Users/owner/Documents/Sesi/main/retro_chat.html):** The generated beveled Win95 Netscape Navigator portal loaded with loop-free, neural-adaptive dialectics.
|
|
201
|
-
|
|
202
|
-
---
|
|
203
|
-
|
|
204
|
-
## 🏆 Conclusion & The Future of Sesi AI
|
|
205
|
-
Sesi AI proves that complex, cognitively adaptive AI environments do not require massive modern cloud API integrations or bloated dependency frameworks.
|
|
206
|
-
|
|
207
|
-
By layering **simple feed-forward neural networks** over **probabilistic Markov structures** and applying **strict LLM-grade decoding constraints (bigram blocking)**, Sesi AI produces highly articulate, technically dense, and contextually empathetic dialog natively on localized hardware.
|
|
208
|
-
|
|
209
|
-
The Sesi compiler and its neural pipelines stand ready for further telemetry, higher-dimensional bag-of-words vocabularies, and expanded multi-layered neural configurations.
|
|
1
|
+
# Historical Stress Tests: Validating the Sesi Interpreter
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## 📖 Executive Summary
|
|
6
|
+
During the early development of **Sesi**—a custom, lightweight programming language with a tree-walking interpreter—we needed rigorous scripts to stress-test the interpreter's math, looping, and memory safety.
|
|
7
|
+
|
|
8
|
+
To prove the engine's viability without external library bloat, we wrote several complex algorithms from scratch natively in Sesi. This included vector math, probability state machines (Markov chains), and binary logic gate calculations.
|
|
9
|
+
|
|
10
|
+
This document serves as a historical record of those early stress tests, proving that Sesi can handle deep procedural logic reliably.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ⚙️ The Sesi Programming Language: Foundation & Architecture
|
|
15
|
+
|
|
16
|
+
### 1. Design Philosophy
|
|
17
|
+
Sesi is structured as a lightweight, offline-first programming language. It was developed to eliminate external library bloat and operate with absolute procedural transparency. Sesi is executed via a **custom tree-walking interpreter**, parsing source code files with a `.sesi` extension into an Abstract Syntax Tree (AST) before executing node traversals.
|
|
18
|
+
|
|
19
|
+
### 2. Core Syntactical Features
|
|
20
|
+
Sesi features a highly lightweight, C-like syntax:
|
|
21
|
+
* **Dynamic Typings & Coercion:** Explicit converters allow seamless casting: `num("123")`, `str(45.6)`, `type(val)`.
|
|
22
|
+
* **Dynamic Collections:** Array lists are fully supported with helper functions: `len(arr)`, `push(arr, element)`, `split(string, delimiter)`.
|
|
23
|
+
* **Natively Built-In JSON Parsing:** Crucial for model synchronization and database ingestion: `from_json(raw_string)`, `to_json(object)`.
|
|
24
|
+
* **Direct File System Access:** Natively handles persistent states: `read_file(path)`, `write_file(path, content)`.
|
|
25
|
+
|
|
26
|
+
### 3. Execution Characteristics and AST Constraints
|
|
27
|
+
Because the tree-walking interpreter processes code instructions by traversing AST nodes directly on every statement:
|
|
28
|
+
* **Computational Complexity (O-Notation):** String tokenization, Bag-of-Words mapping, and high-epoch training loops run entirely in single-threaded user space.
|
|
29
|
+
* **Optimization Solutions:** Highly recursive operations are avoided, and large text operations are optimized using localized index boundaries rather than heavy string concatenations.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 📈 The Sesi Stress Tests
|
|
34
|
+
|
|
35
|
+
To achieve stability, we implemented several extreme execution scenarios to guarantee Sesi's performance under load:
|
|
36
|
+
|
|
37
|
+
### Test 1: Probabilistic Bigram Markov Walkers
|
|
38
|
+
To test memory allocation and text parsing, we mapped 300 varied dialogue responses into localized word association tables (Bigram Tables).
|
|
39
|
+
* The walker parsed a text corpus, mapping transitions: `transitions[word_1] = [word_2, word_3, ...]`.
|
|
40
|
+
* This validated deeply nested Object-Array insertions within Sesi's AST processing.
|
|
41
|
+
|
|
42
|
+
### Test 2: The Proving Ground - Floating Point Logic Gates (`main/sesi_ai.sesi`)
|
|
43
|
+
To verify if the custom AST-traversing tree-walking compiler could execute math-heavy loop blocks, we programmed raw mathematical logic tests using binary `1` and `0` inputs:
|
|
44
|
+
|
|
45
|
+
#### 1. The Zero-Dependency Logic Test
|
|
46
|
+
We engineered a 2-Layer Feedforward Neural Network trained **natively in pure Sesi** to solve the non-linear **XOR Logical Gate** table with absolute zero external language dependencies:
|
|
47
|
+
* **The Math:** Structured a multi-layered network (2 Inputs, 2 Hidden Neurons, 1 Output Neuron) utilizing pure procedure-loop Sigmoid functions and derivatives:
|
|
48
|
+
$$f(x) = \frac{1}{1 + e^{-x}}, \quad f'(y) = y \cdot (1 - y)$$
|
|
49
|
+
* **The Self-Healing Watchdog Engine:** Since random weight allocations can sometimes get stuck in local minima linear traps, we engineered an automated **Self-Healing Watchdog** directly inside the Sesi script:
|
|
50
|
+
- All synaptic weights ($W_{hidden}$, $W_{output}$) and biases ($B_{hidden}$, $b_{output}$) were randomized to $[-2.0, 2.0]$.
|
|
51
|
+
- The model underwent **4,000 backpropagation training epochs** at a learning rate ($\eta$) of `0.40`.
|
|
52
|
+
- After the loop, the watchdog evaluated the final Mean Squared Error (MSE).
|
|
53
|
+
- If $MSE \ge 0.01$, the watchdog triggered an automatic retry:
|
|
54
|
+
```
|
|
55
|
+
⚠️ Stuck in linear saddle trap (MSE: 0.098). Re-seeding synapses...
|
|
56
|
+
⚡ Training attempt #2...
|
|
57
|
+
```
|
|
58
|
+
- It repeatedly re-seeded the synapses and re-ran the training until the model achieved perfect convergence ($MSE < 0.01$).
|
|
59
|
+
* **Significance:** Once the watchdog printed `🎯 Perfect convergence achieved!`, Sesi saved the trained synapses to `sesi_model_weights.json` using `write_file(..., to_json(...))`. This proved mathematically that the custom Sesi tree-walker was capable of deep recursion, greenlighting the interpreter for general purpose computing!
|
|
60
|
+
|
|
61
|
+
#### 2. The Native Sesi AND Logic Gate (`main/playground.sesi`)
|
|
62
|
+
To test single-neuron floating-point calculations and weight adjustments on a simpler truth table, we trained a single-neuron classifier to solve the binary **AND Logical Gate**:
|
|
63
|
+
* **The Math:** Developed a custom, high-speed **Fast Sigmoid (Softsign)** activation function to prevent custom AST float representation overflows:
|
|
64
|
+
$$f(x) = 0.5 + 0.5 \cdot \left(\frac{x}{1 + |x|}\right)$$
|
|
65
|
+
accompanied by its exact analytical derivative $f'(y) = y \cdot (1 - y)$.
|
|
66
|
+
* **Training Parameters:** Programmed weight and bias gradient backpropagation updates ($w_i \leftarrow w_i + \eta \cdot \text{error} \cdot f'(y) \cdot x_i$) over **1,500 epochs** at a learning rate ($\eta$) of `0.30`.
|
|
67
|
+
* **Results:** Successfully converged to a near-zero Mean Squared Error (MSE) loss of **`0.003`**, saving calibrated parameters to `model_weights.json` and delivering 100% accurate binary logic evaluations.
|
|
68
|
+
|
|
69
|
+
#### 3. The Telemetric Python XOR Network (`gpu_trainer.py`)
|
|
70
|
+
To visualize training curves dynamically, we built a duplicate **2-Layer XOR Network** from scratch in Python, integrating direct graphics card telemetry:
|
|
71
|
+
* **The Math:** Implemented standard Sigmoid functions. To guarantee symmetry breaking and force perfect deterministic convergence, weights were initialized dynamically to a wider $[-2.5, 2.5]$ range under seed `42` at a learning rate of `0.35` across `8000` epochs.
|
|
72
|
+
* **GPU Hardware Telemetry:** Embedded an active loop querying your physical **NVIDIA GeForce GTX 1660 Ti** graphics card, tracking live dedicated VRAM consumption (GDDR6 pool), core graphics utilization, and core operating temperatures.
|
|
73
|
+
* **Telemetry Dashboard:** Built a daemon local HTTP server on port 8000 to bypass browser CORS security protocols, streaming epoch-by-epoch predictions and training telemetry directly into the glowing SVG circular gauges of **[`training_hub.html`](file:///c:/Users/owner/Documents/Sesi/training_hub.html)**.
|
|
74
|
+
|
|
75
|
+
### Stage 3: A Native "Baby" Neural Network (Text Classification)
|
|
76
|
+
Having successfully proved logical gate convergence (XOR and AND), we decided to push the interpreter to the absolute limit. We built **`main/nn_personas_trainer.sesi`** and **`main/nn_responses_trainer.sesi`**, effectively creating a "baby" neural network entirely from scratch in pure Sesi.
|
|
77
|
+
|
|
78
|
+
Instead of binary logic, these scripts read raw character profiles and conversational sentences, constructed Bag-of-Words (BoW) feature vectors, and trained a 10x3 Single-Layer Feedforward Neural Network Classifier directly in the Sesi tree-walker over thousands of epochs.
|
|
79
|
+
|
|
80
|
+
#### 1. Vectorization Space (Bag-of-Words)
|
|
81
|
+
The input text was tokenized, stripped of punctuation, and mapped against a **10-Feature Vocabulary**. Each string produced a 10-dimensional one-hot representation vector.
|
|
82
|
+
|
|
83
|
+
#### 2. Forward Pass & Softmax
|
|
84
|
+
For our 3 output classes (e.g., "audio", "mechanical", "systems"), the raw activation value was calculated against class biases and weights. To calculate probability distributions without overflow on a custom AST interpreter, we successfully implemented a **Softmax activation function** in pure Sesi math.
|
|
85
|
+
|
|
86
|
+
#### 3. Backpropagation
|
|
87
|
+
Natively programmed in Sesi, the network computed Mean Squared Error (MSE) loss combined with Softmax derivatives to adjust weights and biases.
|
|
88
|
+
The final calibrated parameters were stored perfectly in **`response_classifier_weights.json`**.
|
|
89
|
+
|
|
90
|
+
This wasn't an API call. It was raw floating-point math, gradient descent, and high-epoch loops executed flawlessly by our custom AST interpreter over thousands of iterations.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 🧠 Conclusion
|
|
95
|
+
|
|
96
|
+
These early neural network and Markov scripts served as the ultimate stress test. They proved that a custom AST tree-walking interpreter could handle intense computational workloads. The Sesi compiler successfully demonstrated stability in floating-point calculus, vector matrix math, deep file I/O operations, and dynamic array handling natively on localized hardware, paving the way for Sesi's future as a stable, lightweight programming language.
|
package/examples/07_prompts.sesi
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Prompt blocks - composable message templates
|
|
2
2
|
prompt greetingTemplate {"Hello! " "How are you today?"}
|
|
3
|
-
prompt responseTemplate {greetingTemplate "
|
|
3
|
+
prompt responseTemplate {greetingTemplate " I hope you're having a great day!"}
|
|
4
4
|
// Prompts evaluate to strings
|
|
5
5
|
let greeting = responseTemplate
|
|
6
6
|
print greeting
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Reasoning-powered text analysis using model calls
|
|
2
2
|
// Requires GEMINI_API_KEY environment variable
|
|
3
3
|
let text = "Artificial intelligence is transforming how we work and live"
|
|
4
|
-
let analysis = model("gemini-3.1-flash-lite") {
|
|
4
|
+
let analysis = model("gemini-3.1-flash-lite") {temperature: 0.5, max_tokens: 400} {"Analyze the following text and provide 3 concise key insights. Keep the total response under 120 words. " text}
|
|
5
5
|
print "Analysis:" analysis
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Sentiment analysis with structured output
|
|
2
2
|
// Requires GEMINI_API_KEY environment variable
|
|
3
3
|
let review = "This product is amazing! I love how it works. Highly recommended!"
|
|
4
|
-
let sentiment = structured_output({sentiment: string, confidence: number, keywords: string})(model("gemini-3.1-flash-lite") {"Analyze the sentiment of this review and extract key information.
|
|
4
|
+
let sentiment = structured_output({sentiment: string, confidence: number, keywords: string})(model("gemini-3.1-flash-lite") {"Analyze the sentiment of this review and extract key information. Return JSON with: sentiment (positive/negative/neutral), confidence (0-1), keywords (comma-separated) " review})
|
|
5
5
|
print "Sentiment:" sentiment["sentiment"]
|
|
6
6
|
print "Confidence:" sentiment["confidence"]
|
|
7
7
|
print "Keywords:" sentiment["keywords"]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Code generation with Reasoning
|
|
2
2
|
// Requires GEMINI_API_KEY environment variable
|
|
3
3
|
let requirement = "A function that checks if a number is prime"
|
|
4
|
-
let generatedCode = model("gemini-3.1-flash-lite") {
|
|
4
|
+
let generatedCode = model("gemini-3.1-flash-lite") {temperature: 0.2, max_tokens: 500} {"Generate JavaScript code for the following requirement: " requirement " Provide only the code, no explanation."}
|
|
5
5
|
print "Generated Code:" generatedCode
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
let reviews = ["This product is amazing! Highly recommended.", "Terrible quality. Waste of money.", "It's okay. Nothing special.", "Love it! Best purchase ever.", "Disappointed. Poor customer service."]
|
|
5
5
|
// Function to analyze single review
|
|
6
6
|
fn analyzeReview(review: string) -> object {
|
|
7
|
-
return structured_output({sentiment: string, confidence: number})(model("gemini-3.1-flash-lite") {
|
|
7
|
+
return structured_output({sentiment: string, confidence: number})(model("gemini-3.1-flash-lite") {temperature: 0.3} {"Analyze sentiment. Return JSON with sentiment (positive/negative/neutral) and confidence (0-1). Review:" review})
|
|
8
8
|
}
|
|
9
9
|
// Process all reviews
|
|
10
10
|
print ("Processing " + len(reviews) + " reviews...")
|
|
@@ -9,7 +9,7 @@ let reports = []
|
|
|
9
9
|
fn analyzeFile(fullPath: string) -> object {
|
|
10
10
|
try
|
|
11
11
|
{let source = read_file(fullPath)
|
|
12
|
-
return structured_output({fileName: string, summary: string, complexity: string})(model("gemini-3.1-flash-lite") {
|
|
12
|
+
return structured_output({fileName: string, summary: string, complexity: string})(model("gemini-3.1-flash-lite") {temperature: 0.2} {"Analyze this file and summarize its purpose. Return JSON with fileName, summary, and complexity (low/medium/high). File path: " fullPath " Contents: " source})}
|
|
13
13
|
catch (e)
|
|
14
14
|
{return {"fileName": fullPath, "summary": "Failed to read or analyze file", "complexity": "unknown"}}}
|
|
15
15
|
for file in files {
|
|
@@ -24,7 +24,7 @@ push(reports, report)
|
|
|
24
24
|
print "Summary:" report["summary"]
|
|
25
25
|
print "Complexity:" report["complexity"]}}}
|
|
26
26
|
print "Generating folder overview..."
|
|
27
|
-
let folderSummary = structured_output({folderOverview: string, keyThemes: array<string>})(model("gemini-3.1-flash-lite") {
|
|
27
|
+
let folderSummary = structured_output({folderOverview: string, keyThemes: array<string>})(model("gemini-3.1-flash-lite") {temperature: 0.2} {"You are summarizing the contents of a documentation folder based on file analyses. Return JSON with folderOverview and keyThemes. Analysis:" reports})
|
|
28
28
|
print "=== Final Folder Summary ==="
|
|
29
29
|
print "Overview:" folderSummary["folderOverview"]
|
|
30
30
|
print "Key Themes:" join(folderSummary["keyThemes"], ", ")
|
|
@@ -9,7 +9,7 @@ for product in products
|
|
|
9
9
|
prompt request {"A clean studio presentation photograph of a " product " on a solid white background."}
|
|
10
10
|
prompt filename { outputDir product ".png" }
|
|
11
11
|
try
|
|
12
|
-
{let imageData = image("gemini-3.1-flash-image-preview") {
|
|
12
|
+
{let imageData = image("gemini-3.1-flash-image-preview") {ratio: '1:1', size: "1K"} {request}
|
|
13
13
|
let success = write_image(filename, imageData)
|
|
14
14
|
if success {print "Saved:" filename}}
|
|
15
15
|
catch (e) {print "Failed processing" product ":"
|
package/examples/16_modules.sesi
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// Example 16: Modules and Standard Library Namespace
|
|
2
|
-
// Demonstrates:
|
|
3
|
-
// 1. Importing named variables/functions from standard library modules.
|
|
4
|
-
// 2. Importing custom Sesi modules using relative paths.
|
|
5
|
-
|
|
6
|
-
print "=== 1. Standard Math Module ==="
|
|
7
|
-
import {PI, E, sqrt, pow, sin} from "std/math"
|
|
8
|
-
print "PI constant:" + str(PI)
|
|
9
|
-
print "Euler's number:" + str(E)
|
|
10
|
-
print "Square root of 144:" + str(sqrt(144))
|
|
11
|
-
print "2 raised to power of 10:" + str(pow(2, 10))
|
|
12
|
-
print "Sine of PI/2:" + str(sin(PI / 2.0))
|
|
13
|
-
print "=== 2. Standard JSON Module ==="
|
|
14
|
-
import {stringify, parse} from "std/json"
|
|
15
|
-
let original = {"project": "Sesi Language", "version": "1.
|
|
16
|
-
let json_str = stringify(original)
|
|
17
|
-
print "Serialized JSON string:"
|
|
18
|
-
print json_str
|
|
19
|
-
let restored = parse(json_str)
|
|
20
|
-
print "Deserialized Project Name:" restored["project"]
|
|
21
|
-
print "Deserialized Version:" restored["version"]
|
|
22
|
-
print "=== 3. Custom Sesi Module ==="
|
|
23
|
-
|
|
24
|
-
// Relative imports let you reuse Sesi code across files cleanly.
|
|
25
|
-
// We will import custom exported variables and functions from a local module.
|
|
26
|
-
import {magic_number, multiply} from "main/tests/temp_math_mod"
|
|
27
|
-
print "Imported magic number from local module:" + str(magic_number)
|
|
1
|
+
// Example 16: Modules and Standard Library Namespace
|
|
2
|
+
// Demonstrates:
|
|
3
|
+
// 1. Importing named variables/functions from standard library modules.
|
|
4
|
+
// 2. Importing custom Sesi modules using relative paths.
|
|
5
|
+
|
|
6
|
+
print "=== 1. Standard Math Module ==="
|
|
7
|
+
import {PI, E, sqrt, pow, sin} from "std/math"
|
|
8
|
+
print "PI constant:" + str(PI)
|
|
9
|
+
print "Euler's number:" + str(E)
|
|
10
|
+
print "Square root of 144:" + str(sqrt(144))
|
|
11
|
+
print "2 raised to power of 10:" + str(pow(2, 10))
|
|
12
|
+
print "Sine of PI/2:" + str(sin(PI / 2.0))
|
|
13
|
+
print "=== 2. Standard JSON Module ==="
|
|
14
|
+
import {stringify, parse} from "std/json"
|
|
15
|
+
let original = {"project": "Sesi Language", "version": "1.3.0", "features": ["modules", "http", "parallel"]}
|
|
16
|
+
let json_str = stringify(original)
|
|
17
|
+
print "Serialized JSON string:"
|
|
18
|
+
print json_str
|
|
19
|
+
let restored = parse(json_str)
|
|
20
|
+
print "Deserialized Project Name:" restored["project"]
|
|
21
|
+
print "Deserialized Version:" restored["version"]
|
|
22
|
+
print "=== 3. Custom Sesi Module ==="
|
|
23
|
+
|
|
24
|
+
// Relative imports let you reuse Sesi code across files cleanly.
|
|
25
|
+
// We will import custom exported variables and functions from a local module.
|
|
26
|
+
import {magic_number, multiply} from "main/tests/temp_math_mod"
|
|
27
|
+
print "Imported magic number from local module:" + str(magic_number)
|
|
28
28
|
print "Running imported multiply(5, 5):" + str(multiply(5, 5))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Example 20: Model Aliases
|
|
2
|
+
// Demonstrates:
|
|
3
|
+
// 1. set_alias(alias, model)
|
|
4
|
+
// 2. Using aliases with model()
|
|
5
|
+
// 3. Using aliases inside workflow() steps
|
|
6
|
+
|
|
7
|
+
print "=== Registering model aliases ==="
|
|
8
|
+
set_alias("fast", "gemini-3.1-flash-lite")
|
|
9
|
+
set_alias("balanced", "gemini-3-flash-preview")
|
|
10
|
+
print "=== Fast summary call ==="
|
|
11
|
+
let quick = model("fast") {max_tokens: 220} {"Summarize the benefits of model aliases in two short bullet points."}
|
|
12
|
+
print quick
|
|
13
|
+
print "=== Deeper reasoning call ==="
|
|
14
|
+
let deepAnswer = model("balanced") {thinkingLevel: "high", max_tokens: 320} {"Give one practical tradeoff between a fast model and a deep reasoning model."}
|
|
15
|
+
print deepAnswer
|
|
16
|
+
print "=== Workflow with aliased model names ==="
|
|
17
|
+
let steps = [
|
|
18
|
+
{"model": "fast", "prompt": "Draft a one-line launch update about aliases: "},
|
|
19
|
+
{"model": "fast", "prompt": "Tighten wording and remove fluff: "}
|
|
20
|
+
]
|
|
21
|
+
let flow = workflow(steps, "Custom model naming is now available")
|
|
22
|
+
print flow["final"]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Example 21: Custom Tool Definitions
|
|
2
|
+
// Demonstrates:
|
|
3
|
+
// 1. define_tool(name, fn, description)
|
|
4
|
+
// 2. list_tools()
|
|
5
|
+
// 3. tool_call(customTool)(...)
|
|
6
|
+
|
|
7
|
+
fn normalizeText(text) {
|
|
8
|
+
return "normalized: " + text
|
|
9
|
+
}
|
|
10
|
+
fn classifyLength(text) {
|
|
11
|
+
if len(text) > 30 {
|
|
12
|
+
return "long"
|
|
13
|
+
} else {
|
|
14
|
+
return "short"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
print "=== Registering custom tools ==="
|
|
18
|
+
define_tool("normalize_text", normalizeText, "Normalize input text for downstream steps")
|
|
19
|
+
define_tool("classify_length", classifyLength, "Classify text by length")
|
|
20
|
+
print "=== Custom tool names ==="
|
|
21
|
+
let names = list_tools()
|
|
22
|
+
print names
|
|
23
|
+
let raw = "Sesi can define and call custom tools at runtime."
|
|
24
|
+
let normalized = tool_call(normalize_text)(raw)
|
|
25
|
+
let label = tool_call(classify_length)(normalized)
|
|
26
|
+
print "normalized -> " normalized
|
|
27
|
+
print "label -> " label
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Example 22: Reasoning + Custom Tools
|
|
2
|
+
// Demonstrates composing model() output with define_tool and tool_call.
|
|
3
|
+
|
|
4
|
+
set_alias("fast", "gemini-3.1-flash-lite")
|
|
5
|
+
fn toBullet(text) {
|
|
6
|
+
return "- " + text
|
|
7
|
+
}
|
|
8
|
+
fn addTag(text) {
|
|
9
|
+
return text + " [ready]"
|
|
10
|
+
}
|
|
11
|
+
define_tool("to_bullet", toBullet, "Convert text to bullet format")
|
|
12
|
+
define_tool("add_tag", addTag, "Append release tag")
|
|
13
|
+
let draft = model("fast") {max_tokens: 180} {"Write one concise launch note for model aliases and custom tools."}
|
|
14
|
+
let bullet = tool_call(to_bullet)(draft)
|
|
15
|
+
let tagged = tool_call(add_tag)(bullet)
|
|
16
|
+
print "Raw draft:"
|
|
17
|
+
print draft
|
|
18
|
+
print "Processed output:"
|
|
19
|
+
print tagged
|
package/main/orchestrator.sesi
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
print "🚀 Master: Launching 5
|
|
1
|
+
print "🚀 Master: Launching 5 Concurrent Processes..."
|
|
2
2
|
make_dir("bank")
|
|
3
3
|
write_file("bank/balance.txt", "1000")
|
|
4
4
|
write_file("bank/lock.txt", "unlocked")
|
|
@@ -11,5 +11,5 @@ spawn("main/atm_deposit.sesi")
|
|
|
11
11
|
let finished = false
|
|
12
12
|
while !finished {let countStr = read_file("bank/done_count.txt")
|
|
13
13
|
if countStr != "" {if num(countStr) >= 5 {finished = true}}}
|
|
14
|
-
print "🏦 Vault:
|
|
14
|
+
print "🏦 Vault: Concurrent processes finished."
|
|
15
15
|
print "Final Balance:" read_file("bank/balance.txt")
|
|
@@ -7,6 +7,10 @@ let queryText = "how do I parse a json string?"
|
|
|
7
7
|
try {
|
|
8
8
|
queryText = read_file("query.txt")
|
|
9
9
|
} catch (e) {}
|
|
10
|
+
let fileContext = ""
|
|
11
|
+
try {
|
|
12
|
+
fileContext = read_file("help_context.txt")
|
|
13
|
+
} catch (e) {}
|
|
10
14
|
// ==================================================
|
|
11
15
|
|
|
12
16
|
print "=================================================="
|
|
@@ -25,7 +29,7 @@ try {
|
|
|
25
29
|
|
|
26
30
|
// Auto-summarize when history gets too long (saves tokens)
|
|
27
31
|
fn summarizeHistory() {
|
|
28
|
-
let summary = model("gemini-3.1-flash-lite") {
|
|
32
|
+
let summary = model("gemini-3.1-flash-lite") {temperature: 0, max_tokens: 300} {"Summarize this conversation history into key facts and context. Be very concise: " chatHistory}
|
|
29
33
|
chatHistory = "Previous conversation summary: " + summary
|
|
30
34
|
print "🗜️ Memory auto-summarized to save tokens."
|
|
31
35
|
}
|
|
@@ -262,9 +266,9 @@ if num_classes == 0 {
|
|
|
262
266
|
summarizeHistory()
|
|
263
267
|
}
|
|
264
268
|
|
|
265
|
-
let ragPrompt = "Conversation History:\n" + chatHistory + "\n\nSesi Official Reference Documentation:\n" + sesiDocs + "\n\nUser Query: " + queryText + "\n\nMatched Context from Sesi DB:\nSummary: " + rec["summary"] + "\nKey Rules: " + rec["key_rules"] + "\n\nInstructions: Write a direct, beautiful, highly conversational response to the user's question using strictly the matched rules.
|
|
269
|
+
let ragPrompt = "Conversation History:\n" + chatHistory + "\n\nSesi Official Reference Documentation:\n" + sesiDocs + "\n\nUser Query: " + queryText + "\n\nActive File Context:\n" + fileContext + "\n\nMatched Context from Sesi DB:\nSummary: " + rec["summary"] + "\nKey Rules: " + rec["key_rules"] + "\n\nInstructions: Write a direct, beautiful, highly conversational response to the user's question using strictly the matched rules. If Active File Context is present, use it directly and talk about that file concretely. Be helpful and concise. Do not mention that you got this from a database—act as a supportive code copilot. Reference any relevant prior conversation context when applicable."
|
|
266
270
|
|
|
267
|
-
let generated_response = model("gemini-3.1-flash-lite") {
|
|
271
|
+
let generated_response = model("gemini-3.1-flash-lite") {temperature: 0.2, max_tokens: 300} {ragPrompt}
|
|
268
272
|
|
|
269
273
|
// Append this turn to conversational memory
|
|
270
274
|
chatHistory = chatHistory + "\nUser: " + queryText + "\nAssistant: " + generated_response
|