<?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: Ramya Perumal</title>
    <description>The latest articles on DEV Community by Ramya Perumal (@ramya_perumal_e93721ef2fa).</description>
    <link>https://dev.to/ramya_perumal_e93721ef2fa</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%2F3900955%2F3e2feb4c-f889-4df6-b8ef-5b1a1ac619ca.png</url>
      <title>DEV Community: Ramya Perumal</title>
      <link>https://dev.to/ramya_perumal_e93721ef2fa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramya_perumal_e93721ef2fa"/>
    <language>en</language>
    <item>
      <title>Docker -Networking and Best Practices</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sat, 27 Jun 2026 20:30:19 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/docker-networking-and-best-practices-17ji</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/docker-networking-and-best-practices-17ji</guid>
      <description>&lt;h1&gt;
  
  
  Docker Networking
&lt;/h1&gt;

&lt;p&gt;Containers are assigned an IP address when they are created. To check the IP address, we can use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker inspect &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we send a request from the host to the container's IP address, the container responds using its assigned IP address.&lt;/p&gt;

&lt;p&gt;By default, Docker creates a &lt;strong&gt;bridge network&lt;/strong&gt;. This bridge network allows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Communication between the host and the container (through port mapping).&lt;/li&gt;
&lt;li&gt;Communication between containers connected to the same bridge network.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the default bridge network, containers generally communicate using &lt;strong&gt;IP addresses&lt;/strong&gt;. To communicate using container names (hostnames), we can use a &lt;strong&gt;custom bridge network&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The main difference between the default bridge network and a custom bridge network is that containers on a custom bridge network can communicate using their &lt;strong&gt;container names (DNS resolution)&lt;/strong&gt;, making it suitable for production environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use a Custom Bridge Network
&lt;/h3&gt;

&lt;p&gt;A custom bridge network is useful when an application consists of multiple services running in separate containers. These containers can communicate with one another using their container names instead of IP addresses.&lt;/p&gt;




&lt;h2&gt;
  
  
  Create a Custom Bridge Network
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker network create mybridge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create and Run Containers Inside the Network
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;--network&lt;/span&gt; mybridge &lt;span class="nt"&gt;--name&lt;/span&gt; container1 busybox:1.36 sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;--network&lt;/span&gt; mybridge &lt;span class="nt"&gt;--name&lt;/span&gt; container2 busybox:1.36 sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, from &lt;strong&gt;container1&lt;/strong&gt;, run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Similarly, from &lt;strong&gt;container2&lt;/strong&gt;, run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If the ping is successful, it confirms that both containers can communicate because they are connected to the same custom bridge network.&lt;/p&gt;




&lt;h1&gt;
  
  
  Example Workflow for a Docker Bridge Network
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Step 1: Build the Images
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-f&lt;/span&gt; Dockerfile &lt;span class="nt"&gt;-t&lt;/span&gt; flask_app:v1 &lt;span class="nb"&gt;.&lt;/span&gt;
docker build &lt;span class="nt"&gt;-f&lt;/span&gt; httpd.Dockerfile &lt;span class="nt"&gt;-t&lt;/span&gt; apache_container:v1 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create the Network
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker network create bridge_app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Run the Containers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; flask_new &lt;span class="nt"&gt;--network&lt;/span&gt; bridge_app flask_app:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; apache_new &lt;span class="nt"&gt;--network&lt;/span&gt; bridge_app apache_container:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Verify the Network
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker network inspect bridge_app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Test Communication
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ping apache_new
ping flask_new
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use &lt;code&gt;curl&lt;/code&gt; with the application's port to access another container's application.&lt;/p&gt;




&lt;h1&gt;
  
  
  Host Network
&lt;/h1&gt;

&lt;p&gt;Suppose we run an application inside a Docker container.&lt;/p&gt;

&lt;p&gt;If we do &lt;strong&gt;not&lt;/strong&gt; expose the application port using &lt;code&gt;-p&lt;/code&gt;, the application cannot be accessed through the host machine. It can only be accessed using the container's IP address (if reachable).&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run flask_app:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we expose the port:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 5000:5000 flask_app:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Docker maps the host port to the container port, allowing the application to be accessed using the host machine's IP address.&lt;/p&gt;

&lt;h3&gt;
  
  
  Host Network Mode
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--network&lt;/span&gt; host flask_app:v1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;strong&gt;host network mode&lt;/strong&gt;, the container shares the host's network stack. Therefore, the application can use the host's network directly without explicit port mapping.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Host networking is supported on Linux. On Docker Desktop for Windows and macOS, host networking is limited and generally not recommended. Port mapping (&lt;code&gt;-p&lt;/code&gt;) is the standard approach.&lt;/p&gt;




&lt;h1&gt;
  
  
  Docker Image Optimization
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Why Is Image Optimization Needed?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Smaller images start containers faster.&lt;/li&gt;
&lt;li&gt;Smaller images are easier to share.&lt;/li&gt;
&lt;li&gt;Smaller images consume less storage.&lt;/li&gt;
&lt;li&gt;Smaller images download faster.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1. Multi-Stage Builds
&lt;/h2&gt;

&lt;p&gt;In a multi-stage build, the first stage builds the application, and the second stage copies only the required artifacts into the final image.&lt;/p&gt;

&lt;p&gt;A single-stage build includes both build tools and runtime dependencies, making the image larger.&lt;/p&gt;

&lt;p&gt;A multi-stage build keeps only the files required to run the application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Single-Stage Build
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.9-slim&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /app&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["python", "main.py"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Multi-Stage Build
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;python:3.9-slim&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;builder&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; main.py .&lt;/span&gt;

&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;python:3.9-slim&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;runner&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; --from=builder /app/main.py .&lt;/span&gt;

&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["python", "main.py"]&lt;/span&gt;
&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;Builder stage&lt;/strong&gt; prepares the application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runner stage&lt;/strong&gt; copies only the required files, resulting in a smaller final image.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Choose a Minimal Base Image
&lt;/h2&gt;

&lt;p&gt;Using a lightweight base image reduces the final image size.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.9-slim&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This image contains only the essential Python packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.9-alpine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This image is even smaller and includes only minimal functionality. Additional packages must be installed separately.&lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;not recommended&lt;/strong&gt; to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;because Docker will pull the latest version, which may introduce compatibility issues. Always specify a version tag.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Layer Caching
&lt;/h2&gt;

&lt;p&gt;Docker caches image layers.&lt;/p&gt;

&lt;p&gt;If no changes occur in a layer or any previous layer, Docker reuses the cached layer, making builds much faster.&lt;/p&gt;

&lt;p&gt;The order of Dockerfile instructions is important.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;COPY . /app&lt;/code&gt; is placed near the beginning of the Dockerfile, any source code change invalidates all subsequent layers.&lt;/p&gt;

&lt;p&gt;Instead, place frequently changing instructions lower in the Dockerfile whenever possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Less Efficient
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.9-slim&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /app&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["python", "main.py"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Better
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:3.9-slim&lt;/span&gt;

&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;

&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . /app&lt;/span&gt;

&lt;span class="k"&gt;CMD&lt;/span&gt;&lt;span class="s"&gt; ["python", "main.py"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents Docker from rebuilding the &lt;code&gt;WORKDIR&lt;/code&gt; layer unnecessarily.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Run Containers as a Non-Root User
&lt;/h2&gt;

&lt;p&gt;By default, containers run as the &lt;strong&gt;root user&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A root user can create or modify files anywhere inside the container.&lt;/p&gt;

&lt;p&gt;If the container is compromised, an attacker may gain elevated privileges.&lt;/p&gt;

&lt;p&gt;Running the container as a non-root user improves security because that user has limited permissions.&lt;/p&gt;

&lt;p&gt;Example (Windows Containers):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;icacls C:&lt;span class="se"&gt;\a&lt;/span&gt;pp /grant ContainerUser:&lt;span class="o"&gt;(&lt;/span&gt;OI&lt;span class="o"&gt;)(&lt;/span&gt;CI&lt;span class="o"&gt;)&lt;/span&gt;F

&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; ContainerUser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example (Linux Containers):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;RUN &lt;/span&gt;useradd &lt;span class="nt"&gt;-m&lt;/span&gt; appuser

&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; appuser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running applications as a non-root user is considered a Docker best practice.&lt;/p&gt;




&lt;h1&gt;
  
  
  Interview Questions
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Question 1
&lt;/h3&gt;

&lt;p&gt;Which Docker network allows containers to communicate with each other without requiring port mapping on the host?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; Bridge network.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 2
&lt;/h3&gt;

&lt;p&gt;Which statement is true about Docker layer caching?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker caches layers unless a previous layer has changed.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 3
&lt;/h3&gt;

&lt;p&gt;Why is it considered best practice to run containers as a non-root user?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It helps prevent attackers from gaining root privileges if the container is compromised.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 4
&lt;/h3&gt;

&lt;p&gt;What is the purpose of using a multi-stage build in Docker?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To reduce the size of the final Docker image.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 5
&lt;/h3&gt;

&lt;p&gt;How do you specify a non-root user in Docker?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;USER&lt;/code&gt; directive in the Dockerfile or the &lt;code&gt;--user&lt;/code&gt; option when running the container.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 6
&lt;/h3&gt;

&lt;p&gt;Which of the following can invalidate the Docker build cache for a layer?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changing the base image version.&lt;/li&gt;
&lt;li&gt;Modifying files copied into that layer.&lt;/li&gt;
&lt;li&gt;Adding or changing an environment variable (&lt;code&gt;ENV&lt;/code&gt;) or build argument (&lt;code&gt;ARG&lt;/code&gt;) used by that layer.&lt;/li&gt;
&lt;li&gt;Changing the Dockerfile instruction itself.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>basic</category>
      <category>virtualmachine</category>
    </item>
    <item>
      <title>Docker – ARG Directive, .dockerignore, and Docker Volumes</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sat, 27 Jun 2026 20:30:07 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/docker-arg-directive-dockerignore-and-docker-volumes-29kh</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/docker-arg-directive-dockerignore-and-docker-volumes-29kh</guid>
      <description>&lt;h2&gt;
  
  
  ARG Directive
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;ARG&lt;/code&gt; directive acts like a variable. We can define it inside the Dockerfile and change its value during the image build process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; PYTHON_VERSION=3.8&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; python:${PYTHON_VERSION}-slim&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, the Python version in the Dockerfile is set to &lt;code&gt;3.8&lt;/code&gt;. However, during the build process, we can change it to &lt;code&gt;3.10&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-f&lt;/span&gt; Dockerfile &lt;span class="nt"&gt;--build-arg&lt;/span&gt; &lt;span class="nv"&gt;PYTHON_VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3.10 &lt;span class="nt"&gt;-t&lt;/span&gt; helloworld_flask:v1 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt; means &lt;strong&gt;tag&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-f&lt;/code&gt; means &lt;strong&gt;Dockerfile path&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can use &lt;code&gt;ARG&lt;/code&gt; to make base image versions and other build-time values configurable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; node:20-alpine&lt;/span&gt;

&lt;span class="c"&gt;# 1. Define the arguments&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; APP_DIR=app&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; INSTALL_ARGS="--omit=dev"&lt;/span&gt;

&lt;span class="c"&gt;# 2. Use them in instructions&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /${APP_DIR}&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; . .&lt;/span&gt;
&lt;span class="k"&gt;RUN &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;INSTALL_ARGS&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;code&gt;ARG&lt;/code&gt; values can only be changed during the image build process. They cannot be changed during container creation.&lt;/p&gt;




&lt;h1&gt;
  
  
  Docker Ignore
&lt;/h1&gt;

&lt;p&gt;A &lt;code&gt;.dockerignore&lt;/code&gt; file is used to specify files and directories that should not be copied into the Docker build context.&lt;/p&gt;

&lt;p&gt;Create a file named &lt;code&gt;.dockerignore&lt;/code&gt; in the application's root directory.&lt;/p&gt;

&lt;p&gt;Examples of files and folders that can be ignored:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dockerfile
.venv
__pycache__
*.pyc
requirements.txt
.git
.gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ignoring unnecessary files reduces the build context size and speeds up image builds.&lt;/p&gt;




&lt;h1&gt;
  
  
  Docker Volumes
&lt;/h1&gt;

&lt;p&gt;Generally, when a container is created, a writable layer is also created.&lt;/p&gt;

&lt;p&gt;If we create files inside the container, they are stored in the writable layer. However, when the container is deleted, all data in the writable layer is lost.&lt;/p&gt;

&lt;p&gt;What if we need to store files permanently on the host machine?&lt;/p&gt;

&lt;p&gt;This is where Docker volumes come into the picture.&lt;/p&gt;

&lt;p&gt;Docker volumes allow data to persist independently of the container lifecycle.&lt;/p&gt;

&lt;p&gt;When a volume is mounted between a host directory and a container directory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Files created in the container appear on the host machine.&lt;/li&gt;
&lt;li&gt;Files created on the host machine appear inside the container.&lt;/li&gt;
&lt;li&gt;Changes are synchronized between both locations.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Types of Docker Volumes
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Bind-Mounted Volumes&lt;/li&gt;
&lt;li&gt;Docker Managed Volumes (Named Volumes)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Bind-Mounted Volumes
&lt;/h2&gt;

&lt;p&gt;A bind mount creates a mapping between a host directory and a container directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; ./data:/data busybox:1.36 sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;./data&lt;/code&gt; = Host machine directory&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/data&lt;/code&gt; = Container directory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tightly coupled with the host file system.&lt;/li&gt;
&lt;li&gt;Multiple containers can share the same host directory.&lt;/li&gt;
&lt;li&gt;Changes made in either location are reflected in the other.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The host directory is not deleted when the container is removed.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Docker Managed Volumes (Named Volumes)
&lt;/h2&gt;

&lt;p&gt;Create a Docker-managed volume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker volume create dockersession
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a volume outside the container lifecycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  List Volumes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker volume &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Inspect a Volume
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker volume inspect dockersession
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays information about the volume, including its mount location.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/lib/docker/volumes/dockersession/_data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Mount the Volume to a Container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; dockersession:/data123 busybox:1.36 sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dockersession&lt;/code&gt; = Volume name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/data123&lt;/code&gt; = Container directory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Multiple containers can use the same volume for data sharing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Find Containers Using a Specific Volume
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;--filter&lt;/span&gt; &lt;span class="nv"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;dockersession
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of the major benefits of Docker volumes is that they are completely decoupled from the container lifecycle.&lt;/p&gt;

&lt;p&gt;When a container is deleted, the volume and all its data remain safely stored on the host machine.&lt;/p&gt;




&lt;h1&gt;
  
  
  Interview Questions
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;What is the primary use of the ARG instruction in Docker?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; To pass build-time variables to the Dockerfile.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;Which of the following is true about ARG variables in Docker?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; They are used only during the image build process.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;Can an ARG variable be used in a RUN instruction within a Dockerfile?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; Yes, but only after it has been declared.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;Which files can be ignored using &lt;code&gt;.dockerignore&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; Any file or directory within the build context.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;What is the purpose of Docker volumes?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; To store data that persists even after a container is destroyed.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;What is the default location of Docker volumes on Linux systems?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/lib/docker/volumes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;Which command allows you to list all Docker volumes?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&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;docker volume &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;In which scenario would you use a bind-mounted volume?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; When you need to share specific directories between the host machine and a container.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>basic</category>
      <category>virtualmachine</category>
      <category>wind</category>
    </item>
    <item>
      <title>Docker – Port Mapping, Logs, Container Management, and Image Removal</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sat, 27 Jun 2026 20:29:51 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/docker-port-mapping-logs-container-management-and-image-removal-20oo</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/docker-port-mapping-logs-container-management-and-image-removal-20oo</guid>
      <description>&lt;h1&gt;
  
  
  Docker – Logs, Remove, and Port Mapping
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Port Mapping
&lt;/h2&gt;

&lt;p&gt;When we run an application inside a container, we define the port on which the application will run. The container runs the application on that port.&lt;/p&gt;

&lt;p&gt;It is not possible to access an application running inside Docker from outside the container unless port mapping is configured.&lt;/p&gt;

&lt;p&gt;Port mapping is specified using the &lt;code&gt;-p&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&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;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; &amp;lt;host_port&amp;gt;:&amp;lt;container_port&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example:&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;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 8888:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;8888&lt;/code&gt; is the host (machine) port used to access the application from outside the container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;8080&lt;/code&gt; is the port defined in the application and exposed inside the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the host port is already in use, Docker displays an error message.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Check Which Ports Are Being Used by Docker Containers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps &lt;span class="nt"&gt;--format&lt;/span&gt; &lt;span class="s2"&gt;"table {{.ID}}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;{{.Names}}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;{{.Ports}}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Detached Mode
&lt;/h2&gt;

&lt;p&gt;To run a container in detached mode, use the &lt;code&gt;-d&lt;/code&gt; option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 2000:2001
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Detached mode means the container runs in the background.&lt;/p&gt;




&lt;h1&gt;
  
  
  Docker Logs
&lt;/h1&gt;

&lt;p&gt;Logs contain information about the activities happening inside a container.&lt;/p&gt;

&lt;h3&gt;
  
  
  View Logs of a Specific Container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker logs &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Follow Logs Continuously
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker logs &lt;span class="nt"&gt;-f&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-f&lt;/code&gt; stands for &lt;strong&gt;follow&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  View Logs from a Specific Time Range
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Seconds &lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;: docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 30s &amp;lt;container_id&amp;gt;
Minutes &lt;span class="o"&gt;(&lt;/span&gt;m&lt;span class="o"&gt;)&lt;/span&gt;: docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 5m &amp;lt;container_id&amp;gt;
Hours &lt;span class="o"&gt;(&lt;/span&gt;h&lt;span class="o"&gt;)&lt;/span&gt;: docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 2h &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Docker supports seconds (&lt;code&gt;s&lt;/code&gt;), minutes (&lt;code&gt;m&lt;/code&gt;), and hours (&lt;code&gt;h&lt;/code&gt;) for relative time.&lt;/p&gt;

&lt;p&gt;For days, weeks, months, or years, use an ISO 8601 date or timestamp.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Weeks:  docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 2026-06-14 &amp;lt;container_id&amp;gt;
Months: docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 2026-05-21 &amp;lt;container_id&amp;gt;
Years:  docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 2025-06-21 &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Combined Time Units
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; 1h30m &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Displays logs from 1 hour and 30 minutes ago.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exact Time
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker logs &lt;span class="nt"&gt;--since&lt;/span&gt; &lt;span class="s2"&gt;"2026-06-21T17:30:00"&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Displays logs generated since the specified date and time.&lt;/p&gt;




&lt;h1&gt;
  
  
  Docker Inspect
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;docker inspect&lt;/code&gt; is used to view detailed information about a container, image, network, or volume.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker inspect &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Access a Running or Exited Container
&lt;/h1&gt;

&lt;p&gt;To open a shell inside a running container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &amp;lt;container_id&amp;gt; sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-i&lt;/code&gt; = Interactive mode&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-t&lt;/code&gt; = Allocate a terminal&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Docker Remove
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Delete an Exited Container
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Delete a Running Container
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-f&lt;/code&gt; forcefully stops and removes the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  Alternative Method
&lt;/h3&gt;

&lt;p&gt;First stop the container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker stop &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then remove it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Delete Multiple Containers
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &amp;lt;container_id1&amp;gt; &amp;lt;container_id2&amp;gt; &amp;lt;container_id3&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Alternative Method (Windows)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;FOR&lt;/span&gt; &lt;span class="na"&gt;/F &lt;/span&gt;&lt;span class="s2"&gt;"tokens=*"&lt;/span&gt; &lt;span class="vm"&gt;%i&lt;/span&gt; &lt;span class="kd"&gt;IN&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'docker ps -aq'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;DO&lt;/span&gt; &lt;span class="kd"&gt;docker&lt;/span&gt; &lt;span class="kd"&gt;rm&lt;/span&gt; &lt;span class="na"&gt;-f &lt;/span&gt;&lt;span class="vm"&gt;%i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command removes all containers.&lt;/p&gt;




&lt;h1&gt;
  
  
  Listing Containers
&lt;/h1&gt;

&lt;h2&gt;
  
  
  View Running Containers
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ps&lt;/code&gt; stands for &lt;strong&gt;Process Status&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This command lists only running containers.&lt;/p&gt;

&lt;h2&gt;
  
  
  View All Containers
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command lists all containers, including exited containers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-a&lt;/code&gt; stands for &lt;strong&gt;all&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  View Only Container IDs
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker ps &lt;span class="nt"&gt;-aq&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command lists all container IDs.&lt;/p&gt;




&lt;h1&gt;
  
  
  Delete Images
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker rmi &lt;span class="nt"&gt;-f&lt;/span&gt; &amp;lt;image_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command forcefully removes an image.&lt;/p&gt;




&lt;h1&gt;
  
  
  Naming a Container
&lt;/h1&gt;

&lt;p&gt;To assign a name to a container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; anyname busybox:1.36
&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 shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; my-container busybox:1.36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a container with the name &lt;code&gt;my-container&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>basic</category>
      <category>virtualmachine</category>
    </item>
    <item>
      <title>Docker – Image and Container Bonding &amp; Client-Server Architecture</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sat, 27 Jun 2026 20:29:32 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/docker-image-and-container-bonding-client-server-architecture-2apd</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/docker-image-and-container-bonding-client-server-architecture-2apd</guid>
      <description>&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A container is running from an image. If we try to delete the image while the container is running, why can't we delete the image?&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer:
&lt;/h3&gt;

&lt;p&gt;If we attempt to delete the image, Docker will display an error message stating that the image is being used by a container.&lt;/p&gt;

&lt;p&gt;The reason is that each line in a Dockerfile creates a layer.&lt;/p&gt;

&lt;p&gt;Each layer is a &lt;strong&gt;read-only layer&lt;/strong&gt;. Once a layer is created, it cannot be modified. If we want to make changes to the image, we need to create a new Dockerfile and build a new image.&lt;/p&gt;

&lt;p&gt;When we create a container, only a reference to the image layers is passed to the container. The container has a &lt;strong&gt;writable layer&lt;/strong&gt;, meaning we can create files, modify files, or generate output inside the container. These changes reside only in the container and do not affect the image.&lt;/p&gt;

&lt;p&gt;However, the container always depends on the image. That is why we cannot delete the image while the container is using it.&lt;/p&gt;

&lt;p&gt;This methodology is called &lt;strong&gt;Copy-on-Write (CoW)&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;If an image size is 10 GB, what will be the container size?&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Answer:
&lt;/h3&gt;

&lt;p&gt;A container contains only references to the image layers. Therefore, the container size consists of the files and changes stored in the writable layer running inside the container.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What command is used to find the size of a container?&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;docker ps &lt;span class="nt"&gt;--size&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;Dive&lt;/strong&gt; application is used to analyze each layer in a Docker image.&lt;/p&gt;




&lt;h1&gt;
  
  
  Client-Server Architecture
&lt;/h1&gt;

&lt;p&gt;Docker works based on the &lt;strong&gt;Client-Server Architecture&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Docker client sends requests to the Docker daemon, and the Docker daemon responds to the client.&lt;/p&gt;

&lt;p&gt;If a requested image is not found on the local system, Docker retrieves it from a public repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker run hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command pulls the image from the repository and runs it on the local system.&lt;/p&gt;




&lt;h3&gt;
  
  
  To pull an image from an image repository
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker pull busybox:1.36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To create a container
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker run busybox:1.36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To create a container, execute the &lt;code&gt;ls&lt;/code&gt; command inside it, and exit immediately
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker run busybox:1.36 ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To create a container and enter interactive mode
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker run -it busybox:1.36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Interview Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Question 1:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;In a Client-Server architecture, who sends requests to the server?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; The client.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 2:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What happens when a container is created from an image?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; A writable layer is created.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 3:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of the writable layer in a container?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; To handle file modifications and store changes made inside the container.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 4:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The read-only layers in Docker come from what?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; The base image and its image layers.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 5:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What happens to the writable layer when the container is deleted?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; It is discarded.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 6:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;In a Docker environment, the client interacts with what?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; The Docker daemon.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 7:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How do you start a container in interactive mode?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&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;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &amp;lt;image-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>docker</category>
      <category>basic</category>
      <category>virtualmachine</category>
    </item>
    <item>
      <title>Docker – Need for Docker and Docker Terminologies</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sat, 27 Jun 2026 20:29:13 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/docker-need-for-docker-and-docker-terminologies-1nmh</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/docker-need-for-docker-and-docker-terminologies-1nmh</guid>
      <description>&lt;h1&gt;
  
  
  Need for Docker
&lt;/h1&gt;

&lt;p&gt;When more than one application runs on a single physical machine, all the applications have to share the machine's memory, CPU, and computational resources.&lt;/p&gt;

&lt;p&gt;Suppose one application consumes more computational power. In that case, the other applications may become slow or even stop responding.&lt;/p&gt;

&lt;p&gt;One solution is to run each application on a separate physical server. Although this provides better performance and isolation, the infrastructure cost and maintenance cost become very high.&lt;/p&gt;

&lt;p&gt;To overcome this problem, the concept of &lt;strong&gt;Virtual Machines (VMs)&lt;/strong&gt; was introduced.&lt;/p&gt;

&lt;p&gt;In a virtual machine environment, each application runs on its own operating system while sharing a single physical machine.&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%2Fcytpsgkdjr2lqfa09sj8.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%2Fcytpsgkdjr2lqfa09sj8.png" alt=" " width="633" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Virtual Machines
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Reduced hardware cost.&lt;/li&gt;
&lt;li&gt;Lower maintenance cost.&lt;/li&gt;
&lt;li&gt;Better isolation between applications.&lt;/li&gt;
&lt;li&gt;Multiple operating systems can run on a single physical machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A software component called a &lt;strong&gt;Hypervisor&lt;/strong&gt; is responsible for virtualizing the physical machine and allowing multiple virtual machines to run on 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%2F7wv2bqtyrfxur91uirru.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%2F7wv2bqtyrfxur91uirru.png" alt=" " width="799" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Hypervisors
&lt;/h3&gt;

&lt;p&gt;There are two types of Hypervisors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type 1 Hypervisor
&lt;/h3&gt;

&lt;p&gt;A Type 1 Hypervisor is installed directly on the physical machine (bare metal).&lt;/p&gt;

&lt;h3&gt;
  
  
  Type 2 Hypervisor
&lt;/h3&gt;

&lt;p&gt;A Type 2 Hypervisor is installed on top of a host operating system.&lt;/p&gt;

&lt;p&gt;We generally use &lt;strong&gt;Type 2 Hypervisors&lt;/strong&gt; on personal computers. They allocate virtual resources to each virtual machine either manually or dynamically.&lt;/p&gt;




&lt;p&gt;However, virtual machines still require a complete operating system for every application, which consumes a significant amount of memory and storage.&lt;/p&gt;

&lt;p&gt;This means we are not fully utilizing the operating system resources for every application.&lt;/p&gt;

&lt;p&gt;To overcome this limitation, &lt;strong&gt;Containers&lt;/strong&gt; were introduced.&lt;/p&gt;

&lt;p&gt;Containers include only the minimum libraries and dependencies required to run an application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Containers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Containers consume much less memory than virtual machines.&lt;/li&gt;
&lt;li&gt;Containers start much faster.&lt;/li&gt;
&lt;li&gt;Containers are lightweight.&lt;/li&gt;
&lt;li&gt;Containers are portable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An application is packaged as a &lt;strong&gt;Docker Image&lt;/strong&gt;, which can be shared with any number of users and run consistently across different environments.&lt;/p&gt;




&lt;h1&gt;
  
  
  Docker Terminologies
&lt;/h1&gt;

&lt;p&gt;For better understanding, let's compare Docker concepts with a kitchen.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Docker Concept&lt;/th&gt;
&lt;th&gt;Kitchen Analogy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Docker Engine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The kitchen where everything happens.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Dockerfile&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The recipe that contains the ingredients and preparation steps.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Docker Image&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The finished dish prepared using the recipe.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Docker Container&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A serving (portion) of the finished dish.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Docker Registry&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A pantry that stores many dishes (images) with different tags.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Docker Daemon&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The chef who prepares the dish (image) by following the recipe (Dockerfile).&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Installing Docker
&lt;/h1&gt;

&lt;p&gt;Download and install Docker Desktop.&lt;/p&gt;

&lt;p&gt;Once the installation is complete, Docker is ready to use.&lt;/p&gt;




&lt;h1&gt;
  
  
  List Images Available on the Local Machine
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command lists all Docker images available on the local machine.&lt;/p&gt;




&lt;h1&gt;
  
  
  Pull an Image from Docker Hub
&lt;/h1&gt;

&lt;p&gt;If the requested image is not available locally, Docker automatically downloads it from the Docker Registry.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker pull hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If no tag (version) is specified, Docker downloads the &lt;strong&gt;latest&lt;/strong&gt; version by default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker pull hello-world:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To download a specific tagged version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker pull hello-world:nanoserver-ltsc2025
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Create a Container from an Image
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker run hello-world:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  List Containers
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;docker ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-a&lt;/code&gt; displays all containers, including exited containers.&lt;/p&gt;




&lt;h1&gt;
  
  
  Interview Questions
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Question 1
&lt;/h3&gt;

&lt;p&gt;What is a Virtual Machine (VM)?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Virtual Machine is a software emulation of a physical computer. It behaves like a separate computer with its own operating system.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 2
&lt;/h3&gt;

&lt;p&gt;What does a Hypervisor do in virtualization?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Hypervisor allows multiple virtual machines to run on a single physical host by managing and allocating hardware resources.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 3
&lt;/h3&gt;

&lt;p&gt;What are the advantages of using containers?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Containers are lightweight.&lt;/li&gt;
&lt;li&gt;Containers start much faster than virtual machines.&lt;/li&gt;
&lt;li&gt;Containers are portable and can run consistently across different environments.&lt;/li&gt;
&lt;li&gt;Containers package only the required dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Containers share the host operating system kernel. If the host kernel encounters a critical issue, all containers may be affected.&lt;/p&gt;

&lt;p&gt;Virtual machines have separate operating systems. Therefore, if one virtual machine crashes, the others continue to run independently.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 4
&lt;/h3&gt;

&lt;p&gt;Which type of Hypervisor runs directly on physical hardware?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Type 1 Hypervisor.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 5
&lt;/h3&gt;

&lt;p&gt;What is the difference between a Virtual Machine and a Container?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Containers share the host operating system kernel.&lt;/li&gt;
&lt;li&gt;Virtual machines run their own operating system on top of a Hypervisor.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Question 6
&lt;/h3&gt;

&lt;p&gt;What is Docker primarily used for?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker is primarily used to containerize applications, ensuring portability, consistency, and providing only the minimum required dependencies to run the application.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>basic</category>
      <category>virtualmachine</category>
    </item>
    <item>
      <title>RAG - Mastering Prompt Frameworks for Better AI Responses</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Tue, 09 Jun 2026 03:16:36 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-mastering-prompt-frameworks-for-better-ai-responses-10ck</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-mastering-prompt-frameworks-for-better-ai-responses-10ck</guid>
      <description>&lt;p&gt;Prompting techniques such as zero-shot, one-shot, few-shot, system prompting, role prompting, contextual prompting, Chain of Thought, Tree of Thoughts, and self-consistent prompting are primarily sources of inspiration.&lt;/p&gt;

&lt;p&gt;There are also structured frameworks that can be followed to generate better outputs from LLMs.&lt;/p&gt;

&lt;p&gt;How do we know these frameworks are effective?&lt;/p&gt;

&lt;p&gt;They have been developed and refined through extensive trial-and-error by practitioners and researchers who have experimented with different prompting approaches.&lt;/p&gt;

&lt;h3&gt;
  
  
  CRISP Framework
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;C (Context/Capacity)&lt;/strong&gt;&lt;br&gt;
Define the expertise or capability the AI should assume.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;R (Role/Request)&lt;/strong&gt;&lt;br&gt;
Clearly specify the task to be performed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I (Instructions/Insight)&lt;/strong&gt;&lt;br&gt;
Provide relevant context and information needed to complete the task.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;S (Style/Specification)&lt;/strong&gt;&lt;br&gt;
Define constraints, requirements, and formatting expectations.&lt;/p&gt;

&lt;p&gt;This can be closely associated with system prompting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P (Purpose/Presentation)&lt;/strong&gt;&lt;br&gt;
Control the output format and explain the intended purpose of the response.&lt;/p&gt;

&lt;h3&gt;
  
  
  Context vs Purpose
&lt;/h3&gt;

&lt;p&gt;Context and Purpose may appear similar, but they are different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;br&gt;
I have an exam tomorrow, so I am asking this question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Purpose:&lt;/strong&gt;&lt;br&gt;
If you provide a good answer, I will be able to perform well in the exam.&lt;/p&gt;

&lt;p&gt;The context explains the background, while the purpose explains the reason or intended outcome.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example :&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.amazonaws.com%2Fuploads%2Farticles%2Fae41cre0yg6g24cnevax.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%2Fae41cre0yg6g24cnevax.png" alt=" " width="799" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use CRISP&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating content&lt;/li&gt;
&lt;li&gt;Generating documents&lt;/li&gt;
&lt;li&gt;Writing blogs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  RICE Framework
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;R (Role)&lt;/strong&gt;&lt;br&gt;
Assign a specific role to the AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I (Instructions)&lt;/strong&gt;&lt;br&gt;
Clearly define what needs to be done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C (Context)&lt;/strong&gt;&lt;br&gt;
Provide background information and relevant details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;E (Expectations)&lt;/strong&gt;&lt;br&gt;
Specify the desired outcome, format, and quality expectations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example :&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.amazonaws.com%2Fuploads%2Farticles%2Fifnod9ah278mwd6sl8bf.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%2Fifnod9ah278mwd6sl8bf.png" alt=" " width="755" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use RICE&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Planning&lt;/li&gt;
&lt;li&gt;Requirement gathering&lt;/li&gt;
&lt;li&gt;Product roadmap creation&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>rag</category>
      <category>nlp</category>
    </item>
    <item>
      <title>RAG - Prompt Engineering</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Mon, 08 Jun 2026 00:56:15 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-prompt-engineering-dm</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-prompt-engineering-dm</guid>
      <description>&lt;p&gt;Prompt engineering is the process of designing and structuring prompts to get better results from an LLM.&lt;/p&gt;

&lt;p&gt;In a RAG application, a prompt template typically contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User query&lt;/li&gt;
&lt;li&gt;Retrieved documents from the vector database&lt;/li&gt;
&lt;li&gt;Additional context or instructions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The quality of the prompt plays a major role in determining the quality of the response generated by the LLM.&lt;/p&gt;

&lt;p&gt;There are several prompting techniques that can be used depending on the use case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Zero-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;In zero-shot prompting, only the query or instruction is provided to the LLM without any examples.&lt;/p&gt;

&lt;p&gt;The model generates a response based on its pre-trained knowledge and the given prompt.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;br&gt;
How do I make tea?&lt;/p&gt;

&lt;p&gt;No examples are provided.&lt;/p&gt;

&lt;p&gt;The LLM generates the answer directly.&lt;/p&gt;

&lt;p&gt;One-Shot and Few-Shot Prompting&lt;/p&gt;

&lt;p&gt;Providing examples helps the LLM understand the expected format and style of the response.&lt;/p&gt;
&lt;h3&gt;
  
  
  One-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;In one-shot prompting, a single example is provided along with the query.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How to make coffee?&lt;/p&gt;

&lt;p&gt;Step 1: Boil water&lt;br&gt;
Step 2: Add coffee powder&lt;br&gt;
Step 3: Mix well&lt;br&gt;
Step 4: Serve&lt;/p&gt;

&lt;p&gt;How to make tea?&lt;/p&gt;

&lt;p&gt;The LLM will likely generate the tea-making instructions using the same format.&lt;/p&gt;
&lt;h3&gt;
  
  
  Few-Shot Prompting
&lt;/h3&gt;

&lt;p&gt;In few-shot prompting, multiple examples are provided before the actual query.&lt;/p&gt;

&lt;p&gt;The model learns the expected structure, style, and pattern from the examples and generates responses accordingly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantage&lt;/strong&gt;&lt;br&gt;
Better formatting consistency&lt;br&gt;
Improved accuracy&lt;br&gt;
Better task understanding&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disadvantage&lt;/strong&gt;&lt;br&gt;
Higher token consumption&lt;br&gt;
Increased cost and latency&lt;/p&gt;
&lt;h3&gt;
  
  
  System Prompting
&lt;/h3&gt;

&lt;p&gt;System prompting is used to define rules, constraints, and behavior for the LLM.&lt;/p&gt;

&lt;p&gt;The model is expected to operate within these boundaries.&lt;/p&gt;
&lt;h4&gt;
  
  
  Examples
&lt;/h4&gt;

&lt;p&gt;You must return the output in JSON format.&lt;br&gt;
Do not include floating-point values in the response.&lt;br&gt;
Answer using only the information provided in the context.&lt;/p&gt;

&lt;p&gt;System prompts are commonly used in production RAG applications to control model behavior.&lt;/p&gt;
&lt;h3&gt;
  
  
  Role Prompting
&lt;/h3&gt;

&lt;p&gt;In role prompting, the LLM is instructed to behave as a specific role, profession, or expert.&lt;/p&gt;
&lt;h4&gt;
  
  
  Examples
&lt;/h4&gt;

&lt;p&gt;Act as a Python developer.&lt;br&gt;
Act as a cybersecurity expert.&lt;br&gt;
Act as a technical interviewer.&lt;/p&gt;

&lt;p&gt;Role prompting helps the model generate responses from a particular perspective and expertise level.&lt;/p&gt;
&lt;h3&gt;
  
  
  Contextual Prompting
&lt;/h3&gt;

&lt;p&gt;Contextual prompting provides background information to help the LLM better understand the situation and generate a more relevant response.&lt;/p&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;I have an exam tomorrow, and this is a difficult subject for me.&lt;br&gt;
Please answer the following question in a simple and easy-to-understand manner.&lt;/p&gt;

&lt;p&gt;The additional context helps the model tailor its response to the user's situation.&lt;/p&gt;
&lt;h3&gt;
  
  
  Chain of Thought Prompting
&lt;/h3&gt;

&lt;p&gt;Chain of Thought (CoT) prompting is a technique where the model is instructed to analyze the input step by step before giving the final answer.&lt;/p&gt;

&lt;p&gt;This helps the LLM break down complex problems into smaller logical steps, leading to better reasoning and more accurate results.&lt;/p&gt;
&lt;h3&gt;
  
  
  Self-Consistent Prompting
&lt;/h3&gt;

&lt;p&gt;In this approach, the LLM is asked to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Try solving the same problem using multiple reasoning paths&lt;/li&gt;
&lt;li&gt;Generate multiple possible answers&lt;/li&gt;
&lt;li&gt;Select the answer that appears most frequently or is the most consistent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This improves reliability by reducing randomness in reasoning.&lt;/p&gt;
&lt;h3&gt;
  
  
  Tree of Thoughts
&lt;/h3&gt;

&lt;p&gt;Tree of Thoughts is an advanced version of self-consistent prompting.&lt;/p&gt;

&lt;p&gt;Instead of following a single reasoning path, the LLM:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explores multiple possible solution paths&lt;/li&gt;
&lt;li&gt;Evaluates each path&lt;/li&gt;
&lt;li&gt;Decides which path is most promising&lt;/li&gt;
&lt;li&gt;Expands only the best or optimal paths further&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates a tree-like structure of reasoning, where different branches represent different thought processes.&lt;/p&gt;

&lt;p&gt;Tree of Thoughts is useful for complex problem-solving tasks that require exploration and decision-making.&lt;/p&gt;
&lt;h3&gt;
  
  
  Prompt Chaining
&lt;/h3&gt;

&lt;p&gt;Prompt chaining is a technique where the output of one prompt is used as the input for another prompt.&lt;/p&gt;

&lt;p&gt;In this approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A problem is broken into multiple stages&lt;/li&gt;
&lt;li&gt;Each stage is handled by a separate prompt&lt;/li&gt;
&lt;li&gt;The result of one prompt flows into the next&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates a pipeline of prompts, allowing complex tasks to be solved step by step in a structured manner.&lt;/p&gt;

&lt;p&gt;Prompt chaining is commonly used in workflows where tasks need decomposition and sequential processing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Combining Prompting Techniques
&lt;/h3&gt;

&lt;p&gt;For better performance, multiple prompting techniques can be combined.&lt;/p&gt;
&lt;h4&gt;
  
  
  Examples
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;System Prompting + User Prompting&lt;/li&gt;
&lt;li&gt;System Prompting + Few-Shot Prompting&lt;/li&gt;
&lt;li&gt;Role Prompting + Contextual Prompting&lt;/li&gt;
&lt;li&gt;Role Prompting + Few-Shot Prompting&lt;/li&gt;
&lt;li&gt;System Prompting + Role Prompting + Contextual Prompting&lt;/li&gt;
&lt;li&gt;Chain of Thought + Prompt Chaining&lt;/li&gt;
&lt;li&gt;Self-Consistent Prompting + Few-Shot Prompting&lt;/li&gt;
&lt;li&gt;Tree of Thoughts + Role Prompting + System Prompting&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;You are a senior Python developer.&lt;/p&gt;

&lt;p&gt;Answer only using the provided context.&lt;/p&gt;

&lt;p&gt;Provide the response in JSON format.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
{&lt;br&gt;
  "language": "Python",&lt;br&gt;
  "difficulty": "Easy"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Question:&lt;br&gt;
How do Python dictionaries work?&lt;/p&gt;

&lt;p&gt;This prompt combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System Prompting&lt;/li&gt;
&lt;li&gt;Role Prompting&lt;/li&gt;
&lt;li&gt;One-Shot Prompting&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Prompt Template in RAG
&lt;/h3&gt;

&lt;p&gt;A typical RAG prompt template consists of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System Instructions&lt;/li&gt;
&lt;li&gt;Retrieved Context/Documents&lt;/li&gt;
&lt;li&gt;User Query&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;You are a helpful assistant.&lt;/p&gt;

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

&lt;p&gt;Question:&lt;br&gt;
What is vector chunking?&lt;/p&gt;

&lt;p&gt;Answer:&lt;/p&gt;

&lt;p&gt;The LLM uses the retrieved documents, instructions, and user query together to generate an accurate and human-readable response.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaway
&lt;/h3&gt;

&lt;p&gt;There is no single prompting technique that works best for every scenario.&lt;/p&gt;

&lt;p&gt;The choice depends on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application requirements&lt;/li&gt;
&lt;li&gt;Cost constraints&lt;/li&gt;
&lt;li&gt;Token limits&lt;/li&gt;
&lt;li&gt;Desired output format&lt;/li&gt;
&lt;li&gt;Accuracy requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In real-world applications, combining multiple prompting techniques often produces the best results.&lt;/p&gt;

&lt;h3&gt;
  
  
  ReAct (Reason + Action)
&lt;/h3&gt;

&lt;p&gt;ReAct (Reasoning + Action) is a proven methodology used to improve the performance of LLMs by combining reasoning with external tool usage.&lt;/p&gt;

&lt;p&gt;In this approach, the model not only thinks about the problem but also decides when to take action by calling external tools or functions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why ReAct is Needed
&lt;/h4&gt;

&lt;p&gt;If we ask a question like:&lt;/p&gt;

&lt;p&gt;“What is the current temperature?”&lt;/p&gt;

&lt;p&gt;A standard LLM cannot directly know real-time information such as current weather or live data.&lt;/p&gt;

&lt;p&gt;However, it can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand the intent of the question&lt;/li&gt;
&lt;li&gt;Identify that external information is required&lt;/li&gt;
&lt;li&gt;Decide to use an available tool (e.g., weather API)&lt;/li&gt;
&lt;li&gt;Use the tool output to generate the final response&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How ReAct Works
&lt;/h3&gt;

&lt;p&gt;ReAct follows a loop of:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Reasoning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The LLM analyzes the question and determines what is needed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is the user asking?&lt;/li&gt;
&lt;li&gt;Do I already know the answer?&lt;/li&gt;
&lt;li&gt;Do I need external data?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Action&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If external data is required, the model selects an appropriate tool or function.&lt;/p&gt;

&lt;p&gt;Examples of tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weather API&lt;/li&gt;
&lt;li&gt;Calculator&lt;/li&gt;
&lt;li&gt;Search engine&lt;/li&gt;
&lt;li&gt;Database query&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Observation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The tool returns results, and the LLM observes the output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Final Answer Generation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The LLM combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reasoning&lt;/li&gt;
&lt;li&gt;Tool output&lt;/li&gt;
&lt;li&gt;Context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and generates the final human-readable response.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

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

&lt;p&gt;“What is the current temperature in Chennai?”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Reasoning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The model understands that this requires real-time data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Action&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It calls a weather API tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Observation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tool returns:&lt;br&gt;
“32°C, partly cloudy”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Final Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;“The current temperature in Chennai is 32°C with partly cloudy conditions.”&lt;/p&gt;

&lt;p&gt;Key Idea of ReAct&lt;/p&gt;

&lt;p&gt;ReAct allows LLMs to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think (Reason)&lt;/li&gt;
&lt;li&gt;Act (Use tools)&lt;/li&gt;
&lt;li&gt;Improve accuracy using real-world data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Benefits of ReAct&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduces hallucination&lt;/li&gt;
&lt;li&gt;Enables real-time information access&lt;/li&gt;
&lt;li&gt;Improves reasoning accuracy&lt;/li&gt;
&lt;li&gt;Makes LLMs more agent-like&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where to use&lt;/strong&gt;&lt;br&gt;
Research Activities&lt;br&gt;
Troubleshooting in Kubernetes&lt;br&gt;
Support in Devops&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>rag</category>
      <category>nlp</category>
    </item>
    <item>
      <title>RAG - Hybrid search and RAG pipeline using FAISS DB</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sun, 31 May 2026 23:45:52 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-hybrid-search-and-rag-pipeline-using-faiss-db-3hhk</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-hybrid-search-and-rag-pipeline-using-faiss-db-3hhk</guid>
      <description>&lt;h3&gt;
  
  
  Hybrid Search
&lt;/h3&gt;

&lt;p&gt;Hybrid search is a combination of dense embeddings and sparse embeddings.&lt;/p&gt;

&lt;p&gt;Dense embeddings focus on semantic meaning, while sparse embeddings focus on exact keyword matching. By combining both approaches, hybrid search improves retrieval accuracy and relevance.&lt;/p&gt;

&lt;p&gt;OpenSearch is commonly used as a search engine for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log analysis&lt;/li&gt;
&lt;li&gt;Observability and monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the key features of OpenSearch is hybrid search, which combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vector search (dense retrieval)&lt;/li&gt;
&lt;li&gt;BM25-based search (sparse retrieval)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;BM25 internally uses concepts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TF (Term Frequency)&lt;/li&gt;
&lt;li&gt;IDF (Inverse Document Frequency)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows OpenSearch to retrieve documents based on both semantic meaning and exact keyword matches.&lt;/p&gt;

&lt;h3&gt;
  
  
  RAG Cycle
&lt;/h3&gt;

&lt;p&gt;A Retrieval-Augmented Generation (RAG) system consists of the following stages:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Document Ingestion
&lt;/h4&gt;

&lt;p&gt;Documents are split into chunks using a chunking strategy.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Embedding Generation
&lt;/h4&gt;

&lt;p&gt;Each chunk is converted into an embedding vector using an embedding model.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Storage
&lt;/h4&gt;

&lt;p&gt;The generated vectors are stored in a vector database.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Retrieval
&lt;/h4&gt;

&lt;p&gt;When a user submits a query:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The query is converted into an embedding vector&lt;/li&gt;
&lt;li&gt;Similar documents are retrieved from the vector database&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  5. Augmentation
&lt;/h4&gt;

&lt;p&gt;The Augmentor combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User query&lt;/li&gt;
&lt;li&gt;Retrieved documents/chunks&lt;/li&gt;
&lt;li&gt;Prompt instructions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This combined context is then sent to the LLM.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The LLM processes the augmented context and generates a human-readable response.&lt;/p&gt;

&lt;h3&gt;
  
  
  RAG Flow
&lt;/h3&gt;

&lt;p&gt;Documents&lt;br&gt;
    ↓&lt;br&gt;
Chunking&lt;br&gt;
    ↓&lt;br&gt;
Embeddings&lt;br&gt;
    ↓&lt;br&gt;
Vector Database&lt;br&gt;
    ↓&lt;br&gt;
User Query&lt;br&gt;
    ↓&lt;br&gt;
Retrieval&lt;br&gt;
    ↓&lt;br&gt;
Augmentation&lt;br&gt;
(Query + Retrieved Documents + Instructions)&lt;br&gt;
    ↓&lt;br&gt;
LLM&lt;br&gt;
    ↓&lt;br&gt;
Human Readable Response&lt;/p&gt;

&lt;h3&gt;
  
  
  FAISS
&lt;/h3&gt;

&lt;p&gt;FAISS (Facebook AI Similarity Search) is an open-source library used for efficient vector similarity search.&lt;/p&gt;

&lt;p&gt;FAISS is commonly used to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store vector indexes locally&lt;/li&gt;
&lt;li&gt;Perform similarity search efficiently&lt;/li&gt;
&lt;li&gt;Build small to medium-scale RAG applications&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Advantages
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Fast similarity search&lt;/li&gt;
&lt;li&gt;Open source&lt;/li&gt;
&lt;li&gt;Easy to set up&lt;/li&gt;
&lt;li&gt;Works well for local development and prototyping&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Limitations
&lt;/h4&gt;

&lt;p&gt;FAISS primarily stores indexes in memory or local files. Because of this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is not a full-fledged vector database&lt;/li&gt;
&lt;li&gt;Managing very large datasets becomes challenging&lt;/li&gt;
&lt;li&gt;Continuous streaming and real-time updates are more difficult compared to dedicated vector databases&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  When to Use FAISS
&lt;/h3&gt;

&lt;h4&gt;
  
  
  FAISS is a good choice when:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Building proof-of-concept projects&lt;/li&gt;
&lt;li&gt;Developing small to medium-sized RAG applications&lt;/li&gt;
&lt;li&gt;Running local experiments&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  When to Consider a Vector Database
&lt;/h4&gt;

&lt;p&gt;For large-scale applications that require:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Billions of vectors&lt;/li&gt;
&lt;li&gt;Real-time updates&lt;/li&gt;
&lt;li&gt;Continuous data ingestion&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>rag</category>
      <category>nlp</category>
    </item>
    <item>
      <title>RAG - Sparse Embedding</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Wed, 27 May 2026 02:09:56 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-sparse-embedding-oc5</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-sparse-embedding-oc5</guid>
      <description>&lt;p&gt;Sparse means thinly spread, scattered, or not dense.&lt;/p&gt;

&lt;p&gt;In sparse embeddings, chunks are converted into tokens, and each token is represented based on whether it exists in the vocabulary dictionary.&lt;/p&gt;

&lt;p&gt;If a token is present in the vocabulary, it is assigned 1; otherwise, it is assigned 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;[0,0,0,1,0,0,1,0,...]&lt;/p&gt;

&lt;p&gt;If the vocabulary dictionary contains 10,000 words, the vector representation will also contain 10,000 dimensions.&lt;/p&gt;

&lt;p&gt;For a particular chunk:&lt;/p&gt;

&lt;p&gt;Only a few positions may contain values like 1&lt;br&gt;
Most other positions will contain 0&lt;/p&gt;

&lt;p&gt;Unlike dense embeddings, sparse embeddings do not contain continuous values. They mainly depend on token occurrence and frequency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Do We Use Sparse Embeddings?
&lt;/h3&gt;

&lt;p&gt;Sparse embeddings are mainly used for direct text matching and keyword-based retrieval.&lt;/p&gt;

&lt;p&gt;They are useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exact keyword matching is important&lt;/li&gt;
&lt;li&gt;Semantic understanding is not the primary requirement&lt;/li&gt;
&lt;li&gt;Traditional search behavior is needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Basic Sparse Representation
&lt;/h3&gt;

&lt;p&gt;In the basic sparse approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Word tokens are compared with the vocabulary dictionary&lt;/li&gt;
&lt;li&gt;If the token exists, the value becomes 1&lt;/li&gt;
&lt;li&gt;Otherwise, the value becomes 0&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is similar to one-hot encoding.&lt;/p&gt;

&lt;h3&gt;
  
  
  Drawback of Basic Sparse Representation
&lt;/h3&gt;

&lt;p&gt;The main drawback is that it does not consider how many times a word appears in the document.&lt;/p&gt;

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

&lt;p&gt;If the word “database” appears 20 times and another word appears only once, both may still receive the same representation.&lt;/p&gt;

&lt;p&gt;To solve this problem, the concept of token weighting was introduced.&lt;/p&gt;

&lt;h3&gt;
  
  
  Term Frequency (TF)
&lt;/h3&gt;

&lt;p&gt;TF stands for Term Frequency.&lt;/p&gt;

&lt;p&gt;It measures how frequently a term appears in a document.&lt;/p&gt;

&lt;p&gt;The formula is:&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%2Fj1tkfe2ihs5oz7kqsjwb.webp" 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%2Fj1tkfe2ihs5oz7kqsjwb.webp" alt=" " width="800" height="128"&gt;&lt;/a&gt;&lt;br&gt;
    ​&lt;/p&gt;

&lt;p&gt;TF gives higher importance to terms that appear more frequently in a document.&lt;/p&gt;

&lt;h3&gt;
  
  
  Issue with TF
&lt;/h3&gt;

&lt;p&gt;The problem with TF is that commonly occurring words may receive very high importance even if they are not meaningful.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;“the”&lt;/li&gt;
&lt;li&gt;“is”&lt;/li&gt;
&lt;li&gt;“and”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These words appear frequently in most documents but do not provide strong contextual meaning.&lt;/p&gt;

&lt;p&gt;To solve this issue, IDF was introduced.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inverse Document Frequency (IDF)
&lt;/h3&gt;

&lt;p&gt;IDF stands for Inverse Document Frequency.&lt;/p&gt;

&lt;p&gt;It measures how rare or important a word is across the entire document collection.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Common words receive lower scores&lt;/li&gt;
&lt;li&gt;Rare and meaningful words receive higher scores&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The formula is:&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%2Fvq6r3v4q6972g15ux3r9.webp" 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%2Fvq6r3v4q6972g15ux3r9.webp" alt=" " width="800" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Issue with IDF
&lt;/h3&gt;

&lt;p&gt;IDF alone does not determine how relevant a document is to the user query.&lt;/p&gt;

&lt;p&gt;It only measures the rarity of terms across documents.&lt;/p&gt;

&lt;p&gt;To improve retrieval quality, TF and IDF are combined together.&lt;/p&gt;

&lt;h3&gt;
  
  
  TF-IDF
&lt;/h3&gt;

&lt;p&gt;TF-IDF combines:&lt;/p&gt;

&lt;p&gt;Term Frequency (TF)&lt;br&gt;
Inverse Document Frequency (IDF)&lt;/p&gt;

&lt;p&gt;The formula is:&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%2F7tej3lgm145dludtdesp.webp" 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%2F7tej3lgm145dludtdesp.webp" alt=" " width="800" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TF-IDF works well for many traditional search systems because it balances:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Word frequency within the document&lt;/li&gt;
&lt;li&gt;Word importance across all documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, TF-IDF still does not fully capture semantic meaning.&lt;/p&gt;

&lt;h3&gt;
  
  
  BM25 (Best Match 25)
&lt;/h3&gt;

&lt;p&gt;BM25 is an advanced ranking algorithm used in sparse retrieval systems.&lt;/p&gt;

&lt;p&gt;It improves upon TF-IDF by considering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Term frequency&lt;/li&gt;
&lt;li&gt;Document length&lt;/li&gt;
&lt;li&gt;Query relevance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;BM25 is one of the most commonly used algorithms in traditional search engines and sparse retrieval systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limitation of Sparse Embeddings
&lt;/h3&gt;

&lt;p&gt;Sparse embeddings alone are usually not enough to retrieve highly relevant documents in modern RAG systems because they mainly focus on exact keyword matching rather than semantic meaning.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;“car” and “automobile” may not match&lt;/li&gt;
&lt;li&gt;“feline” and “cat” may not match&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even though the meanings are similar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hybrid Search
&lt;/h3&gt;

&lt;p&gt;To improve retrieval quality, modern systems combine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dense embeddings&lt;/li&gt;
&lt;li&gt;Sparse embeddings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach is called hybrid search.&lt;/p&gt;

&lt;h4&gt;
  
  
  Typical Combination
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Dense retrieval → Sentence transformers or embedding models&lt;/li&gt;
&lt;li&gt;Sparse retrieval → BM25&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dense embeddings help with semantic understanding, while sparse embeddings help with exact keyword matching.&lt;/p&gt;

&lt;p&gt;Together, they provide better retrieval performance in RAG applications.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>rag</category>
    </item>
    <item>
      <title>RAG - Dense Embedding</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Wed, 20 May 2026 03:03:30 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-dense-embedding-cmi</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-dense-embedding-cmi</guid>
      <description>&lt;p&gt;Dense means continuous.&lt;/p&gt;

&lt;p&gt;When text is converted into a numerical representation called a vector (point) that contains continuous values, it is called a dense embedding.&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%2Fcv7xv5m15y0kp11l6tmn.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%2Fcv7xv5m15y0kp11l6tmn.png" alt=" " width="799" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unlike sparse vectors, where many values are zero, dense vectors contain meaningful numerical values across most dimensions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A dense vector may look like:&lt;br&gt;
[0.123, -0.456, 0.789, 0.245, ...]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-Dimensional Representation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Each vector is represented in an n-dimensional space.&lt;br&gt;
This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every value in the vector represents one dimension&lt;/li&gt;
&lt;li&gt;Each dimension contains some numerical value other than zero&lt;/li&gt;
&lt;li&gt;Similar meanings are stored closer together in vector space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All vectors are stored in a mathematical space called latent space.&lt;/p&gt;

&lt;p&gt;Words or sentences with similar meanings are usually positioned closer together inside this latent space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Dense Embeddings are Generated&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To convert text into vectors, we can use:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Embedding Models&lt;/strong&gt;&lt;br&gt;
Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nomic-embed-text&lt;/li&gt;
&lt;li&gt;BGE (Beijing Academy of Artificial Intelligence General Embedding) models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Transformer Models&lt;/strong&gt;&lt;br&gt;
Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all-MiniLM-L6-v2&lt;/li&gt;
&lt;li&gt;Nomic Transformer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These models are commonly available through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hugging Face&lt;/li&gt;
&lt;li&gt;Ollama&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Relationship Between LLMs and Transformers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LLMs internally use transformer architecture.&lt;/p&gt;

&lt;p&gt;A transformer mainly contains two parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encoder&lt;/li&gt;
&lt;li&gt;Decoder&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Encoder&lt;/strong&gt;&lt;br&gt;
The encoder converts text into embeddings (vectors).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoder&lt;/strong&gt;&lt;br&gt;
The decoder processes embeddings and generates human-readable text.&lt;/p&gt;

&lt;p&gt;In embedding models, the encoder part is mainly used to generate vector representations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Methods to Generate Embeddings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Embeddings can be generated in two ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Using Dedicated Embedding Models&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These models are specifically trained for embedding generation.&lt;/p&gt;

&lt;p&gt;Examples&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;nomic-embed-text&lt;/li&gt;
&lt;li&gt;BGE models&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the most common and efficient approach in RAG systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Using General LLMs Through Prompting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A general-purpose LLM can also generate embeddings by giving prompts that instruct the model to convert text into vector representations.&lt;/p&gt;

&lt;p&gt;This approach is sometimes used in vectorless RAG systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disadvantage&lt;/strong&gt;&lt;br&gt;
Higher computational cost&lt;br&gt;
Slower performance&lt;br&gt;
More token consumption&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Measuring Embedding and Retrieval Accuracy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To measure retrieval accuracy effectively, unit tests should be written for the RAG pipeline.&lt;/p&gt;

&lt;p&gt;The test cases should include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expected inputs&lt;/li&gt;
&lt;li&gt;Expected outputs&lt;/li&gt;
&lt;li&gt;Different query scenarios&lt;/li&gt;
&lt;li&gt;Edge cases&lt;/li&gt;
&lt;li&gt;Semantic similarity checks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This helps evaluate how accurately the embedding model retrieves relevant information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Similarity Methods Used in Dense Embeddings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dense embeddings commonly use one of the following similarity measurement methods:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cosine Similarity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the most commonly used similarity method in RAG applications.&lt;/p&gt;

&lt;p&gt;It measures the angle between vectors rather than physical distance.&lt;/p&gt;

&lt;p&gt;If the vectors point in similar directions, the similarity score becomes higher.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Euclidean Distance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Measures the straight-line distance between vectors in vector space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dot Product&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Measures similarity by multiplying corresponding vector values and summing them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why the Same Embedding Model Must Be Used&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The same embedding model should be used for both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data ingestion phase&lt;/li&gt;
&lt;li&gt;Retrieval phase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If different embedding models are used, the generated vectors may exist in completely different latent spaces or vector distributions.&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%2Frwf66ofrwuhm0owu2ljt.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%2Frwf66ofrwuhm0owu2ljt.png" alt=" " width="545" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Similarity calculations become inaccurate&lt;/li&gt;
&lt;li&gt;Retrieval quality decreases&lt;/li&gt;
&lt;li&gt;Relevant chunks may not be retrieved correctly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the same embedding model ensures that both stored documents and user queries are represented consistently in the same vector space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sparse Embeddings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sparse embeddings use TF-IDF and BM25 mechanisms for retrieval.&lt;/p&gt;

&lt;p&gt;In sparse embeddings, vectors are generated mainly based on keyword frequency and importance rather than semantic meaning.&lt;/p&gt;

&lt;p&gt;The combination of BM25 and vector search is called hybrid search.&lt;/p&gt;

&lt;p&gt;Tools such as OpenSearch and Elasticsearch support hybrid search by combining:&lt;/p&gt;

&lt;p&gt;Traditional keyword-based retrieval&lt;br&gt;
Semantic vector-based retrieval&lt;/p&gt;

&lt;p&gt;Similar to one-hot encoding, sparse embeddings generate vectors based on text frequency. Most values in the vector remain 0, while only important terms receive higher numerical values.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;[3.91, 0, 0, 1.62]&lt;/p&gt;

&lt;p&gt;In this representation:&lt;/p&gt;

&lt;p&gt;Higher values indicate more important or frequently occurring terms&lt;br&gt;
Zero values indicate terms that are absent or not important in the document&lt;/p&gt;

&lt;p&gt;Sparse embeddings mainly focus on exact keyword matching and are highly effective for traditional search use cases.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>llm</category>
      <category>beginners</category>
    </item>
    <item>
      <title>RAG- Understanding of Embedding</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Sun, 17 May 2026 22:43:09 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-understanding-of-embedding-nlk</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-understanding-of-embedding-nlk</guid>
      <description>&lt;h2&gt;
  
  
  What is Embedding?
&lt;/h2&gt;

&lt;p&gt;After text is split into chunks, the next process is called embedding. In this step, each chunk is converted into vectors (points in vector space). In vector-based RAG systems, chunks are converted into vectors so that semantic search can be performed efficiently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Do We Need to Convert Chunks into Vectors?
&lt;/h2&gt;

&lt;p&gt;The main goal of a RAG application is to achieve semantic search.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
The word feline is related to the cat family, even though the words are different. Understanding that “feline” and “cat” are related is called semantic understanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Similarity&lt;/strong&gt;&lt;br&gt;
When a user asks a query, semantically related chunks are returned even though the exact words in the chunks may be different.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Semantic Similarity&lt;/strong&gt;&lt;br&gt;
Semantic similarity combines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Intent&lt;/li&gt;
&lt;li&gt;Context&lt;/li&gt;
&lt;li&gt;Meaning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The purpose is to establish relationships between the user query and the documents stored in the RAG system. This allows the system to retrieve relevant information from the database and provide it to the LLM for further processing.&lt;/p&gt;

&lt;p&gt;Words that are semantically related are usually stored closer together in multi-dimensional vector space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cosine Similarity&lt;/strong&gt;&lt;br&gt;
To determine how close vectors are to each other, cosine similarity is commonly used.&lt;/p&gt;

&lt;p&gt;When a user query arrives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The query is converted into a vector&lt;/li&gt;
&lt;li&gt;Cosine similarity is calculated between the query vector and stored vectors&lt;/li&gt;
&lt;li&gt;The closest vectors are retrieved&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Retrieval Methodologies
&lt;/h2&gt;

&lt;p&gt;Two major retrieval methodologies are used:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. KNN (K-Nearest Neighbors)&lt;/strong&gt;&lt;br&gt;
KNN compares the query vector with all stored vectors one by one to find the nearest neighbors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantage&lt;/strong&gt;&lt;br&gt;
More accurate retrieval&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disadvantage&lt;/strong&gt;&lt;br&gt;
Slow for very large datasets&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. ANN (Approximate Nearest Neighbors)&lt;/strong&gt;&lt;br&gt;
ANN approximately finds the nearest vectors instead of comparing every single point.&lt;/p&gt;

&lt;p&gt;This method is mainly used when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The document volume is huge&lt;/li&gt;
&lt;li&gt;Faster retrieval is required&lt;/li&gt;
&lt;li&gt;Time constraints exist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ANN improves retrieval speed while sacrificing a small amount of accuracy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Cosine Similarity Instead of Sine or Tangent?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cosine similarity works effectively because:&lt;br&gt;
If two vectors are very close and highly related, the cosine similarity value approaches 1. If the angle between vectors increases, the cosine similarity value decreases, meaning the vectors are less related&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Not Sine or Tangent?&lt;/strong&gt;&lt;br&gt;
For small angles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sine values remain close to 0&lt;/li&gt;
&lt;li&gt;Tangent values can fluctuate significantly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These measurements are not stable for semantic comparison. Cosine similarity provides a more reliable way to measure semantic closeness between vectors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Embedding Dimensions&lt;/strong&gt;&lt;br&gt;
Embedding models can generate vectors with dimensions ranging from 256 to 3000 or more.&lt;/p&gt;

&lt;p&gt;The dimension size depends on the embedding model and the amount of contextual information it captures.&lt;/p&gt;

&lt;p&gt;Generally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Higher dimensions capture richer semantic information&lt;/li&gt;
&lt;li&gt;Lower dimensions are faster and cheaper but may lose context&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Types of Embedding Models&lt;/strong&gt;&lt;br&gt;
Choosing an embedding model completely depends on the application scenario.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Based on Query Type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Symmetric Models&lt;/strong&gt;&lt;br&gt;
Symmetric embedding models are used when the query and the documents are similar in structure and length.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;br&gt;
nomic-embed-text&lt;br&gt;
Qwen embeddings&lt;/p&gt;

&lt;p&gt;These are commonly used in semantic search systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asymmetric Models&lt;/strong&gt;&lt;br&gt;
Asymmetric embedding models are used when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Queries are short&lt;/li&gt;
&lt;li&gt;Documents are long&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
Google Gemini embedding models&lt;/p&gt;

&lt;p&gt;These models are optimized for retrieving long documents from short queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Based on Retrieval Type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dense Embeddings&lt;/strong&gt;&lt;br&gt;
Dense embeddings mainly focus on semantic meaning.&lt;/p&gt;

&lt;p&gt;These embeddings generate dense vectors where most values contain meaningful information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;br&gt;
Cohere embedding models&lt;br&gt;
ChatGPT OSS 120B embeddings&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantage&lt;/strong&gt;&lt;br&gt;
Better semantic understanding&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sparse Embeddings&lt;/strong&gt;&lt;br&gt;
Sparse embeddings mainly focus on exact keyword matching.&lt;/p&gt;

&lt;p&gt;They commonly use the BM25 (Best Match 25) algorithm, which is based on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TF (Term Frequency)&lt;/li&gt;
&lt;li&gt;IDF (Inverse Document Frequency)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TF-IDF Concepts
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TF (Term Frequency)&lt;/strong&gt;&lt;br&gt;
Measures how many times a word appears in a document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IDF (Inverse Document Frequency)&lt;/strong&gt;&lt;br&gt;
Measures how important a word is across the entire document collection.Words that appear too frequently across all documents are considered less important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transformer Architecture
&lt;/h2&gt;

&lt;p&gt;The transformer architecture was a major breakthrough for LLMs.&lt;br&gt;
Transformers mainly contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encoder&lt;/li&gt;
&lt;li&gt;Decoder&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Encoder&lt;/strong&gt;&lt;br&gt;
The encoder converts text into embeddings (vectors).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoder&lt;/strong&gt;&lt;br&gt;
The decoder converts embeddings back into human-readable text after processing.&lt;/p&gt;

&lt;p&gt;This architecture enables modern LLMs to understand and generate natural language effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choosing a Vector Database&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chroma&lt;/strong&gt;&lt;br&gt;
Open source&lt;br&gt;
Easy to set up&lt;br&gt;
Suitable for basic and small-scale applications&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FAISS&lt;/strong&gt;&lt;br&gt;
Better for large document collections&lt;br&gt;
Optimized for high-performance semantic search&lt;br&gt;
Commonly used in production-scale retrieval systems&lt;/p&gt;

</description>
      <category>ai</category>
      <category>rag</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>RAG - Sliding Window, Token Based Chunking and PDF Chunking Packages</title>
      <dc:creator>Ramya Perumal</dc:creator>
      <pubDate>Thu, 14 May 2026 23:25:36 +0000</pubDate>
      <link>https://dev.to/ramya_perumal_e93721ef2fa/rag-sliding-window-token-based-chunking-and-pdf-chunking-packages-18nd</link>
      <guid>https://dev.to/ramya_perumal_e93721ef2fa/rag-sliding-window-token-based-chunking-and-pdf-chunking-packages-18nd</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Sliding Window Chunking&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Sliding Window Chunking is a more intensive chunking mechanism.&lt;/p&gt;

&lt;p&gt;In this method, a window size is defined based on a character or token limit. Instead of creating completely separate chunks, the window moves forward gradually while keeping part of the previous content.&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%2Ff3gx1hccb28qu5t5twi4.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%2Ff3gx1hccb28qu5t5twi4.png" alt=" " width="626" height="251"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The character or token limit is called the &lt;strong&gt;window size&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The amount the window moves forward each time is called the &lt;strong&gt;step size&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a stricter form of overlapping chunking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose:&lt;/p&gt;

&lt;p&gt;Window size = 500 characters&lt;br&gt;
Step size = 100 characters&lt;/p&gt;

&lt;p&gt;The first chunk may contain characters 1–500.&lt;br&gt;
The second chunk starts after moving 100 characters and may contain characters 101–600.&lt;/p&gt;

&lt;p&gt;Because of this overlap, related information is repeatedly included across chunks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The major benefit of this method is that semantically related points are stored closer together in the vector database, almost like clusters. This improves retrieval in scenarios where context changes frequently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Problem 1: Higher Token Consumption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since overlapping data is repeatedly embedded, the embedding model consumes more tokens. This increases computational cost unless local embedding models are used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 2: Duplicate Retrieval&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because related chunks are stored very close together, the LLM may retrieve multiple duplicate or nearly identical chunks instead of retrieving different contexts.&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%2Fzgegxk8g0uzqkaoyoyl0.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%2Fzgegxk8g0uzqkaoyoyl0.png" alt=" " width="626" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Context diversity decreases&lt;/li&gt;
&lt;li&gt;Token usage increases&lt;/li&gt;
&lt;li&gt;Retrieval efficiency may reduce&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where Sliding Window Chunking is Useful&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sliding window chunking is useful in scenarios where context switching happens frequently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Source Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In coding-related datasets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Different parts of the code may not be directly related&lt;/li&gt;
&lt;li&gt;One service or module may trigger another service indirectly&lt;/li&gt;
&lt;li&gt;Important context may exist across multiple sections&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, in microservices architecture:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One service event may trigger another service&lt;/li&gt;
&lt;li&gt;Related logic may exist in different files or services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sliding window chunking helps preserve such relationships, even though it comes with higher token consumption.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Token Based Chunking&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Token-based chunking mainly focuses on cost optimization and model limitations.&lt;/p&gt;

&lt;p&gt;LLMs process text as tokens rather than words.&lt;/p&gt;

&lt;p&gt;Depending on the tokenizer and model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One word may become a single token&lt;/li&gt;
&lt;li&gt;One word may become multiple tokens&lt;/li&gt;
&lt;li&gt;Sometimes even a single character can become a token&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since models have token input limits, token-based chunking is used to ensure the content stays within the allowed token size.&lt;/p&gt;

&lt;p&gt;In this method:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Text is split based on token count&lt;/li&gt;
&lt;li&gt;Chunks are converted into embedding vectors&lt;/li&gt;
&lt;li&gt;Vectors are stored in the vector database&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This method is mainly used when working with strict token constraints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TOON (Token-Oriented Object Notation)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TOON stands for Token-Oriented Object Notation.&lt;/p&gt;

&lt;p&gt;It is an alternative representation format designed to reduce token usage compared to JSON.&lt;/p&gt;

&lt;p&gt;JSON is human-readable, but repeated keys increase token consumption.&lt;/p&gt;

&lt;p&gt;Repeated structures and keys increase token usage.&lt;/p&gt;

&lt;p&gt;TOON reduces repeated keys and represents the same information in a more token-efficient format.&lt;/p&gt;

&lt;p&gt;The purpose is to reduce embedding and inference cost while preserving context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLMLingua&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;LLMLingua is a framework used for prompt compression.&lt;/p&gt;

&lt;p&gt;It converts user queries or prompts into simplified versions while preserving the original meaning and context.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Reduce token consumption&lt;/li&gt;
&lt;li&gt;Lower inference cost&lt;/li&gt;
&lt;li&gt;Improve efficiency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, aggressive compression may sometimes reduce retrieval quality compared to the original JSON or text structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary of Chunking Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The commonly used chunking methods are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fixed Chunking&lt;/li&gt;
&lt;li&gt;Overlapping Chunking&lt;/li&gt;
&lt;li&gt;Semantic Chunking&lt;/li&gt;
&lt;li&gt;Embedding-Based Chunking&lt;/li&gt;
&lt;li&gt;Sliding Window Chunking&lt;/li&gt;
&lt;li&gt;Token-Based Chunking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These methods represent different approaches and trade-offs.&lt;/p&gt;

&lt;p&gt;In real-world applications, multiple chunking methods are often combined depending on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dataset type&lt;/li&gt;
&lt;li&gt;Retrieval quality&lt;/li&gt;
&lt;li&gt;Cost constraints&lt;/li&gt;
&lt;li&gt;Token limitations&lt;/li&gt;
&lt;li&gt;Application requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is no single chunking strategy that works best for every dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PDF Reading in RAG Systems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To process documents such as company internal communication files, PDFs must first be converted into readable text.&lt;/p&gt;

&lt;p&gt;Several libraries are commonly used for this purpose under LangChain Framework:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PyPDFLoader&lt;/li&gt;
&lt;li&gt;PyPDF&lt;/li&gt;
&lt;li&gt;PyMuPDF&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different document types require different processing approaches. A single package may not work effectively for all document formats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Challenges in PDF Processing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Documents may contain:&lt;/p&gt;

&lt;p&gt;Scanned images&lt;br&gt;
Multi-column layouts&lt;br&gt;
Tables&lt;br&gt;
Handwritten text&lt;br&gt;
Two-sided scanned pages&lt;/p&gt;

&lt;p&gt;Because of this, preprocessing becomes an important step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools Used in PDF Processing&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Camelot&lt;/strong&gt;&lt;br&gt;
Camelot is commonly used to extract table content from PDFs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tesseract&lt;/strong&gt; &lt;br&gt;
Tesseract or computer vision models are used to convert scanned images into readable text documents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final RAG Flow for Documents&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Raw documents are collected&lt;/li&gt;
&lt;li&gt;Images, tables, and scanned content are converted into text&lt;/li&gt;
&lt;li&gt;Data is cleaned &lt;/li&gt;
&lt;li&gt;Documents are split into chunks using chunking methods&lt;/li&gt;
&lt;li&gt;Chunks are converted into embedding vectors&lt;/li&gt;
&lt;li&gt;Vectors are stored in the vector database for retrieval&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>rag</category>
    </item>
  </channel>
</rss>
