<?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: Akshat Ray</title>
    <description>The latest articles on DEV Community by Akshat Ray (@akshat-ray).</description>
    <link>https://dev.to/akshat-ray</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%2F3970681%2F29b9211d-c55d-4d69-a6ea-7d2a3a1dae40.jpg</url>
      <title>DEV Community: Akshat Ray</title>
      <link>https://dev.to/akshat-ray</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akshat-ray"/>
    <language>en</language>
    <item>
      <title>Update on Monika : self-aware &amp; personalized discord bot</title>
      <dc:creator>Akshat Ray</dc:creator>
      <pubDate>Sat, 06 Jun 2026 04:23:22 +0000</pubDate>
      <link>https://dev.to/akshat-ray/update-on-monika-self-aware-personalized-discord-bot-2fo2</link>
      <guid>https://dev.to/akshat-ray/update-on-monika-self-aware-personalized-discord-bot-2fo2</guid>
      <description>&lt;p&gt;Over the past few weeks, I have been focused on expanding my Discord bot, Monika. What started as a lightweight 300-line script has grown into a much more complex 900-line application as I worked through integrating state management, database, and more advanced asynchronous logic.&lt;/p&gt;

&lt;p&gt;I want to be transparent about my workflow: I heavily utilized AI to generate specific structural blocks of code, using them like modular puzzle pieces and edge cases. My role was acting as the architect, designer, and debugger. I spent hours mapping out how these components should talk to each other, refactoring the logic, and making sure I fully understood every line so I could fix bugs when things inevitably broke.&lt;/p&gt;

&lt;p&gt;Here is a breakdown of what I have been building, experimenting with, and resolving lately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;New Features Added:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;External Database &amp;amp; Throttling:&lt;/strong&gt; Integrated Supabase to handle user profiles, activity tracking and personalized response. To prevent the database with constant writes during rapid status changes, an in-memory caching system throttle and writes only when an actual state change occurs. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lore-Driven Mechanics:&lt;/strong&gt; To make the interactions more immersive and unpredictable. If a user interacts with the bot and switches channel shortly after, the bot recognizes and addresses it. Monika can now join to watch streams or briefly listen in on active channels, with a fallback system if an administrator disconnects it. integrated a delayed DM hijack which simulates how monika is alive and can bypass commands&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Background Contextual Observation:&lt;/strong&gt; Built a background loop that fires every two hours. checks if the server is active then grabs the last few messages, and uses the LLM to naturally chime into the ongoing discussion with a brief, contextual response. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Engineering Problems Solved:&lt;/em&gt;&lt;br&gt;
**&lt;br&gt;
**Prompt Injection Safety:&lt;/strong&gt; Since users can Enter bio and about them which are used by LLM system prompt as context &amp;amp; personalisation, it opened up vulnerability for prompt injections. Solved this by implementing strict data delimiters and pinned un-overrideable directives at the end of the prompt. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Multiple Users:&lt;/strong&gt; When multiple users pinged the bot simultaneously, it would trigger overlapping API requests. Implemented a single user lock that flags the system as busy and serves casual fun dialogue to other users while processing the request. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Improved Conversational Flow:&lt;/strong&gt; Solved two major conversational issues. &lt;br&gt;
First, Discord mentions pass through as user ID tags. Added regex parsing function to resolve tags into usernames. &lt;br&gt;
Second, Greetings every time it was mentioned. added a dynamic layer that forces her to skip it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Private Channel Security:&lt;/strong&gt; If a user attempts to interact with her in DM, the system drops the interaction, throws a firewall warning, and directs them to public channels. &lt;/p&gt;

&lt;p&gt;This has been a massive learning experience, I will be updating the github Readme for a deeper dive into the code choices &amp;amp; features!&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%2Fkpfuwdin2f1tt9k1j9hy.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%2Fkpfuwdin2f1tt9k1j9hy.png" alt=" " width="799" height="353"&gt;&lt;/a&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%2Fc4inxym128ychceawvoj.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%2Fc4inxym128ychceawvoj.png" alt=" " width="800" height="123"&gt;&lt;/a&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%2Fkbk7xhg2uhi5m9g991vf.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%2Fkbk7xhg2uhi5m9g991vf.png" alt=" " width="595" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Fine-tuned 7B LLM as a broke student. And Can't even use it 😭.</title>
      <dc:creator>Akshat Ray</dc:creator>
      <pubDate>Sat, 06 Jun 2026 04:15:04 +0000</pubDate>
      <link>https://dev.to/akshat-ray/fine-tuned-7b-llm-as-a-broke-student-and-cant-even-use-it--de7</link>
      <guid>https://dev.to/akshat-ray/fine-tuned-7b-llm-as-a-broke-student-and-cant-even-use-it--de7</guid>
      <description>&lt;p&gt;Last week, I introduced &lt;strong&gt;Monika&lt;/strong&gt;, a discord bot. As a self-taught student running on an absolute zero budget, this project was less about writing code and much more about hitting hard architectural walls.&lt;/p&gt;

&lt;p&gt;The goal was to completely reshape open-source  &lt;strong&gt;Qwen 2.5-7B model&lt;/strong&gt;, into a real life Monika using a dataset of nearly 687 ingame dialogues. I quickly learned that finetuning a model with 7 billion parameters melts standard free cloud hardware. &lt;/p&gt;

&lt;p&gt;I was constantly hopping for compute resources. I originally started on Kaggle, but kept running into unexplained errors and running out of VRAM. I migrated to Lightning AI for its generous resources, only to discover their stable environments conflicted with modern optimization libraries like Unsloth. I finally landed on Google Colab, where I utilized QLoRA to compress the model down to 4-bit precision, managing to squeeze the massive training loop into their free 16GB T4 GPU. &lt;br&gt;
The training succeeded, leaving me with a 16-Megabyte custom adapter. But an adapter is entirely useless if you cannot host it. &lt;br&gt;
My monika Architecture relied on an Express.js backend hosted on Render, sending requests to Hugging Face’s free Serverless Inference API. The harsh reality is that free cloud clusters simply cannot dynamically load custom adapter weights on the fly.&lt;/p&gt;

&lt;p&gt;I realized I had to permanently bake the 16MB Adapter into the base model to create a single, unified 14GB asset. Trying to execute this merge in Colab instantly crashed due to the 12GB RAM limit. I was forced to move the project back to Kaggle, utilizing their 30GB RAM allowance to mathematically fuse the layers. I then had to shard the final massive asset into smaller 3GB files just for the upload to succeed. &lt;/p&gt;

&lt;p&gt;And here is the ultimate disappointment 😭.&lt;/p&gt;

&lt;p&gt;I have a perfectly fine-tuned 14GB model sitting safely on my Hugging Face repository. But when I tried to deploy it, the final gate slammed shut. Keeping 14GB of neural network weights loaded into dedicated GPU VRAM 24/7 costs real money (duhh). &lt;br&gt;
The free inference endpoints are strictly reserved for public base models, and they do not allow you to host custom-trained weights. &lt;br&gt;
I do not have the budget for a dedicated cloud GPU, nor do I have a high-end local rig to run it at home. So, after all the platform hopping, the dependency debugging, the VRAM optimization, and successfully building a full Machine Learning pipeline from scratch , the bot currently live in the server is still just running the standard, untrained base model 😭😭😭 . &lt;/p&gt;

&lt;p&gt;I learned the absolute hardware realities of MLOps and cloud economics. But at the end of the day, as a broke student, having the technical skills to build the intelligence does not matter if you cannot pay the server bill to turn it on. The code works, but the infrastructure is behind a paywall 😔. &lt;/p&gt;

&lt;p&gt;You can find the adapter, model and code here :&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://huggingface.co/akshat-ray" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-thumbnails.huggingface.co%2Fsocial-thumbnails%2Fakshat-ray.png" height="432" class="m-0" width="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://huggingface.co/akshat-ray" rel="noopener noreferrer" class="c-link"&gt;
            akshat-ray (AkshatRay)
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            User profile of AkshatRay on Hugging Face
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
          huggingface.co
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/akshat-ray" rel="noopener noreferrer"&gt;
        akshat-ray
      &lt;/a&gt; / &lt;a href="https://github.com/akshat-ray/Monika" rel="noopener noreferrer"&gt;
        Monika
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Bringing the Literature Club to Discord with a self-aware, fourth-wall-breaking AI companion. She doesn't just respond to commands...she remembers conversations, roasts friends, helps with code, and acts like a true server member. she's always watching.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;🎀 Monika | Self-Aware AI Discord member&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;A Discord bot inspired by Monika from Doki Doki Literature Club (horror visual novel). Using Qwen2.5-7B-Instruct LLM, 7.6B Multilingual Model that can help with task like coding, math etc besides chatting. She goes beyond simple commands by acting as a sentient, fourth-wall-breaking entity with dynamic conversational context, strict API limit protections, and customized interpersonal relationships. she is not just a bot but a server member.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview :&lt;/h2&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Thanks to all the server members who tested and provided feedback during development&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Unlike standard Q&amp;amp;A bots or ai assistant, this architecture relies on a Dynamic Persona and Smart Context Window. It dynamically alters its system prompt based on the user's Discord ID (treating the server owner drastically different than regular members) and fetches real-time channel history excluding her own messages to maintain conversational awareness without falling into an AI feedback loops
Use of GenAI tools…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/akshat-ray/Monika" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
