<?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: Taha hussein</title>
    <description>The latest articles on DEV Community by Taha hussein (@taha_hussein_bb6f837d4c81).</description>
    <link>https://dev.to/taha_hussein_bb6f837d4c81</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%2F4125970%2Fb99151e6-c010-4e6c-b4df-1ee88cd8ad20.jpg</url>
      <title>DEV Community: Taha hussein</title>
      <link>https://dev.to/taha_hussein_bb6f837d4c81</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/taha_hussein_bb6f837d4c81"/>
    <language>en</language>
    <item>
      <title>How I Built TokenSaver: An Image Optimizer for AI Tools</title>
      <dc:creator>Taha hussein</dc:creator>
      <pubDate>Wed, 07 Oct 2026 22:12:44 +0000</pubDate>
      <link>https://dev.to/taha_hussein_bb6f837d4c81/how-i-built-tokensaver-an-image-optimizer-for-ai-tools-4l1o</link>
      <guid>https://dev.to/taha_hussein_bb6f837d4c81/how-i-built-tokensaver-an-image-optimizer-for-ai-tools-4l1o</guid>
      <description>&lt;p&gt;I recently built a small Firefox extension called &lt;strong&gt;TokenSaver&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The idea started with a simple observation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI tools don't necessarily need every pixel in a huge screenshot.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But we often send them exactly that.&lt;/p&gt;

&lt;p&gt;A screenshot from a MacBook can easily be thousands of pixels wide. If I'm asking an AI model to read a small piece of code or understand an error message, most of that image may not be useful.&lt;/p&gt;

&lt;p&gt;So I built a tool to optimize the image before sending it.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/tokensaver-image-optimizer/" rel="noopener noreferrer"&gt;Try TokenSaver on Firefox&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;AI coding assistants are becoming part of my daily development workflow.&lt;/p&gt;

&lt;p&gt;I regularly send screenshots for things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI debugging&lt;/li&gt;
&lt;li&gt;Error messages&lt;/li&gt;
&lt;li&gt;Code snippets&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;Terminal output&lt;/li&gt;
&lt;li&gt;Design feedback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem is that screenshots can be much larger than necessary.&lt;/p&gt;

&lt;p&gt;A 3000×2000 screenshot and a smaller optimized version may contain essentially the same information for the task I'm asking the model to perform.&lt;/p&gt;

&lt;p&gt;But the image still has to be processed as an image input.&lt;/p&gt;

&lt;p&gt;That's where the idea for TokenSaver came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;The workflow is intentionally simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Screenshot
    ↓
TokenSaver
    ↓
Optimize dimensions
    ↓
Estimate image tokens
    ↓
AI tool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Screenshot
    ↓
AI tool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal isn't to destroy image quality.&lt;/p&gt;

&lt;p&gt;It's to remove unnecessary image data while keeping the information that matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  What TokenSaver does
&lt;/h2&gt;

&lt;p&gt;TokenSaver currently supports several ways of providing an image:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File picker&lt;/li&gt;
&lt;li&gt;Drag and drop&lt;/li&gt;
&lt;li&gt;Paste screenshots directly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It can then optimize the image based on the selected mode.&lt;/p&gt;

&lt;p&gt;The extension also displays an estimated token count before and after optimization.&lt;/p&gt;

&lt;p&gt;This gives you an idea of whether the optimization actually made a meaningful difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  Different optimization modes
&lt;/h2&gt;

&lt;p&gt;I didn't want to create a single "compress" button.&lt;/p&gt;

&lt;p&gt;Sometimes quality matters.&lt;/p&gt;

&lt;p&gt;Sometimes saving as much as possible matters more.&lt;/p&gt;

&lt;p&gt;So TokenSaver provides different optimization modes, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sharp&lt;/strong&gt; — prioritize image quality&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto&lt;/strong&gt; — balance quality and optimization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Max Saving&lt;/strong&gt; — prioritize reducing the image size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it possible to choose based on the type of screenshot.&lt;/p&gt;

&lt;p&gt;For example, I would treat a screenshot containing tiny code text differently from a simple UI screenshot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why local processing?
&lt;/h2&gt;

&lt;p&gt;This was an important design decision.&lt;/p&gt;

&lt;p&gt;A screenshot can contain sensitive information.&lt;/p&gt;

&lt;p&gt;As developers, we regularly have screenshots containing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API responses
Source code
Customer information
Internal dashboards
Terminal output
Personal data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I didn't want users to upload those images to another service just to resize them.&lt;/p&gt;

&lt;p&gt;So TokenSaver performs the image optimization locally in the browser.&lt;/p&gt;

&lt;p&gt;No TokenSaver server is required to process the image.&lt;/p&gt;

&lt;h2&gt;
  
  
  One interesting lesson
&lt;/h2&gt;

&lt;p&gt;The biggest lesson from building this wasn't image resizing.&lt;/p&gt;

&lt;p&gt;It was realizing that &lt;strong&gt;image optimization for AI is different from normal image optimization&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Traditional image compression usually focuses on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File size&lt;/li&gt;
&lt;li&gt;JPEG/WebP quality&lt;/li&gt;
&lt;li&gt;Bandwidth&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For AI inputs, another question becomes important:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How much visual information does the model actually need for this task?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's a different optimization problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm working on next
&lt;/h2&gt;

&lt;p&gt;TokenSaver is currently available for Firefox.&lt;/p&gt;

&lt;p&gt;I'm keeping the project small for now and using real user feedback to decide what should come next.&lt;/p&gt;

&lt;p&gt;Possible directions include broader browser support and additional AI-input optimizations.&lt;/p&gt;

&lt;p&gt;But I don't want to add features just because they sound interesting.&lt;/p&gt;

&lt;p&gt;I'd rather solve one problem properly first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;If you use AI tools for development and regularly paste screenshots, give it a try:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/tokensaver-image-optimizer/" rel="noopener noreferrer"&gt;Install TokenSaver – Image Optimizer&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's free, and I'd genuinely like to hear what happens with your own screenshots.&lt;/p&gt;

&lt;p&gt;Especially the difficult cases where the image contains small text or code.&lt;/p&gt;




&lt;h2&gt;
  
  
  About the developer
&lt;/h2&gt;

&lt;p&gt;I'm &lt;strong&gt;Taha Hussein&lt;/strong&gt;, an engineer working with iOS development and AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LinkedIn:&lt;/strong&gt; &lt;a href="https://www.linkedin.com/in/taha-hussein-b0a583425/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/taha-hussein-b0a583425/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;YouTube:&lt;/strong&gt; &lt;a href="https://www.youtube.com/@Tahahussein-Ai" rel="noopener noreferrer"&gt;https://www.youtube.com/@Tahahussein-Ai&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>showdev</category>
      <category>tools</category>
    </item>
    <item>
      <title>Build a Tiny Semantic Search Engine in Python</title>
      <dc:creator>Taha hussein</dc:creator>
      <pubDate>Mon, 21 Sep 2026 08:58:12 +0000</pubDate>
      <link>https://dev.to/taha_hussein_bb6f837d4c81/build-a-tiny-semantic-search-engine-in-python-4hgm</link>
      <guid>https://dev.to/taha_hussein_bb6f837d4c81/build-a-tiny-semantic-search-engine-in-python-4hgm</guid>
      <description>&lt;p&gt;What if a search engine could understand that these two sentences are related?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love programming"

"I enjoy coding"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They don't use the exact same words, but their meanings are close.&lt;/p&gt;

&lt;p&gt;That's the basic idea behind &lt;strong&gt;semantic search&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll build a tiny semantic search engine in Python using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sentence Transformers&lt;/li&gt;
&lt;li&gt;Embeddings&lt;/li&gt;
&lt;li&gt;Cosine Similarity&lt;/li&gt;
&lt;li&gt;scikit-learn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No database.&lt;br&gt;
No RAG.&lt;br&gt;
No complicated architecture.&lt;/p&gt;

&lt;p&gt;Just the core idea.&lt;/p&gt;


&lt;h2&gt;
  
  
  Step 1 — Install the Libraries
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;sentence-transformers scikit-learn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then import them:&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;from&lt;/span&gt; &lt;span class="n"&gt;sentence_transformers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SentenceTransformer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.metrics.pairwise&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cosine_similarity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2 — Load an Embedding Model
&lt;/h2&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;SentenceTransformer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all-MiniLM-L6-v2&lt;/span&gt;&lt;span class="sh"&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 model converts text into numerical embeddings.&lt;/p&gt;

&lt;p&gt;Think of the process as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love programming"
        ↓
   Embedding Model
        ↓
   [0.02, -0.14, 0.08, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sentence has now been represented by numbers.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3 — Create Some Sentences
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sentences&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I love programming&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I enjoy coding&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The weather is very hot&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate their embeddings:&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;embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sentences&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="n"&gt;embeddings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll get something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(3, 384)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3 sentences
384 numbers for each sentence
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4 — Compare the Sentences
&lt;/h2&gt;

&lt;p&gt;Now let's calculate their similarity:&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;similarity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cosine_similarity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;embeddings&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="n"&gt;similarity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
 [1.00, 0.63, 0.12],
 [0.63, 1.00, 0.22],
 [0.12, 0.22, 1.00]
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember our sentences:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 → I love programming
1 → I enjoy coding
2 → The weather is very hot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So:&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;similarity&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I love programming"
        ↕
"I enjoy coding"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and gives approximately:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;That's considerably higher than the similarity between programming and weather.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 5 — Let's Build an Actual Search
&lt;/h1&gt;

&lt;p&gt;Now we'll create a few documents:&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;documents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python is a programming language.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Machine learning is a branch of artificial intelligence.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The weather is very hot today.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Football is a popular sport.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our user will search for:&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;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I want to learn coding&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The interesting question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which document is closest to this query?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 6 — Embed the Documents
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;document_embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each document now has its own embedding.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 7 — Embed the Query
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;query_embedding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query → Embedding

Documents → Embeddings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 8 — Calculate Similarity
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cosine_similarity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_embedding&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;document_embeddings&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="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[0.70, 0.55, 0.12, 0.08]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact numbers can vary.&lt;/p&gt;

&lt;p&gt;But the interpretation is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Python                    0.70
Machine learning          0.55
Weather                   0.12
Football                  0.08
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Python document is the closest match to our query.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 9 — Rank the Search Results
&lt;/h1&gt;

&lt;p&gt;Let's make the output easier to read:&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;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&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="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; - &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0.700 - Python is a programming language.
0.550 - Machine learning is a branch of artificial intelligence.
0.120 - The weather is very hot today.
0.080 - Football is a popular sport.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations.&lt;/p&gt;

&lt;p&gt;You just built a tiny semantic search engine.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Complete Code
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentence_transformers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SentenceTransformer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.metrics.pairwise&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cosine_similarity&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SentenceTransformer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all-MiniLM-L6-v2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;documents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Python is a programming language.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Machine learning is a branch of artificial intelligence.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;The weather is very hot today.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Football is a popular sport.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I want to learn coding&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;document_embeddings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;query_embedding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cosine_similarity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;query_embedding&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;document_embeddings&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;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;document&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&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="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; - &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  What Did We Actually Build?
&lt;/h1&gt;

&lt;p&gt;The architecture is surprisingly simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              Query
                ↓
           Embedding
                ↓
       ┌────────┴────────┐
       ↓        ↓        ↓
    Document Document Document
    Embedding Embedding Embedding
       └────────┬────────┘
                ↓
       Cosine Similarity
                ↓
          Similarity Scores
                ↓
             Ranking
                ↓
        Search Results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Why Not Just Search for Keywords?
&lt;/h1&gt;

&lt;p&gt;Suppose the user searches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I want to learn coding"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the document says:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Python is a programming language."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There may be no exact match for the word &lt;code&gt;coding&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Semantic search doesn't depend only on exact words.&lt;/p&gt;

&lt;p&gt;The embedding model creates representations that allow us to compare the meaning of the texts.&lt;/p&gt;

&lt;p&gt;That's why:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;can produce relatively similar embeddings.&lt;/p&gt;




&lt;h1&gt;
  
  
  Three Concepts to Remember
&lt;/h1&gt;

&lt;p&gt;If you're learning NLP or modern AI systems, keep these three concepts separate.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Embedding
&lt;/h3&gt;

&lt;p&gt;Turns text into numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text → Numbers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Cosine Similarity
&lt;/h3&gt;

&lt;p&gt;Compares two embeddings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Embedding A
     +
Embedding B
     ↓
Similarity Score
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Semantic Search
&lt;/h3&gt;

&lt;p&gt;Uses those similarities to find relevant information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Query
 ↓
Embedding
 ↓
Compare
 ↓
Rank
 ↓
Results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Where Do We Go From Here?
&lt;/h1&gt;

&lt;p&gt;This example is intentionally small.&lt;/p&gt;

&lt;p&gt;Real applications may contain thousands or millions of documents, so calculating similarity against every document isn't always efficient.&lt;/p&gt;

&lt;p&gt;That's where techniques such as &lt;strong&gt;vector databases&lt;/strong&gt; and &lt;strong&gt;approximate nearest-neighbor search&lt;/strong&gt; become useful.&lt;/p&gt;

&lt;p&gt;And when retrieved documents are passed to a language model to help answer a user's question, we enter the world of &lt;strong&gt;Retrieval-Augmented Generation (RAG)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But before moving there, make sure this basic pipeline is clear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text
 ↓
Embedding
 ↓
Similarity
 ↓
Search
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this clicks, the more advanced systems become much easier to understand.&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/taha-hussein-b0a583425/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/taha-hussein-b0a583425/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;YouTube: &lt;a href="https://www.youtube.com/@Tahahussein-Ai" rel="noopener noreferrer"&gt;https://www.youtube.com/@Tahahussein-Ai&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>nlp</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>RAG Explained: How to Build AI Systems That Can Use Your Own Knowledge</title>
      <dc:creator>Taha hussein</dc:creator>
      <pubDate>Fri, 18 Sep 2026 09:07:44 +0000</pubDate>
      <link>https://dev.to/taha_hussein_bb6f837d4c81/rag-explained-how-to-build-ai-systems-that-can-use-your-own-knowledge-2lhp</link>
      <guid>https://dev.to/taha_hussein_bb6f837d4c81/rag-explained-how-to-build-ai-systems-that-can-use-your-own-knowledge-2lhp</guid>
      <description>&lt;p&gt;Large Language Models are powerful.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your application may need information that was never included in the model's training data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Maybe you want an AI assistant that understands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your company's documentation&lt;/li&gt;
&lt;li&gt;Internal PDFs&lt;/li&gt;
&lt;li&gt;Product information&lt;/li&gt;
&lt;li&gt;Customer support articles&lt;/li&gt;
&lt;li&gt;Legal documents&lt;/li&gt;
&lt;li&gt;Technical documentation&lt;/li&gt;
&lt;li&gt;A private knowledge base&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Should you fine-tune the entire model?&lt;/p&gt;

&lt;p&gt;Usually, that's not the first thing I would try.&lt;/p&gt;

&lt;p&gt;A more natural architecture is:&lt;/p&gt;

&lt;h1&gt;
  
  
  Retrieval-Augmented Generation
&lt;/h1&gt;

&lt;p&gt;or simply:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAG&lt;/strong&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  1. What Is RAG?
&lt;/h1&gt;

&lt;p&gt;The basic idea is simple.&lt;/p&gt;

&lt;p&gt;Instead of asking the LLM to answer from its internal knowledge alone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
 ↓
LLM
 ↓
Answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we first retrieve relevant information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Question
      ↓
Retrieve relevant knowledge
      ↓
Context
      ↓
LLM
      ↓
Answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model receives the relevant information as part of its context.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. A Simple Example
&lt;/h1&gt;

&lt;p&gt;Imagine you have a company policy document.&lt;/p&gt;

&lt;p&gt;It contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Employees can request annual leave
after completing three months of employment.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A user asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Can I request annual leave during my first month?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A generic LLM may not know your company's actual policy.&lt;/p&gt;

&lt;p&gt;Instead, a RAG system searches your company's knowledge base.&lt;/p&gt;

&lt;p&gt;It finds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Employees can request annual leave
after completing three months of employment.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the application sends something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context:
Employees can request annual leave
after completing three months of employment.

Question:
Can I request annual leave during my first month?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to the model.&lt;/p&gt;

&lt;p&gt;Now the model has the relevant information.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. The RAG Pipeline
&lt;/h1&gt;

&lt;p&gt;A typical RAG system looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Documents
    │
    ▼
Document Loading
    │
    ▼
Chunking
    │
    ▼
Embeddings
    │
    ▼
Vector Database
    │
    │
    │
User Question
    │
    ▼
Question Embedding
    │
    ▼
Similarity Search
    │
    ▼
Relevant Chunks
    │
    ▼
LLM
    │
    ▼
Answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break this down.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. Step 1 — Collect Documents
&lt;/h1&gt;

&lt;p&gt;Your knowledge source might contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PDF
Markdown
HTML
Database records
Documentation
TXT
CSV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;company_docs/
├── policies.pdf
├── onboarding.md
├── security.md
└── benefits.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  5. Step 2 — Chunk the Documents
&lt;/h1&gt;

&lt;p&gt;You usually don't want to send an entire 200-page PDF to the model for every question.&lt;/p&gt;

&lt;p&gt;Instead, split the document into smaller pieces.&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;Document
   ↓
Chunk 1
Chunk 2
Chunk 3
Chunk 4
...
Chunk 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The chunk size matters.&lt;/p&gt;

&lt;p&gt;If chunks are too small:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Context may lose meaning.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If chunks are too large:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Retrieval may become less precise
and context becomes more expensive.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Chunking is therefore an engineering decision, not just a preprocessing step.&lt;/p&gt;




&lt;h1&gt;
  
  
  6. Step 3 — Convert Text Into Embeddings
&lt;/h1&gt;

&lt;p&gt;Now we need a way to represent semantic meaning numerically.&lt;/p&gt;

&lt;p&gt;An embedding model converts text into vectors.&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;"How do I reset my password?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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;[0.21, -0.13, 0.82, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another sentence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I forgot my account password."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;may produce a vector that is close to the first one.&lt;/p&gt;

&lt;p&gt;The important idea is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Similar meanings should produce relatively similar vector representations.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  7. Step 4 — Store the Vectors
&lt;/h1&gt;

&lt;p&gt;We can store the embeddings in a vector database or another retrieval system.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chunk                    Vector
-----------------------------------------
Password reset      →   [0.21, 0.11, ...]
Refund policy       →   [0.82, 0.42, ...]
Vacation policy     →   [0.17, 0.93, ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the user asks a question, we embed the question too.&lt;/p&gt;

&lt;p&gt;Then we search for vectors that are close to the query vector.&lt;/p&gt;




&lt;h1&gt;
  
  
  8. Step 5 — Retrieve Relevant Information
&lt;/h1&gt;

&lt;p&gt;Suppose the user asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How can I reset my password?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The retriever might return:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Password Reset Guide
2. Account Security Policy
3. Login Troubleshooting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those documents become context for the LLM.&lt;/p&gt;




&lt;h1&gt;
  
  
  9. Step 6 — Generate the Answer
&lt;/h1&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Question
+
Retrieved Context
        ↓
      LLM
        ↓
     Answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model can now generate an answer grounded in the retrieved information.&lt;/p&gt;

&lt;p&gt;A good production system may also instruct the model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Answer only using the provided context.

If the answer is not contained in the context,
say that the information was not found.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can help reduce unsupported answers, although RAG does not automatically eliminate hallucinations.&lt;/p&gt;




&lt;h1&gt;
  
  
  10. RAG Does Not "Teach" the Model
&lt;/h1&gt;

&lt;p&gt;This is one of the most important concepts.&lt;/p&gt;

&lt;p&gt;When you add a PDF to a RAG system, you are generally &lt;strong&gt;not changing the model's weights&lt;/strong&gt;.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Model
  +
Retrieved Context
  =
Context-aware response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compare that with fine-tuning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dataset
   ↓
Training
   ↓
Updated Parameters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This distinction is fundamental.&lt;/p&gt;




&lt;h1&gt;
  
  
  11. RAG vs Fine-Tuning
&lt;/h1&gt;

&lt;p&gt;A simple comparison:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Common approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Give the model private documents&lt;/td&gt;
&lt;td&gt;RAG&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Information changes frequently&lt;/td&gt;
&lt;td&gt;RAG&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Company documentation&lt;/td&gt;
&lt;td&gt;RAG&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Improve a specific output format&lt;/td&gt;
&lt;td&gt;Fine-tuning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Teach a specialized behavior&lt;/td&gt;
&lt;td&gt;Fine-tuning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Need both knowledge + behavior&lt;/td&gt;
&lt;td&gt;RAG + Fine-tuning&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These aren't strict rules.&lt;/p&gt;

&lt;p&gt;The correct architecture depends on the application, data, latency, cost, and evaluation results.&lt;/p&gt;




&lt;h1&gt;
  
  
  12. The Real Difficulty: Retrieval
&lt;/h1&gt;

&lt;p&gt;A beginner might think:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAG = Vector Database + LLM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But production RAG is more complicated.&lt;/p&gt;

&lt;p&gt;What if the retriever returns the wrong documents?&lt;/p&gt;

&lt;p&gt;Then even a powerful LLM receives bad context.&lt;/p&gt;

&lt;p&gt;You get:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bad retrieval
     ↓
Bad context
     ↓
Bad answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So improving RAG often means improving retrieval.&lt;/p&gt;




&lt;h1&gt;
  
  
  13. Retrieval Quality Matters
&lt;/h1&gt;

&lt;p&gt;Suppose the knowledge base contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Refund Policy
Password Policy
Shipping Policy
Account Deletion Policy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;How long does a refund take?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A good retriever should prioritize:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Refund Policy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it retrieves:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Password Policy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the LLM cannot magically recover the missing information.&lt;/p&gt;

&lt;p&gt;This is why RAG systems need evaluation.&lt;/p&gt;




&lt;h1&gt;
  
  
  14. Beyond Basic Vector Search
&lt;/h1&gt;

&lt;p&gt;A more advanced architecture might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Question
      ↓
Query Processing
      ↓
Hybrid Retrieval
      ↓
Vector Search
      +
Keyword Search
      ↓
Reranking
      ↓
Top Documents
      ↓
LLM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Depending on the application, you may use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Metadata filtering&lt;/li&gt;
&lt;li&gt;Hybrid search&lt;/li&gt;
&lt;li&gt;Rerankers&lt;/li&gt;
&lt;li&gt;Query rewriting&lt;/li&gt;
&lt;li&gt;Multiple retrieval strategies&lt;/li&gt;
&lt;li&gt;Citation generation&lt;/li&gt;
&lt;li&gt;Retrieval evaluation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more serious the application, the more important these components become.&lt;/p&gt;




&lt;h1&gt;
  
  
  15. RAG Is an AI Engineering Problem
&lt;/h1&gt;

&lt;p&gt;This is why I think RAG is such an important project for anyone learning AI engineering.&lt;/p&gt;

&lt;p&gt;It combines multiple areas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Python
   +
NLP
   +
Embeddings
   +
Vector Search
   +
LLMs
   +
Prompt Engineering
   +
Backend Engineering
   +
Evaluation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You are no longer simply calling an AI API.&lt;/p&gt;

&lt;p&gt;You are designing a system around a model.&lt;/p&gt;




&lt;h1&gt;
  
  
  16. A Project I Would Build
&lt;/h1&gt;

&lt;p&gt;If I were learning RAG from scratch, I would build:&lt;/p&gt;

&lt;h2&gt;
  
  
  "Personal AI Knowledge Assistant"
&lt;/h2&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PDFs
Markdown
Notes
Documentation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              Documents
                  │
                  ▼
               Chunker
                  │
                  ▼
             Embedding Model
                  │
                  ▼
            Vector Database
                  │
                  │
User ───────► Retriever
                  │
                  ▼
             Relevant Context
                  │
                  ▼
                 LLM
                  │
                  ▼
               Answer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Sources
Conversation history
Metadata filtering
Evaluation
Streaming
Authentication
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have a real AI engineering portfolio project.&lt;/p&gt;




&lt;h1&gt;
  
  
  17. What I Would Learn After RAG
&lt;/h1&gt;

&lt;p&gt;Once you understand the architecture, continue with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAG
 ↓
Advanced Retrieval
 ↓
Tool Calling
 ↓
Structured Outputs
 ↓
Agents
 ↓
Agent Workflows
 ↓
Evaluation
 ↓
LLMOps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At that point, you're moving from:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"I can call an LLM API"
&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;"I can design AI-powered systems."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That distinction is extremely important.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;RAG is not a magic solution.&lt;/p&gt;

&lt;p&gt;It is an architecture that gives an LLM access to relevant external information at inference time.&lt;/p&gt;

&lt;p&gt;The core idea is simple:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Retrieve
   ↓
Augment
   ↓
Generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But building a reliable RAG application requires much more than connecting a vector database to an LLM.&lt;/p&gt;

&lt;p&gt;You need to think about:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Data quality
Chunking
Embeddings
Retrieval
Ranking
Context
Prompting
Evaluation
Latency
Cost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's exactly what makes RAG such a valuable project for an aspiring AI Engineer.&lt;/p&gt;




&lt;h2&gt;
  
  
  Connect With Me
&lt;/h2&gt;

&lt;p&gt;YouTube: &lt;a href="https://www.youtube.com/@Tahahussein-Ai" rel="noopener noreferrer"&gt;https://www.youtube.com/@Tahahussein-Ai&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/taha-hussein-b0a583425/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/taha-hussein-b0a583425/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I share practical content about &lt;strong&gt;Python, Machine Learning, Deep Learning, LLMs, RAG, and AI Engineering&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>rag</category>
    </item>
    <item>
      <title>I Built a Mini-GPT From Scratch to Actually Understand Transformers (Not Just Copy Code)</title>
      <dc:creator>Taha hussein</dc:creator>
      <pubDate>Tue, 15 Sep 2026 09:29:25 +0000</pubDate>
      <link>https://dev.to/taha_hussein_bb6f837d4c81/i-built-a-mini-gpt-from-scratch-to-actually-understand-transformers-not-just-copy-code-47ni</link>
      <guid>https://dev.to/taha_hussein_bb6f837d4c81/i-built-a-mini-gpt-from-scratch-to-actually-understand-transformers-not-just-copy-code-47ni</guid>
      <description>&lt;p&gt;**# Full Post Content (Markdown, ready to paste into DEV.to editor)&lt;/p&gt;

&lt;p&gt;A few weeks ago, I asked an AI assistant to build me a poetry-generation model using a Transformer architecture. It worked. The output was decent. But when I read through the code, I could only really explain about 80% of it.&lt;/p&gt;

&lt;p&gt;That bothered me more than it should have.&lt;/p&gt;

&lt;p&gt;So I went back to the fundamentals: Attention, Query/Key/Value, Multi-Head Attention, positional encoding — and rebuilt everything from scratch, line by line, without copying from the original code. No shortcuts this time.&lt;/p&gt;

&lt;p&gt;The result is a small, fully working GPT-style model, and a step-by-step video series (in Arabic, with English code) documenting the entire build.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the series actually covers
&lt;/h2&gt;

&lt;p&gt;Instead of jumping straight to a wall of code, I broke the build into small, focused pieces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings&lt;/strong&gt;: turning word IDs into vectors, and why we need a separate positional embedding on top of the token embedding&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-Attention&lt;/strong&gt;: building &lt;code&gt;Head&lt;/code&gt; from scratch — the Q/K/V projections, the scaled dot-product, causal masking, softmax, and the final weighted sum&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Head Attention&lt;/strong&gt;: running several attention heads in parallel and merging them with a projection layer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feed-Forward + Residual Connections&lt;/strong&gt;: why attention alone isn't enough, and why skip connections matter for training stability&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The full &lt;code&gt;MiniGPT&lt;/code&gt; class&lt;/strong&gt;: stacking everything into blocks, adding the final LayerNorm and &lt;code&gt;lm_head&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Training loop&lt;/strong&gt;: computing cross-entropy loss, running backprop, and actually watching the loss go down on a tiny toy dataset&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's a snippet from the core attention head, one of the most important 15 lines in the whole project:&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;Head&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Module&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="n"&gt;head_size&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&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="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Linear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_embd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bias&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&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;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Linear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_embd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bias&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&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;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Linear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n_embd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bias&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&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;register_buffer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tril&lt;/span&gt;&lt;span class="sh"&gt;"&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;tril&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;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;block_size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;block_size&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;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="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;C&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;
        &lt;span class="n"&gt;k&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;key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;q&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;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;v&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;value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;wei&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transpose&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="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="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="o"&gt;**-&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;
        &lt;span class="n"&gt;wei&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wei&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;masked_fill&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;tril&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;]&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="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-inf&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;wei&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;F&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;softmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wei&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dim&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;wei&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing fancy — no external attention libraries, no shortcuts. Just &lt;code&gt;nn.Linear&lt;/code&gt;, matrix multiplication, and a triangular mask to prevent the model from "cheating" by looking at future tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why rebuild something that already works?
&lt;/h2&gt;

&lt;p&gt;Because there's a real difference between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"I can read this code and follow the logic"&lt;/li&gt;
&lt;li&gt;"I can write this from an empty file and explain every decision"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first gets you through a tutorial. The second is what actually sticks when you're debugging a production model six months later, or when someone in an interview asks you to explain why attention scores are scaled by &lt;code&gt;1/sqrt(head_size)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The video series
&lt;/h2&gt;

&lt;p&gt;The full series (18 short episodes, 3–7 minutes each) walks through this build in Arabic, but all the code, variable names, and comments are in English — so it should be followable even if you don't speak Arabic.&lt;/p&gt;

&lt;p&gt;📺 &lt;a href="https://www.youtube.com/@Tahahussein-Ai" rel="noopener noreferrer"&gt;https://www.youtube.com/@Tahahussein-Ai&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;Now that the Transformer fundamentals are solid, I'm moving on to tokenization (BPE) and then into fine-tuning real pretrained models (LoRA/QLoRA) — building on this same "understand it deeply, then apply it" approach.&lt;/p&gt;

&lt;p&gt;If you've ever felt like you understand a model "well enough" but couldn't quite rebuild it yourself, I'd genuinely recommend trying this exercise. It's humbling, but it's the fastest way I've found to close that gap.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Suggested tags:&lt;/strong&gt; &lt;code&gt;#machinelearning&lt;/code&gt; &lt;code&gt;#python&lt;/code&gt; &lt;code&gt;#ai&lt;/code&gt; &lt;code&gt;#tutorial&lt;/code&gt; &lt;code&gt;#showdev&lt;/code&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>datascience</category>
    </item>
    <item>
      <title>PyTorch Tutorial for Beginners: Learn Deep Learning with Python</title>
      <dc:creator>Taha hussein</dc:creator>
      <pubDate>Tue, 15 Sep 2026 09:22:38 +0000</pubDate>
      <link>https://dev.to/taha_hussein_bb6f837d4c81/pytorch-tutorial-for-beginners-learn-deep-learning-with-python-9mc</link>
      <guid>https://dev.to/taha_hussein_bb6f837d4c81/pytorch-tutorial-for-beginners-learn-deep-learning-with-python-9mc</guid>
      <description>&lt;h1&gt;
  
  
  PyTorch for Beginners: What You Actually Need to Understand
&lt;/h1&gt;

&lt;p&gt;If you're learning Deep Learning, you'll probably encounter PyTorch very early.&lt;/p&gt;

&lt;p&gt;But there's a common mistake:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;People learn PyTorch syntax without understanding what PyTorch is actually doing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's fix that.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is PyTorch?
&lt;/h2&gt;

&lt;p&gt;PyTorch is a machine learning framework used to create and train neural networks.&lt;/p&gt;

&lt;p&gt;It provides several important components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tensors&lt;/li&gt;
&lt;li&gt;Automatic differentiation&lt;/li&gt;
&lt;li&gt;Neural network modules&lt;/li&gt;
&lt;li&gt;Optimizers&lt;/li&gt;
&lt;li&gt;GPU acceleration&lt;/li&gt;
&lt;li&gt;Data loading utilities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important thing is understanding how these components work together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start With Tensors
&lt;/h2&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="n"&gt;x&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&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="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tensors are the basic data structure used throughout PyTorch.&lt;/p&gt;

&lt;p&gt;Neural networks perform mathematical operations on tensors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Then Understand Gradients
&lt;/h2&gt;

&lt;p&gt;Training a neural network requires gradients.&lt;/p&gt;

&lt;p&gt;PyTorch can calculate them automatically:&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;x&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="mf"&gt;2.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requires_grad&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&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;y&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;backward&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="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;grad&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;because the derivative of &lt;code&gt;x²&lt;/code&gt; is &lt;code&gt;2x&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Then Build a Model
&lt;/h2&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.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="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Sequential&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Linear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ReLU&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Linear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;32&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="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a simple neural network.&lt;/p&gt;

&lt;p&gt;But creating the model is only one part of Deep Learning.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Most Important Part: Training
&lt;/h2&gt;

&lt;p&gt;A typical training step looks like:&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;optimizer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zero_grad&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="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&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="nf"&gt;criterion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prediction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&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="nf"&gt;backward&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;step&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you understand these five lines, you're already understanding one of the fundamental patterns of Deep Learning.&lt;/p&gt;

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

&lt;p&gt;Because the same general idea appears in much more advanced models.&lt;/p&gt;

&lt;p&gt;The architecture changes.&lt;/p&gt;

&lt;p&gt;The data changes.&lt;/p&gt;

&lt;p&gt;The loss function changes.&lt;/p&gt;

&lt;p&gt;But the fundamental training process remains surprisingly similar.&lt;/p&gt;

&lt;p&gt;This is why I recommend learning PyTorch from the fundamentals instead of jumping directly into huge pre-trained models.&lt;/p&gt;

&lt;h2&gt;
  
  
  From PyTorch to Transformers
&lt;/h2&gt;

&lt;p&gt;Once you're comfortable with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tensors&lt;/li&gt;
&lt;li&gt;Gradients&lt;/li&gt;
&lt;li&gt;Neural Networks&lt;/li&gt;
&lt;li&gt;Loss functions&lt;/li&gt;
&lt;li&gt;Optimizers&lt;/li&gt;
&lt;li&gt;Training loops&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you can start learning:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attention → Self-Attention → Multi-Head Attention → Transformers → LLMs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's where PyTorch becomes particularly powerful.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Your Experience With PyTorch?
&lt;/h2&gt;

&lt;p&gt;Are you learning PyTorch for:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A)&lt;/strong&gt; Computer Vision&lt;br&gt;
&lt;strong&gt;B)&lt;/strong&gt; NLP&lt;br&gt;
&lt;strong&gt;C)&lt;/strong&gt; Transformers / LLMs&lt;br&gt;
&lt;strong&gt;D)&lt;/strong&gt; General Deep Learning&lt;br&gt;
&lt;strong&gt;E)&lt;/strong&gt; Research&lt;/p&gt;

&lt;p&gt;I'd love to know what you're currently building.&lt;/p&gt;

&lt;p&gt;I also publish practical tutorials about &lt;strong&gt;PyTorch, Transformers, Machine Learning frameworks, and modern AI&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;YouTube:&lt;/strong&gt; &lt;a href="https://www.youtube.com/@Tahahussein-Ai" rel="noopener noreferrer"&gt;https://www.youtube.com/@Tahahussein-Ai&lt;/a&gt;&lt;/p&gt;

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

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