<?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: Rijul Rajesh</title>
    <description>The latest articles on DEV Community by Rijul Rajesh (@rijultp).</description>
    <link>https://dev.to/rijultp</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%2F1207862%2F60f14114-548d-4857-87c3-87cd2e09375d.png</url>
      <title>DEV Community: Rijul Rajesh</title>
      <link>https://dev.to/rijultp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rijultp"/>
    <language>en</language>
    <item>
      <title>Build Your Own Personal AI Agent That Works for You With Hermes</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Sun, 26 Jul 2026 19:32:48 +0000</pubDate>
      <link>https://dev.to/rijultp/build-your-own-personal-ai-agent-that-works-for-you-with-hermes-ln7</link>
      <guid>https://dev.to/rijultp/build-your-own-personal-ai-agent-that-works-for-you-with-hermes-ln7</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;AI assistants can remember things about you now.&lt;/p&gt;

&lt;p&gt;But what if you wanted to run your &lt;strong&gt;own personal AI agent&lt;/strong&gt; that acts as your assistant across different parts of your life?&lt;/p&gt;

&lt;p&gt;One that can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access your environment&lt;/li&gt;
&lt;li&gt;Use tools&lt;/li&gt;
&lt;li&gt;Remember the things you want it to remember&lt;/li&gt;
&lt;li&gt;Continue working beyond a single chat window&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For that, I want to introduce you to &lt;strong&gt;Hermes Agent&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Hermes Agent?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Hermes Agent&lt;/strong&gt; is an open-source personal AI agent developed by Nous Research.&lt;/p&gt;

&lt;p&gt;At its core, it is a program that connects a language model to an environment where it can actually perform tasks.&lt;/p&gt;

&lt;p&gt;You give Hermes a task.&lt;/p&gt;

&lt;p&gt;Hermes sends that task to an AI model, receives the model's decisions, and then gives the model access to tools that can perform actions in the real world.&lt;/p&gt;

&lt;p&gt;This makes it more than just a chatbot.&lt;/p&gt;

&lt;p&gt;It is also different from traditional coding agents.&lt;/p&gt;

&lt;p&gt;Coding agents are primarily designed to work on software projects.&lt;/p&gt;

&lt;p&gt;Hermes is designed to act more like a &lt;strong&gt;personal AI assistant&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can use it for tasks such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Research this topic.&lt;/p&gt;

&lt;p&gt;Check my server.&lt;/p&gt;

&lt;p&gt;Fix this code.&lt;/p&gt;

&lt;p&gt;Search my previous conversations.&lt;/p&gt;

&lt;p&gt;Run this workflow every morning.&lt;/p&gt;

&lt;p&gt;Message me on Telegram when it's done.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The idea is to have an AI agent that can work across different areas instead of being limited to a single coding environment.&lt;/p&gt;

&lt;p&gt;Now let's see how quickly we can set it up.&lt;/p&gt;




&lt;h2&gt;
  
  
  Setting Up Hermes Agent
&lt;/h2&gt;

&lt;p&gt;You can find the repository here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/nousresearch/hermes-agent" rel="noopener noreferrer"&gt;https://github.com/nousresearch/hermes-agent&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The installation instructions are available in the README.&lt;/p&gt;

&lt;p&gt;For this article, I'll demonstrate the Linux installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://hermes-agent.nousresearch.com/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the installation is complete the setup wizard is launched, where you can configure the agent.&lt;/p&gt;

&lt;p&gt;Once the setup is complete, we can start Hermes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hermes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Hermes Agent in Action
&lt;/h2&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%2Fxhbepszfzvnt6xn5f5e6.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%2Fxhbepszfzvnt6xn5f5e6.png" alt=" " width="799" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's try a simple example.&lt;/p&gt;

&lt;p&gt;I'll give Hermes a workflow that I regularly follow when publishing technical articles.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I regularly publish technical articles.

When I finish an article, my usual workflow is:

1. Check the article structure
2. Create a thumbnail
3. Create a short LinkedIn post

Remember this workflow.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F0pygkgopo7jn4qpd3b1p.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%2F0pygkgopo7jn4qpd3b1p.png" alt=" " width="798" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, Hermes has been told about my workflow.&lt;/p&gt;

&lt;p&gt;Now I'll close Hermes.&lt;/p&gt;

&lt;p&gt;Later, I start it again and ask:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I just finished an article.

What should I do next?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F4u2dnbpkmudcvqhqbe7x.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%2F4u2dnbpkmudcvqhqbe7x.png" alt=" " width="799" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hermes is able to retrieve the workflow I previously told it about and suggest the next steps.&lt;/p&gt;

&lt;p&gt;It even offers to help me with those steps.&lt;/p&gt;

&lt;p&gt;This is the interesting part.&lt;/p&gt;

&lt;p&gt;The memory belongs to an agent that I can run myself.&lt;/p&gt;

&lt;p&gt;It is not limited to a single chat session.&lt;/p&gt;

&lt;p&gt;I can run the agent, give it information, close it, and return later.&lt;/p&gt;

&lt;p&gt;The agent can then use the information I previously asked it to remember.&lt;/p&gt;

&lt;p&gt;That starts to feel much more like a personal assistant than a traditional chatbot.&lt;/p&gt;

&lt;h2&gt;
  
  
  More Than Just Memory
&lt;/h2&gt;

&lt;p&gt;Memory is only one part of Hermes Agent.&lt;/p&gt;

&lt;p&gt;It also supports various connectors and tools that allow the agent to interact with different systems.&lt;/p&gt;

&lt;p&gt;This means you can potentially build workflows around things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your local environment&lt;/li&gt;
&lt;li&gt;Servers&lt;/li&gt;
&lt;li&gt;Messaging platforms&lt;/li&gt;
&lt;li&gt;Research&lt;/li&gt;
&lt;li&gt;Scheduled tasks&lt;/li&gt;
&lt;li&gt;Other external services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'll cover some of those connectors in a separate article.&lt;/p&gt;

&lt;p&gt;For now, the main idea is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can run your own personal AI agent, give it access to tools, teach it your workflows, and allow it to remember information across sessions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's it for this introduction to Hermes Agent.&lt;/p&gt;

&lt;p&gt;Thanks for reading. I'd love to hear 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.amazonaws.com%2Fuploads%2Farticles%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>Your AI Agent Has a Backpack. It's Called Retrieval Memory.</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Sat, 25 Jul 2026 20:40:54 +0000</pubDate>
      <link>https://dev.to/rijultp/your-ai-agent-has-a-backpack-its-called-retrieval-memory-1d95</link>
      <guid>https://dev.to/rijultp/your-ai-agent-has-a-backpack-its-called-retrieval-memory-1d95</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Imagine your AI agent has a backpack.&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%2Fhf2if7kw35cwddhumogm.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%2Fhf2if7kw35cwddhumogm.png" alt=" " width="644" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It stores your preferences, project details, past experiences, and procedures.&lt;/p&gt;

&lt;p&gt;But it doesn't carry everything in that backpack into every conversation. When something becomes relevant, it reaches in and retrieves what it needs.&lt;/p&gt;

&lt;p&gt;This is the basic idea behind retrieval memory.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Context Problem
&lt;/h2&gt;

&lt;p&gt;When you interact with an AI agent, it has a limited context window.&lt;/p&gt;

&lt;p&gt;As the conversation continues, more information gets added to that context.&lt;/p&gt;

&lt;p&gt;Eventually, the context can become full.&lt;/p&gt;

&lt;p&gt;At that point, the system may need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start a new session&lt;/li&gt;
&lt;li&gt;Compress the existing context&lt;/li&gt;
&lt;li&gt;Remove information that is no longer relevant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But there is another way to prevent the context from becoming unnecessarily large.&lt;/p&gt;

&lt;p&gt;Instead of keeping every piece of information inside the active context, the system can store information externally and retrieve it only when it is needed.&lt;/p&gt;

&lt;p&gt;This is the basic idea behind &lt;strong&gt;retrieval memory&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Retrieval Memory?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Retrieval memory&lt;/strong&gt; is a way for an AI system to remember information by storing it externally and retrieving the relevant parts when needed.&lt;/p&gt;

&lt;p&gt;The basic flow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User asks something
       ↓
Search stored memory
       ↓
Retrieve relevant information
       ↓
Add it to the AI's context
       ↓
Generate a response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important idea is that the information does not need to remain inside the active context all the time.&lt;/p&gt;

&lt;p&gt;It can be stored somewhere else and brought back when it becomes relevant.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Simple Example
&lt;/h2&gt;

&lt;p&gt;Suppose I tell an AI assistant:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;My favourite programming language is Rust.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The system might store this as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User preference:
Favourite programming language = Rust
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later, I ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Suggest a programming language for my next project.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The system can then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Search its stored memories.&lt;/li&gt;
&lt;li&gt;Retrieve the fact that I prefer Rust.&lt;/li&gt;
&lt;li&gt;Add that information to the current context.&lt;/li&gt;
&lt;li&gt;Use it when generating the response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The AI might then suggest Rust, or at least consider it as one of the options.&lt;/p&gt;

&lt;p&gt;The important point is that the preference did not need to remain in the active context between the two conversations.&lt;/p&gt;

&lt;p&gt;It was stored externally and retrieved when relevant.&lt;/p&gt;

&lt;p&gt;That is retrieval memory.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The memory is not directly inside the model. It is retrieved into the context when relevant.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How Is This Different From RAG?
&lt;/h2&gt;

&lt;p&gt;Retrieval memory is similar to &lt;strong&gt;RAG&lt;/strong&gt;, or Retrieval-Augmented Generation.&lt;/p&gt;

&lt;p&gt;The basic process is similar:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query
  ↓
Retrieve relevant information
  ↓
Add it to the context
  ↓
Generate a response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main difference is usually the source of the information.&lt;/p&gt;

&lt;p&gt;With traditional RAG, the system might retrieve information from:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;PDFs&lt;/li&gt;
&lt;li&gt;Websites&lt;/li&gt;
&lt;li&gt;Knowledge bases&lt;/li&gt;
&lt;li&gt;Company documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With retrieval memory, the system usually retrieves information specific to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A particular user&lt;/li&gt;
&lt;li&gt;A particular agent&lt;/li&gt;
&lt;li&gt;A previous interaction&lt;/li&gt;
&lt;li&gt;A project&lt;/li&gt;
&lt;li&gt;A specific workflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the source is often &lt;strong&gt;personal or agent-specific memory&lt;/strong&gt;, rather than a general document collection.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Kind of Information Can Be Retrieved?
&lt;/h2&gt;

&lt;p&gt;Retrieval memory can contain many different types of information.&lt;/p&gt;

&lt;h3&gt;
  
  
  User Preferences
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The user prefers the Fetch API over Axios.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Facts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The user is working on Project X.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Past Experiences
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This approach failed previously because the API rate limit was exceeded.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Procedures
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When deploying this project, run these commands in this order.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conversation Summaries
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The previous discussion concluded that the system should use PostgreSQL instead of SQLite.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system can then retrieve the relevant information when it becomes useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Idea
&lt;/h2&gt;

&lt;p&gt;Retrieval memory allows an AI agent to separate &lt;strong&gt;storage&lt;/strong&gt; from &lt;strong&gt;active context&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of keeping every piece of information in the context window all the time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Store information externally
            ↓
User asks a question
            ↓
Search stored memory
            ↓
Retrieve what is relevant
            ↓
Add it to the current context
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps the agent access information from previous interactions without carrying the entire history into every new conversation.&lt;/p&gt;

&lt;p&gt;So when you see terms like &lt;strong&gt;semantic memory&lt;/strong&gt;, &lt;strong&gt;episodic memory&lt;/strong&gt;, or &lt;strong&gt;retrieval memory&lt;/strong&gt;, they are describing different ways an AI system can store and use information.&lt;/p&gt;

&lt;p&gt;Understanding these concepts makes it easier to understand how modern AI agents build memory systems that go beyond simply keeping a giant conversation history.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>agents</category>
    </item>
    <item>
      <title>Context Compression: Making AI Agents Forget Without Losing the Plot</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Fri, 24 Jul 2026 20:09:52 +0000</pubDate>
      <link>https://dev.to/rijultp/context-compression-making-ai-agents-forget-without-losing-the-plot-5g7a</link>
      <guid>https://dev.to/rijultp/context-compression-making-ai-agents-forget-without-losing-the-plot-5g7a</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Suppose you are working with an AI agent to fix an API.&lt;/p&gt;

&lt;p&gt;You give it a simple instruction:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Fix the API 500 error.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agent might go through a workflow like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent:
→ Reads the logs
→ Searches the codebase
→ Checks the database
→ Checks recent commits
→ Runs tests
→ Tries a fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After 30 tool calls, the agent's context can become huge.&lt;/p&gt;

&lt;p&gt;But most of that information may no longer be useful.&lt;/p&gt;

&lt;p&gt;The agent does not need to keep every detail of the investigation forever.&lt;/p&gt;

&lt;p&gt;It does not need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every line from every log&lt;/li&gt;
&lt;li&gt;Every failed search&lt;/li&gt;
&lt;li&gt;Repeated information&lt;/li&gt;
&lt;li&gt;Old tool outputs&lt;/li&gt;
&lt;li&gt;Intermediate steps that are no longer relevant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What it really needs is the &lt;strong&gt;current state of the investigation&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Context Problem
&lt;/h2&gt;

&lt;p&gt;Imagine the agent has accumulated &lt;strong&gt;40,000 tokens of context&lt;/strong&gt; during the investigation.&lt;/p&gt;

&lt;p&gt;That context takes up valuable space.&lt;/p&gt;

&lt;p&gt;As the agent continues working, the context window gradually fills up.&lt;/p&gt;

&lt;p&gt;Eventually, the agent may have less room for new information, which can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Higher costs&lt;/li&gt;
&lt;li&gt;Slower processing&lt;/li&gt;
&lt;li&gt;Less room for future tool calls&lt;/li&gt;
&lt;li&gt;Important information being pushed out of context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So instead of carrying the entire history forward, we can compress it.&lt;/p&gt;

&lt;p&gt;The original 40,000 tokens might become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal:
Fix the API 500 error.

Found:
The error started after deployment v1.4.
The database is healthy.
The payment service is missing PAYMENT_API_KEY.

Tried:
Restarting the service. No effect.

Next:
Fix the environment configuration and retest.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is &lt;strong&gt;context compression&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Context Compression?
&lt;/h2&gt;

&lt;p&gt;Context compression is not simply about making the context shorter.&lt;/p&gt;

&lt;p&gt;The goal is to:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remove the information that is no longer useful while preserving what the agent needs to continue working.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agent does not need to remember every step it took.&lt;/p&gt;

&lt;p&gt;It needs to remember the important conclusions from those steps.&lt;/p&gt;




&lt;h1&gt;
  
  
  Three Basic Context Compression Techniques
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Pruning
&lt;/h2&gt;

&lt;p&gt;The simplest technique is &lt;strong&gt;pruning&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You remove information that is no longer useful.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent:
→ Searched for config.yaml
→ Found nothing

Agent:
→ Searched for settings.yaml
→ Found nothing

Agent:
→ Searched environment variables
→ Found PAYMENT_API_KEY is missing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the agent has found the actual cause, the failed searches may no longer be useful.&lt;/p&gt;

&lt;p&gt;They can be removed from the active context.&lt;/p&gt;

&lt;p&gt;The important information is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PAYMENT_API_KEY is missing.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pruning is essentially:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remove what the agent no longer needs.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Distillation
&lt;/h2&gt;

&lt;p&gt;Instead of keeping the entire conversation, we can convert it into a structured summary.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal:
Fix the API 500 error.

Facts:
- The database is healthy.
- The error started after deployment v1.4.
- PAYMENT_API_KEY is missing.

Decisions:
- Do not modify the database.
- Fix the environment configuration.

Completed:
- Checked the logs.
- Verified database connectivity.
- Inspected environment variables.

Next Action:
- Add PAYMENT_API_KEY.
- Restart the service.
- Retest the API.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The original investigation may have taken thousands of tokens.&lt;/p&gt;

&lt;p&gt;But the distilled state contains the information the agent needs to continue.&lt;/p&gt;

&lt;p&gt;A useful structure might be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Goal
Facts
Decisions
Completed Work
Next Action
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Distillation is essentially:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Turn a long history into a structured state.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. Generalisation
&lt;/h2&gt;

&lt;p&gt;Sometimes an investigation contains knowledge that can be reused in future situations.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Specific experience:

Missing API key caused the payment API to fail.
              ↓
Reusable knowledge:

Check environment variables when an API integration fails.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent is no longer just remembering what happened in one specific incident.&lt;/p&gt;

&lt;p&gt;It is extracting a general rule from that experience.&lt;/p&gt;

&lt;p&gt;This can be useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Future investigations&lt;/li&gt;
&lt;li&gt;Runbooks&lt;/li&gt;
&lt;li&gt;Agent skills&lt;/li&gt;
&lt;li&gt;Long-term memory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Generalisation is essentially:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Turn a specific experience into reusable knowledge.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  The Big Idea
&lt;/h1&gt;

&lt;p&gt;An AI agent does not need to carry its entire history forever.&lt;/p&gt;

&lt;p&gt;It needs to preserve the parts of that history that are still useful.&lt;/p&gt;

&lt;p&gt;A long investigation might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;40,000 tokens of raw history
              ↓
       Context compression
              ↓
      Goal + Facts + Decisions
              ↓
          Next Action
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent can then continue working with a much smaller context while retaining the information that actually matters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context compression is not about forgetting everything.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is about forgetting the right things.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>AI Runbooks Explained: How to Give AI Agents Procedures to Follow</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Tue, 21 Jul 2026 19:59:48 +0000</pubDate>
      <link>https://dev.to/rijultp/ai-runbooks-explained-how-to-give-ai-agents-procedures-to-follow-52e</link>
      <guid>https://dev.to/rijultp/ai-runbooks-explained-how-to-give-ai-agents-procedures-to-follow-52e</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you have read about AI agents, you may have come across the term &lt;strong&gt;AI runbook&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You may also have seen people confidently talk about agents handling routine tasks, running commands, investigating issues, and performing actions much like a human engineer would.&lt;/p&gt;

&lt;p&gt;But there is an important distinction here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Just because an agent can use tools does not mean it knows what to do or what procedure to follow.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think about the difference between an experienced engineer and a new employee joining a team.&lt;/p&gt;

&lt;p&gt;An experienced engineer may already know the team's standard procedures.&lt;/p&gt;

&lt;p&gt;A new employee might have the technical ability to do the work, but still needs to learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What to check first&lt;/li&gt;
&lt;li&gt;Which tools to use&lt;/li&gt;
&lt;li&gt;What actions to avoid&lt;/li&gt;
&lt;li&gt;How the team normally handles a particular situation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;AI agents are similar.&lt;/p&gt;

&lt;p&gt;Suppose you tell an agent:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The API is broken. Fix it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agent might start investigating broadly.&lt;/p&gt;

&lt;p&gt;It could check different files, inspect various configurations, run multiple commands, and try several approaches before figuring out what is actually wrong.&lt;/p&gt;

&lt;p&gt;This can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wasted time&lt;/li&gt;
&lt;li&gt;Wasted tokens&lt;/li&gt;
&lt;li&gt;Unnecessary tool calls&lt;/li&gt;
&lt;li&gt;More iterations than necessary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But what if we already had a standard procedure for handling this particular problem?&lt;/p&gt;

&lt;p&gt;The agent could follow that procedure and focus its investigation.&lt;/p&gt;

&lt;p&gt;That is where &lt;strong&gt;AI runbooks&lt;/strong&gt; come in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is an AI Runbook?
&lt;/h2&gt;

&lt;p&gt;A runbook is simply a documented procedure for handling a specific situation.&lt;/p&gt;

&lt;p&gt;For example, suppose an API starts returning HTTP 500 errors.&lt;/p&gt;

&lt;p&gt;A runbook might say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The API is returning 500 errors.

1. Check if the API is running.
2. Inspect the logs.
3. Check the database configuration.
4. Verify that the database is accessible.
5. Make the smallest necessary fix.
6. Verify that the API is working again.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives the agent a procedure to follow.&lt;/p&gt;

&lt;p&gt;The agent still has to perform the investigation and use its tools.&lt;/p&gt;

&lt;p&gt;The runbook simply provides a structure for that investigation.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Small AI Runbook Demo
&lt;/h2&gt;

&lt;p&gt;To demonstrate this, I created a small task management API using &lt;strong&gt;FastAPI&lt;/strong&gt; and &lt;strong&gt;SQLite&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can also try the demo yourself through &lt;a href="https://github.com/RijulTP/ai-runbook-demo" rel="noopener noreferrer"&gt;my repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The project contains a runbook for handling API failures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;runbooks/
└── api-500-error.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's look at the scenario.&lt;/p&gt;

&lt;p&gt;First, I start the server.&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%2Fzmm1900x82i7t7candx2.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%2Fzmm1900x82i7t7candx2.png" alt=" " width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The API is working correctly.&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%2Fbs8ldmgkay07muc62lsp.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%2Fbs8ldmgkay07muc62lsp.png" alt=" " width="800" height="41"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, I intentionally break the application by changing the database path from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./data/app.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./data1/app.db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F34o2goen851ytwf6dsod.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%2F34o2goen851ytwf6dsod.png" alt=" " width="534" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, when I call the health endpoint, the API returns an error.&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%2Fhu862al0861761g7o5je.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%2Fhu862al0861761g7o5je.png" alt=" " width="800" height="45"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, I ask my AI agent to investigate the issue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The API is returning HTTP 500 errors.

Please check whether there is a relevant runbook in the runbooks/ directory and follow it.

Diagnose the root cause, make the smallest safe fix, and verify that the API is working again.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fwws8wthp441n8da9qgp5.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%2Fwws8wthp441n8da9qgp5.png" alt=" " width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of immediately changing application code, the agent can follow the procedure defined in the runbook:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find the relevant runbook.&lt;/li&gt;
&lt;li&gt;Check the API.&lt;/li&gt;
&lt;li&gt;Inspect the logs.&lt;/li&gt;
&lt;li&gt;Check the database configuration.&lt;/li&gt;
&lt;li&gt;Identify the incorrect database path.&lt;/li&gt;
&lt;li&gt;Fix the configuration.&lt;/li&gt;
&lt;li&gt;Verify that the API is healthy again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The agent still performs the investigation.&lt;/p&gt;

&lt;p&gt;The runbook simply gives that investigation a structure.&lt;/p&gt;

&lt;p&gt;In this case, the agent finds the root cause and applies the fix.&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%2Fza68u9evfe1zbcy9ttvf.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%2Fza68u9evfe1zbcy9ttvf.png" alt=" " width="799" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt vs Runbook
&lt;/h2&gt;

&lt;p&gt;Compare these two instructions.&lt;/p&gt;

&lt;p&gt;A simple prompt might say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fix the API.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A runbook provides something more specific:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When the API returns a 500 error, check these things in this order.

Avoid making unnecessary changes.

After applying a fix, verify that the API is working again.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is important.&lt;/p&gt;

&lt;p&gt;With a simple prompt, the agent has to figure out the entire process by itself.&lt;/p&gt;

&lt;p&gt;With a runbook, the agent gets &lt;strong&gt;procedural knowledge&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It knows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What to check&lt;/li&gt;
&lt;li&gt;In what order to check it&lt;/li&gt;
&lt;li&gt;What actions to take&lt;/li&gt;
&lt;li&gt;What actions to avoid&lt;/li&gt;
&lt;li&gt;How to verify the result&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes the agent's behavior more predictable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Idea
&lt;/h2&gt;

&lt;p&gt;AI agents already have the ability to use tools.&lt;/p&gt;

&lt;p&gt;They can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read files&lt;/li&gt;
&lt;li&gt;Run commands&lt;/li&gt;
&lt;li&gt;Inspect logs&lt;/li&gt;
&lt;li&gt;Modify code&lt;/li&gt;
&lt;li&gt;Call APIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But tools only provide &lt;strong&gt;capabilities&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A runbook provides a &lt;strong&gt;procedure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That is the key idea behind AI runbooks.&lt;/p&gt;

&lt;p&gt;You are not just telling the agent:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here are some tools. Figure it out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You are giving it:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here is how this team normally handles this situation. Follow these steps, use your judgment where necessary, and verify the result when you are done.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is how you give an AI agent procedural knowledge.&lt;/p&gt;

&lt;p&gt;And in many cases, that can lead to a much more predictable outcome than simply giving an agent a vague instruction and hoping it figures out the best approach.&lt;/p&gt;

&lt;p&gt;That's it for this introduction to AI runbooks.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
    </item>
    <item>
      <title>Semantic Memory: How AI Builds Knowledge About You</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Mon, 20 Jul 2026 20:40:07 +0000</pubDate>
      <link>https://dev.to/rijultp/semantic-memory-how-ai-builds-knowledge-about-you-cdj</link>
      <guid>https://dev.to/rijultp/semantic-memory-how-ai-builds-knowledge-about-you-cdj</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When building personal AI systems, one of the most important types of memory to understand is &lt;strong&gt;semantic memory&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In simple terms, semantic memory is a structured store of knowledge such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Facts&lt;/li&gt;
&lt;li&gt;Concepts&lt;/li&gt;
&lt;li&gt;Preferences&lt;/li&gt;
&lt;li&gt;Relationships&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is the part of an AI memory system that helps answer:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"What do I know about this person, project, company, or concept?"&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Episodic Memory vs Semantic Memory
&lt;/h2&gt;

&lt;p&gt;Let's say the following conversation happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User: I usually use React and TypeScript for frontend projects.

AI: Got it.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single conversation can be stored in two very different ways.&lt;/p&gt;




&lt;h2&gt;
  
  
  Episodic Memory
&lt;/h2&gt;

&lt;p&gt;Episodic memory stores the event itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;On July 21, 2026, the user said:

"I usually use React and TypeScript for frontend projects."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system remembers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happened, when it happened, and what was said.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is similar to remembering an experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  Semantic Memory
&lt;/h2&gt;

&lt;p&gt;Semantic memory extracts the knowledge from that conversation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
├── frontend_framework → React
└── primary_language → TypeScript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system no longer needs to remember the original conversation to understand the underlying information.&lt;/p&gt;

&lt;p&gt;It has converted the conversation into structured knowledge.&lt;/p&gt;

&lt;p&gt;This is the key difference:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Episodic memory remembers the event.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic memory remembers what was learned from the event.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Semantic Memory as a Knowledge Layer
&lt;/h2&gt;

&lt;p&gt;You can think of semantic memory as a &lt;strong&gt;knowledge layer&lt;/strong&gt; for an AI system.&lt;/p&gt;

&lt;p&gt;For example, an AI assistant might maintain a structured representation of a user like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
├── prefers → React
├── uses → TypeScript
├── prefers → Linux
├── works_on → E-commerce platform
├── interested_in → AI agents
└── prefers → concise technical explanations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is semantic memory.&lt;/p&gt;

&lt;p&gt;The information is no longer stored as a conversation.&lt;/p&gt;

&lt;p&gt;Instead, it is stored as knowledge about entities and the relationships between them.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Are Entities?
&lt;/h2&gt;

&lt;p&gt;An entity is something that the AI system knows about.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User&lt;/li&gt;
&lt;li&gt;Customer&lt;/li&gt;
&lt;li&gt;Company&lt;/li&gt;
&lt;li&gt;Product&lt;/li&gt;
&lt;li&gt;Project&lt;/li&gt;
&lt;li&gt;Document&lt;/li&gt;
&lt;li&gt;Location&lt;/li&gt;
&lt;li&gt;Organization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User ──works_on──&amp;gt; E-commerce platform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User&lt;/strong&gt; is an entity&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;E-commerce platform&lt;/strong&gt; is an entity&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;works_on&lt;/strong&gt; is the relationship between them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure allows an AI system to reason about information instead of simply searching through old conversations.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Does This Matter?
&lt;/h2&gt;

&lt;p&gt;Imagine an AI assistant that has stored hundreds of conversations with you.&lt;/p&gt;

&lt;p&gt;If it only has episodic memory, it may need to search through those conversations every time it wants to answer a question about your preferences or projects.&lt;/p&gt;

&lt;p&gt;With semantic memory, it can directly access structured knowledge such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
├── uses → React
├── uses → TypeScript
├── works_on → E-commerce platform
└── interested_in → AI agents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The assistant does not need to reread every conversation to discover these facts.&lt;/p&gt;

&lt;p&gt;The knowledge has already been extracted and organized.&lt;/p&gt;

&lt;p&gt;That is what makes semantic memory such an important part of personal AI systems.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
    </item>
    <item>
      <title>Are You Missing Out on Agent Skills? Here's How They Work</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Fri, 17 Jul 2026 20:32:30 +0000</pubDate>
      <link>https://dev.to/rijultp/are-you-missing-out-on-agent-skills-heres-how-they-work-4dk5</link>
      <guid>https://dev.to/rijultp/are-you-missing-out-on-agent-skills-heres-how-they-work-4dk5</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt; &lt;/p&gt;




&lt;p&gt;Do you keep hearing terms like “agent skills” being thrown around without really understanding what they mean?&lt;/p&gt;

&lt;p&gt;And is the FOMO starting to get to you?&lt;/p&gt;

&lt;p&gt;Let’s understand what agent skills are in this article.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a skill?
&lt;/h3&gt;

&lt;p&gt;A skill is a way to give an AI agent &lt;strong&gt;procedural knowledge&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At its core, a skill is simply a &lt;code&gt;SKILL.md&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;But what exactly does this file contain?&lt;/p&gt;

&lt;h2&gt;
  
  
  The YAML Frontmatter
&lt;/h2&gt;

&lt;p&gt;At the top of the file, we have the YAML frontmatter.&lt;/p&gt;

&lt;p&gt;At a minimum, it contains two things:&lt;/p&gt;

&lt;h3&gt;
  
  
  Name
&lt;/h3&gt;

&lt;p&gt;This identifies the skill.&lt;/p&gt;

&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;p&gt;This tells the agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What the skill does&lt;/li&gt;
&lt;li&gt;When it should be used&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The description essentially acts as the trigger condition for the skill.&lt;/p&gt;

&lt;p&gt;Below the frontmatter, we have the body of the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Body
&lt;/h2&gt;

&lt;p&gt;This contains the actual instructions.&lt;/p&gt;

&lt;p&gt;It explains what the agent needs to know to perform the task.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What steps should be followed&lt;/li&gt;
&lt;li&gt;In what order should they be performed&lt;/li&gt;
&lt;li&gt;What decisions should be made along the way&lt;/li&gt;
&lt;li&gt;What rules or constraints should be followed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Skills can also contain optional directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  scripts/
&lt;/h3&gt;

&lt;p&gt;This can contain executable code that the agent can run when needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  references/
&lt;/h3&gt;

&lt;p&gt;This directory can contain additional documents that the agent can refer to.&lt;/p&gt;

&lt;h3&gt;
  
  
  assets/
&lt;/h3&gt;

&lt;p&gt;This can contain static resources that may be needed while performing the task.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Happens When an Agent Has Many Skills?
&lt;/h2&gt;

&lt;p&gt;An agent can have a large number of skills.&lt;/p&gt;

&lt;p&gt;But this raises an obvious question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If an agent has hundreds of skills, does loading all of them consume a huge amount of context?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where a concept called &lt;strong&gt;progressive disclosure&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;p&gt;The information is loaded in three stages.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Metadata Only
&lt;/h3&gt;

&lt;p&gt;When the agent starts, it loads only the name and description of each skill.&lt;/p&gt;

&lt;p&gt;This allows the agent to understand what skills are available without loading all of their instructions into the context.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Full Instructions
&lt;/h3&gt;

&lt;p&gt;When the description of a skill matches the task, the agent loads the full instructions from that skill into its context.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Optional Resources
&lt;/h3&gt;

&lt;p&gt;Scripts, references, and assets are loaded or used only when they are needed.&lt;/p&gt;

&lt;p&gt;This prevents the agent from loading everything at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Are Skills Different From Other AI Concepts?
&lt;/h2&gt;

&lt;p&gt;There are a few concepts that may sound similar.&lt;/p&gt;

&lt;h3&gt;
  
  
  MCP: Tool Access
&lt;/h3&gt;

&lt;p&gt;MCP gives agents the ability to interact with external tools and APIs.&lt;/p&gt;

&lt;p&gt;It is mainly about &lt;strong&gt;what the agent can reach&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  RAG: Factual Knowledge
&lt;/h3&gt;

&lt;p&gt;RAG retrieves relevant information from a knowledge base.&lt;/p&gt;

&lt;p&gt;It is mainly about giving the agent &lt;strong&gt;reference material and factual knowledge&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fine-Tuning: Model Weights
&lt;/h3&gt;

&lt;p&gt;Fine-tuning changes the model's weights.&lt;/p&gt;

&lt;p&gt;The knowledge or behavior is effectively baked into the model itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Skills: Procedural Knowledge
&lt;/h3&gt;

&lt;p&gt;Skills are different.&lt;/p&gt;

&lt;p&gt;They provide the agent with &lt;strong&gt;procedural knowledge&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They tell the agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to perform a task&lt;/li&gt;
&lt;li&gt;What steps to follow&lt;/li&gt;
&lt;li&gt;In what order to perform them&lt;/li&gt;
&lt;li&gt;What decisions to make along the way&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A skill can also use other technologies, such as MCP.&lt;/p&gt;

&lt;p&gt;For example, a skill could provide the instructions and judgment for &lt;strong&gt;when to call a particular MCP tool&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  An Open Standard
&lt;/h2&gt;

&lt;p&gt;This format is based on the open standard from Agent Skills.&lt;/p&gt;

&lt;p&gt;It has also been adopted by AI platforms such as Claude and Codex.&lt;/p&gt;

&lt;p&gt;This makes skills a useful way to package and share procedural knowledge across different AI tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  Be Careful With Skills
&lt;/h2&gt;

&lt;p&gt;There is one important thing to keep in mind.&lt;/p&gt;

&lt;p&gt;Skills can execute scripts.&lt;/p&gt;

&lt;p&gt;That means installing a skill is not always as simple as downloading a text file.&lt;/p&gt;

&lt;p&gt;A malicious skill could potentially introduce risks such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prompt injection&lt;/li&gt;
&lt;li&gt;Tool poisoning&lt;/li&gt;
&lt;li&gt;Malicious scripts&lt;/li&gt;
&lt;li&gt;Malware&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So you should treat skill installation similarly to installing any other software.&lt;/p&gt;

&lt;p&gt;Only install skills from sources you trust, and review what they contain before giving them access to your AI tools.&lt;/p&gt;

&lt;p&gt;So that's it about this article, see you on the next one!&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
    </item>
    <item>
      <title>Not Every LLM Is Built the Same: GPT vs Mixture of Experts (MoE)</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Wed, 15 Jul 2026 09:19:08 +0000</pubDate>
      <link>https://dev.to/rijultp/not-every-llm-is-built-the-same-gpt-vs-mixture-of-experts-moe-8ai</link>
      <guid>https://dev.to/rijultp/not-every-llm-is-built-the-same-gpt-vs-mixture-of-experts-moe-8ai</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Are you aware that there are different types of AI model architectures?&lt;/p&gt;

&lt;p&gt;Two of the most common are &lt;strong&gt;Dense (GPT-style)&lt;/strong&gt; models and &lt;strong&gt;Mixture of Experts (MoE)&lt;/strong&gt; models.&lt;/p&gt;

&lt;p&gt;I find myself using both.&lt;/p&gt;

&lt;p&gt;For general day-to-day tasks, I usually prefer dense GPT-style models.&lt;/p&gt;

&lt;p&gt;But when I'm researching a topic or working through a complex plan, I often reach for a Mixture of Experts model.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Let's look at how they differ.&lt;/p&gt;




&lt;h2&gt;
  
  
  Dense Models (Traditional GPT-Style)
&lt;/h2&gt;

&lt;p&gt;A traditional GPT model is called a &lt;strong&gt;dense model&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To help you visualise better, I will use an example.&lt;/p&gt;

&lt;p&gt;Imagine a company with &lt;strong&gt;100 employees&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every time a customer asks a question like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"How do I bake a cake?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All &lt;strong&gt;100 employees&lt;/strong&gt; gather together to answer it.&lt;/p&gt;

&lt;p&gt;Even if only 10 of them actually know anything about baking, everyone still participates.&lt;/p&gt;

&lt;p&gt;This is similar to how a dense model works.&lt;/p&gt;

&lt;p&gt;Every layer of the model is used for every prompt.&lt;/p&gt;

&lt;p&gt;All of the model's parameters are active during inference.&lt;/p&gt;

&lt;p&gt;For example, if a dense model has &lt;strong&gt;100 billion parameters&lt;/strong&gt;, all &lt;strong&gt;100 billion parameters&lt;/strong&gt; are involved every time you ask it a question.&lt;/p&gt;




&lt;h2&gt;
  
  
  Mixture of Experts (MoE)
&lt;/h2&gt;

&lt;p&gt;Now imagine the company works differently.&lt;/p&gt;

&lt;p&gt;Instead of making everyone attend every meeting, there are specialists:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programming expert&lt;/li&gt;
&lt;li&gt;Law expert&lt;/li&gt;
&lt;li&gt;Biology expert&lt;/li&gt;
&lt;li&gt;Writing expert&lt;/li&gt;
&lt;li&gt;Translation expert&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When someone asks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Write Python code."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The manager says:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Only the programming expert and the writing expert are needed."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The other experts stay idle.&lt;/p&gt;

&lt;p&gt;This is exactly how a &lt;strong&gt;Mixture of Experts (MoE)&lt;/strong&gt; model works.&lt;/p&gt;

&lt;p&gt;A small component called the &lt;strong&gt;router&lt;/strong&gt; decides which experts should handle your prompt.&lt;/p&gt;

&lt;p&gt;So if a model contains &lt;strong&gt;64 experts&lt;/strong&gt;, perhaps only &lt;strong&gt;2 or 4 experts&lt;/strong&gt; are activated for a given request.&lt;/p&gt;

&lt;p&gt;The rest remain inactive.&lt;/p&gt;




&lt;h2&gt;
  
  
  Examples of Dense and MoE Models
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Dense (Traditional GPT-Style)
&lt;/h3&gt;

&lt;p&gt;These models use &lt;strong&gt;all of their parameters&lt;/strong&gt; for every request.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI GPT-3&lt;/li&gt;
&lt;li&gt;OpenAI GPT-3.5&lt;/li&gt;
&lt;li&gt;Meta Llama 1&lt;/li&gt;
&lt;li&gt;Meta Llama 2&lt;/li&gt;
&lt;li&gt;Meta Llama 3, 3.1, and 3.2&lt;/li&gt;
&lt;li&gt;Google Gemma (all versions)&lt;/li&gt;
&lt;li&gt;Qwen 2, 2.5, and the dense variants of Qwen 3&lt;/li&gt;
&lt;li&gt;Mistral 7B&lt;/li&gt;
&lt;li&gt;Microsoft Phi-2, Phi-3, and Phi-4&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Mixture of Experts (MoE)
&lt;/h3&gt;

&lt;p&gt;These models activate &lt;strong&gt;only a subset of experts&lt;/strong&gt; for each request.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mixtral 8x7B&lt;/li&gt;
&lt;li&gt;Mixtral 8x22B&lt;/li&gt;
&lt;li&gt;DeepSeek V2&lt;/li&gt;
&lt;li&gt;DeepSeek V3&lt;/li&gt;
&lt;li&gt;DeepSeek R1&lt;/li&gt;
&lt;li&gt;Gemini 1.5&lt;/li&gt;
&lt;li&gt;Gemini 2.0&lt;/li&gt;
&lt;li&gt;Gemini 2.5&lt;/li&gt;
&lt;li&gt;Grok 2&lt;/li&gt;
&lt;li&gt;Grok 3&lt;/li&gt;
&lt;li&gt;GPT-4 (widely reported as MoE)&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Neither architecture is universally better.&lt;/p&gt;

&lt;p&gt;Dense models are simpler and use their entire network for every prompt.&lt;/p&gt;

&lt;p&gt;Mixture of Experts models improve efficiency by activating only the experts that are most relevant to the task.&lt;/p&gt;

&lt;p&gt;As AI models continue to grow larger, MoE has become an increasingly popular approach for scaling performance without proportionally increasing inference costs.&lt;/p&gt;

&lt;p&gt;Understanding the difference helps explain why modern LLMs can vary so much in speed, memory usage, and overall efficiency, even when they appear similar on the surface.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatgpt</category>
    </item>
    <item>
      <title>Finding the Right Local LLM Doesn't Have to Take Hours</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Mon, 13 Jul 2026 20:18:49 +0000</pubDate>
      <link>https://dev.to/rijultp/finding-the-right-local-llm-doesnt-have-to-take-hours-56kp</link>
      <guid>https://dev.to/rijultp/finding-the-right-local-llm-doesnt-have-to-take-hours-56kp</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Choosing a local LLM often comes down to trial and error. If you're not sure which models your hardware can comfortably run, here's a tool worth checking out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet LLMFit
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Repository:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/AlexsJones/llmfit" rel="noopener noreferrer"&gt;https://github.com/AlexsJones/llmfit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;llmfit&lt;/code&gt; analyzes your hardware and recommends the models that best fit your machine.&lt;/p&gt;

&lt;p&gt;Instead of manually comparing VRAM requirements, quantizations, and model sizes, it tells you what is likely to run well on your system.&lt;/p&gt;

&lt;p&gt;The installation instructions are available in the project's README.&lt;/p&gt;

&lt;p&gt;For my machine, I installed it using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://llmfit.axjns.dev/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;llmfit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the output I got:&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%2Fkl5ekwzcxtnuz7zcac91.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%2Fkl5ekwzcxtnuz7zcac91.png" alt=" " width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding the Output
&lt;/h2&gt;

&lt;p&gt;At first glance, the table can look overwhelming.&lt;/p&gt;

&lt;p&gt;Let's go through each column one by one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Model
&lt;/h3&gt;

&lt;p&gt;The name of the language model.&lt;/p&gt;

&lt;p&gt;Examples include &lt;strong&gt;Llama 3.1 8B&lt;/strong&gt;, &lt;strong&gt;Qwen2.5 14B&lt;/strong&gt;, and many others.&lt;/p&gt;




&lt;h3&gt;
  
  
  Provider
&lt;/h3&gt;

&lt;p&gt;The organization or repository that publishes the model.&lt;/p&gt;

&lt;p&gt;Examples include &lt;strong&gt;Meta&lt;/strong&gt;, &lt;strong&gt;bartowski&lt;/strong&gt;, &lt;strong&gt;Unsloth&lt;/strong&gt;, &lt;strong&gt;TheBloke&lt;/strong&gt;, and other Hugging Face publishers.&lt;/p&gt;




&lt;h3&gt;
  
  
  Params
&lt;/h3&gt;

&lt;p&gt;The number of parameters in the model.&lt;/p&gt;

&lt;p&gt;Generally, larger models are more capable, but they also require more memory and compute.&lt;/p&gt;




&lt;h3&gt;
  
  
  Score
&lt;/h3&gt;

&lt;p&gt;An overall recommendation score between &lt;strong&gt;0 and 100&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It combines multiple factors such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model quality&lt;/li&gt;
&lt;li&gt;Generation speed&lt;/li&gt;
&lt;li&gt;Hardware compatibility&lt;/li&gt;
&lt;li&gt;Context length&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Higher scores are generally better.&lt;/p&gt;




&lt;h3&gt;
  
  
  Tok/s
&lt;/h3&gt;

&lt;p&gt;The estimated number of tokens the model can generate every second.&lt;/p&gt;

&lt;p&gt;Higher values mean faster responses.&lt;/p&gt;




&lt;h3&gt;
  
  
  Quant
&lt;/h3&gt;

&lt;p&gt;The quantization format used by the model.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Q8_0&lt;/li&gt;
&lt;li&gt;Q6_K&lt;/li&gt;
&lt;li&gt;Q4_K_M&lt;/li&gt;
&lt;li&gt;Q3_K&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lower quantization levels usually reduce memory usage and improve speed, while slightly reducing quality.&lt;/p&gt;




&lt;h3&gt;
  
  
  Disk
&lt;/h3&gt;

&lt;p&gt;The amount of disk space required by the selected model.&lt;/p&gt;




&lt;h3&gt;
  
  
  GPU
&lt;/h3&gt;

&lt;p&gt;Shows how the model will actually run on your machine.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPU&lt;/li&gt;
&lt;li&gt;CPU + GPU&lt;/li&gt;
&lt;li&gt;CPU&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Mem %
&lt;/h3&gt;

&lt;p&gt;The percentage of your available RAM or VRAM that the model is expected to use.&lt;/p&gt;

&lt;p&gt;A value between &lt;strong&gt;50% and 80%&lt;/strong&gt; is usually a comfortable range.&lt;/p&gt;




&lt;h3&gt;
  
  
  Ctx
&lt;/h3&gt;

&lt;p&gt;The maximum context window supported by the model.&lt;/p&gt;

&lt;p&gt;A larger context window allows the model to process longer conversations and larger documents.&lt;/p&gt;




&lt;h3&gt;
  
  
  Date
&lt;/h3&gt;

&lt;p&gt;The release date or last update date of the model.&lt;/p&gt;

&lt;p&gt;This helps you judge how recent the model is.&lt;/p&gt;




&lt;h3&gt;
  
  
  Fit
&lt;/h3&gt;

&lt;p&gt;Indicates how well the model matches your hardware.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Perfect&lt;/strong&gt; — Excellent fit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Good&lt;/strong&gt; — Runs comfortably.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Marginal&lt;/strong&gt; — Usable, but close to the hardware limit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Too Tight&lt;/strong&gt; — Not recommended for your machine.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Use Case
&lt;/h3&gt;

&lt;p&gt;The primary scenario the model is optimized for.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;General&lt;/li&gt;
&lt;li&gt;Chat&lt;/li&gt;
&lt;li&gt;Multimodal&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;That's all there is to it.&lt;/p&gt;

&lt;p&gt;If you're planning to experiment with local LLMs, &lt;code&gt;llmfit&lt;/code&gt; is a handy tool for figuring out which models are most suitable for your hardware before you spend time downloading them.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;




</description>
      <category>tools</category>
      <category>productivity</category>
      <category>llms</category>
    </item>
    <item>
      <title>Typing Too Much While Using AI? This Tool Will Save You Hours</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Mon, 06 Jul 2026 20:04:44 +0000</pubDate>
      <link>https://dev.to/rijultp/typing-too-much-while-using-ai-this-tool-will-save-you-hours-2p0b</link>
      <guid>https://dev.to/rijultp/typing-too-much-while-using-ai-this-tool-will-save-you-hours-2p0b</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello, I'm Rijul. I'm building git-lrc, a micro AI code reviewer that runs on every commit. It's free and source-available on GitHub. &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;Star git-lrc&lt;/a&gt; to help more developers discover the project. Do give it a try and share your feedback&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Are you tired of typing the same prompts over and over again?&lt;/p&gt;

&lt;p&gt;I definitely was.&lt;/p&gt;

&lt;p&gt;When working with AI tools, I noticed I kept writing the same instructions repeatedly. Sometimes I'd even dig through old chats just to copy and paste a prompt I had already written dozens of times.&lt;/p&gt;

&lt;p&gt;It isn't difficult, but it breaks your flow.&lt;/p&gt;

&lt;p&gt;Thankfully, there's a fantastic tool that completely solves this problem: &lt;strong&gt;Espanso&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can create your own shortcuts, and Espanso instantly expands them into full text anywhere on your computer.&lt;/p&gt;

&lt;p&gt;For example, here's the built-in &lt;code&gt;:date&lt;/code&gt; shortcut.&lt;/p&gt;

&lt;p&gt;As soon as I type &lt;code&gt;:date&lt;/code&gt;, it automatically replaces it with today's date.&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%2F1muhen7qgtatoz9hja9v.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1muhen7qgtatoz9hja9v.gif" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pretty cool, right?&lt;/p&gt;

&lt;p&gt;Let's install it and create our own shortcuts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Installing Espanso
&lt;/h2&gt;

&lt;p&gt;Head over to &lt;a href="https://espanso.org" rel="noopener noreferrer"&gt;espanso.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You'll find the installation button right on the homepage.&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%2Fx8ilpt78ieso1985kp67.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%2Fx8ilpt78ieso1985kp67.png" alt=" " width="799" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Installation depends on your operating system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;macOS&lt;/strong&gt;: Install the bundle or use Homebrew.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windows&lt;/strong&gt;: Download and run the installer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linux&lt;/strong&gt;: Choose the installation method for your distribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Linux users
&lt;/h3&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%2Fjlh2yattkqxexhitpuvt.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%2Fjlh2yattkqxexhitpuvt.png" alt=" " width="799" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before installing, check whether you're running &lt;strong&gt;X11&lt;/strong&gt; or &lt;strong&gt;Wayland&lt;/strong&gt;.&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="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$XDG_SESSION_TYPE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My machine is running &lt;strong&gt;X11&lt;/strong&gt;, so I'll install the AppImage like so.&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;# Create the $HOME/opt destination folder&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/opt

&lt;span class="c"&gt;# Download the AppImage&lt;/span&gt;
wget &lt;span class="nt"&gt;-O&lt;/span&gt; ~/opt/Espanso.AppImage &lt;span class="s1"&gt;'https://github.com/espanso/espanso/releases/latest/download/Espanso-X11.AppImage'&lt;/span&gt;

&lt;span class="c"&gt;# Make it executable&lt;/span&gt;
&lt;span class="nb"&gt;chmod &lt;/span&gt;u+x ~/opt/Espanso.AppImage

&lt;span class="c"&gt;# Create the "espanso" command alias&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ~/opt/Espanso.AppImage env-path register
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the installation finishes, verify that everything is working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;espanso &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now start Espanso.&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;# Required only once&lt;/span&gt;
espanso service register

&lt;span class="c"&gt;# Start Espanso&lt;/span&gt;
espanso start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Espanso is now running in the background.&lt;/p&gt;

&lt;p&gt;If you'd like more installation details, the official documentation is available here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://espanso.org/docs/get-started/" rel="noopener noreferrer"&gt;https://espanso.org/docs/get-started/&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Witness the Magic
&lt;/h2&gt;

&lt;p&gt;Let's try one of the built-in shortcuts.&lt;/p&gt;

&lt;p&gt;I'll type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:espanso
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As soon as I finish typing, Espanso replaces it with "Hi there!"&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%2F4ch19vh4oilheqfx4yzo.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4ch19vh4oilheqfx4yzo.gif" alt=" " width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No copy-pasting.&lt;/p&gt;

&lt;p&gt;No scripts.&lt;/p&gt;

&lt;p&gt;Just instant text expansion.&lt;/p&gt;

&lt;p&gt;Now let's create our own shortcut.&lt;/p&gt;




&lt;h2&gt;
  
  
  Creating Your Own Shortcuts
&lt;/h2&gt;

&lt;p&gt;Espanso stores its configuration in a simple YAML file.&lt;/p&gt;

&lt;p&gt;First, locate your configuration directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;espanso path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mine returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Config: /home/rtp/.config/espanso
Packages: /home/rtp/.config/espanso/match/packages
Runtime: /home/rtp/.cache/espanso
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the &lt;strong&gt;Config&lt;/strong&gt; directory and navigate to the &lt;strong&gt;match&lt;/strong&gt; folder.&lt;/p&gt;

&lt;p&gt;I will head to &lt;code&gt;/home/rtp/.config/espanso&lt;/code&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxnml86ph4o0mtbyg4z3x.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%2Fxnml86ph4o0mtbyg4z3x.png" alt=" " width="745" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside, you'll find a file named &lt;strong&gt;base.yml&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4prkzfpqn5baf79ap6d9.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%2F4prkzfpqn5baf79ap6d9.png" alt=" " width="499" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open it.&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%2Fuldoe0h5ne1of6fcmep7.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%2Fuldoe0h5ne1of6fcmep7.png" alt=" " width="800" height="591"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll notice some existing shortcuts already defined.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;:date&lt;/code&gt; inserts the current date.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:espanso&lt;/code&gt; expands to &lt;code&gt;Hi there!&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Creating your own shortcut is just as easy.&lt;/p&gt;




&lt;h2&gt;
  
  
  A Real-World Example
&lt;/h2&gt;

&lt;p&gt;When I'm prompting AI, I frequently include this instruction:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make only minimal, non-destructive changes to the code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It helps prevent the AI from making unnecessary modifications that could accidentally break my software.&lt;/p&gt;

&lt;p&gt;The problem is that I end up typing this sentence countless times every week.&lt;/p&gt;

&lt;p&gt;Instead, I created a shortcut.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;trigger&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;:mdc"&lt;/span&gt;
  &lt;span class="na"&gt;replace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Make&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;only&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;minimal,&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;non-destructive&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;changes&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;to&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;the&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;code."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding it to &lt;code&gt;base.yml&lt;/code&gt;, my configuration looks like this:&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%2Fw6bwq5l6qf0gqgfyz07b.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%2Fw6bwq5l6qf0gqgfyz07b.png" alt=" " width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, whenever I type &lt;code&gt;:mdc&lt;/code&gt;, Espanso instantly expands it into the full sentence.&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%2F2nhtqiose39lovzajy47.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2nhtqiose39lovzajy47.gif" alt=" " width="760" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It feels like magic, and after a few days of using it, you'll wonder how you ever worked without it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Espanso is one of those small tools that quietly saves you hundreds of keystrokes every day.&lt;/p&gt;

&lt;p&gt;Whether you're writing prompts, code snippets, email templates, commit messages, or anything repetitive, custom text expansions can make your workflow noticeably faster.&lt;/p&gt;

&lt;p&gt;Huge kudos to &lt;a href="https://federicoterzi.com/" rel="noopener noreferrer"&gt;Federico Terzi&lt;/a&gt; for creating such an awesome tool.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>productivity</category>
      <category>automation</category>
      <category>ai</category>
    </item>
    <item>
      <title>Building Word Embeddings with PyTorch and Lightning AI Part 2: Creating Labels for Next-Word Prediction</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Sat, 04 Jul 2026 21:28:40 +0000</pubDate>
      <link>https://dev.to/rijultp/building-word-embeddings-with-pytorch-and-lightning-ai-part-2-creating-labels-for-next-word-ka3</link>
      <guid>https://dev.to/rijultp/building-word-embeddings-with-pytorch-and-lightning-ai-part-2-creating-labels-for-next-word-ka3</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/rijultp/building-word-embeddings-with-pytorch-and-lightning-ai-part-1-setting-up-the-word-embedding-model-3ka3"&gt;previous article&lt;/a&gt;, we created the training inputs for our word embedding model using one-hot encoding. In this article, we will define the labels and prepare the data for training&lt;/p&gt;

&lt;p&gt;Let's continue by setting up the labels.&lt;/p&gt;

&lt;p&gt;Our goal is to predict &lt;strong&gt;the next token&lt;/strong&gt; given the current token.&lt;/p&gt;

&lt;p&gt;Consider the sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The Incredibles is great&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the current token is &lt;strong&gt;"The Incredibles"&lt;/strong&gt;, the next token is &lt;strong&gt;"is"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So, the correct label is the one-hot encoding for &lt;strong&gt;"is"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Next, if the current token is &lt;strong&gt;"is"&lt;/strong&gt;, the model should predict the one-hot encoding for &lt;strong&gt;"great"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;After &lt;strong&gt;"great"&lt;/strong&gt;, the sentence ends. To continue training with the next sentence, we set the next token to the one-hot encoding for &lt;strong&gt;"Despicable Me"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now let's convert these labels into a PyTorch tensor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;labels&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&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;At this point, we have finished encoding our training data.&lt;/p&gt;

&lt;p&gt;Next, we combine the inputs and labels into a &lt;code&gt;TensorDataset&lt;/code&gt;, and then use that dataset to create a &lt;code&gt;DataLoader&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;dataset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TensorDataset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;dataloader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DataLoader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Creating the Neural Network
&lt;/h2&gt;

&lt;p&gt;Now let's start implementing the word embedding model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;WordEmbedding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;L&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LightningModule&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Initialize the weight tensors for the embedding network and loss function
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Make a forward pass through the embedding network
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;configure_optimizers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Configure the Adam optimizer
&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;training_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch_idx&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Calculate the loss (Cross Entropy Loss)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next article, we will begin implementing each of these methods one by one.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Building Word Embeddings with PyTorch and Lightning AI Part 1: Setting Up the Word Embedding Model</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Fri, 03 Jul 2026 18:56:36 +0000</pubDate>
      <link>https://dev.to/rijultp/building-word-embeddings-with-pytorch-and-lightning-ai-part-1-setting-up-the-word-embedding-model-3ka3</link>
      <guid>https://dev.to/rijultp/building-word-embeddings-with-pytorch-and-lightning-ai-part-1-setting-up-the-word-embedding-model-3ka3</guid>
      <description>&lt;p&gt;In this article, we will explore how to implement &lt;strong&gt;word embeddings&lt;/strong&gt; using PyTorch and Lightning AI.&lt;/p&gt;

&lt;p&gt;The implementation is based on the same example that we used in my &lt;a href="https://dev.to/rijultp/series/41618"&gt;Word2Vec article series&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First, let's import the required modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch.nn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;torch.optim&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Adam&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;torch.distributions.uniform&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Uniform&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;torch.utils.data&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TensorDataset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DataLoader&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;lightning&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;L&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These imports are used for the following purposes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;torch&lt;/code&gt; – Create tensors and use helper functions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;torch.nn&lt;/code&gt; – Create neural network layers and weights.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Adam&lt;/code&gt; – Optimize the neural network using backpropagation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Uniform&lt;/code&gt; – Initialize the network weights.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TensorDataset&lt;/code&gt; and &lt;code&gt;DataLoader&lt;/code&gt; – Prepare and load the training data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pandas&lt;/code&gt;, &lt;code&gt;matplotlib&lt;/code&gt;, and &lt;code&gt;seaborn&lt;/code&gt; – Analyze and visualize the results.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Creating the Training Inputs
&lt;/h2&gt;

&lt;p&gt;Now let's create the word embeddings for the following two sentences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The Incredibles is great!&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Despicable Me is great!&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first step is to create a token for every unique word in the training data and connect those tokens to the word embedding network.&lt;/p&gt;

&lt;p&gt;Suppose we want to pass &lt;strong&gt;"The Incredibles"&lt;/strong&gt; through the network.&lt;/p&gt;

&lt;p&gt;In that case, we set its corresponding input to &lt;strong&gt;1&lt;/strong&gt; and all the other inputs to &lt;strong&gt;0&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fh8pi2jyb1lunxuzjh85n.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%2Fh8pi2jyb1lunxuzjh85n.png" alt=" " width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This representation, where one input is &lt;strong&gt;1&lt;/strong&gt; and all the others are &lt;strong&gt;0&lt;/strong&gt;, is called &lt;strong&gt;one-hot encoding&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In PyTorch, we can represent &lt;strong&gt;"The Incredibles"&lt;/strong&gt; using a four-element vector with &lt;strong&gt;1&lt;/strong&gt; in the first position and &lt;strong&gt;0&lt;/strong&gt; everywhere else.&lt;/p&gt;

&lt;p&gt;Similarly, we create one-hot vectors for the remaining words.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&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;Finally, we convert these vectors into a PyTorch tensor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;inputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&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;Now that we have created the input data, the next step is to define the labels. We will explore that in the next article.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Building LSTMs with PyTorch and Lightning AI Part 9: Completing the Simplified LSTM</title>
      <dc:creator>Rijul Rajesh</dc:creator>
      <pubDate>Thu, 02 Jul 2026 21:04:46 +0000</pubDate>
      <link>https://dev.to/rijultp/building-lstms-with-pytorch-and-lightning-ai-part-9-completing-the-simplified-lstm-24m4</link>
      <guid>https://dev.to/rijultp/building-lstms-with-pytorch-and-lightning-ai-part-9-completing-the-simplified-lstm-24m4</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/rijultp/building-lstms-with-pytorch-and-lightning-ai-part-8-setting-up-a-simpler-lstm-2ig3"&gt;previous article&lt;/a&gt;, we just saw how we can start using a more simplified version of LSTM via pytorch via nn.LSTM()&lt;/p&gt;

&lt;p&gt;In this article, we will continue building the simplified LSTM and test how it performs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing the &lt;code&gt;forward()&lt;/code&gt; Method
&lt;/h2&gt;

&lt;p&gt;Let's start by implementing the &lt;code&gt;forward()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;input_trans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;input&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="n"&gt;lstm_out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lstm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_trans&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lstm_out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;prediction&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;input_trans&lt;/code&gt;, we reshape the input so that there is one row for each data point, regardless of how many data points we have.&lt;/p&gt;

&lt;p&gt;Next, we specify that the input should have &lt;strong&gt;one column&lt;/strong&gt;, since each data point contains only a single feature.&lt;/p&gt;

&lt;p&gt;This reshaped input is then passed to the LSTM.&lt;/p&gt;

&lt;p&gt;The output is stored in &lt;code&gt;lstm_out&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lstm_out&lt;/code&gt; contains the short-term memory values produced by each LSTM unit as the sequence is processed.&lt;/p&gt;

&lt;p&gt;In our example, the sequence contains four input values, so the LSTM is unrolled four times and &lt;code&gt;lstm_out&lt;/code&gt; contains four outputs.&lt;/p&gt;

&lt;p&gt;Next, we extract the prediction from the final LSTM unit by selecting the last element in the sequence using the index &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, we return this prediction.&lt;/p&gt;




&lt;h2&gt;
  
  
  Configuring the Optimizer
&lt;/h2&gt;

&lt;p&gt;Next, let's implement &lt;code&gt;configure_optimizers()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It is almost identical to the previous implementation, except that we increase the learning rate from its default value of &lt;strong&gt;0.001&lt;/strong&gt; to &lt;strong&gt;0.1&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This allows us to observe how the Adam optimizer converges to the optimal weights and biases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;configure_optimizers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Adam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;lr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Implementing &lt;code&gt;training_step()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Finally, we implement &lt;code&gt;training_step()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This method is exactly the same as before. It calculates the loss and logs the training progress.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;training_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch_idx&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;input_i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label_i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;
    &lt;span class="n"&gt;output_i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_i&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;output_i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;label_i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;train_loss&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;label_i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;out_0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;output_i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;out_1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;output_i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;loss&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, our model contains everything it needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__init__()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;forward()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;configure_optimizers()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;training_step()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Testing the Model
&lt;/h2&gt;

&lt;p&gt;Let's run the model before training and check its predictions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LightningLSTM&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Comparing observed and predicted values&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Company A: Observed = 0, Predicted =&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;])).&lt;/span&gt;&lt;span class="nf"&gt;detach&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Company B: Observed = 1, Predicted =&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.&lt;/span&gt;&lt;span class="p"&gt;])).&lt;/span&gt;&lt;span class="nf"&gt;detach&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;This produces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Comparing observed and predicted values

Company A: Observed = 0, Predicted = tensor([0.0131])
Company B: Observed = 1, Predicted = tensor([0.0102])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Training the Model
&lt;/h2&gt;

&lt;p&gt;Now let's create a Lightning trainer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;trainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;L&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Trainer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_epochs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;log_every_n_steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We train for &lt;strong&gt;300 epochs&lt;/strong&gt; and set &lt;code&gt;log_every_n_steps&lt;/code&gt; to &lt;strong&gt;2&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By default, Lightning logs every &lt;strong&gt;50 steps&lt;/strong&gt;, which is too infrequent for a small training run like this.&lt;/p&gt;

&lt;p&gt;Next, we simply call &lt;code&gt;fit()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;trainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;train_dataloaders&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dataloader&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Checking the Results
&lt;/h2&gt;

&lt;p&gt;Once training is complete, we check the predictions again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Comparing observed and predicted values

Company A: Observed = 0, Predicted = tensor([0.0001])
Company B: Observed = 1, Predicted = tensor([0.9857])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The prediction for &lt;strong&gt;Company A&lt;/strong&gt; is now very close to &lt;strong&gt;0&lt;/strong&gt;, and the prediction for &lt;strong&gt;Company B&lt;/strong&gt; is very close to &lt;strong&gt;1&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Analyzing the Training
&lt;/h2&gt;

&lt;p&gt;Let's open TensorBoard once again.&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%2Fnig2424htxeaglm0kih0.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%2Fnig2424htxeaglm0kih0.png" alt=" " width="800" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that the graphs have flattened out as the model converged toward the desired predictions.&lt;/p&gt;

&lt;p&gt;With that, we have completed our exploration of LSTMs.&lt;/p&gt;

&lt;p&gt;We built an LSTM from scratch, then implemented a much simpler version using PyTorch's built-in functionality. Along the way, we also learned how to analyze the training process using TensorBoard and how to use those insights to make training decisions.&lt;/p&gt;

&lt;p&gt;In the next series of articles, we will explore how to implement &lt;strong&gt;word embeddings&lt;/strong&gt; using PyTorch and Lightning AI.&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%2F2c6mz17iiajj885fmxgb.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%2F2c6mz17iiajj885fmxgb.png" alt=" " width="360" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;git-lrc&lt;/a&gt; fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.&lt;/p&gt;

&lt;p&gt;Give it a ⭐ &lt;a href="https://github.com/HexmosTech/git-lrc" rel="noopener noreferrer"&gt;star on Github&lt;/a&gt;&lt;/p&gt;

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