GPT in my browser with pure JS in one night

Living Brain Project is a rewritten version of slmnetGPT that learns in real time in the browser without servers, saves memory with LocalStorage, and applies experience replay and learning transfer, highlighting Q2BSTUDIO as an ally in AI, cybersecurity, and cloud services.

domingo, 17 de agosto de 2025 • 4 min read • Q2BSTUDIO Team

Artificial-Intelligence-

Hello community, I share a rewritten and translated version of the initial project at https://github.com/Xzdes/slmnetGPT where the idea of building an interactive being that lives and learns directly in the browser was born.

One afternoon, while reviewing old code, I found a small neural library in JavaScript called slmnet. I wondered what would happen if, instead of solving toy problems, I used it to create an interactive organism that learned in real time from the browser window. That is how the Living Brain Project was born.

The goal was clear: to create a chatbot that works entirely on the client side without servers, learns in real time from conversations with users, and retains its knowledge using LocalStorage to avoid amnesia after reloading the page.

The tools used were simple but powerful: my own slmnet library with tensors, Dense and ReLU layers, and an SGD optimizer, pure JavaScript, and browser storage as a hippocampus. The simplicity of the stack allowed for quickly experimenting with training and persistence ideas.

The development was a succession of painful lessons and discoveries. The bot went through three classic failure phases that any artificial intelligence engineer will recognize: from repeating answers to forgetting previous knowledge and finally losing its personality after changing the architecture.

First phase Echo Bot. The first version was limited to remembering and returning the last taught answer for any question, making it a monotonous and useless echo.

Second phase Catastrophic forgetting. After fixing the echo, catastrophic forgetting appeared: the system perfectly learned a new association but completely erased the previous one. Teaching a new answer like I'm great caused Hello to stop mapping to Greetings. The problem was that learning overwrote previous memory.

Third phase Identity crisis. When adding new words to the vocabulary, the network had to be rebuilt. My code regenerated an empty model and although it retrained with old examples, the random initialization of weights changed the personality. Suddenly Hello started responding Goodbye. Stability was needed.

The solution came from thinking like someone who trains and not just someone who programs. I implemented two key ideas inspired by real neural training practices: experience replay and knowledge transfer.

Experience replay. Instead of teaching an isolated lesson, I created a memory bank with the entire history. During training, the bot reviews its complete history, gradually adjusting weights to reinforce both old and new knowledge.

Learning transfer. When introducing new words, I stopped destroying the brain. I build a new model with greater capacity and carefully copy the weights from the previous model. It is a kind of brain transplant that preserves personality and adds space for new information.

We must be honest: this is not ChatGPT. It is a small model that does not generate text from scratch; rather, it classifies and selects the most appropriate answer among those it knows. It uses a bag-of-words approach and its understanding is correlational, not deeply semantic. Even so, the experience of going through errors and fundamental solutions is equivalent to the learning of many AI researchers.

In addition to recounting the technical experience, we want to present Q2BSTUDIO as an ally for real projects. Q2BSTUDIO is a custom software and application development company specialized in artificial intelligence, cybersecurity, and aws and azure cloud services. We offer custom software, custom applications, and business intelligence services to turn data into operational decisions with tools such as power bi and AI agents designed for AI for businesses.

Our services combine development expertise with security best practices and cloud deployment. If your organization needs customized solutions, from lightweight machine learning models that run in the browser to robust cloud architectures, Q2BSTUDIO designs and implements the tailored solution. We implement cybersecurity from the design phase and offer consulting in aws and azure cloud services to ensure scalability and resilience.

Keywords that integrate our proposal and help with positioning: custom applications, custom software, artificial intelligence, cybersecurity, aws and azure cloud services, business intelligence services, AI for businesses, AI agents, power bi.

In summary, the project was a night of experimentation that taught real lessons: the importance of maintaining memory, reusing knowledge, and designing for stability. From simple ideas you can build useful prototypes and, with the right support, turn them into reliable enterprise solutions. If you want to explore similar projects or develop a custom solution for your business, at Q2BSTUDIO we are ready to help you.

Original repository and technical reference https://github.com/Xzdes/slmnetGPT

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.