<?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: Hasindu Nagolla</title>
    <description>The latest articles on DEV Community by Hasindu Nagolla (@hasindu-nagolla).</description>
    <link>https://dev.to/hasindu-nagolla</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2639742%2F39f0b7ed-6d4c-4bcf-b19c-196074c5b432.jpg</url>
      <title>DEV Community: Hasindu Nagolla</title>
      <link>https://dev.to/hasindu-nagolla</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hasindu-nagolla"/>
    <language>en</language>
    <item>
      <title>Understanding the Transformer Model in LLMs</title>
      <dc:creator>Hasindu Nagolla</dc:creator>
      <pubDate>Fri, 04 Sep 2026 15:54:00 +0000</pubDate>
      <link>https://dev.to/hasindu-nagolla/understanding-the-transformer-model-in-llms-33bh</link>
      <guid>https://dev.to/hasindu-nagolla/understanding-the-transformer-model-in-llms-33bh</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you are using ChatGPT, Google Gemini, Claude or any other modern AI Language Model, you are interacting with a transformer. The transformer architecture introduced in 2017 by Google researchers revolutionized the ability of computers to understand and generate human language. This article will walk you through what transformers are and how they work step-by-step. Before transformers, language models looked at one word at a time. It was like reading a book with a flashlight that only shows one word. This made it hard for the model to understand long sentences. As an Example, In the sentence "The bank was steep," the word "bank" could mean a financial bank or a riverbank. To choose the right meaning, the model needs to see the word "steep". Transformers fix this by looking at all words in a sentence at once. This helps the model see how each word connects to the others&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 01 - Breaking Text Into Tokens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before the transformer reads the text, it splits it into smaller units called tokens. Each token becomes a number (a vector) that the model understands. This is called tokenization and embedding.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input - "I love artificial intelligence"&lt;/li&gt;
&lt;li&gt;Tokens - ["I", "love", "art", "ificial", "intell", "igence"]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 02 - Adding Positional Information&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transformers look at all words at once, so they need to know the order. For example, "dog bites man" is very different from "man bites dog." Positional encoding adds order to the tokens. It's like giving page numbers to mixed-up book pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 03 - Attention Mechanism&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the key part of transformers. Attention helps the model focus on important words when reading a sentence. Let's try to understand how Attention Works. Let's assume we need to translate "Le chat noir" (the black cat) into English.  For this, the model needs to focus on "Le" and "noir" when working on "chat." The model uses three parts for this&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Query - What word are we looking at now?&lt;/li&gt;
&lt;li&gt;Key - What other words are there?&lt;/li&gt;
&lt;li&gt;Value - What meaning do they give?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The model gives attention scores to all words to decide which ones are more important. Transformers use many attention heads at the same time (Multi-Head Attention). Each head looks at different things like grammar, meaning or logic. This helps the model understand better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 04 - Feed-Forward Neural Networks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After attention, the model sends each word's information through a feed-forward neural network. This helps the model learn more and improve its guesses. It’s like asking, “Now that I understand the sentence better, now what else can I figure out about this word?”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 05 - Stacking Layers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transformers use many layers, not just one. Each layer improves the output of the one before it.&lt;/p&gt;

&lt;p&gt;Layer 1 - Finds simple word links&lt;br&gt;
Layer 5 - Understands grammar better&lt;br&gt;
Layer 10 - Handles deep meaning&lt;br&gt;
Layer 20+ - Deals with complex ideas and reasoning&lt;/p&gt;

&lt;p&gt;It’s like editing a paper many times to make it a better and clearer output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 07 - Training the Model&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transformers learn by reading lots of text. During training:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The model reads billions of sentences&lt;/li&gt;
&lt;li&gt;It guesses the next word&lt;/li&gt;
&lt;li&gt;If wrong, it makes small changes to improve&lt;/li&gt;
&lt;li&gt;It repeats this many times&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This helps the model learn grammar, facts, patterns, and some logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8 - How It Writes Text&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you ask a question:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your text becomes tokens&lt;/li&gt;
&lt;li&gt;Tokens go through all the layers&lt;/li&gt;
&lt;li&gt;Attention helps the model find meaning&lt;/li&gt;
&lt;li&gt;It guesses the next word&lt;/li&gt;
&lt;li&gt;Adds it to the answer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will repeat until the answer is complete&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transformers are more powerful because they can read all words at once, understand long texts well, work better with more data and can be used for many tasks. Transformers changed how AI understands language by focusing on what matters and using many layers of learning. It became the core of most modern language models. They are not magic, but they are clever tools that learn from huge amounts of text and help computers understand and create human language better than ever before.&lt;/p&gt;

</description>
      <category>llm</category>
      <category>ai</category>
      <category>chatgpt</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Cyber war 😂</title>
      <dc:creator>Hasindu Nagolla</dc:creator>
      <pubDate>Fri, 04 Sep 2026 04:56:53 +0000</pubDate>
      <link>https://dev.to/hasindu-nagolla/cyber-war-39f9</link>
      <guid>https://dev.to/hasindu-nagolla/cyber-war-39f9</guid>
      <description>&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1wcbo55rnlv5siugccrj.jpg" 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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1wcbo55rnlv5siugccrj.jpg" alt=" " width="556" height="645"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't do that&lt;/p&gt;

</description>
      <category>linux</category>
      <category>development</category>
      <category>devops</category>
    </item>
    <item>
      <title>What is the RAG (Retrieval-Augmented Generation) 🔥😳</title>
      <dc:creator>Hasindu Nagolla</dc:creator>
      <pubDate>Fri, 04 Sep 2026 04:49:12 +0000</pubDate>
      <link>https://dev.to/hasindu-nagolla/what-is-the-rag-retrieval-augmented-generation-52k0</link>
      <guid>https://dev.to/hasindu-nagolla/what-is-the-rag-retrieval-augmented-generation-52k0</guid>
      <description>&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frcrxcfomfmkzun068wh3.jpg" 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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frcrxcfomfmkzun068wh3.jpg" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Think, you are writing an exam. We usually write exams based on what we have memorized. But RAG is like an open book exam. It means we will write the exam using the resources on time, not based on our memory. just like writing answers to the question using a book.&lt;/p&gt;

&lt;p&gt;AI models like ChatGPT (actually LLMs) can answer based on their training data set. They cannot provide answers beyond their training data. After integrating the RAG technology, AI models can provide answers by accessing the new outside databases or documents. It will be more accurate than the common answers that return from the LLMs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why RAG? 🤔🤔&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI models (LLMs) like ChatGPT and Gemini are brilliant, but they have some limitations,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Outdated Data - they trained on past data, because they have no idea about on time information. So they do predict. (Knowledge Cutoff)&lt;/li&gt;
&lt;li&gt;Hallucinations - sometimes they provide random answers instead of the correct answer.&lt;/li&gt;
&lt;li&gt;Personal Data - general AI models have no idea about your personal information, like private details or company information.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can completely mitigate these issues using RAG.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This entire process is done through 4 steps,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Asking a question - think you are asking "can i get a leave?"&lt;/li&gt;
&lt;li&gt;Retrieve (search) - The AI model (RAG integrated) does not provide the answer directly; it will search your company's HR policies and regulations.&lt;/li&gt;
&lt;li&gt;Augmented - then the system will collect your problem and the company information and send it to the AL model. &lt;/li&gt;
&lt;li&gt;Generation - now, the AI model is providing an accurate answer after analysing your question with your company details.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Advantages of RAG, 😮😮&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;👉Low cost - no need to train an AI model from scratch&lt;/li&gt;
&lt;li&gt;👉Real-time information - if you ask for real time news, you can get answers if they exist in the databases&lt;/li&gt;
&lt;li&gt;👉Stopping hallucinations - because the AI model will generate answers based on provided real information.&lt;/li&gt;
&lt;li&gt;👉Sources - The AI model can highlight references based on the provided documents or databases.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a summary, RAG(Retrieval-Augmented Generation) is like a bridge between your data and a separate AI model like ChatGPT. We can get highly accurate answers from AI models by providing our information as an outside data source. 👍👍&lt;/p&gt;

</description>
      <category>rag</category>
      <category>ai</category>
      <category>deeplearning</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Artificial Intelligence</title>
      <dc:creator>Hasindu Nagolla</dc:creator>
      <pubDate>Fri, 14 Aug 2026 08:45:25 +0000</pubDate>
      <link>https://dev.to/hasindu-nagolla/artificial-intelligence-2cji</link>
      <guid>https://dev.to/hasindu-nagolla/artificial-intelligence-2cji</guid>
      <description>&lt;p&gt;AI stands for Artificial Intelligence. It is the ability of a computer, or a robot controlled by a computer to mimic human Intelligence.AI is rapidly changing the world.&lt;/p&gt;

&lt;h2&gt;
  
  
  Subfields of artificial intelligence (AI)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Machine learning&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Machine learning is a type of AI that allows machines to learn from data without being explicitly programmed.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deep learning&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Deep learning is a type of machine learning that uses artificial neural networks to learn from data.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Natural language processing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Natural language processing is a type of AI that allows machines to understand and process human language.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Computer vision&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Computer vision is a type of AI that allows machines to see and understand the world around them.&lt;/p&gt;

&lt;p&gt;Nowadays, AI is very familiar to most people. It is in everything we use today. for example, automated tasks, AI chatbots, image searching, generate content.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Automating tasks - AI can be used to automate tasks. such as post-scheduling, managing comments and responding to emails.&lt;/li&gt;
&lt;li&gt;Generating content - AI can be used to generate content. such as blog posts, articles and social media posts.&lt;/li&gt;
&lt;li&gt;AI chatbots - AI can be used to replace customer care centres. such as checking customer issues and auto-reply. (Dialog dia AI chat bot)&lt;/li&gt;
&lt;li&gt;Image searching - Ai can be used to search images needed by users. example, google image search.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;here are some examples of using Artificial Intelligence,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Self-driving cars&lt;/li&gt;
&lt;li&gt;Virtual assistants (Apple Siri, Alexa, Google Assistant)&lt;/li&gt;
&lt;li&gt;Spam filter&lt;/li&gt;
&lt;li&gt;finance&lt;/li&gt;
&lt;li&gt;healthcare&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI is still in its early stages of development, but it has the potential to revolutionize the industry. As AI technology continues to improve, we can expect to see more innovative ways to use AI in industry.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
    </item>
    <item>
      <title>Building a Lag-Free Telegram Music Bot for Concurrent Streams in Python</title>
      <dc:creator>Hasindu Nagolla</dc:creator>
      <pubDate>Fri, 10 Jul 2026 11:45:50 +0000</pubDate>
      <link>https://dev.to/hasindu-nagolla/building-a-lag-free-telegram-music-bot-for-concurrent-streams-in-python-444g</link>
      <guid>https://dev.to/hasindu-nagolla/building-a-lag-free-telegram-music-bot-for-concurrent-streams-in-python-444g</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey DEV community! 👋&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Building a simple Telegram bot is fun, but building a &lt;strong&gt;music streaming bot&lt;/strong&gt; that streams audio to many voice chats at the same time is a completely different challenge.&lt;/p&gt;

&lt;p&gt;For the past year, I have been developing &lt;strong&gt;HasiiMusicBot&lt;/strong&gt;, an open-source Telegram music player that focuses on performance and scalability. I build it to solve many of the problems that existing music bots face.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Framework:&lt;/strong&gt; Pyrogram (MTProto API)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voice Streaming:&lt;/strong&gt; PyTgCalls&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Media Processing:&lt;/strong&gt; FFmpeg &amp;amp; yt-dlp&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database:&lt;/strong&gt; MongoDB with Motor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment:&lt;/strong&gt; Docker &amp;amp; Docker Compose&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🧗‍♂️ Challenges I Solve
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Handling Multiple Streams Without Lag
&lt;/h3&gt;

&lt;p&gt;Many Python music bots have a problem with blocking tasks like downloading audio or generating thumbnails. These tasks can freeze the event loop and cause audio interruptions in all active voice chats.&lt;/p&gt;

&lt;p&gt;I redesigned the bot to use non-blocking asynchronous tasks. This keeps the event loop free and allows the bot to handle concurrent streams smoothly with no audio drops.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Handling yt-dlp Anti-Bot Restrictions
&lt;/h3&gt;

&lt;p&gt;Many developers now face the &lt;strong&gt;"Sign in to confirm you're not a bot"&lt;/strong&gt; error when using yt-dlp with YouTube.&lt;/p&gt;

&lt;p&gt;To reduce this issue, I improved the metadata extraction process and add secure cookie handling. This helps the bot fetch high-quality audio streams more reliably.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 Open Source and Contributions
&lt;/h2&gt;

&lt;p&gt;The project is now available under the &lt;strong&gt;GPL-3.0 License&lt;/strong&gt; and is completely open source.&lt;/p&gt;

&lt;p&gt;If you are interested in &lt;strong&gt;Python, audio streaming, or Telegram bots&lt;/strong&gt;, please check out the project.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/hasindu-nagolla/HasiiMusicBot" rel="noopener noreferrer"&gt;https://github.com/hasindu-nagolla/HasiiMusicBot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I welcome feedback, code reviews, and contributions. I also added some &lt;code&gt;good first issue&lt;/code&gt; labels for beginners who want to make their first open-source contribution.&lt;/p&gt;

&lt;p&gt;If you like the project, please give it a ⭐ and let me know your thoughts in the comments!&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fli28m8nf2jnsbshtr75t.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fli28m8nf2jnsbshtr75t.png" alt="Hasii Music Bot" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>telegram</category>
      <category>opensource</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
