<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Haresh kumar on Medium]]></title>
        <description><![CDATA[Stories by Haresh kumar on Medium]]></description>
        <link>https://medium.com/@hjethani20?source=rss-af1e45ab4c28------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Swb9oa4jRaMVHGjI</url>
            <title>Stories by Haresh kumar on Medium</title>
            <link>https://medium.com/@hjethani20?source=rss-af1e45ab4c28------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:47:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hjethani20/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Visual Document RAG System: How I Combined ColPali and Qwen2-VL to Search 2,000…]]></title>
            <link>https://medium.com/@hjethani20/building-a-visual-document-rag-system-how-i-combined-colpali-and-qwen2-vl-to-search-2-000-1cf18e015f63?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf18e015f63</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 22:37:20 GMT</pubDate>
            <atom:updated>2026-07-28T22:37:20.730Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Building a Visual Document RAG System: How I Combined ColPali and Qwen2-VL to Search 2,000 Documents Without OCR</strong></h3><p><em>A journey through retrieval bugs, evaluation pitfalls, and what it actually takes to make Retrieval-Augmented Generation work on real document images.</em></p><h3>The Problem: Traditional Document Search Falls Apart on Real-World Files</h3><p>Ask any team that has tried to build a searchable knowledge base out of invoices, forms, or scanned reports, and they’ll tell you the same thing: OCR is fragile. Tables break. Handwriting fails. Layout information the thing that often carries the actual meaning of a document gets flattened into a soup of disconnected words.</p><p>I wanted to test a different approach: skip OCR entirely, and let a model <em>see</em> the document the way a human would.</p><p>That meant combining two relatively recent ideas in multimodal AI:</p><ul><li><strong>ColPali</strong>, a retriever that indexes document pages as images rather than extracted text</li><li><strong>Qwen2-VL</strong>, a vision-language model that can read and reason over an image directly, no separate text extraction step required</li></ul><p>The goal: given a natural-language question, retrieve the correct document page from a 2,000-image corpus (built from the DocVQA dataset) and generate an accurate answer end to end, with no OCR pipeline in between.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6vcEOZGQZ-22HlXkAbcSg.png" /></figure><h3>Why ColPali Instead of Standard Embedding Models</h3><p>Most retrieval systems still lean on models like CLIP: encode text and images into a shared vector space, then do nearest-neighbor search. It works, but it treats a document page like a single flattened concept it doesn’t reason about layout, tables, or the fine-grained regions where an answer might actually live.</p><p>ColPali takes a different approach. Instead of compressing a page into one vector, it breaks the image into patches and keeps a rich, multi-vector representation for each one closer in spirit to how ColBERT does late interaction retrieval for text, but applied to vision. The result is a retriever that’s noticeably better at picking out the right <em>document</em>, especially when the corpus contains dense forms, financial tables, or scanned letters where OCR-based systems tend to struggle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnazsE_TJSFHsBAp4VkXtA.png" /></figure><h3>Building the Index: 2,000 Documents, One Retriever</h3><p>The corpus came from DocVQA a mix of business letters, invoices, forms, and reports, exactly the kind of unglamorous real-world documents that break naive pipelines. Using the Byaldi library as a wrapper around ColPali, I indexed 2,000 document images, storing everything as dense patch-level embeddings.</p><p>This step alone is worth pausing on, because it’s where the first hard lesson showed up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*Ukpuw2DMv-ZaJtV8bGtxJA.png" /></figure><h3>Lesson One:A “Working” Retriever Can Still Be Silently Broken</h3><p>Early evaluation runs reported a <strong>0% Recall@3</strong> and an <strong>MRR of 0.0</strong> — numbers that looked catastrophic. But the retriever wasn’t actually failing. The bug was in the evaluation code itself: the ground-truth document IDs (string-based, tied to original filenames) weren’t being compared correctly against the retriever’s internal integer IDs. The retrieval was working; the <em>scoring</em> wasn’t.</p><p>This turned into the most valuable part of the whole project not the model, but the discipline of not trusting a metric until you’ve traced exactly where its inputs come from. After fixing the ID-mapping logic, the same retriever scored:</p><ul><li><strong>Recall@3: 100%</strong></li><li><strong>MRR: 0.7667</strong></li></ul><p>Same model. Same index. The only thing that changed was whether the evaluation code was actually measuring what it claimed to measure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*Fxrom_YOjsLokU4wxydtrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*wI3FNXYVTSIA4K0s3hGDXg.png" /></figure><h3>Bringing in Qwen2-VL: From “Which Document?” to “What’s the Answer?”</h3><p>Retrieval only solves half the problem. Once ColPali points to the right page, something still has to read it and answer the question. That’s where <strong>Qwen2-VL-2B-Instruct</strong> comes in a vision-language model that takes the retrieved image directly as input, alongside the user’s question, and generates a natural-language answer without any intermediate OCR or layout-parsing step.</p><p>To keep this runnable on a single Kaggle T4 GPU, Qwen2-VL was loaded in 4-bit precision via bitsandbytes, which cut memory usage dramatically without gutting output quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RduUUUWO2zyZY70kXHbT3Q.png" /></figure><h3>Proving Retrieval Actually Matters: The Three-Way Comparison</h3><p>It’s easy to build a RAG pipeline and simply report its accuracy. It’s much more convincing to prove that <em>retrieval itself</em> is doing real work. So the evaluation compared three conditions:</p><ol><li><strong>Blind</strong> — Qwen2-VL answers with no image at all</li><li><strong>RAG</strong> — Qwen2-VL answers using whatever ColPali retrieved</li><li><strong>Oracle</strong> — Qwen2-VL answers using the actual ground-truth image, retrieval bypassed entirely</li></ol><p>The blind baseline collapsed to 0% across every metric — Exact Match, ANLS, and relaxed numeric accuracy which is exactly what you’d expect and hope for: without an image, the model has nothing to reason over. Once retrieval was fixed, the RAG condition matched the Oracle condition almost exactly, landing around <strong>60% Exact Match</strong> and <strong>73.7% ANLS</strong>.</p><p>That equivalence between RAG and Oracle is the real headline: it means the retriever was consistently handing Qwen2-VL the correct page, and the generation model was doing the rest of the work reliably.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jir_uy7IAEFK6HsQNRO-uw.png" /></figure><h3>What This Project Actually Teaches</h3><p>A few things stood out that go beyond this specific pipeline:</p><p><strong>Retrieval bugs hide behind generation quality.</strong> A generator can look “bad” when the real fault lies upstream, in what it was even given to read. Debugging in isolation testing the retriever and the generator separately before judging the combined system was what actually surfaced the problem.</p><p><strong>Visual retrieval genuinely competes with OCR pipelines on messy documents.</strong> ColPali didn’t need a single line of extracted text to find the right page in a corpus of scanned forms and letters.</p><p><strong>Small evaluation samples lie convincingly.</strong> Early results on five test queries looked clean and dramatic. They were also statistically meaningless. Scaling evaluation to the full test set is the difference between a demo and a defensible result.</p><p><strong>A capable generator doesn’t compensate for a broken retriever.</strong> Qwen2-VL performed well whenever it was shown the right document but no amount of generation quality can rescue a system that hands the model the wrong page in the first place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jXMwDL3t_sTZw4ISuNTTZA.png" /></figure><h3>Closing Thoughts</h3><p>Multimodal RAG is often pitched as a plug-and-play upgrade over text-only pipelines, but building one that’s actually trustworthy takes more than swapping in a vision-language model. It takes indexing real documents at scale, catching evaluation bugs that quietly zero out your metrics, and proving with a proper baseline comparison that retrieval is pulling its weight rather than just adding latency.</p><p>The end result: a 2,000-document visual search system where ColPali finds the page and Qwen2-VL reads it, with no OCR step anywhere in between.</p><p>If you’re building something similar, the two components worth getting right first are the ID-mapping between your retriever and your evaluation code, and a no-retrieval baseline both are cheap to add and will save you from trusting numbers that aren’t real.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf18e015f63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Fine-Tuned Qwen2.5–3B]]></title>
            <link>https://medium.com/@hjethani20/i-fine-tuned-qwen2-5-3b-8102a8e6c06b?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/8102a8e6c06b</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Wed, 08 Jul 2026 12:39:11 GMT</pubDate>
            <atom:updated>2026-07-08T12:39:11.701Z</atom:updated>
            <content:encoded><![CDATA[<h3>I Fine-Tuned Qwen2.5–3B With Reinforcement Learning on a Free Kaggle GPU Here’s What Actually Happened</h3><p>A few weeks ago I decided to stop reading papers about reasoning models and actually try to build one. Not a full DeepSeek-R1 clone, I don’t have that kind of compute but a small-scale version of the same idea: take a base language model and use reinforcement learning to push it toward better step-by-step reasoning on math problems.</p><p>I picked Qwen2.5–3B-Instruct as the base model, GSM8K as the dataset, and GRPO (Group Relative Policy Optimization) as the training algorithm. The whole thing ran on a single Kaggle T4 GPU — free tier, 16GB of VRAM, session time limits, all of it. This post is a walkthrough of what I did, what broke, and what the results actually looked like, without rounding anything up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*eLSinimCcACUp9xYGoseSA.png" /><figcaption>Training environment: Kaggle T4 GPU, free tier</figcaption></figure><p><strong>Why GRPO</strong></p><p>Most people fine-tune LLMs with supervised fine-tuning: show the model a bunch of correct question-answer pairs and let it imitate them. That works, but it doesn’t teach a model to reason it teaches it to pattern-match a format. GRPO takes a different approach. For every prompt, the model generates several candidate answers (I used 4 per prompt), those answers get scored by a reward function, and the scores are normalized within that group. The model is then nudged toward whichever answers scored above the group average, and away from the ones that scored below it. No separate value network needed, which is exactly why it works on cheaper hardware than classic PPO.</p><p><strong>Setting things up</strong></p><p>The environment fighting was, honestly, half the project. Getting bitsandbytes, torch, and transformers to agree on a dtype took longer than writing the training loop. I ended up forcing everything to float16 explicitly and disabling Accelerate’s automatic mixed precision, because the notebook kept quietly trying to switch to bfloat16 and crashing on the T4 (T4s don’t support bf16 natively).</p><p>To fit a 3B parameter model with RL training in 16GB of memory, I used:</p><ul><li>4-bit NF4 quantization for the base weights</li><li>LoRA adapters (rank 16) on the attention projections only</li><li>Gradient checkpointing</li><li>A batch size of 1 with gradient accumulation to simulate a larger effective batch</li></ul><p>None of this is exotic it’s the standard playbook for training on consumer/free-tier GPUs but it’s worth saying out loud because a lot of tutorials assume you have an A100 sitting around.</p><p><strong>The reward function and where I cut a corner</strong></p><p>This is the part I want to be upfront about. I told the model, via the system prompt, to wrap its reasoning in &lt;think&gt; tags and its final answer in &lt;answer&gt; tags. My reward function checked for the presence of those tags half a point for each — and normalized the scores across the group of 4 rollouts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BTViU3eoBsLdN4w8t2rfgQ.png" /><figcaption>The GRPO reward function format-check only</figcaption></figure><p>What this reward function does <em>not</em> do is check whether the answer is actually correct. It only checks formatting. I knew this going in, and I want to be clear about why: building a reliable math-correctness reward (parsing the model’s numeric answer, comparing it to ground truth, handling edge cases like fractions or units) is its own project, and I wanted to first confirm the training loop itself was stable before adding that complexity. It’s a real limitation, not an oversight I’m hiding and it directly explains the results below.</p><p><strong>Training</strong></p><p>200 steps, checkpointing every 50, resuming automatically if a session got interrupted (which, on Kaggle’s free tier, it will). I logged reward, KL divergence, entropy, and completion length throughout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z237xnqQUw58pdu_URG51Q.png" /><figcaption>Reward curves over 200 training steps</figcaption></figure><p>The format-adherence reward climbed steadily and mostly plateaued near max value after roughly 100 steps which makes sense, since tag formatting is a comparatively easy pattern for a 3B model to pick up. The KL term stayed within a reasonable band, meaning the fine-tuned policy didn’t drift wildly from the base model, which is a good sign the training wasn’t destabilizing.</p><p><strong>Testing on a few hand-picked questions</strong></p><p>Before running any real evaluation, I sanity-checked the model on a handful of individual problems a simple linear equation, a percentage calculation, a two-variable word problem about chickens and cows. It got all of them right, with clean step-by-step reasoning inside the &lt;think&gt; tags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*yZ-pXx4G6NNKslROtrsQ1A.png" /><figcaption>Model output showing step-by-step reasoning</figcaption></figure><p>It would have been easy to stop here and call it a success. Three for three sounds great. But three questions is not a benchmark, and I didn’t want to publish a number that looked better than it was.</p><p><strong>The real test: 50 unseen GSM8K questions</strong></p><p>So I ran a proper evaluation 50 questions randomly sampled from the GSM8K test set, none of which the model had seen during training, with greedy decoding so results are reproducible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*VRvKALZtksbOkpdjc5GTWg.png" /><figcaption>Final benchmark: 52% accuracy on 50 unseen questions</figcaption></figure><p><strong>52% accuracy.</strong> Twenty-six out of fifty correct.</p><p>That’s a meaningfully lower number than the earlier three-question test suggested, and it’s the number I’d actually put on a resume or in a report not the misleadingly clean 100%. It’s a reminder of something obvious in hindsight: a reward function that only checks formatting will teach a model to <em>format</em> its reasoning correctly, not to <em>reason</em> correctly. The model learned to wrap things in tags reliably. It did not fully learn to get the math right.</p><p><strong>What I’d do differently</strong></p><p>If I were extending this, the first thing I’d change is the reward function adding a correctness term that extracts the model’s final numeric answer and compares it against the ground truth, on top of the existing format check. I’d also want a baseline number: what does the <em>un-fine-tuned</em> Qwen2.5–3B score on the same 50 questions? Without that comparison, I can’t actually say GRPO training improved anything I can only say the final model scores 52%. That comparison is the next thing on my list.</p><p>I’d also run the full 1,319-question GSM8K test set rather than 50, since 50 questions leaves a fairly wide margin of error on the accuracy estimate.</p><p><strong>Why this is still worth doing</strong></p><p>Even with a limited reward function, this project is a working, end-to-end GRPO pipeline: quantized model loading, LoRA, custom reward shaping, checkpoint resumption, and a real (if imperfect) evaluation all running on hardware anyone can get for free. The gap between “3 for 3 on cherry-picked questions” and “26 for 50 on unseen questions” is, in a way, the most useful part of the write-up. It’s the kind of gap that shows up constantly in ML work and rarely gets talked about honestly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8102a8e6c06b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-Tuning a Vision Language Model with QLoRA for Document-to-Markdown Generation]]></title>
            <link>https://medium.com/@hjethani20/fine-tuning-a-vision-language-model-with-qlora-for-document-to-markdown-generation-ec0dcb92f0d1?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec0dcb92f0d1</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Sun, 03 May 2026 18:29:38 GMT</pubDate>
            <atom:updated>2026-05-03T18:29:38.063Z</atom:updated>
            <content:encoded><![CDATA[<p>How we fine-tuned Qwen2-VL-2B-Instruct using parameter-efficient QLoRA to convert document images into structured Markdown</p><h3>Introduction</h3><p>Every researcher, student, and professional has faced this problem you have a scanned document, a PDF page, or a photograph of a research paper, and you need its content in a clean, editable, structured format. Traditional OCR tools extract raw text, but they lose all formatting headings disappear, equations become gibberish, and structure is gone entirely.</p><p>What if a model could look at a document image and produce perfectly structured Markdown with headings, equations, bullet points, and all?</p><p>That is exactly what we built.</p><p>In this blog, we walk through our complete pipeline for fine-tuning <strong>Qwen2-VL-2B-Instruct</strong> — a state-of-the-art Vision Language Model using <strong>QLoRA (Quantized Low-Rank Adaptation)</strong> on the <strong>Nougat</strong> and <strong>LaTeX OCR</strong> datasets to generate structured Markdown from document images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OLiEpP9AMcpcSZYl.png" /></figure><h3>What is a Vision Language Model (VLM)?</h3><p>A Vision Language Model is a multimodal neural network that can process both images and text simultaneously. Unlike traditional language models that only understand text, VLMs have a vision encoder that processes images and a language decoder that generates text based on what it “sees.”</p><p><strong>Qwen2-VL-2B-Instruct</strong> is developed by Alibaba’s Qwen team and is one of the most capable open-source VLMs at the 2B parameter scale. It supports high-resolution image understanding, making it ideal for document understanding tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/0*GLt6kn9jXxK0t8MW.png" /></figure><h3>Why QLoRA Instead of Full Fine-Tuning?</h3><p>Full fine-tuning of a 2B parameter model requires enormous GPU memory easily 40–80GB VRAM. We were working on Kaggle’s free T4 GPU with only 15GB VRAM per GPU.</p><p><strong>QLoRA solves this with two tricks:</strong></p><p><strong>1. 4-bit Quantization: </strong>The base model weights are compressed from 32-bit floats to 4-bit integers, reducing memory by ~8x. The model’s original knowledge is preserved but stored more efficiently.</p><p><strong>2. LoRA Adapters: </strong>Instead of updating all 2 billion parameters, we freeze the base model completely and only train small “adapter” matrices injected into the attention layers. These adapters have only ~1–2% of the total parameters but capture task-specific knowledge effectively.</p><p>The result: we fine-tuned a 2B parameter VLM on a single T4 GPU in just over an hour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L9Ob2vpzxY1r-S65.png" /></figure><h3>Dataset</h3><p>We used two complementary datasets:</p><h3>1. Nougat Training Dataset (Primary Required)</h3><ul><li>14,200 image-markdown pairs from scientific papers</li><li>Covers physics, mathematics, and computer science papers</li><li>Each sample: a page image + its corresponding .mmd Markdown</li></ul><h3>2. LaTeX OCR Dataset (Secondary HuggingFace)</h3><ul><li>Source: unsloth/LaTeX_OCR on HuggingFace</li><li>68,686 samples of mathematical expressions as images paired with LaTeX/Markdown</li><li>Adds diversity especially for equation-heavy documents</li></ul><p>We selected <strong>300 Nougat + 50 LaTeX OCR</strong> samples for training due to T4 compute constraints, with an 80/20 train-validation split.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vTYfX-NIXPP5czzg.png" /></figure><h3>Data Preparation ChatML Format</h3><p>Qwen2-VL expects data in <strong>ChatML format</strong> — a structured conversation format where each training sample is a user-assistant exchange:</p><p>{<br>“messages”: [<br>{<br>“role”: “user”,<br>“content”: [<br>{“type”: “image”, “image”: “path/to/image.png”},<br>{“type”: “text”, “text”: “Convert this document image to structured Markdown.”}<br>]<br>},<br>{<br>“role”: “assistant”,<br>“content”: “# Document Title\n\nThis is the extracted markdown…”<br>}<br>]<br>}</p><p>Every image-markdown pair was converted into this format before training.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*OZ1hh-O7kMPi_FV2.png" /></figure><p><strong>Trainable parameters: only ~1.2% of total</strong> this is the power of QLoRA.</p><h3>Training Results</h3><p>The training loss dropped dramatically from <strong>~10.5 at step 1 to ~4.0 by the end</strong> a clear sign the model learned the document-to-markdown mapping.</p><p>Total Steps : 280<br>Training Loss : 4.6338<br>Time Taken : 1h 9m<br>Val Loss : 4.2802</p><p>The validation loss remained stable and close to training loss no significant overfitting despite the small dataset.</p><h3>Inference Results</h3><p>After fine-tuning, we tested the model on both training images and completely unseen document images.</p><p><strong>Example Unseen Sample 2:</strong></p><p><em>Ground Truth:</em></p><p>an interstellar cloud that has been shocked, and is in the<br>process of being disrupted by hydrodynamic instabilities.<br>The basis of our premise is that the morphology of the<br>bar and cap strongly resemb…</p><p>Model Prediction:</p><p>an interstellar cloud that has been shocked, and is in the<br>process of being disrupted by hydrodynamic instabilities.<br>The basis of our premise is that the morphology of the<br>bar and cap strongly resemb…</p><p>Nearly identical! The model generalized well to unseen documents.</p><h3>Zero-Shot vs Fine-Tuned Bonus Analysis</h3><p>We ran the base model (before any fine-tuning) on the same unseen images. The zero-shot output was mostly incoherent or unrelated to the document content.</p><p><strong>After just 2 epochs of QLoRA fine-tuning:</strong></p><ul><li>ROUGE-1 jumped from 0.0053 → 0.3724</li><li>CER dropped from 0.9962 → 0.7317</li><li>Model started correctly identifying document structure, headings, and equations</li></ul><p>This demonstrates that even minimal fine-tuning with QLoRA on a small dataset produces dramatic improvements for specialized tasks.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*uASmscJD-Hf1ivS8.png" /></figure><h3>Live Demo Gradio App</h3><p>We deployed the fine-tuned model as a live Gradio app on HuggingFace Spaces.</p><p><a href="https://huggingface.co/spaces/zahidmiana/DocumentTOMarkdown"><strong>Live Demo:</strong></a></p><p><a href="https://huggingface.co/spaces/haresh8765/EasyMarkdown">https://huggingface.co/spaces/haresh8765/EasyMarkdown</a></p><p>Upload any document image a research paper page, a math textbook scan, or a printed document and the model generates structured Markdown instantly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jPom3Gbb7DO6bZlI.png" /></figure><h3>Challenges We Faced</h3><p><strong>1. GPU Memory Constraints: </strong>T4 has only 15GB VRAM. We had to carefully tune batch size, sequence length, and dataset size to fit everything in memory.</p><p><strong>2. Training Speed</strong> : QLoRA on a Vision model is inherently slow (~0.07 it/s on T4). We reduced dataset size from 3500 to 350 samples to get training done in reasonable time.</p><p><strong>3. Dataset Path Issues: </strong>Kaggle mounts datasets differently than expected. The Nougat dataset was nested under /kaggle/input/datasets/zphilip/ instead of the standard path.</p><p><strong>4. HuggingFace Space Deployment: </strong>Free Spaces have no GPU, so we had to remove 4-bit quantization and run inference on CPU for the deployed app.</p><h3>Conclusion</h3><p>In this project, we successfully fine-tuned <strong>Qwen2-VL-2B-Instruct</strong> using <strong>QLoRA</strong> for document-to-markdown generation. Key achievements:</p><ul><li>Parameter-efficient fine-tuning with only ~1.2% trainable parameters</li><li>70x improvement in ROUGE-1 over zero-shot baseline</li><li>Complete pipeline from data preparation to live deployment</li><li>Working Gradio app deployed on HuggingFace Spaces</li></ul><p>QLoRA makes it possible to fine-tune billion-parameter VLMs on consumer hardware — opening up multimodal AI to researchers and students who don’t have access to expensive GPU clusters.</p><p><em>Written by </em><strong><em>Haresh Kumar (22F-3076) </em></strong><em>&amp;</em><strong><em> Zahid Iqbal (22P-9077)</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec0dcb92f0d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Diffusion Models: How I Built a Face Generator from Pure Noise]]></title>
            <link>https://medium.com/@hjethani20/diffusion-models-how-i-built-a-face-generator-from-pure-noise-7a2ae68b4739?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a2ae68b4739</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 20:33:24 GMT</pubDate>
            <atom:updated>2026-04-28T20:51:50.633Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Random Pixels to Realistic Faces Using DDPM + U-Net</h3><h3>Introduction</h3><p>Have you ever wondered how AI generates realistic human faces from nothing? No starting image, no reference — just pure random noise that slowly becomes a face. That is exactly what I built for my Generative AI assignment, and in this blog I will walk you through the entire journey.</p><p>The model is called <strong>DDPM Denoising Diffusion Probabilistic Model</strong>. It was introduced in 2020 and has since become one of the most powerful approaches in generative AI, forming the backbone of modern tools like Stable Diffusion and DALL-E.</p><h3>What is a Diffusion Model?</h3><p>Think of it like this. Take a clear photo of a face. Now slowly add noise to it a little at step 1, more at step 50, and by step 400 it is just pure random static. This is called the <strong>Forward Process</strong>.</p><p>Now flip it. Train a neural network to reverse this given a noisy image at step 400, predict what step 399 looked like. Do this repeatedly from pure noise all the way to step 0, and you get a brand new realistic face. This is the <strong>Reverse Process</strong> and this is how generation works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Ei1FmJKE4DWUXJG.png" /></figure><h3>The Architecture: U-Net</h3><p>The brain of the reverse process is a <strong>U-Net </strong>originally designed for medical image segmentation but perfectly suited for diffusion models.</p><p>Input (Noisy Image + Timestep)<br>↓<br>[64ch Encoder] ──────────────────────→ [64ch Decoder]<br>↓ ↑<br>[128ch Encoder] ─────────────────→ [128ch Decoder]<br>↓ ↑<br>[256ch Bottleneck + Attention] ────────────<br>↓<br>Output (Predicted Noise)</p><h3>The key components are:</h3><ul><li><strong>Residual Blocks</strong> :prevent vanishing gradients, stable training</li><li><strong>Attention Blocks</strong> : help the model focus on important facial features</li><li><strong>Timestep Embeddings</strong> : tell the model which noise level it is working at</li><li><strong>Skip Connections</strong> : preserve fine details like eyes and lips</li></ul><h3>Dataset</h3><p>I used <strong>CelebA-HQ 256</strong> dataset from Kaggle — 30,000 high quality celebrity face images. Images were resized to <strong>128×128</strong> for training on Kaggle T4×2 GPU within memory limits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4RvyQYOXn8BJ0LbC.png" /></figure><p>One important thing I implemented was <strong>checkpoint resume</strong> if the Kaggle session crashes due to OOM (out of memory), training automatically continues from where it stopped. This saved me multiple times during training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xv8BzGfGvQF5U_P-.png" /></figure><h3>Loss Curve</h3><p>The training loss decreased steadily from around 0.09 at epoch 1 down to 0.022 by epoch 13, showing stable and healthy training with no signs of overfitting or divergence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TKE49TFOG8-z4BCl.png" /></figure><h3>Results</h3><p>After training, I used <strong>DDIM sampling </strong>a faster variant that generates high quality images in just 50 steps instead of 400.</p><p>Generated Images (Pure Noise → Face)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aoZmGD6yo2BVaZ7k.png" /></figure><p>Image Reconstruction</p><p>Given a target face, the model adds noise and then reconstructs it through the reverse process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3hckQHvGFtbDu8Gv.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/0*l3fQ6ilo6pBCeYmI.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a2ae68b4739" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From DCGAN to CycleGAN: Building Stable Anime Generation and Image Translation Systems with GANs]]></title>
            <link>https://medium.com/@hjethani20/from-dcgan-to-cyclegan-building-stable-anime-generation-and-image-translation-systems-with-gans-9b723bc14b71?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b723bc14b71</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 06:14:57 GMT</pubDate>
            <atom:updated>2026-04-18T23:56:39.208Z</atom:updated>
            <content:encoded><![CDATA[<p>Generative Adversarial Networks (GANs) have reshaped modern computer vision, enabling machines to generate realistic images, translate between domains, and even assist in creative workflows like digital art.</p><p>But behind the impressive results lies a difficult truth: GANs are notoriously unstable to train.</p><p>In this article, I share a complete journey through three progressively advanced GAN implementations:</p><ul><li>DCGAN to WGAN-GP for anime face generation</li><li>Pix2Pix for sketch colorization</li><li>CycleGAN for unpaired image translation</li></ul><p>This is not just a collection of models — it is a practical exploration of how improving loss functions and training strategies can transform unstable systems into reliable ones.</p><h3>The Beginning: DCGAN and Its Limitations</h3><p>The journey started with a standard Deep Convolutional GAN trained on an anime faces dataset.</p><p>The setup was simple:</p><ul><li>A Generator creates images from noise</li><li>A Discriminator classifies them as real or fake</li><li>Training is guided using Binary Cross-Entropy loss</li></ul><p>At first, the results looked promising. The model learned to generate recognizable anime faces. However, the limitations quickly became apparent.</p><p>The generator began producing nearly identical faces repeatedly — a classic case of mode collapse. At the same time, training became unstable, and image quality suffered from blurriness and artifacts.</p><p>Another major issue was vanishing gradients. Once the discriminator became too strong, the generator stopped receiving meaningful feedback, effectively halting learning.</p><p>It was clear that a more robust approach was needed.</p><h3>Moving Forward: WGAN-GP and Stable Training</h3><p>To address these issues, the model was upgraded to Wasserstein GAN with Gradient Penalty (WGAN-GP).</p><p>Instead of predicting probabilities, the discriminator was replaced with a critic that estimates the distance between real and generated data distributions. This shift from classification to distance measurement made a significant difference.</p><p>The use of Wasserstein distance provided smooth and meaningful gradients, ensuring that the generator continued learning even when the critic became strong.</p><p>Gradient penalty replaced weight clipping, enforcing stability without limiting the model’s capacity.</p><p>Additionally, batch normalization was removed from the critic and replaced with instance or layer normalization to ensure correct gradient behavior.</p><p>The results were immediately noticeable. Training became stable, generated faces were sharper, and most importantly, diversity returned. The model was no longer stuck producing a single type of face.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/0*7VbExslQ730aMuWL" /></figure><h3>Controlled Generation: Sketch Colorization with Pix2Pix</h3><p>After solving generation stability, the next step was controlled image translation.</p><p>The goal was simple: convert black-and-white anime sketches into fully colored images.</p><p>For this task, a paired dataset was used where each sketch had a corresponding colored version. The images were split, resized to 128 by 128, and normalized for training.</p><p>The model architecture was based on Pix2Pix, a conditional GAN framework.</p><p>The generator used a U-Net architecture, which includes skip connections between encoder and decoder layers. These connections preserve fine details, ensuring that the structure of the sketch remains intact during colorization.</p><p>The discriminator followed a PatchGAN approach, focusing on local image patches instead of the entire image. This helps produce realistic textures and sharp details.</p><p>Training used a combination of adversarial loss for realism and L1 loss for structural accuracy. A high weight was assigned to the L1 loss to ensure that the generated image closely followed the ground truth.</p><p>With optimizations like dual GPU training and mixed precision, the model achieved fast and stable convergence.</p><p>The results were strong. The model produced vibrant, accurate colorizations while preserving the original sketch structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/0*XK3GWjXXJ8RNMjhJ" /></figure><h3>Going Further: Unpaired Translation with CycleGAN</h3><p>The final stage tackled a more challenging problem: translating images between domains without paired data.</p><p>This included tasks like:</p><ul><li>Sketch to photo</li><li>Photo to sketch</li></ul><p>CycleGAN solves this using cycle consistency. The idea is that if an image is translated to another domain and then back again, the final output should match the original input.</p><p>The architecture included two generators and two discriminators. The generators were based on a ResNet architecture, optimized for memory efficiency, while the discriminators used PatchGAN to enforce local realism.</p><p>Training involved three types of losses:</p><ul><li>Adversarial loss for realism</li><li>Cycle consistency loss for structure preservation</li><li>Identity loss for maintaining style and color</li></ul><p>Since no direct ground truth exists, evaluation was performed using cyclic reconstruction metrics like SSIM and PSNR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*y9APhPen5sc0o-YH3xrYXA.png" /></figure><h3>A Key Real-World Insight: Domain Shift</h3><p>One of the most interesting observations came during testing.</p><p>The model performed very well on rough, hand-drawn sketches similar to the training dataset. However, it struggled when given clean, digital line art.</p><p>This highlighted a critical concept in machine learning: models only perform well on data distributions they have seen during training.</p><p>This kind of domain mismatch is a common challenge in real-world deployments.</p><h3>Deployment and Interactive Applications</h3><p>All three models were deployed using Gradio and Hugging Face Spaces, allowing real-time interaction.</p><p>Users can:</p><ul><li>Generate anime faces</li><li>Upload sketches for colorization</li><li>Translate sketches into realistic images</li><li>Compare outputs between models</li></ul><p>Anime Face Generator<br><a href="https://huggingface.co/spaces/haresh8765/Anime-Face-Generator-WGANGP">https://huggingface.co/spaces/haresh8765/Anime-Face-Generator-WGANGP</a></p><p>Anime Sketch Colorizer<br><a href="https://huggingface.co/spaces/haresh8765/pix2pix-anime-magic">https://huggingface.co/spaces/haresh8765/pix2pix-anime-magic</a></p><p>CycleGAN Translator<br><a href="https://huggingface.co/spaces/haresh8765/sketch-to-photo-generator-Cyclegan">https://huggingface.co/spaces/haresh8765/sketch-to-photo-generator-Cyclegan</a></p><h3>Final Thoughts</h3><p>This journey from DCGAN to WGAN-GP, Pix2Pix, and CycleGAN demonstrates how GANs evolve from unstable models into powerful systems when designed correctly.</p><p>The most important takeaway is simple:</p><p>Improving how a model learns is often more impactful than changing what the model looks like.</p><p>By refining loss functions, stabilizing training, and understanding data distribution, it is possible to build systems that are not only technically sound but also practically useful.</p><h3>Team</h3><p>This project was developed collaboratively by:</p><p>Haresh Kumar<br> Zahid Iqbal</p><h3>Tags</h3><p>#MachineLearning #DeepLearning #GANs #ComputerVision #ArtificialIntelligence #PyTorch #ImageProcessing #GenerativeAI<br> #DataScience#AIProjects</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b723bc14b71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Self-Supervised Learning: Building a Masked Autoencoder (MAE) from Scratch]]></title>
            <link>https://medium.com/@hjethani20/demystifying-self-supervised-learning-building-a-masked-autoencoder-mae-from-scratch-8f82b146f78f?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f82b146f78f</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 21:23:27 GMT</pubDate>
            <atom:updated>2026-03-08T21:23:27.970Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>A deep dive into the architecture and training of a custom Vision Transformer that learns by predicting 75% missing image data.</strong></p><p>For years, the progress of Computer Vision was bottlenecked by a single, expensive resource: <strong>labeled data</strong>. Training robust models required millions of human-annotated images. However, the paradigm is shifting. <strong>Self-Supervised Learning (SSL)</strong> allows models to learn rich, complex representations from raw, unlabeled data.</p><p>In this article, I will walk you through my recent project, <strong>Mask2Rep</strong>, where I built and trained a custom <strong>Masked Autoencoder (MAE)</strong> from scratch using PyTorch. We will dive deep into the math, the asymmetric architecture, and the training pipeline that enables an AI to hallucinate 75% of an image based entirely on context.</p><blockquote><strong><em>💡 What is a Masked Autoencoder (MAE)?</em></strong><em> &gt; The core idea behind MAE is brilliantly simple but extremely powerful. An input image is divided into patches, and a very high percentage (typically 75%) of these patches are randomly masked (hidden). The model’s encoder processes only the visible patches, and a lightweight decoder attempts to reconstruct the full original image. This extreme masking forces the model to learn a holistic understanding of object shapes and textures rather than just memorizing local pixels.</em></blockquote><h3>Step 1: Patchification and Random Masking</h3><p>The first step in our pipeline is converting a 2D image into a sequence of 1D tokens, similar to how text is fed into Language Models.</p><p>For a standard 224x224 image, we divide it into non-overlapping 16x16 patches. This gives us a grid of 14x14, or <strong>196 total patches</strong>.</p><p>Next comes the crucial masking step. I implemented a random masking strategy with a mask_ratio of 0.75.</p><ol><li>We generate random noise for each of the 196 patches.</li><li>We sort this noise to randomly shuffle the indices.</li><li>We keep only the top 25% (49 patches) and drop the remaining 75% (147 patches).</li></ol><p>Only the 49 visible patches are passed to the Encoder. This is the secret to MAE’s incredible computational efficiency.</p><h3>Step 2: The Asymmetric Encoder-Decoder Architecture</h3><p>The heart of Mask2Rep is an <strong>Asymmetric Vision Transformer (ViT)</strong>.</p><blockquote><strong><em>🏗️ Why Asymmetric?</em></strong><em> &gt; It is “asymmetric” because the Encoder is heavy and deep, while the Decoder is lightweight and shallow. Since the encoder only operates on the 25% visible patches, making it deep doesn’t exponentially increase the compute cost. The decoder, which processes all 100% of the patches (visible + masked), is kept shallow to save memory.</em></blockquote><h4>1. The Heavyweight Encoder</h4><p>The encoder’s job is to map the visible patches into a rich latent space.</p><ul><li><strong>Patch Embedding:</strong> A linear projection maps the RGB patches into an embedding dimension of <strong>768</strong>.</li><li><strong>Positional Embedding:</strong> Since transformers are permutation-invariant, we add 1D positional embeddings to let the model know where each patch belongs in the original image.</li><li><strong>Transformer Blocks:</strong> The data passes through <strong>12 deep Transformer blocks</strong>, utilizing Multi-Head Self-Attention (12 heads) and MLP layers.</li></ul><h4>2. The Lightweight Decoder</h4><p>The decoder’s job is to take the encoder’s latent representations and reconstruct the original pixels.</p><ul><li><strong>Dimensionality Reduction:</strong> The 768-dimensional latent vectors are projected down to a smaller dimension of <strong>384</strong>.</li><li><strong>Mask Tokens Introduced:</strong> Here, we re-introduce the 75% missing patches as shared, learnable “mask tokens.” We add positional embeddings to all tokens.</li><li><strong>Reconstruction:</strong> The full set of 196 tokens passes through a shallower network of <strong>12 Transformer blocks</strong> (with 6 attention heads). Finally, a linear projection maps the features back into the original pixel values.</li></ul><h3>Step 3: Training the Beast</h3><p>Training a Vision Transformer requires careful handling of hyperparameters and compute.</p><blockquote><strong><em>⚙️ Key Training Configurations</em></strong><em> &gt; * </em><strong><em>Hardware:</em></strong><em> Kaggle Nvidia Tesla T4 GPUs</em></blockquote><ul><li><strong>Mask Ratio:</strong> 0.75 (Extreme masking)</li><li><strong>Loss Function:</strong> Mean Squared Error (MSE)</li><li><strong>Loss Calculation:</strong> Computed only on the masked patches.</li></ul><p>I trained this architecture entirely on <strong>Kaggle</strong>. The combination of a high masking ratio and an encoder that only processes visible patches meant I could train a heavy 1.29 GB model efficiently.</p><blockquote><strong><em>📉 Visualizing the Learning Process (Epochs)</em></strong><em> As the training progressed through multiple epochs, the transformation was fascinating to watch. In the initial epochs, the model’s output was essentially blurry gray noise. However, as the MSE loss dropped epoch by epoch, the model began capturing high-frequency details, sharp edges, and contextually accurate shapes.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*apW3bydWhfCDv0U7Nbeedw.png" /></figure><h3>See it in Action: Live Interactive Demo</h3><p>Building models in a Jupyter Notebook is fun, but AI is meant to be interacted with. I have deployed the fully trained model to the cloud so you can test it yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYIvHaNpn_I1An1zbZkgTw.png" /></figure><p>You can drop any image into the application, and the Vision Transformer will automatically hide 75% of it and attempt to hallucinate the missing details in real-time.</p><p>🚀 <strong>Experience the Live Demo here:</strong><a href="https://huggingface.co/spaces/haresh8765/Mask2Rep-Self-Supervised-Image-Representation-Learning">https://huggingface.co/spaces/haresh8765/Mask2Rep-Self-Supervised-Image-Representation-Learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f82b146f78f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bridging Pixels and Prose: A Deep Dive into Neural Image Captioning with ResNet-50 and Attention]]></title>
            <link>https://medium.com/@hjethani20/bridging-pixels-and-prose-a-deep-dive-into-neural-image-captioning-with-resnet-50-and-attention-de2891f77636?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/de2891f77636</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 01:38:01 GMT</pubDate>
            <atom:updated>2026-02-14T16:27:00.559Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Subtitle:</strong> Bridging the gap between Computer Vision and Natural Language Processing</p><h3>1. Introduction: The Complexity of Multimodal AI</h3><p>Humans perceive the world through multiple senses simultaneously. Replicating this in AI requires a <strong>Multimodal</strong> architecture — a system that can “see” (Computer Vision) and “speak” (Natural Language Processing).</p><p>In this project, I developed an end-to-end <strong>Neural Image Captioning System</strong> that translates high-dimensional visual features into grammatically coherent English sequences. Unlike basic classifiers that label an image with a single word, this model generates descriptive narratives by understanding the relationship between objects.</p><p><strong>Live Demo:</strong> <a href="https://huggingface.co/spaces/haresh8765/image-caption-bot">https://huggingface.co/spaces/haresh8765/image-caption-bot</a></p><h3>2. Deep-Dive into the Model Architecture</h3><p>The system is built on a sophisticated <strong>Encoder-Decoder with Attention</strong> framework, optimized for spatial awareness and sequential accuracy.</p><h3>A. The Visual Encoder: A 50-Layer Feature Extractor</h3><p>For the vision component, I utilized <strong>Transfer Learning</strong> with a pre-trained <strong>ResNet-50</strong> backbone.</p><ul><li><strong>Architecture:</strong> 50 Residual layers (skip connections) to mitigate the vanishing gradient problem in deep networks.</li><li><strong>Modification:</strong> I bypassed the final Average Pooling and Fully Connected layers.</li><li><strong>Output Dimensionality:</strong> Instead of a single vector, the encoder produces a <strong>7 x 7 x 2048</strong> feature map. This preserves 49 distinct spatial regions of the image, allowing the model to focus on specific objects rather than the image as a whole.</li></ul><h3>B. The Attention Mechanism: Soft Visual Focus</h3><p>The “bridge” between vision and language is a <strong>Soft Attention layer</strong>.</p><ul><li><strong>Neuron Count:</strong> The attention MLP consists of a Linear layer with <strong>256 hidden units</strong>.</li><li><strong>Logic:</strong> It takes the current LSTM hidden state (h_t) and the encoder features to compute <strong>Alpha weights</strong>. These weights tell the decoder which of the 49 regions are most relevant for the next word.</li></ul><h3>C. The Language Decoder: Sequential LSTM</h3><p>The decoder is a sophisticated Recurrent Neural Network designed to maintain context over long sequences.</p><ul><li><strong>Word Embeddings:</strong> <strong>256-dimensional</strong> neurons that convert tokens into dense vector representations.</li><li><strong>LSTM Cells:</strong> A single-layer LSTM with <strong>512 hidden units</strong>.</li><li><strong>Gate Logic:</strong> It utilizes Input, Forget, and Output gates to manage the “memory” of what has already been said in the caption.</li><li><strong>The Output Head:</strong> A Linear layer mapping the 512-D hidden state to the total <strong>Vocabulary Size</strong> (e.g., 10,000+ neurons), followed by a Softmax activation to predict the word probability distribution.</li></ul><h3>3. Advanced Decoding Strategies: Why Beam Search Matters</h3><p>Generating a caption isn’t just about picking the “most likely” word. I implemented two strategies to compare performance:</p><ul><li><strong>Greedy Search (k=1):</strong> Picks the highest probability word at each step. While fast, it often leads to repetitive or logically stuck sequences.</li><li><strong>Beam Search (k=3):</strong> This is a heuristic search algorithm that explores multiple possibilities. It keeps the <strong>top 3 most probable sequences</strong> alive at every step. This drastically improves the grammatical structure and descriptive depth of the results.</li></ul><h3>4. Training Specifications &amp; Performance</h3><ul><li><strong>Dataset:</strong> <strong>Flickr30k</strong> (31,000+ images, 155,000+ captions).</li><li><strong>Loss Function:</strong> Categorical Cross-Entropy.</li><li><strong>Optimizer:</strong> Adam Optimizer with a learning rate of $4 \times 10^{-4}$.</li><li><strong>Regularization:</strong> <strong>Dropout (0.5)</strong> in the decoder to prevent the model from memorizing the training captions (overfitting).</li></ul><p><strong>Component </strong>Dimensionality / NeuronsEncoder</p><p><strong>Output </strong>2048 (channels)</p><p><strong>Attention Dim </strong>256</p><p><strong>Embedding Dim </strong>256</p><p><strong>LSTM Hidden Dim </strong>512</p><p><strong>Beam Width </strong>3</p><h3>5. Summary &amp; Engineering Challenges</h3><p>The primary engineering challenge was <strong>Tensor Dimensionality Alignment</strong>. Aligning the 2048-D features from a 50-layer CNN with a 512-D LSTM required careful linear projection and normalization.</p><p>Through this project, I demonstrated that <strong>Attention Mechanisms</strong> are not just for Transformers; they are essential for any system where the model must “reason” about the spatial relationship between visual input and linguistic output.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de2891f77636" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating and Accessing a Cloud‑Hosted Linux Virtual Machine on AWS]]></title>
            <link>https://medium.com/@hjethani20/creating-and-accessing-a-cloud-hosted-linux-virtual-machine-on-aws-86c626a13bda?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/86c626a13bda</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 12:40:21 GMT</pubDate>
            <atom:updated>2026-02-08T12:40:21.880Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Cloud computing has made it incredibly easy for students and professionals to experiment with real infrastructure without buying physical hardware. In this post, I will walk through how I created, secured, and used a Linux virtual machine (VM) on Amazon Web Services (AWS) as part of my Cloud Computing course assignment. The same steps are a solid starting point for anyone who wants hands‑on experience with the cloud.</em></blockquote><h3>1. Setting Up the AWS Environment and Launching an EC2 Instance</h3><p>The first step was to prepare the cloud environment. After creating my AWS account with a supported payment method, I signed in to the AWS Management Console and navigated to the EC2 service. From the EC2 dashboard, I used the “Launch instance” wizard to create a new virtual machine.</p><p>I chose “Ubuntu Server 24.04 LTS” as the Amazon Machine Image (AMI) and selected a free‑tier‑eligible instance type (t3.micro), which is more than enough for basic experiments. I kept the default VPC and subnet, and made sure that “Auto‑assign Public IP” was enabled so the instance could be accessed from the internet. During this process I also configured an initial security group that allowed SSH access on port 22 from my own IP address. After reviewing the settings, I launched the instance and waited a short time for it to enter the “running” state with an assigned public IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*81N0vpfdmhYB5f6F.png" /><figcaption>Instance Creation (Name, Number of Instances etc)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cj2vw9qMb80Cyol4.png" /><figcaption>Instance Created (Summary)</figcaption></figure><h3>2. Configuring SSH Key‑Based Access</h3><p>To manage the VM securely, I used key‑based SSH authentication instead of simple passwords. While launching the instance, AWS prompted me to create or select an existing key pair. I created a new key pair named cloude-pehli-key, downloaded the .pem private key file to my local Fedora machine, and stored it in the ~/.ssh directory.</p><p>On Fedora, I adjusted the key file permissions so that only my user account could read it:</p><pre>chmod 400 ~/.ssh/cloude-pehli-key.pem</pre><p>With this in place, the key pair became my secure “identity” for logging in to the EC2 instance. Anyone without this private key would be unable to authenticate, which significantly improves security compared to using a plain password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CWeLonbrVqSgx0HL.png" /><figcaption>Create Key Pair (cloude-pehli-key)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oty4WCMl9IzBR-zk.png" /><figcaption>Permission Command</figcaption></figure><h3>3. Connecting to the VM via SSH</h3><p>Once the instance was running and the key pair was configured, I connected to the VM from my Fedora terminal using the SSH client:</p><pre>ssh -i ~/.ssh/cloude-pehli-key.pem ubuntu@13.60.171.18</pre><p>Here, ubuntu is the default username for the Ubuntu AMI, and 13.60.171.18 is the public IP address assigned to my EC2 instance. On the first connection, I accepted the host key fingerprint so my system could trust the remote server. After that, I was greeted by the Ubuntu login banner and shell prompt, confirming that I had successfully established a secure remote terminal session to my cloud‑hosted VM.</p><p>At this point I could run Linux commands, install packages, and manage the system exactly as if it were a physical server sitting on my desk.</p><h3>4. Configuring Firewall Rules with Security Groups</h3><p>Network security is a critical part of any cloud deployment. In AWS, inbound traffic to an EC2 instance is controlled by security groups. To support the rest of the assignment tasks, I needed to open additional ports besides SSH.</p><p>From the EC2 console, I selected my instance, opened the Security tab, and edited the inbound rules of the attached security group. I added the following rules:</p><ul><li>SSH (port 22) from my IP address for secure terminal access</li><li>RDP (port 3389) from my IP address for remote desktop access</li><li>HTTP (port 80) from anywhere so that a simple web server would be reachable publicly</li></ul><p>This configuration allowed only the services I needed while keeping all other ports closed. Combining instance‑level security groups with OS‑level firewall controls provides a layered security model for the VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s3gdJqzkQQ-S_GjT.png" /><figcaption>Configure Firewall Security Rules</figcaption></figure><h3>5. Enabling Remote Desktop (RDP) Access</h3><p>While SSH is perfect for command‑line administration, sometimes a graphical desktop is more convenient, especially for demonstrations. To enable remote desktop, I installed a lightweight desktop environment and xRDP on the Ubuntu instance.</p><p>After connecting via SSH, I ran:</p><pre>sudo apt update<br>sudo apt install -y xfce4 xfce4-goodies<br>sudo apt install -y xrdp<br>sudo usermod -a -G ssl-cert xrdp<br>sudo systemctl restart xrdp</pre><p>I also ensured that port 3389 was allowed in the Ubuntu firewall (if enabled) and that the AWS security group rule for RDP was in place. Next, I set a password for the ubuntu user:</p><pre>sudo passwd ubuntu</pre><p>On my local Fedora machine, I installed an RDP client (Remmina / GNOME Connections) and created a new connection using the instance’s public IP address (13.60.171.18), username ubuntu, and the password I had just configured. This allowed me to initiate graphical sessions to the cloud VM over RDP, providing a full desktop experience running in the cloud but controlled from my local system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PvQH-MLg44Vu62mC.png" /><figcaption>Remote Desktop Configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qfJ5TzZKFos7OTMX.png" /><figcaption>RDP Configured (Successfully</figcaption></figure><h3>6. Hosting Files with a Simple HTTP Server</h3><p>The final technical task was to host files on the VM and access them using its public IP address. Still connected via SSH, I created a directory for web content:</p><pre>mkdir ~/webfiles<br>cd ~/webfiles<br>echo &quot;Cloud Computing Assignment 1 - Test Page&quot; &gt; index.html</pre><p>To expose this folder over HTTP, I used Python’s built‑in web server:</p><pre>sudo apt install -y python3<br>sudo python3 -m http.server 80</pre><p>Because port 80 was already allowed in the security group, I could open a browser on my local machine and visit:</p><pre>http://13.60.171.18/</pre><p>The test page loaded successfully, confirming that the instance was serving files to the public internet. This simple approach is ideal for quick demos and assignments, though in production one would typically use a full web server such as Apache or Nginx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WzhY_nU10t494ZOQ.png" /><figcaption>Hosting File Configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AKhJ8uKZT6DsNRTr.png" /><figcaption>Successfully File Configuration (See on web)</figcaption></figure><h3>7. Lessons Learned and Best Practices</h3><p>Working through this exercise provided a practical understanding of how cloud infrastructure is created, secured, and accessed in real life. A few key takeaways stood out:</p><ul><li>Security from day one Using SSH key pairs, security groups, and restricted ports greatly reduces the attack surface.</li><li>Separation of concerns Instance‑level security (security groups) and OS‑level firewall rules complement each other.</li><li>Cost awareness It is important to stop or terminate unused instances and services after testing to avoid unnecessary charges.</li><li>Cross‑platform tools Managing AWS from Fedora using SSH and RDP clients demonstrates how flexible cloud‑based workflows can be, regardless of the local operating system.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86c626a13bda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Berkeley View of Cloud Computing]]></title>
            <link>https://medium.com/@hjethani20/a-berkeley-view-of-cloud-computing-f439ec123533?source=rss-af1e45ab4c28------2</link>
            <guid isPermaLink="false">https://medium.com/p/f439ec123533</guid>
            <dc:creator><![CDATA[Haresh kumar]]></dc:creator>
            <pubDate>Sat, 31 Jan 2026 17:17:17 GMT</pubDate>
            <atom:updated>2026-01-31T17:17:17.243Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2009, researchers of the University of California, Berkeley published a Berkeley View of Cloud Computing. The paper describes cloud computing and its reason why it was a revolution in IT industry. The authors define cloud computing as those applications that are offered on the internet (Software as a Service) and the IT infrastructure (hardware and software) that facilitate such services. The public cloud platforms enable startups and firms to roll out services without developing their own data centers. Elasticity is one of the largest benefits of cloud computing, as it implies that users can scale resources in either direction within a short period in accordance with the demand.</p><p>The paper singles out three revolutionary aspects of cloud computing:</p><blockquote>The delusion of unlimited computing resources.</blockquote><blockquote>None of the initial capital outlay.</blockquote><blockquote>Only pay the resources used.</blockquote><p>Cloud computing was unsuccessful in the past (2000–2005) because of bad infrastructure, slow internet connection and inadequate virtual machine technology. After 2009, it became successful, as such companies as Google, Amazon, and Microsoft had constructed large-scale data center. The economies of scale meant that costs were greatly minimized and the location of power and cooling was better to minimise operational costs. Another fact that is mentioned in the paper is that 5–20% of the time the traditional data centres are used, however, cloud computing eliminates it as the services are only charged when they are actually used.</p><p>There are three tiers of cloud services, and they include: Amazon EC2 with low-level control of the virtual machine; Microsoft Azure giving the medium-level platform environment; and Google App Engine giving the high-level platform and the developer merely deploys code. It is scalable and cost effective, as real-life stories of the Washington Post and the Black Friday traffic reveal. There is also the increase of various cloud providers, mobile cloud applications, and pay-as-you-go licensing models, which have been predicted by the authors.</p><h3><strong>State-of-the-Art and Research Challenges</strong></h3><p>The paper State-of-the-Art and Research Challenges, written in 2010 by researchers at the University of Waterloo, presents a survey of cloud computing technologies and discusses open research challenges. According to the NIST definition, cloud computing is a model that enables convenient, on-demand network access to shared computing resources that can be rapidly provisioned and released with minimal management effort.</p><p>The paper outlines six major benefits of cloud computing, including no upfront investment, lower operating costs, high scalability, easy accessibility, reduced business risks, and lower maintenance expenses. It describes cloud computing architecture as a four-layer model: hardware/data center layer, infrastructure layer, platform layer, and application layer. These layers are loosely coupled, allowing independent development and easier management.</p><p>The authors classify cloud deployment models into public, private, hybrid, and virtual private clouds. The paper also explains data center network design using a three-layer structure: access, aggregation, and core layers. Current technologies discussed include distributed file systems such as Google File System (GFS) and Hadoop HDFS, the MapReduce programming model, and commercial cloud platforms like Amazon EC2, Microsoft Azure, and Google App Engine. Finally, the paper identifies future research challenges, including automated provisioning, virtual machine migration, energy management, data security, and performance modeling.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f439ec123533" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>