<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pavel</title>
    <description>The latest articles on DEV Community by Pavel (@xzdes).</description>
    <link>https://dev.to/xzdes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3189947%2F559d45bb-fbaa-490c-94b6-fc3d7c73d301.png</url>
      <title>DEV Community: Pavel</title>
      <link>https://dev.to/xzdes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xzdes"/>
    <language>en</language>
    <item>
      <title>Synapse v1.0 — A Programming Language for AI, Not Humans</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Fri, 30 Jan 2026 21:18:37 +0000</pubDate>
      <link>https://dev.to/xzdes/synapse-v10-a-programming-language-for-ai-not-humans-4a2o</link>
      <guid>https://dev.to/xzdes/synapse-v10-a-programming-language-for-ai-not-humans-4a2o</guid>
      <description>&lt;p&gt;It’s finally ready.&lt;/p&gt;

&lt;p&gt;After six months of work and 16,500 lines of code, I’m introducing &lt;strong&gt;Synapse&lt;/strong&gt; — a programming language designed specifically for LLMs, not for programmers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why another language?
&lt;/h3&gt;

&lt;p&gt;Every existing language was built for humans: Python is for readability, Rust is for safety, and JavaScript is for ubiquity. But when Claude or GPT generates code, they often stumble over syntactic sugar, ambiguities, and complex indentation rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Synapse is a language that LLMs understand better than you do.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
And that’s not a bug — it’s a feature.&lt;/p&gt;


&lt;h3&gt;
  
  
  Key Advantages
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. S-Expression Syntax — 0% Ambiguity&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;fn&lt;/span&gt; &lt;span class="nv"&gt;factorial&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;factorial&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)))))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No &lt;code&gt;if x: ... elif: ... else:&lt;/code&gt;. No debates over tabs vs. spaces. One bracket equals one operation. LLMs generate this perfectly on the first try.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. ASG instead of AST — Code as a Graph&lt;/strong&gt;&lt;br&gt;
Traditional compilers build a tree. Synapse builds a graph (Abstract Semantic Graph). This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The AI sees all dependencies simultaneously.&lt;/li&gt;
&lt;li&gt;Code transformations are seamless.&lt;/li&gt;
&lt;li&gt;It’s perfectly optimized for analysis and refactoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Three Backends — One Codebase&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Interpreter:&lt;/strong&gt; Instant execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLVM:&lt;/strong&gt; Compilation into native code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebAssembly:&lt;/strong&gt; Run it in the browser.
Write once, deploy anywhere.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. LSP Out of the Box&lt;/strong&gt;&lt;br&gt;
Autocompletion, hover hints, and error diagnostics. Just plug it into VSCode and it works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Built-in Type Inference&lt;/strong&gt;&lt;br&gt;
Powered by &lt;strong&gt;Hindley-Milner&lt;/strong&gt; typing. Write code without annotations — the compiler figures it out for you.&lt;/p&gt;


&lt;h3&gt;
  
  
  What’s Under the Hood?
&lt;/h3&gt;

&lt;p&gt;✅ Full S-expression parser&lt;br&gt;&lt;br&gt;
✅ Interpreter with 60+ operations&lt;br&gt;&lt;br&gt;
✅ Pattern matching&lt;br&gt;&lt;br&gt;
✅ Lazy sequences&lt;br&gt;&lt;br&gt;
✅ Dicts / HashMaps&lt;br&gt;&lt;br&gt;
✅ Pipe operator &lt;code&gt;|&amp;gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;
✅ Try/catch error handling&lt;br&gt;&lt;br&gt;
✅ WASM compilation&lt;br&gt;&lt;br&gt;
✅ Module system&lt;br&gt;&lt;br&gt;
✅ Robust Standard Library&lt;br&gt;&lt;br&gt;
✅ 48/48 core tests passing  &lt;/p&gt;


&lt;h3&gt;
  
  
  Who is this for?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Not for you.&lt;/strong&gt; Seriously.&lt;/p&gt;

&lt;p&gt;Synapse was created so you could tell Claude:&lt;br&gt;&lt;br&gt;
&lt;em&gt;"Write me a web server in Synapse."&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;And it will. Without errors. On the first attempt. Because the syntax is architected for how an AI "thinks."&lt;/p&gt;


&lt;h3&gt;
  
  
  What’s Next (v1.1)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Official VSCode Extension Marketplace launch.&lt;/li&gt;
&lt;li&gt;  LLVM Closures.&lt;/li&gt;
&lt;li&gt;  Comprehensive tutorial with real-world examples.&lt;/li&gt;
&lt;li&gt;  Benchmarks vs. Python/Lua/Node.js.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  Try It Now
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Xzdes/synapse.git
&lt;span class="nb"&gt;cd &lt;/span&gt;synapse
cargo build &lt;span class="nt"&gt;--release&lt;/span&gt;
cargo run &lt;span class="nt"&gt;--bin&lt;/span&gt; synapse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Inside the REPL:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="nv"&gt;synapse&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s"&gt;"Hello from the future!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;Hello&lt;/span&gt; &lt;span class="nv"&gt;from&lt;/span&gt; &lt;span class="k"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;future!&lt;/span&gt;

&lt;span class="nv"&gt;synapse&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;range&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
             &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;filter&lt;/span&gt; &lt;span class="nv"&gt;even?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
             &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt; &lt;span class="nv"&gt;square&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
             &lt;span class="nv"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="mi"&gt;120&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is just the beginning. There is a lot of work ahead, but it’s already stable enough to touch, try, and break.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The language not for humans. The language for AI. The future.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;⭐ &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Xzdes/synapse" rel="noopener noreferrer"&gt;github.com/Xzdes/synapse&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;P.S. Yes, I know Lisp-like syntax isn't new. But no one has built it specifically for LLMs with a native WASM backend and built-in LSP from day one.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>rust</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Synapse 0.2: REPL, S-Expressions &amp; Working Loops</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Sun, 25 Jan 2026 18:50:45 +0000</pubDate>
      <link>https://dev.to/xzdes/synapse-02-repl-s-expressions-working-loops-4i8j</link>
      <guid>https://dev.to/xzdes/synapse-02-repl-s-expressions-working-loops-4i8j</guid>
      <description>&lt;p&gt;Hey everyone! &lt;/p&gt;

&lt;p&gt;It's been a while since the last update on &lt;strong&gt;Synapse&lt;/strong&gt; — the AI-first programming language built on Abstract Syntax Graphs. Today I'm excited to share &lt;strong&gt;version 0.2.0&lt;/strong&gt; with some major new features!&lt;/p&gt;

&lt;h2&gt;
  
  
  What's New in 0.2.0
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. S-Expression Syntax (Lisp-like)
&lt;/h3&gt;

&lt;p&gt;I chose S-Expressions for maximum LLM-friendliness:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="c1"&gt;; Factorial using a loop&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;result&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="nv"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;do&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;result&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;result&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))))&lt;/span&gt;
&lt;span class="nv"&gt;result&lt;/span&gt;  &lt;span class="c1"&gt;; =&amp;gt; 120&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why S-Expressions?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ Unambiguous structure — every expression in parentheses&lt;br&gt;
✅ No whitespace dependency — unlike Python&lt;br&gt;
✅ Easy for AI to parse and generate&lt;br&gt;
✅ Homoiconicity — code is data&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Interactive REPL 🖥️
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cargo run &lt;span class="nt"&gt;--bin&lt;/span&gt; synapse

Synapse 0.2.0 - AI-friendly language
Type :help &lt;span class="k"&gt;for &lt;/span&gt;commands, :quit to exit.

synapse&amp;gt; &lt;span class="o"&gt;(&lt;/span&gt;+ 1 2&lt;span class="o"&gt;)&lt;/span&gt;
3
synapse&amp;gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;let &lt;/span&gt;x 10&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;()&lt;/span&gt;
synapse&amp;gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt; x x&lt;span class="o"&gt;)&lt;/span&gt;
100
synapse&amp;gt; :quit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;REPL Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Command history (persisted)&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;:help&lt;/code&gt;, &lt;code&gt;:quit&lt;/code&gt;, &lt;code&gt;:ast&lt;/code&gt;, &lt;code&gt;:clear&lt;/code&gt; commands&lt;/li&gt;
&lt;li&gt;  Execute files: &lt;code&gt;synapse examples/demo.syn&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  One-liners: &lt;code&gt;synapse -e "(* 6 7)"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  3. Working Loops &amp;amp; Blocks
&lt;/h3&gt;

&lt;p&gt;I have updated the interpreter to fully support &lt;code&gt;while&lt;/code&gt; loops with the &lt;code&gt;(do ...)&lt;/code&gt; construct for multiple statements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;sum&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;do&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;sum&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;sum&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;i&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))))&lt;/span&gt;
&lt;span class="nv"&gt;sum&lt;/span&gt;  &lt;span class="c1"&gt;; 15&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Benchmarks
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Simple arithmetic&lt;/td&gt;
&lt;td&gt;~1.4 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nested expressions&lt;/td&gt;
&lt;td&gt;~1.8 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conditionals&lt;/td&gt;
&lt;td&gt;~2.1 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSON serialization&lt;/td&gt;
&lt;td&gt;~1.6 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Updated Roadmap
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  [x] S-Expression Parser (logos)&lt;/li&gt;
&lt;li&gt;  [x] Type Checker (Hindley-Milner)&lt;/li&gt;
&lt;li&gt;  [x] LLVM Backend&lt;/li&gt;
&lt;li&gt;  [x] Interpreter (30+ node types)&lt;/li&gt;
&lt;li&gt;  [x] REPL &amp;amp; CLI ✨ NEW&lt;/li&gt;
&lt;li&gt;  [x] While loops &amp;amp; blocks ✨ NEW&lt;/li&gt;
&lt;li&gt;  [ ] Recursive functions&lt;/li&gt;
&lt;li&gt;  [ ] Standard Library&lt;/li&gt;
&lt;li&gt;  [ ] Pattern Matching&lt;/li&gt;
&lt;li&gt;  [ ] VSCode Extension&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Try It Now
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Xzdes/synapse.git
&lt;span class="nb"&gt;cd &lt;/span&gt;synapse
cargo run &lt;span class="nt"&gt;--bin&lt;/span&gt; synapse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get Involved
&lt;/h3&gt;

&lt;p&gt;⭐ &lt;strong&gt;GitHub&lt;/strong&gt;&lt;br&gt;
Open issues, PRs welcome!&lt;/p&gt;

&lt;p&gt;What features would you like to see next? Drop a comment below!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>ai</category>
      <category>rust</category>
      <category>programming</category>
    </item>
    <item>
      <title>I Built a Deep Learning Framework in Rust from Scratch - Part 2: GPU Backend and the Lonely Debugging Journey</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Tue, 20 Jan 2026 15:02:21 +0000</pubDate>
      <link>https://dev.to/xzdes/i-built-a-deep-learning-framework-in-rust-from-scratch-part-2-gpu-backend-and-the-lonely-13p4</link>
      <guid>https://dev.to/xzdes/i-built-a-deep-learning-framework-in-rust-from-scratch-part-2-gpu-backend-and-the-lonely-13p4</guid>
      <description>&lt;p&gt;In &lt;strong&gt;Part 1&lt;/strong&gt;, I showed the basic architecture of &lt;strong&gt;RustyASG&lt;/strong&gt; - my attempt to build a deep learning framework in Rust. Since then, a lot has happened. I want to share both the technical progress and the reality of working on such a complex project alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Struggle Was Real
&lt;/h2&gt;

&lt;p&gt;After publishing Part 1, I spent weeks battling errors. The thing is - nobody really helps with projects like this. The topic is too specialized. I asked questions on forums, searched through issues in similar projects... &lt;em&gt;crickets&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Neural networks (the AI assistants) helped somewhat - not to solve specific bugs, but to organize my thoughts and break down the chaos into manageable pieces. When you're staring at 36 compilation errors and your brain is fried, sometimes you just need someone (or something) to help you see the structure.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The hardest part wasn't writing new features - it was fixing subtle type mismatches and reference issues in Rust's strict type system.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  What Actually Got Done
&lt;/h2&gt;

&lt;h3&gt;
  
  
  GPU Backend with wgpu
&lt;/h3&gt;

&lt;p&gt;The main achievement of this period - a working GPU backend. Not a toy, but real GPU acceleration using &lt;strong&gt;wgpu&lt;/strong&gt; (WebGPU API that works on Vulkan, Metal, DX12).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implemented operations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Element-wise:&lt;/strong&gt; Add, Sub, Mul, Div, Neg, Abs, Exp, Log, Sqrt&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Activations:&lt;/strong&gt; ReLU, Sigmoid, Tanh, GELU, SiLU, LeakyReLU, Softmax&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Matrix operations:&lt;/strong&gt; MatMul (including batched)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Reductions:&lt;/strong&gt; Sum, Mean, Variance&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Convolutions:&lt;/strong&gt; Conv2d with stride and padding&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Shape operations:&lt;/strong&gt; Transpose, Reshape, Broadcast&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each operation has its own WGSL shader generated at runtime.&lt;/p&gt;

&lt;h3&gt;
  
  
  Proper Error Handling
&lt;/h3&gt;

&lt;p&gt;In the first version, the GPU code was littered with &lt;code&gt;.unwrap()&lt;/code&gt; - the Rust equivalent of "crash and pray." I replaced all of that with proper &lt;code&gt;Result&lt;/code&gt; types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Before (bad)&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="py"&gt;.nodes&lt;/span&gt;&lt;span class="nf"&gt;.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;node_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="nf"&gt;.unwrap&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// After (good)  &lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;graph&lt;/span&gt;&lt;span class="nf"&gt;.get_node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sounds simple, but this change touched hundreds of lines and uncovered many hidden issues. The fun part: &lt;code&gt;get_node()&lt;/code&gt; returns &lt;code&gt;Result&lt;/code&gt;, not &lt;code&gt;Option&lt;/code&gt;, so I had to use &lt;code&gt;map_err&lt;/code&gt; instead of &lt;code&gt;ok_or_else&lt;/code&gt;. Rust teaches you to read type signatures carefully.&lt;/p&gt;

&lt;h3&gt;
  
  
  149 Tests Pass
&lt;/h3&gt;

&lt;p&gt;The test suite now includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;77&lt;/strong&gt; unit tests for core functionality&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;38&lt;/strong&gt; integration tests for neural network layers&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;26&lt;/strong&gt; GPU tests that compare CPU and GPU results&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;8&lt;/strong&gt; autograd tests for backpropagation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every GPU operation is tested by running the same computation on CPU and GPU, then comparing results with tolerance for floating-point differences.&lt;/p&gt;




&lt;h2&gt;
  
  
  RustyASG vs Competitors: Honest Assessment
&lt;/h2&gt;

&lt;p&gt;Let me be straight about where RustyASG stands compared to other options.&lt;/p&gt;

&lt;h3&gt;
  
  
  Compared to PyTorch/TensorFlow
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Don't even compare.&lt;/strong&gt; These are battle-tested frameworks with thousands of contributors, CUDA optimization, and years of development. RustyASG is an educational/experimental project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Compared to tch-rs (Rust bindings to LibTorch)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;tch-rs wins for production use.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;tch-rs:&lt;/strong&gt; Full PyTorch functionality, CUDA support, maintained by the community&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;RustyASG:&lt;/strong&gt; Pure Rust, no external dependencies, but limited operations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compared to Burn
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Burn is more mature.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Burn:&lt;/strong&gt; Multiple backends, WebGPU support, active development, production focus&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;RustyASG:&lt;/strong&gt; Simpler codebase, easier to understand and modify&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compared to Candle (by Hugging Face)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Candle is better for inference.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Candle:&lt;/strong&gt; Optimized for inference, quantization support, GGUF models&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;RustyASG:&lt;/strong&gt; Training-focused with autograd, but slower execution&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Honest Pros and Cons
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What RustyASG Can Actually Do
&lt;/h3&gt;

&lt;p&gt;✅ Train simple neural networks (MLP, small CNNs)&lt;br&gt;
✅ Run on GPU via WebGPU (cross-platform: Windows, Linux, Mac, even web)&lt;br&gt;
✅ Automatic differentiation for backpropagation&lt;br&gt;
✅ Load/save models in SafeTensors format&lt;br&gt;
✅ PyTorch-style API for datasets and dataloaders&lt;br&gt;
✅ Full transformer building blocks (MultiHeadAttention, positional encodings)&lt;/p&gt;

&lt;h3&gt;
  
  
  What RustyASG Cannot Do (Yet or Ever)
&lt;/h3&gt;

&lt;p&gt;❌ Run large models efficiently (no memory optimization)&lt;br&gt;
❌ Match CUDA performance (WebGPU has overhead)&lt;br&gt;
❌ Support all PyTorch operations (maybe 30% coverage)&lt;br&gt;
❌ Run in production (not battle-tested)&lt;br&gt;
❌ Distributed training&lt;br&gt;
❌ Mixed precision training&lt;/p&gt;




&lt;h2&gt;
  
  
  When to Consider RustyASG
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  Learning how deep learning frameworks work internally&lt;/li&gt;
&lt;li&gt;  Need pure Rust without external dependencies&lt;/li&gt;
&lt;li&gt;  Experimenting with custom operations&lt;/li&gt;
&lt;li&gt;  Want to contribute to a young project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The repository includes examples that actually work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Linear Regression&lt;/strong&gt; - Basic gradient descent&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;XOR Problem&lt;/strong&gt; - Simple MLP with backpropagation&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;MNIST&lt;/strong&gt; - Digit classification (if you supply the dataset)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simple training loop&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;epoch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="n"&gt;epochs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;batch_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="nf"&gt;.iter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Forward pass&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="nf"&gt;.forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;batch_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mse_loss&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;batch_y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Backward pass&lt;/span&gt;
        &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="nf"&gt;.backward&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// Update weights&lt;/span&gt;
        &lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="nf"&gt;.step&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="nf"&gt;.zero_grad&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Code Quality
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Published on crates.io: &lt;code&gt;cargo add rustyasg&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  Documentation with rustdoc&lt;/li&gt;
&lt;li&gt;  No unsafe code (pure safe Rust)&lt;/li&gt;
&lt;li&gt;  Clean module structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;RustyASG is not a PyTorch killer. It's not trying to be. It's an honest attempt to understand how deep learning frameworks work by building one from scratch in Rust.&lt;/p&gt;

&lt;p&gt;If you want to learn about computational graphs, automatic differentiation, and GPU programming - the source code is open. If you want to train GPT-4 - use PyTorch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Links:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/xzdes/RustyASG" rel="noopener noreferrer"&gt;https://github.com/xzdes/RustyASG&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;crates.io:&lt;/strong&gt; &lt;a href="https://crates.io/crates/rustyasg" rel="noopener noreferrer"&gt;https://crates.io/crates/rustyasg&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Part 1:&lt;/strong&gt; &lt;a href="https://dev.to/xzdes/i-built-a-deep-learning-framework-in-rust-from-scratch-heres-how-it-works-2984"&gt;I Built a Deep Learning Framework in Rust from Scratch - Part 1&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rust</category>
      <category>deeplearning</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
    <item>
      <title>I Built a Deep Learning Framework in Rust from Scratch. Here’s How It Works.</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Tue, 02 Sep 2025 21:37:07 +0000</pubDate>
      <link>https://dev.to/xzdes/i-built-a-deep-learning-framework-in-rust-from-scratch-heres-how-it-works-2984</link>
      <guid>https://dev.to/xzdes/i-built-a-deep-learning-framework-in-rust-from-scratch-heres-how-it-works-2984</guid>
      <description>&lt;p&gt;I've just published &lt;code&gt;RustyASG&lt;/code&gt; to &lt;a href="https://crates.io/crates/rustyasg" rel="noopener noreferrer"&gt;crates.io&lt;/a&gt;, a deep learning framework I built from the ground up in Rust. The project's goal was to explore a graph-based architecture, moving away from the eager execution model common in frameworks like PyTorch.&lt;/p&gt;

&lt;p&gt;This post is a technical breakdown of its architecture, core design, and the most critical bug I had to fix to make it work correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Core Idea: Define-then-Run
&lt;/h3&gt;

&lt;p&gt;RustyASG does not compute operations immediately. Instead, every operation constructs a node in an &lt;strong&gt;Abstract Semantic Graph (ASG)&lt;/strong&gt;. This graph serves as a complete blueprint of the entire computation before any numbers are crunched.&lt;/p&gt;

&lt;p&gt;Once the graph is fully defined, it can be:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Analyzed:&lt;/strong&gt; Statically infer tensor shapes to catch dimension mismatches before execution.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Differentiated:&lt;/strong&gt; Automatically generate a new graph that calculates the gradients of any node.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Executed:&lt;/strong&gt; Run the optimized graph on a backend, such as a CPU or GPU.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach provides a high degree of control and enables global optimizations like kernel fusion and static memory planning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Overview
&lt;/h3&gt;

&lt;p&gt;The framework's components are strictly separated. This flowchart shows how the pieces fit together:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzeus8ypu8ru341z565p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzeus8ypu8ru341z565p.png" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;&lt;code&gt;tensor&lt;/code&gt;:&lt;/strong&gt; A lightweight, symbolic handle to a node in the graph. All operations on it modify the graph.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;&lt;code&gt;asg&lt;/code&gt;:&lt;/strong&gt; The core data structures that define the graph (&lt;code&gt;Node&lt;/code&gt;, &lt;code&gt;NodeType&lt;/code&gt;). This layer only &lt;em&gt;describes&lt;/em&gt; computation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;&lt;code&gt;autograd&lt;/code&gt;:&lt;/strong&gt; The reverse-mode automatic differentiation engine. It transforms a forward-pass graph into a new graph that computes gradients.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;&lt;code&gt;runtime&lt;/code&gt;:&lt;/strong&gt; Contains the &lt;code&gt;Backend&lt;/code&gt; trait and its concrete implementations for CPU (&lt;code&gt;ndarray&lt;/code&gt;) and GPU (&lt;code&gt;wgpu&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Started: Training a Transformer Block
&lt;/h3&gt;

&lt;p&gt;An example is included to demonstrate a full training loop on a Transformer block.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Clone the repository:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Xzdes/RustyAsg.git
&lt;span class="nb"&gt;cd &lt;/span&gt;RustyAsg
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Run the demo (GPU is the default backend):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo run &lt;span class="nt"&gt;--example&lt;/span&gt; transformer_demo &lt;span class="nt"&gt;--release&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;To use the CPU, set the &lt;code&gt;use_gpu&lt;/code&gt; flag to &lt;code&gt;false&lt;/code&gt; in &lt;code&gt;examples/transformer_demo.rs&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The output shows the training loss decreasing, which confirms that the entire stack—from graph construction to backpropagation on the GPU—is functioning correctly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nt"&gt;---&lt;/span&gt; TRAINING LOOP START &lt;span class="nt"&gt;---&lt;/span&gt;
Epoch: 1 , Loss: 3.081630
Epoch: 2 , Loss: 2.840065
...
Epoch: 15, Loss: 0.982813
&lt;span class="nt"&gt;---&lt;/span&gt; TRAINING FINISHED IN 1.34s &lt;span class="nt"&gt;---&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Hardest Bug: A Flaw in the Gradient Logic
&lt;/h3&gt;

&lt;p&gt;The framework appeared stable until I implemented a gradient checker. The tests compared the analytical gradients produced by the &lt;code&gt;autograd&lt;/code&gt; engine against numerical estimates. A key test, which emulated a &lt;code&gt;LayerNorm&lt;/code&gt; operation, was consistently failing with an error margin of nearly 60%.&lt;/p&gt;

&lt;p&gt;The root cause was a subtle but critical flaw in the backpropagation logic for division, specifically when &lt;strong&gt;broadcasting&lt;/strong&gt; was involved.&lt;/p&gt;

&lt;p&gt;When a vector like &lt;code&gt;[10, 20]&lt;/code&gt; is divided by a scalar &lt;code&gt;2&lt;/code&gt;, the result is &lt;code&gt;[5, 10]&lt;/code&gt;. During backpropagation, the gradient for the scalar &lt;code&gt;2&lt;/code&gt; receives contributions from &lt;em&gt;both&lt;/em&gt; elements of the output. Therefore, the incoming gradients must be &lt;strong&gt;summed&lt;/strong&gt; to produce the final, correct gradient for the original scalar.&lt;/p&gt;

&lt;p&gt;My autograd implementation for &lt;code&gt;Add&lt;/code&gt; and &lt;code&gt;Subtract&lt;/code&gt; handled this, but I had overlooked it for &lt;code&gt;Divide&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The incorrect autograd logic for the divisor 'b'&lt;/span&gt;
&lt;span class="c1"&gt;// grad_b = ... // Calculation was mathematically correct but missed a step.&lt;/span&gt;
&lt;span class="c1"&gt;// self.accumulate_grad(b_id, grad_b)?;&lt;/span&gt;

&lt;span class="c1"&gt;// The corrected logic&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;b_shape&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.source_asg&lt;/span&gt;&lt;span class="nf"&gt;.get_node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="py"&gt;.shape&lt;/span&gt;&lt;span class="nf"&gt;.as_ref&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.unwrap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// ... calculate grad_b ...&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;b_shape&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;grad_shape&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// If 'b' was broadcast, its gradient must be summed to match its original shape.&lt;/span&gt;
    &lt;span class="n"&gt;grad_b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.grad_asg&lt;/span&gt;&lt;span class="nf"&gt;.add_node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;NodeType&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;Sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grad_b&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="nf"&gt;.accumulate_grad&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grad_b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This conditional sum was the missing piece. Adding it fixed the &lt;code&gt;LayerNorm&lt;/code&gt; test and validated the entire &lt;code&gt;autograd&lt;/code&gt; engine.&lt;/p&gt;

&lt;h3&gt;
  
  
  What's Next
&lt;/h3&gt;

&lt;p&gt;The foundation is now stable. The immediate roadmap is focused on expanding core functionality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Implement gradients for &lt;code&gt;MatrixMultiply&lt;/code&gt; and &lt;code&gt;Softmax&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Add more optimizers, starting with &lt;code&gt;AdamW&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Develop a memory-recycling buffer allocator for the &lt;code&gt;wgpu&lt;/code&gt; backend to improve performance.&lt;/li&gt;
&lt;li&gt;  Implement model serialization to save and load trained weights.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contributions are welcome. Please feel free to open Issues or Pull Requests.&lt;/p&gt;

&lt;p&gt;You can find the project at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Xzdes/RustyAsg" rel="noopener noreferrer"&gt;https://github.com/Xzdes/RustyAsg&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Crates.io:&lt;/strong&gt; &lt;a href="https://crates.io/crates/rustyasg" rel="noopener noreferrer"&gt;https://crates.io/crates/rustyasg&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rust</category>
      <category>opensource</category>
      <category>deeplearning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>I've Seen the Future of UI Development. It's Insane, Written in Rust, and Rendered by an AI.</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Thu, 28 Aug 2025 07:42:14 +0000</pubDate>
      <link>https://dev.to/xzdes/ive-seen-the-future-of-ui-development-its-insane-written-in-rust-and-rendered-by-an-ai-39dg</link>
      <guid>https://dev.to/xzdes/ive-seen-the-future-of-ui-development-its-insane-written-in-rust-and-rendered-by-an-ai-39dg</guid>
      <description>&lt;p&gt;Hey dev.to community!&lt;/p&gt;

&lt;p&gt;We’re all used to thinking about UI frameworks in the same terms: React, Vue, Svelte, Flutter, SwiftUI... We argue about the Virtual DOM, reactivity, and performance. But what if we're all looking in the wrong direction? What if the next big leap isn't about &lt;em&gt;how&lt;/em&gt; we render, but &lt;em&gt;who&lt;/em&gt; does the rendering?&lt;/p&gt;

&lt;p&gt;I decided to test a crazy idea. What if, instead of writing code to draw every pixel of a button, we just &lt;strong&gt;described that button with words and let an AI draw it for us?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And after a debugging marathon that nearly broke my brain, I did it. Meet the &lt;strong&gt;Shadowin AI-Render Engine&lt;/strong&gt;, a working prototype of a UI framework where the visuals are generated by Stable Diffusion in real-time.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Concept: A Skeleton of Rust, A Skin of AI
&lt;/h3&gt;

&lt;p&gt;The entire idea behind Shadowin is built on a simple but powerful separation of concerns:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Logic is Rust.&lt;/strong&gt; My code, written from scratch in Rust, is only responsible for the "physics" of the interface. It knows there's a button with ID=0, its dimensions are 200x60, it's located at coordinates (50, 50), and it's currently being hovered over. It knows that a click should increment a counter. But it has absolutely no idea what this button looks like.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The Visuals are AI.&lt;/strong&gt; When it's time to draw, my Rust code doesn't touch the pixel buffer. Instead, it forms a text prompt and sends it to a locally running Stable Diffusion server:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;"a crisp UI button with the text 'Submit', photorealistic, octane render, trending on artstation, dark sci-fi style, neon blue highlights, glowing, hovered state"&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The neural network generates an image, and my engine simply "stamps" it onto the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's what it looks like in action:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29sq3vffodx1euslxsns.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F29sq3vffodx1euslxsns.gif" alt=" " width="700" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you hover or click, it's not just the color that changes—&lt;strong&gt;the entire generated texture of the button swaps out!&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works Under the Hood
&lt;/h3&gt;

&lt;p&gt;It's not magic, it's Rust and a bit of madness.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The Engine:&lt;/strong&gt; Written from scratch in Rust, using &lt;code&gt;winit&lt;/code&gt; for windowing and &lt;code&gt;pixels&lt;/code&gt; for direct framebuffer access. No browsers, no Electron.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The AI Communicator:&lt;/strong&gt; A module that talks to the &lt;code&gt;stable-diffusion-webui&lt;/code&gt; API via HTTP requests using &lt;code&gt;reqwest&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Caching:&lt;/strong&gt; Image generation is slow. That's why the engine caches every generated asset. The first launch "warms up" the cache by generating all necessary states for all widgets. After that, the interface runs smoothly.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Synchronicity:&lt;/strong&gt; After some painful experiments with async, I settled on a simple, blocking approach. Yes, the application freezes during generation, and that's honest. Make it work first, then make it fast.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why Is This a Glimpse into the Future?
&lt;/h3&gt;

&lt;p&gt;Imagine the possibilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Natural Language Theming:&lt;/strong&gt; A user could type in the settings, "I want an interface in the style of a Fallout terminal" or "make everything look like a watercolor painting," and the entire UI would instantly transform.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Next-Level Adaptive Design:&lt;/strong&gt; A "Delete" button could become visually more "alarming" based on the importance of the data being deleted. The interface could change its "mood" depending on the time of day.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Infinite Uniqueness:&lt;/strong&gt; Your instance of the application will look different from anyone else's.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yes, this approach has huge downsides. Accessibility is a nightmare. Performance needs serious work. And as you can see from the demo, getting Stable Diffusion v1.5 to render text clearly and consistently is a challenge in itself. I chose not to compromise by rendering text on top of a generated background; &lt;strong&gt;I forced the neural network to draw the button entirely, text included, to prove the purity of the concept.&lt;/strong&gt; Using more modern models specifically trained for text rendering (like DeepFloyd-IF or a fine-tuned SDXL) would solve this.&lt;/p&gt;

&lt;p&gt;But that doesn't matter. What matters is that &lt;strong&gt;it works.&lt;/strong&gt; It's proof that we can create interfaces in a completely new way.&lt;/p&gt;

&lt;p&gt;I believe the future lies in declarative, context-aware, and personalized interfaces. And AI is the key to unlocking that future.&lt;/p&gt;

&lt;p&gt;The entire project is up on &lt;a href="https://github.com/Xzdes/shadowin" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Check it out, try it, break it. Let's brainstorm together where this crazy idea could lead.&lt;/p&gt;

&lt;p&gt;What do you think? Is this a breakthrough technology or just a fun toy? Let me know in the comments&lt;/p&gt;

</description>
      <category>rust</category>
      <category>ai</category>
      <category>opensource</category>
      <category>ui</category>
    </item>
    <item>
      <title>I Supercharged My Browser GPT with Rust and WebAssembly: The Journey to a Dual-Engine AI</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Tue, 26 Aug 2025 09:02:31 +0000</pubDate>
      <link>https://dev.to/xzdes/i-supercharged-my-browser-gpt-with-rust-and-webassembly-the-journey-to-a-dual-engine-ai-3ili</link>
      <guid>https://dev.to/xzdes/i-supercharged-my-browser-gpt-with-rust-and-webassembly-the-journey-to-a-dual-engine-ai-3ili</guid>
      <description>&lt;p&gt;&lt;em&gt;(This is Part 2 of my journey. If you haven't read it yet, start with &lt;a href="https://dev.to/xzdes/i-built-a-gpt-in-my-browser-in-one-evening-the-journey-from-amnesia-to-stable-learning-with-pure-28ch"&gt;Part 1 here&lt;/a&gt;!)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Last time, I performed a small miracle: I built, trained, and got a GPT model to generate text using only pure JavaScript. I went through the trenches of debugging gradients, battled &lt;code&gt;NaN&lt;/code&gt; values, and ultimately ended up with a working model. It was proof that the fundamental concepts of AI are accessible right in the browser.&lt;/p&gt;

&lt;p&gt;But a question lingered in the back of my mind: &lt;strong&gt;"What if...?"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  What if I needed performance comparable to a native application?&lt;/li&gt;
&lt;li&gt;  What if I wanted the strict typing and safety that JavaScript can't offer?&lt;/li&gt;
&lt;li&gt;  What if I wanted to turn this educational project into a true high-performance experimental testbed?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer to all these questions was the same: &lt;strong&gt;Rust and WebAssembly&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chapter 1: The Birth of the Second Engine — &lt;code&gt;RustyGradients&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Before bringing anything into WebAssembly, I needed the engine itself. Simply porting &lt;code&gt;slmnet.js&lt;/code&gt; to Rust felt uninspired. Instead, I decided to build a complete, strictly-typed, and modular deep learning framework from scratch, heavily inspired by PyTorch.&lt;/p&gt;

&lt;p&gt;And so, &lt;strong&gt;&lt;a href="https://github.com/Xzdes/RustyGradients" rel="noopener noreferrer"&gt;RustyGradients&lt;/a&gt;&lt;/strong&gt; was born.&lt;/p&gt;

&lt;p&gt;This is not just a port. It's a different beast entirely, built on the principles of Rust:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Safety and Reliability:&lt;/strong&gt; No more &lt;code&gt;undefined is not a function&lt;/code&gt;. The Rust compiler became my best friend, catching errors long before they could ever reach the browser.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Performance:&lt;/strong&gt; Rust compiles down to blazingly fast machine code. All those endless loops in matrix multiplications and backpropagation now execute at near-native speed.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Robust Architecture:&lt;/strong&gt; A &lt;code&gt;Module&lt;/code&gt; trait (similar to &lt;code&gt;torch.nn.Module&lt;/code&gt;) and a clear separation of operations (&lt;code&gt;ops&lt;/code&gt;), optimizers (&lt;code&gt;optim&lt;/code&gt;), and layers (&lt;code&gt;nn&lt;/code&gt;) makes the code clean and extensible.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Building &lt;code&gt;RustyGradients&lt;/code&gt; was an adventure in itself, but the goal was always clear: to forge a powerful engine ready to be installed in my "race car."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Chapter 2: The Bridge to the Future — Integration via WebAssembly
&lt;/h3&gt;

&lt;p&gt;WebAssembly (WASM) is the magic that allows code written in languages like Rust, C++, or Go to run right in the browser. It's not a replacement for JavaScript, but its perfect companion: JS handles the UI, while WASM crunches the heavy numbers.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;wasm-pack&lt;/code&gt; tool, I compiled the entire &lt;code&gt;RustyGradients&lt;/code&gt; framework and the GPT model written with it into a single, compact &lt;code&gt;.wasm&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;For JavaScript, the complexity of the Rust code was hidden behind a simple and elegant API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// JS code in index.html&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;WasmGptTrainer&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./pkg/rusty_gradients.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ... initialization ...&lt;/span&gt;

&lt;span class="c1"&gt;// I can create an instance of the entire Rust model in one line!&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;trainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WasmGptTrainer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;...);&lt;/span&gt;

&lt;span class="c1"&gt;// A single training step is just one function call,&lt;/span&gt;
&lt;span class="c1"&gt;// all the magic happens inside WASM&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;trainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;train_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x_batch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;y_batch&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

&lt;span class="c1"&gt;// Text generation is also a single call&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;generated_ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;trainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prompt_ids&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the math, all the tensors, all the gradients now live and breathe inside the lightning-fast WASM module.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chapter 3: The Ultimate Testbed — Choice and Persistence
&lt;/h3&gt;

&lt;p&gt;Just replacing the engine wasn't interesting enough. I wanted to create a platform where I could &lt;strong&gt;compare&lt;/strong&gt; these two worlds. And frankly, I was tired of losing my trained model every time I refreshed the page.&lt;/p&gt;

&lt;p&gt;This led to the final version of &lt;strong&gt;&lt;a href="https://github.com/Xzdes/slmnetGPT" rel="noopener noreferrer"&gt;slmnetGPT&lt;/a&gt;&lt;/strong&gt;, which now includes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Engine Switch:&lt;/strong&gt;&lt;br&gt;
The UI now features a choice: run the model on pure &lt;code&gt;slmnet.js&lt;/code&gt; or on &lt;code&gt;RustyGradients (WASM)&lt;/code&gt;. This allows for a real-time comparison of the training speed and performance of the two approaches.&lt;/p&gt;

&lt;p&gt;&amp;lt;!-- Replace with a screenshot of your UI --&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Long-Term Memory with IndexedDB:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;localStorage&lt;/code&gt; was fine for a start, but it's too small and slow. I integrated &lt;strong&gt;IndexedDB&lt;/strong&gt;, a full-fledged NoSQL database in the browser. Now you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Save&lt;/strong&gt; the state of a trained model after a long session.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Load&lt;/strong&gt; it at any time, even after a browser restart.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Delete&lt;/strong&gt; the saved weights to start fresh.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Crucially, the models for the JS and WASM engines are saved separately. You can train both and switch between their "brains."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Localization:&lt;/strong&gt;&lt;br&gt;
As a final touch, I added a simple language switcher (RU/EN) to make the testbed even more user-friendly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion: Two Worlds, One Mission
&lt;/h3&gt;

&lt;p&gt;This project grew from a simple "What if?" into a comprehensive "Yes, and here's how." It has become a living demonstration of a powerful synergy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;JavaScript&lt;/strong&gt; remains the king of the user interface. Its flexibility and simplicity make building interactive applications a joy.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Rust + WebAssembly&lt;/strong&gt; is the turbocharger for your web app. They take over the heavy lifting, providing a level of performance that was once only a dream in the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, &lt;code&gt;slmnetGPT&lt;/code&gt; is more than just a model. It's a laboratory in your browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Come in, experiment, and compare:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The JavaScript version:&lt;/strong&gt; &lt;a href="https://github.com/Xzdes/slmnetGPT" rel="noopener noreferrer"&gt;https://github.com/Xzdes/slmnetGPT&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Rust engine:&lt;/strong&gt; &lt;a href="https://github.com/Xzdes/RustyGradients" rel="noopener noreferrer"&gt;https://github.com/Xzdes/RustyGradients&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run the training on both engines. Save the result. See how the Rust-trained model generates text. Feel the difference.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ai</category>
      <category>rust</category>
      <category>webdev</category>
    </item>
    <item>
      <title>I Taught My JavaScript AI to Rewrite Its Own Code</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Sat, 23 Aug 2025 17:45:54 +0000</pubDate>
      <link>https://dev.to/xzdes/i-taught-my-javascript-ai-to-rewrite-its-own-code-l0a</link>
      <guid>https://dev.to/xzdes/i-taught-my-javascript-ai-to-rewrite-its-own-code-l0a</guid>
      <description>&lt;p&gt;What if the AI systems we build could take an active role in their own evolution? This is the question that drove my latest experiment.&lt;/p&gt;

&lt;p&gt;Many of you are familiar with my from-scratch neural network library, &lt;strong&gt;slmnet&lt;/strong&gt;. After porting it from the browser to Node.js, I set myself a challenge: to stay within a pure JavaScript and Node.js environment. No Python wrappers, no C++ bindings. This constraint was intentional—it forced a deeper understanding and ensured that every part of the system was transparent and malleable.&lt;/p&gt;

&lt;p&gt;This foundation allowed me to explore a fascinating, advanced AI concept: creating a system that could &lt;strong&gt;learn to optimize itself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I architected a high-level supervisor, the &lt;strong&gt;Meta-Controller&lt;/strong&gt;, designed to guide an AI agent (powered by slmnet itself) through a cycle of self-improvement. The process is a fully automated loop:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Benchmark:&lt;/strong&gt; The cycle begins by measuring the current performance of the &lt;code&gt;slmnet&lt;/code&gt; library. A standardized script runs a short training session and outputs two key metrics: final loss (accuracy) and execution time (speed). This gives us a hard, numerical baseline.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Analyze &amp;amp; Decide:&lt;/strong&gt; The Meta-Controller then presents the AI agent with a choice. It shows it the current, stable code of a core file (e.g., &lt;code&gt;Ops.js&lt;/code&gt;) and a pre-written "mutation"—an alternative version containing a potential optimization. The AI's task is not to generate complex code from nothing, but to act as an engineer in a code review. It must analyze the difference, form a hypothesis, and make a simple, critical decision: &lt;strong&gt;is this change worth testing?&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automated Testing:&lt;/strong&gt; If the AI agrees, the Meta-Controller temporarily overwrites the live code with the proposed mutation. It then immediately re-runs the exact same benchmark to measure the impact of the change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Evolve or Revert:&lt;/strong&gt; This is the core of the feedback loop. The new performance metrics are compared to the baseline.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  If the change was beneficial—faster execution or a lower loss—it's deemed a successful &lt;strong&gt;evolution&lt;/strong&gt;. The new code becomes the new standard.&lt;/li&gt;
&lt;li&gt;  If the change was detrimental or made no difference, it’s a failure. The Meta-Controller instantly &lt;strong&gt;reverts&lt;/strong&gt; the code back to its last known stable version.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first time I ran this loop, the AI—being very new—produced a nonsensical answer. But the system itself performed flawlessly. It correctly identified the invalid response, logged the failure, and maintained the stability of the codebase without human intervention. &lt;strong&gt;The architecture for self-optimization was proven to work.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What this experiment demonstrates is that the core concepts of meta-learning and self-improving systems are not exclusively the domain of massive, closed-off models. We can build, test, and understand these feedback loops using accessible tools. By confining the project to pure JavaScript, I built a transparent testbed where the process of an AI reasoning about its own code is not a black box, but a clear, observable engineering cycle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Xzdes/reasoningHeuristicAI" rel="noopener noreferrer"&gt;https://github.com/Xzdes/reasoningHeuristicAI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>ai</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I Gave My LLM a Promotion: Now It Delegates Its Own Work</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Fri, 15 Aug 2025 20:41:21 +0000</pubDate>
      <link>https://dev.to/xzdes/i-gave-my-llm-a-promotion-now-it-delegates-its-own-work-2loe</link>
      <guid>https://dev.to/xzdes/i-gave-my-llm-a-promotion-now-it-delegates-its-own-work-2loe</guid>
      <description>&lt;p&gt;Large Language Models are powerful, but they're also resource-intensive. Every query, no matter how simple, consumes expensive computational cycles. I realized a huge chunk of my server costs was from the LLM repeatedly answering "hello," "thanks," and "ok."&lt;/p&gt;

&lt;p&gt;These queries are a waste. They don't teach the model anything new. They don't require complex reasoning. They are pure resource drain.&lt;/p&gt;

&lt;p&gt;My first thought was to filter them out on the client-side. But that creates a manual chore—I'd have to constantly update the list of simple phrases. That approach doesn't scale.&lt;/p&gt;

&lt;p&gt;So, I flipped the problem on its head. What if the LLM could solve this problem itself?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The core idea is this: I created a system where the LLM itself decides which queries are too simple for its attention and teaches a client-side helper to handle them in the future.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Architecture: Self-Delegation
&lt;/h3&gt;

&lt;p&gt;I built a project around this single concept, stripping away everything non-essential from a previous version. It has only two key parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The Server-Side "Teacher" (The LLM):&lt;/strong&gt; The main, powerful model. Its job is to handle complex tasks and—crucially—to identify low-value, repetitive queries.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Client-Side "Gatekeeper" (The Helper):&lt;/strong&gt; A tiny, zero-dependency JavaScript agent in the browser. It intercepts all user input and asks the LLM for help only when it encounters something it hasn't been taught to handle.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  How the LLM Offloads Its Work
&lt;/h3&gt;

&lt;p&gt;The first time a user sends a simple query like "thx", the Gatekeeper doesn't recognize it and forwards it to the LLM.&lt;/p&gt;

&lt;p&gt;The LLM knows "thx" is simple. Instead of just sending back a text answer, it sends back a special JSON payload containing a direct order:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"userResponse"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"You're welcome!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"learningInstruction"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"LEARN_SIMPLE_PHRASE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"query"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"thx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"response"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"You're welcome!"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;code&gt;learningInstruction&lt;/code&gt; is the key. It’s the LLM telling its Gatekeeper:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"I've answered this for you once. Now learn it. From now on, you handle this query yourself. Do not send it to me again."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The Gatekeeper receives this command, saves the new rule to the browser's &lt;code&gt;localStorage&lt;/code&gt;, and delivers the response to the user. The user sees nothing but a fast response.&lt;/p&gt;

&lt;p&gt;But in the background, the system just became smarter and more efficient. The next time "thx" is sent, the Gatekeeper handles it instantly, and the server is never bothered.&lt;/p&gt;

&lt;p&gt;The LLM is actively, automatically, and invisibly making its own job easier. It's not being trained &lt;em&gt;by&lt;/em&gt; a human; it's training its own assistant to filter out the noise.&lt;/p&gt;

&lt;p&gt;This project was an exercise in minimalism. I threw out a complex neural network library and other unnecessary features to focus solely on perfecting this self-delegation loop. The result is a lean, powerful system that demonstrates a smarter way to build AI applications.&lt;/p&gt;

&lt;p&gt;We don't just need bigger models; we need smarter architectures where models can work together and optimize their own workflows.&lt;/p&gt;

&lt;p&gt;Check out the full implementation on GitHub and see the self-delegation in action.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Xzdes/slmnet-Hybrid" rel="noopener noreferrer"&gt;https://github.com/Xzdes/slmnet-Hybrid&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>I Built an Honest AI Agent to Fight Hallucinations. Here's How It Works.</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Thu, 14 Aug 2025 21:43:15 +0000</pubDate>
      <link>https://dev.to/xzdes/i-built-an-honest-ai-agent-to-fight-hallucinations-heres-how-it-works-2p7e</link>
      <guid>https://dev.to/xzdes/i-built-an-honest-ai-agent-to-fight-hallucinations-heres-how-it-works-2p7e</guid>
      <description>&lt;p&gt;Hello, everyone!&lt;/p&gt;

&lt;p&gt;We've all been amazed by Large Language Models. They can generate code, poetry, and coherent essays seemingly out of thin air. But I’ve always been bothered by their dark side: a tendency to "hallucinate." Ask a question about an obscure topic, and a model might confidently invent a non-existent term or "fact."&lt;/p&gt;

&lt;p&gt;I decided to tackle this problem head-on and came to a simple conclusion: &lt;strong&gt;the process is more important than size, and honesty is more important than omniscience.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of relying on a giant model that &lt;em&gt;knows everything&lt;/em&gt;, I created &lt;code&gt;WeblookAI&lt;/code&gt;—an autonomous agent that starts by knowing &lt;em&gt;nothing&lt;/em&gt;. Its only power lies in a clever algorithm I designed, which allows it to find, analyze, and synthesize information, all while remaining intellectually honest.&lt;/p&gt;

&lt;p&gt;This post is the story of how I built it. I believe this project will be especially interesting for learners, as it clearly demonstrates how you can achieve impressive results with minimal resources. And yes, I asked my local neural network what it thinks of the agent—it's a fan ;)&lt;/p&gt;

&lt;h4&gt;
  
  
  The Problem: A Passive "Know-it-all" vs. My Active "Researcher"
&lt;/h4&gt;

&lt;p&gt;The standard approach to AI is to build a colossal library of knowledge and force a model to memorize it. My approach is inverted. I didn't want to build another librarian; I wanted to build a detective with nothing but a notebook, a magnifying glass, and endless curiosity.&lt;/p&gt;

&lt;p&gt;I built &lt;code&gt;WeblookAI&lt;/code&gt; on three core principles that make it unique:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Intellectual Honesty — My Guiding Principle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This isn't just a feature; it's the foundation. I designed the agent's main advantage to be its ability to &lt;strong&gt;minimize hallucinations&lt;/strong&gt;. I achieved this through a strict, final-step prompt: "Answer the question based &lt;em&gt;only&lt;/em&gt; on the provided facts. If a direct answer isn't available, say so."&lt;/p&gt;

&lt;p&gt;The results are fantastic. When I asked it about "Wise JSON," it didn't invent a new framework. Instead, it honestly reported that it found separate data on "WISE" and "JSON." It just so happens that Wise JSON is another project of mine, but the internet doesn't know much about it yet—and my agent correctly reflected that reality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. My Homegrown Web Agent — The "Magnifying Glass and Notebook"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of paying for search APIs, I built a unique data-gathering engine from scratch using &lt;code&gt;Puppeteer&lt;/code&gt;. It doesn't just "search"; it conducts a genuine, almost human-like investigation I programmed it to perform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Fault Tolerance:&lt;/strong&gt; If one "fishing spot" (Brave Search) is empty, the agent doesn't give up. It automatically moves to the next one (DuckDuckGo, StartPage).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;"Human-like" Emulation:&lt;/strong&gt; I made the agent present itself to websites as a standard Chrome browser on Windows, allowing it to bypass basic anti-bot defenses.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;"Smart" Filtering:&lt;/strong&gt; I abandoned fragile CSS selectors that break with every site redesign. Instead, I programmed my agent to grab &lt;em&gt;all&lt;/em&gt; links on a page and apply its own heuristic algorithm: it discards ads and junk using a domain blacklist, analyzes URLs for "usefulness," and assigns a "relevance score" to each link.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. 100% Local and Autonomous — My Commitment to Independence&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;A Local Brain:&lt;/strong&gt; The entire "thinking" process—from planning the search to synthesizing the final answer—is handled by a language model (like &lt;code&gt;llama3:8b&lt;/code&gt;) that I run on my own machine via &lt;strong&gt;Ollama&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Privacy:&lt;/strong&gt; Your queries and the data my agent finds never leave your computer.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Zero Cost:&lt;/strong&gt; The project I built requires no API keys, no subscriptions, and is completely independent of the whims of cloud services.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How I Made It Work in Practice
&lt;/h4&gt;

&lt;p&gt;I broke down the entire process into three crystal-clear steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;DECOMPOSE:&lt;/strong&gt; The local LLM receives the user's question and breaks it down into 3-4 simple search queries, creating a research plan.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;INVESTIGATE:&lt;/strong&gt; My &lt;code&gt;WebAgent&lt;/code&gt; on &lt;code&gt;Puppeteer&lt;/code&gt; heads into the field—methodically cycling through search engines, filtering links, visiting websites, and extracting clean, core text content.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;SYNTHESIZE:&lt;/strong&gt; The local LLM receives the original question and the collected "evidence" with one ironclad rule I gave it: do not invent.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Who I Built This Project For
&lt;/h4&gt;

&lt;p&gt;First and foremost, for learners. For anyone who wants to understand that AI is not just about giant models but also about elegant, effective algorithms. I've open-sourced it on GitHub so you can download it, run it with a single command, and see firsthand how you can achieve impressive results by making a small model "think" the right way.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;⚠️ Important Notice:&lt;/strong&gt;&lt;br&gt;
This project and its web scraping agent are intended &lt;strong&gt;for educational purposes only&lt;/strong&gt;. Please be respectful of the websites the agent visits. You are solely responsible for your actions and any use of this tool.&lt;/p&gt;

&lt;p&gt;You can find the entire project on my GitHub:&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/Xzdes/weblookai" rel="noopener noreferrer"&gt;https://github.com/Xzdes/weblookai&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! I hope this story inspires you to start your own experiments. Feel free to ask questions in the comments.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>tutorial</category>
      <category>opensource</category>
      <category>node</category>
    </item>
    <item>
      <title>I Built a "GPT" in My Browser in One Evening. The Journey from Amnesia to Stable Learning with Pure JS.</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Tue, 12 Aug 2025 15:45:55 +0000</pubDate>
      <link>https://dev.to/xzdes/i-built-a-gpt-in-my-browser-in-one-evening-the-journey-from-amnesia-to-stable-learning-with-pure-28ch</link>
      <guid>https://dev.to/xzdes/i-built-a-gpt-in-my-browser-in-one-evening-the-journey-from-amnesia-to-stable-learning-with-pure-28ch</guid>
      <description>&lt;p&gt;Hello, community!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Xzdes/slmnetGPT" rel="noopener noreferrer"&gt;https://github.com/Xzdes/slmnetGPT&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, the best projects are born from a simple "What if...?" question. One evening, I was looking at some of my old code—a tiny neural network library in JS I had written for fun, called &lt;code&gt;slmnet&lt;/code&gt;. A thought struck me: what if, instead of just solving toy problems, I could use it to build a real interactive organism that lives and learns right in the browser?&lt;/p&gt;

&lt;p&gt;And so, &lt;strong&gt;Project "Living Brain"&lt;/strong&gt; was born.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Goal:&lt;/strong&gt; Create a chatbot that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Runs entirely on the client-side, with no servers.&lt;/li&gt;
&lt;li&gt;  Learns in real-time from user conversations.&lt;/li&gt;
&lt;li&gt;  Saves its knowledge in &lt;code&gt;LocalStorage&lt;/code&gt; so it doesn't suffer from amnesia after a page refresh.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  My self-made library, &lt;code&gt;slmnet&lt;/code&gt; (Tensors, &lt;code&gt;Dense&lt;/code&gt;/&lt;code&gt;ReLU&lt;/code&gt; layers, an &lt;code&gt;SGD&lt;/code&gt; optimizer).&lt;/li&gt;
&lt;li&gt;  Pure JavaScript.&lt;/li&gt;
&lt;li&gt;  The browser's &lt;code&gt;LocalStorage&lt;/code&gt; as its hippocampus.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A Journey of Pain and Discovery: The Three Stages of Failure
&lt;/h3&gt;

&lt;p&gt;I thought it would be easy. I was wrong. The bot went through three evolutionary stages, and each one was a classic problem from the world of AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 1: The Echo Bot&lt;/strong&gt;&lt;br&gt;
The first version was terrible. It would simply memorize the last answer it was taught and repeat it for every single question. Boring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 2: The Bot with Catastrophic Forgetting&lt;/strong&gt;&lt;br&gt;
I solved problem #1, only to create a new one. The bot would perfectly learn a new lesson (e.g., "How are you?" -&amp;gt; "I'm great!"), but in the process, it would &lt;strong&gt;completely forget&lt;/strong&gt; everything it knew before ("Hello" -&amp;gt; "Greetings"). This is a classic AI problem where new knowledge completely overwrites the old. I was literally forcing it to cram for one test question, wiping its entire memory clean.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stage 3: The Bot with an Identity Crisis&lt;/strong&gt;&lt;br&gt;
I taught it to stop forgetting old lessons. But as soon as I added a &lt;strong&gt;new word&lt;/strong&gt; to its vocabulary, its brain (the network architecture) had to be rebuilt. My code would just create a new, empty brain. And although it retrained on all the old examples, the random initialization of its weights meant its "personality" completely changed. It would start answering "Hello" with "See you later." There was no stability.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Final Insight: Thinking Like Real AI
&lt;/h3&gt;

&lt;p&gt;The solution came when I stopped thinking like a programmer and started thinking like... a trainer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Experience Replay:&lt;/strong&gt; Instead of cramming one lesson, I created a "memory bank" to store all past conversations. Now, during training, the bot runs through its &lt;strong&gt;entire history&lt;/strong&gt;, gently adjusting its weights and reinforcing old knowledge along with the new.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Transfer Learning:&lt;/strong&gt; When new words appear, I stopped "demolishing the house." Instead, I implemented a "brain transplant": I create a new, larger model and carefully &lt;strong&gt;copy all the weights from the old one into it&lt;/strong&gt;. This way, its personality is preserved, and there's new space for new knowledge.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Let's Be Honest: This Isn't ChatGPT
&lt;/h3&gt;

&lt;p&gt;My project is a "little" language model, not a large one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  It &lt;strong&gt;doesn't generate&lt;/strong&gt; text; it performs classification by selecting the most appropriate response from those it already knows.&lt;/li&gt;
&lt;li&gt;  It uses a simple "Bag-of-Words" model, not complex transformers.&lt;/li&gt;
&lt;li&gt;  Its "understanding" is a statistical correlation, not semantic awareness.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But you know what? That doesn't matter. This one-evening project allowed me to experience the same journey AI researchers go through: from the simplest mistakes to implementing fundamental concepts. And it all happens in your browser window.&lt;/p&gt;

&lt;p&gt;It was an incredibly fascinating ride. Sometimes, old code is the best playground for new ideas.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Building a Neural Network is Easy. The Hard Part is Making It Think</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Mon, 11 Aug 2025 21:44:17 +0000</pubDate>
      <link>https://dev.to/xzdes/building-a-neural-network-is-easy-the-hard-part-is-making-it-think-3mjp</link>
      <guid>https://dev.to/xzdes/building-a-neural-network-is-easy-the-hard-part-is-making-it-think-3mjp</guid>
      <description>&lt;p&gt;Anyone with a bit of JavaScript and a library like TensorFlow.js can spin up a neural network in an afternoon. You feed it some data, call &lt;code&gt;.train()&lt;/code&gt;, and watch the numbers fly. There's a moment of magic when &lt;code&gt;.predict()&lt;/code&gt; gives you a result.&lt;/p&gt;

&lt;p&gt;But making it produce the &lt;em&gt;right&lt;/em&gt; result, consistently, across new and unexpected data? That's a different journey entirely.&lt;/p&gt;

&lt;p&gt;This repository is a chronicle of that journey. It started as a simple sentiment analyzer and evolved into a complex, hierarchical, self-learning system I call the "AI Corporation." The final code is not the most important artifact here; the evolution is.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Journey: From a Simple Script to a Flawed Mind
&lt;/h3&gt;

&lt;p&gt;Our path wasn't a straight line. It was a cycle of building, testing, failing, and gaining a deeper understanding at each step.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 1: The Black Box
&lt;/h4&gt;

&lt;p&gt;It began with a single, "flat" neural network. It worked, sometimes. But when it failed, it was impossible to know why. It was a black box. &lt;strong&gt;Lesson:&lt;/strong&gt; A working model isn't a smart model. If you can't debug its reasoning, you can't trust it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 2: The "AI Corporation" Architecture
&lt;/h4&gt;

&lt;p&gt;To solve the black box problem, I broke the task down. I created a hierarchical system with distinct layers of responsibility:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;L1 Experts:&lt;/strong&gt; Simple functions for raw text analysis.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;L2 Managers:&lt;/strong&gt; Logic-based modules to interpret the experts' reports.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;L3 Director:&lt;/strong&gt; The final neural network, making strategic decisions based on clean, structured data from the managers.
&lt;strong&gt;Lesson:&lt;/strong&gt; A good architecture is more valuable than a complex algorithm. Interpretability is key.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Phase 3: Building the Engine from Scratch
&lt;/h4&gt;

&lt;p&gt;To truly understand what was happening, I threw away TensorFlow.js and built my own neural network engine from the ground up: &lt;strong&gt;&lt;code&gt;DirectorNet.js&lt;/code&gt;&lt;/strong&gt;. Implementing the matrix math, the feedforward algorithm, and the backpropagation of errors was the most enlightening part of this project.&lt;br&gt;
&lt;strong&gt;Lesson:&lt;/strong&gt; You don't truly understand a tool until you can build a simple version of it yourself.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 4: The Paradox of Self-Learning
&lt;/h4&gt;

&lt;p&gt;I gave the system a feedback loop. It could now process new, unlabeled data, assign a verdict, and use that new "experience" in its next training cycle.&lt;/p&gt;

&lt;p&gt;And that's when it broke in the most fascinating way.&lt;/p&gt;

&lt;p&gt;It started making small errors, which were then saved as "experience." In the next cycle, it trained on its own mistakes. This created a feedback loop of negativity. My AI developed a &lt;strong&gt;Model Bias&lt;/strong&gt;. It became a paranoid pessimist, classifying almost every neutral review as a complaint because its "life experience" was tainted by its own past errors.&lt;br&gt;
&lt;strong&gt;Lesson:&lt;/strong&gt; Self-learning is a powerful but dangerous tool. An AI that learns from its own flawed conclusions will only become more confident in its mistakes.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 5: The AI Trainer
&lt;/h4&gt;

&lt;p&gt;The final stage wasn't about writing more complex code. It was about becoming an AI trainer. The solution was to "re-educate" the model by creating a "Cognitive Retraining" process, forcing it to give more weight to a "golden set" of human-verified data over its own flawed experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Real Challenge Isn't the Code
&lt;/h3&gt;

&lt;p&gt;This project proved to me that the code is the easy part. The real work of creating a useful AI is in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Architecture:&lt;/strong&gt; Designing a system that is transparent and debuggable.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Data Curation:&lt;/strong&gt; Understanding that the model's "mind" is a direct reflection of the data you feed it. Garbage in, garbage out.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Debugging Logic, Not Just Code:&lt;/strong&gt; Finding the root cause of a bad decision not in a syntax error, but in a flawed "belief" the model formed during training.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Understanding Limitations:&lt;/strong&gt; Knowing when a neural network is the right tool, and when a simple &lt;code&gt;if/else&lt;/code&gt; statement is more reliable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/Xzdes/neuralnetwork" rel="noopener noreferrer"&gt;https://github.com/Xzdes/neuralnetwork&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>ai</category>
      <category>learning</category>
    </item>
    <item>
      <title>My LLM Was a Terrible Co-Pilot, So I Built It a Better Cockpit: Introducing AxleLLM</title>
      <dc:creator>Pavel</dc:creator>
      <pubDate>Thu, 31 Jul 2025 08:24:32 +0000</pubDate>
      <link>https://dev.to/xzdes/my-llm-was-a-terrible-co-pilot-so-i-built-it-a-better-cockpit-introducing-axlellm-ha8</link>
      <guid>https://dev.to/xzdes/my-llm-was-a-terrible-co-pilot-so-i-built-it-a-better-cockpit-introducing-axlellm-ha8</guid>
      <description>&lt;p&gt;We’ve all been there. You’re staring at a tricky problem, so you tab over to your favorite LLM.&lt;/p&gt;

&lt;p&gt;"Write me a JavaScript function that..."&lt;/p&gt;

&lt;p&gt;Sometimes, what you get back is pure magic. It’s elegant, efficient, and saves you an hour of work. But other times... it's a disaster. It hallucinates a library that doesn’t exist, uses outdated syntax, or produces a buggy, convoluted mess that takes you &lt;em&gt;longer&lt;/em&gt; to debug than it would have taken to write from scratch.&lt;/p&gt;

&lt;p&gt;This is the cycle of hope and frustration with AI in development. LLMs are incredibly powerful, but they lack context. They are brilliant at generating &lt;em&gt;text that looks like code&lt;/em&gt;, but they struggle with the implicit rules, structure, and constraints of a real-world application.&lt;/p&gt;

&lt;p&gt;I realized the problem wasn't the AI. The problem was the environment I was asking it to work in. Asking an LLM to write imperative code in a large project is like putting a brilliant but distractible apprentice in a workshop full of unlabeled, razor-sharp tools. They're going to make a mess.&lt;/p&gt;

&lt;p&gt;So, I asked myself: What if, instead of asking the LLM to write messy code, I built it a better cockpit? A playground with simple, unbreakable rules and big, obvious buttons for the important stuff. A framework where the only way to build is the right way.&lt;/p&gt;

&lt;p&gt;That’s why I created &lt;strong&gt;AxleLLM&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is AxleLLM? The "Guardrails" Your AI Needs
&lt;/h3&gt;

&lt;p&gt;AxleLLM is a declarative engine for building native, cross-platform desktop apps with Node.js and Electron.&lt;/p&gt;

&lt;p&gt;Its core idea is to change the nature of our requests to the AI. Instead of &lt;strong&gt;"write code,"&lt;/strong&gt; the request becomes &lt;strong&gt;"describe the system."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The entire application—data, UI, logic, everything—is defined as a series of plain JavaScript objects in a &lt;code&gt;manifest&lt;/code&gt; directory. This structure acts as "guardrails" for the LLM. It can't generate buggy loops or import sketchy libraries. It can only do one thing: describe the system's architecture by filling in the blanks.&lt;/p&gt;

&lt;h3&gt;
  
  
  From Frustration to Flow in 60 Seconds
&lt;/h3&gt;

&lt;p&gt;This isn't just theory. You can experience this new way of working right now. You can go from an empty folder to a running, native desktop application with three commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Create a new app using the AxleLLM CLI&lt;/span&gt;
npx axle-llm new my-first-app

&lt;span class="c"&gt;# 2. Navigate and install dependencies&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;my-first-app
npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# 3. Launch the app in development mode&lt;/span&gt;
npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
&lt;strong&gt;(Pro Tip: I'd include a GIF here showing these commands running and the app window popping up.)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that's it. A "Hello, World!" desktop app is running on your screen, with hot-reloading ready to go.&lt;/p&gt;
&lt;h3&gt;
  
  
  Anatomy of an LLM-Friendly App
&lt;/h3&gt;

&lt;p&gt;Let's look at the "Hello, World!" app that the CLI just created. It's the perfect example of how this declarative structure makes AI collaboration easy and safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Data (&lt;code&gt;manifest/connectors.js&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, we declare all the data our app will use. The LLM can't guess where state comes from; it must define it here. This eliminates a whole class of &lt;code&gt;undefined&lt;/code&gt; errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// manifest/connectors.js&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;viewState&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;in-memory&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;initialState&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;message&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, World!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. The UI (&lt;code&gt;app/components/pages/home-page.html&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The UI is just "dumb" HTML with Mustache tags. The LLM can't write complex, error-prone client-side JavaScript. It can only map the data we just defined to the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- app/components/pages/home-page.html --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;{{ data.viewState.message }}&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;atom-action=&lt;/span&gt;&lt;span class="s"&gt;"POST /action/change-message"&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Change Message
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. The Logic (&lt;code&gt;manifest/routes.js&lt;/code&gt;)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the magic. The business logic isn't code; it's a simple array of &lt;code&gt;steps&lt;/code&gt;. It’s a recipe. And LLMs are fantastic at writing recipes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// manifest/routes.js&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST /action/change-message&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;action&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;writes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;viewState&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// The engine will auto-save this state&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;update&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;homePage&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;// and auto-update this component&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;steps&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;set&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data.viewState.message&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;to&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'Hello, AxleLLM!'&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We just described a fully reactive application without writing a single line of traditional, imperative code. We gave the LLM a structured language of architecture, and it delivered a perfect result.&lt;/p&gt;

&lt;h3&gt;
  
  
  The "Right Tools" for the Job
&lt;/h3&gt;

&lt;p&gt;AxleLLM provides a few key features that make this collaboration work so well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  ** The Super Validator:** Think of this as a senior developer who instantly code-reviews your LLM's architecture. Before the app even runs, it catches mistakes like trying to use data that wasn't loaded or linking to a component that doesn't exist.&lt;/li&gt;
&lt;li&gt;  ** The Secure Native Bridge:** Want to save a file? The LLM doesn't need to learn the &lt;code&gt;fs&lt;/code&gt; module and its security risks. It just needs to add one line to a whitelist (&lt;code&gt;manifest/bridge.js&lt;/code&gt;). The framework handles the safe implementation. The AI declares the &lt;em&gt;intent&lt;/em&gt;, the framework provides the &lt;em&gt;safe execution&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;  ** Declarative Steps:** The limited, powerful set of &lt;code&gt;steps&lt;/code&gt; (like &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;run:set&lt;/code&gt;) forces the LLM to build logic from reliable, tested building blocks, not from scratch every time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A New Way to Collaborate
&lt;/h3&gt;

&lt;p&gt;AxleLLM isn't about replacing the developer. It's about upgrading the relationship we have with our AI assistants. It's about moving from a frustrating "boss-intern" dynamic to a productive &lt;strong&gt;"architect-apprentice"&lt;/strong&gt; collaboration.&lt;/p&gt;

&lt;p&gt;It's about spending less time debugging quirky AI code and more time on the creative, high-level design of your application.&lt;/p&gt;

&lt;p&gt;The project is open-source and I'm actively developing it. I invite you to join this experiment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it out.&lt;/strong&gt; Create your first app in under a minute and see what it feels like to have an AI co-pilot that actually stays on course.&lt;/p&gt;

&lt;p&gt;I'd love to hear your thoughts in the comments below&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>node</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
