<?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 Soham Lad on Medium]]></title>
        <description><![CDATA[Stories by Soham Lad on Medium]]></description>
        <link>https://medium.com/@ladsoham14202sk?source=rss-812a63d63616------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TdzbaVcBdtxsEogO8H-tyA.png</url>
            <title>Stories by Soham Lad on Medium</title>
            <link>https://medium.com/@ladsoham14202sk?source=rss-812a63d63616------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:47:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ladsoham14202sk/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[LeetCode 1984: Minimum Difference Between Highest and Lowest of K Scores (Explained Simply)]]></title>
            <link>https://python.plainenglish.io/leetcode-1984-minimum-difference-between-highest-and-lowest-of-k-scores-explained-simply-4cc3311581b7?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cc3311581b7</guid>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[leetcode]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 11:42:05 GMT</pubDate>
            <atom:updated>2026-02-01T11:42:05.460Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*4JpJ4QQQ7Vuff0VKkJ9xhQ.png" /></figure><p>Many array problems become significantly easier once we identify the right pattern.<br> LeetCode 1984 is a good example of how sorting combined with a sliding window can replace a brute-force approach with an efficient and elegant solution.</p><p>This article walks through the intuition, approach, and implementation in a clear and structured way.</p><h3>Problem Overview</h3><p>You are given an array nums representing scores.<br> Your task is to select exactly k scores such that the difference between the highest and lowest scores is minimized.</p><h3>Example</h3><pre>nums = [9, 4, 1, 7], k = 2</pre><p>Possible selections:</p><ul><li>(1, 4) → difference = 3</li><li>(4, 7) → difference = 3</li><li>(7, 9) → difference = 2</li></ul><p><strong>Minimum difference: 2</strong></p><h3>Intuition</h3><p>To minimize the difference between the maximum and minimum values, the chosen elements must be as close to each other as possible.</p><p>After sorting the array, elements with minimal differences become adjacent. This observation allows us to focus only on contiguous subarrays of size k, rather than checking all possible combinations.</p><h3>Approach</h3><ol><li>Sort the array in ascending order.</li><li>If k is equal to 1, return 0 since a single element has no difference.</li><li>Use a sliding window of size k over the sorted array.</li><li>For each window, compute the difference between the first and last elements.</li><li>Track the minimum difference found across all windows.</li><li>Return the minimum difference.</li></ol><h3>Python Implementation</h3><pre>class Solution:<br>    def minimumDifference(self, nums: List[int], k: int) -&gt; int:<br>        nums = sorted(nums)<br>        n = lennums)<br>        min_diff = float(&#39;inf&#39;)<br>        <br>        if k == 1:<br>            return 0<br>        for i in range(n - k + 1):<br>            diff = nums[i + k - 1] - nums[i]<br>            min_diff = min(min_diff, diff)<br>        return min_diff</pre><h3>Complexity Analysis</h3><ul><li><strong>Time Complexity:</strong><br> O(n log n), dominated by the sorting step.</li><li><strong>Space Complexity:</strong><br> O(n), due to the creation of a sorted array.</li></ul><h3>Conclusion</h3><p>This problem demonstrates how recognizing patterns such as sorting and sliding windows can simplify problem-solving and improve efficiency. Instead of exploring every possible combination, we leverage the properties of a sorted array to arrive at an optimal solution.</p><p>For interview preparation, problems like this reinforce the importance of identifying reusable algorithmic patterns rather than relying on brute force approaches.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cc3311581b7" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/leetcode-1984-minimum-difference-between-highest-and-lowest-of-k-scores-explained-simply-4cc3311581b7">LeetCode 1984: Minimum Difference Between Highest and Lowest of K Scores (Explained Simply)</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a “PDF-INSIGHTS : Chat with PDF” App Using Gemini 2.0]]></title>
            <link>https://medium.com/@ladsoham14202sk/building-a-pdf-insights-chat-with-pdf-app-using-gemini-2-0-b2547beb37a3?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2547beb37a3</guid>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Tue, 02 Dec 2025 17:36:57 GMT</pubDate>
            <atom:updated>2025-12-02T17:36:57.867Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a “PDF-INSIGHTS : Chat with PDF” App Using Gemini 2.0 Flash, LangChain,FastAPI, and Streamlit</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZLo0fzpM3OZNycjQEDV5GA.png" /></figure><p>Large Language Models (LLMs) have unlocked entirely new ways of interacting with information. One of the most practical applications today is the ability to <em>chat</em> with your own documents — whether you’re working with legal agreements, academic papers, financial reports, or project manuals.</p><p>In this guide, we’ll build <strong>PDF Insight AI</strong>, a Retrieval-Augmented Generation (RAG) application that lets you ask questions directly from your PDF documents. The system uses:</p><ul><li><strong>FastAPI</strong> for the backend</li><li><strong>Streamlit</strong> for the frontend</li><li><strong>FAISS</strong> for similarity search</li><li><strong>Hugging Face embeddings</strong></li><li><strong>Gemini 2.0 Flash</strong> as the LLM</li></ul><p>This walkthrough is designed for beginners looking to build hands-on projects to strengthen their AI engineering skills.</p><h3>Tech Stack Overview</h3><p><strong>LLM</strong><br> Google Gemini 2.0 Flash — a fast, cost-efficient model suitable for real-time querying.</p><p><strong>Backend</strong><br> FastAPI — a high-performance Python web framework for building APIs.</p><p><strong>Frontend</strong><br> Streamlit — creates a clean, interactive UI with minimal code.</p><p><strong>Orchestration</strong><br> LangChain — helps manage text splitting, chains, and model integration.</p><p><strong>Vector Store</strong><br> FAISS — performs efficient similarity search.</p><p><strong>Embeddings</strong><br> Hugging Face — sentence-transformers/all-MiniLM-L6-v2 for embedding text chunks.</p><h3>System Architecture</h3><p>The application follows a simple, scalable client-server architecture:</p><ul><li><strong>Backend (FastAPI):</strong><br> Handles PDF uploads, text extraction, chunking, embeddings, and answering queries.</li><li><strong>Frontend (Streamlit):</strong><br> Provides a chat interface, manages user interactions, and communicates with the backend.</li></ul><p>The backend processes documents once, stores them in memory (for simplicity), and performs retrieval + generation every time the user asks a question.</p><h3>Step 1: Building the RAG Engine (rag.py)</h3><p>The core of the system consists of three tasks:</p><ul><li>Extracting text from PDF files</li><li>Splitting the text into smaller chunks</li><li>Creating a vector store with embeddings</li></ul><h3>Text Chunking</h3><pre>from langchain_text_splitters import RecursiveCharacterTextSplitter<br>from langchain_community.vectorstores import FAISS<br>from langchain_huggingface import HuggingFaceEmbeddings</pre><pre>def create_chunks(text):<br>    splitter = RecursiveCharacterTextSplitter(<br>        chunk_size=1000,<br>        chunk_overlap=200<br>    )<br>    return splitter.split_text(text)</pre><h3>Creating Vector Store</h3><pre>def create_vectorstore(chunks):<br>    embeddings = HuggingFaceEmbeddings(<br>        model_name=&quot;sentence-transformers/all-MiniLM-L6-v2&quot;,<br>        model_kwargs={&quot;device&quot;: &quot;cpu&quot;}<br>    )<br>    return FAISS.from_texts(chunks, embeddings)</pre><h3>Retrieving and Responding</h3><pre>def rag_answer(vectorstore, query, history):<br>    docs = retrieve_docs(vectorstore, query)<br>    context = &quot;\n&quot;.join([doc.page_content for doc in docs])</pre><pre>    prompt = PromptTemplate(<br>        template=&quot;&quot;&quot;<br>        You are a helpful PDF assistant.<br>        Conversation so far: {history}<br>        Context: {context}<br>        Question: {query}<br>        &quot;&quot;&quot;<br>    )<br>    # Execute prompt with Gemini model<br>    # ...</pre><h3>Step 2: Creating the Backend API (main.py)</h3><p>The backend exposes two endpoints:</p><ul><li>POST /upload — uploads PDF files, processes them, and builds the vector store</li><li>POST /ask — retrieves answers from the processed documents</li></ul><pre>from fastapi import FastAPI, UploadFile, File<br>from rag import extract_text, create_chunks, create_vectorstore, rag_answer</pre><pre>app = FastAPI(title=&quot;PDF Insight RAG API&quot;)</pre><pre>VECTORSTORE = None<br>MEMORY = {}</pre><pre>@app.post(&quot;/upload&quot;)<br>async def upload_pdf(files: list[UploadFile] = File(...)):<br>    global VECTORSTORE<br>    text = extract_text(files)<br>    chunks = create_chunks(text)<br>    VECTORSTORE = create_vectorstore(chunks)<br>    return {&quot;message&quot;: &quot;PDF uploaded &amp; vector database created successfully!&quot;}</pre><pre>@app.post(&quot;/ask&quot;)<br>async def ask_question(data: Query):<br>    answer = rag_answer(VECTORSTORE, data.query, MEMORY)<br>    return {&quot;answer&quot;: answer}</pre><h3>Step 3: Building the Frontend UI (app.py)</h3><p>Streamlit makes frontend development straightforward. You can build a chat interface with only a few lines of code.</p><pre>import streamlit as st<br>import requests<br>import uuid</pre><pre>API_URL = &quot;<a href="http://localhost:8000/">http://localhost:8000</a>&quot;</pre><pre>st.set_page_config(page_title=&quot;PDF Insight&quot;, layout=&quot;wide&quot;)</pre><pre># Create a unique session ID for each user<br>if &quot;session_id&quot; not in st.session_state:<br>    st.session_state.session_id = str(uuid.uuid4())</pre><pre># Sidebar UI<br>with st.sidebar:<br>    st.title(&quot;💬 Chat with your PDF&quot;)<br>    st.write(&quot;Upload PDFs and chat with them in real time.&quot;)</pre><pre>uploaded_files = st.file_uploader(<br>        &quot;Upload PDF file(s)&quot;,<br>        type=[&quot;pdf&quot;],<br>        accept_multiple_files=True<br>    )</pre><pre>if st.button(&quot;Process PDF&quot;):<br>        if not uploaded_files:<br>            st.error(&quot;Please upload at least one PDF!&quot;)<br>        else:<br>            files = [<br>                (&quot;files&quot;, (f.name, f, &quot;application/pdf&quot;))<br>                for f in uploaded_files<br>            ]</pre><pre>with st.spinner(&quot;Creating vector database...&quot;):<br>                response = requests.post(f&quot;{API_URL}/upload&quot;, files=files)<br>                st.success(response.json()[&quot;message&quot;])</pre><pre>st.markdown(&quot;---&quot;)<br>st.write(&quot;Made with ❤️ using FastAPI + Streamlit + LangChain by SOHAM LAD&quot;)</pre><pre># Main Title<br>st.title(&quot;📄 PDF Insight RAG&quot;, anchor=False)</pre><pre># Initialize chat history<br>if &quot;messages&quot; not in st.session_state:<br>    st.session_state.messages = []</pre><pre># Display previous chat messages<br>for msg in st.session_state.messages:<br>    st.chat_message(msg[&quot;role&quot;]).markdown(msg[&quot;content&quot;])</pre><pre># User query input<br>query = st.chat_input(&quot;Ask something from your PDF...&quot;)</pre><pre>if query:<br>    # Show user message immediately<br>    st.chat_message(&quot;user&quot;).markdown(query)<br>    st.session_state.messages.append({&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: query})</pre><pre># Send request to FastAPI<br>    with st.spinner(&quot;Thinking...&quot;):<br>        response = requests.post(<br>            f&quot;{API_URL}/ask&quot;,<br>            json={<br>                &quot;session_id&quot;: st.session_state.session_id,<br>                &quot;question&quot;: query<br>            }<br>        )</pre><pre>answer = response.json().get(&quot;answer&quot;, &quot;Error: No answer returned&quot;)</pre><pre># Display assistant&#39;s response<br>    st.chat_message(&quot;assistant&quot;).markdown(answer)<br>    st.session_state.messages.append({&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: answer})</pre><h3>Running the Application</h3><p>Open two terminal windows.</p><p><strong>Backend</strong></p><pre>uvicorn main:app --reload</pre><p><strong>Frontend</strong></p><pre>streamlit run app.py</pre><p>Then open the Streamlit URL, upload a PDF, and start exploring your documents through natural language queries.</p><h3>Final Thoughts</h3><p>This project is just the starting point. You now have a working RAG setup that you can continue to refine, enhance, and build upon as your skills grow. There are many directions to explore — better retrieval, improved UI, multi-document support, and more. Keep experimenting and pushing forward; this is how real AI engineering confidence develops.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2547beb37a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building PDF Insight AI with LangChain, Gemini, Streamlit, and FAISS]]></title>
            <link>https://medium.com/@ladsoham14202sk/building-pdf-insight-ai-with-langchain-gemini-streamlit-and-faiss-a0d4d285d730?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0d4d285d730</guid>
            <category><![CDATA[google-gemini]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[ai-projects]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Tue, 18 Nov 2025 17:52:20 GMT</pubDate>
            <atom:updated>2025-11-18T17:52:20.451Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A Beginner-Friendly, Hands-On Project Guide</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZLo0fzpM3OZNycjQEDV5GA.png" /></figure><p>So you’ve learned a bunch of ML, played with a few models, maybe followed some tutorials… but still don’t feel “project-ready”?<br> Welcome to the club. Every beginner hits that awkward phase — <em>“I know things, but I can’t build things.”</em></p><p>Good news: this project fixes exactly that.</p><p>In this guide, we’ll build <strong>PDF Insight AI</strong>, a simple yet solid app that lets users chat with their PDFs using <strong>LangChain, Google Gemini, Hugging Face embeddings, Streamlit, and FAISS</strong>.<br> Think of it as the minimum-viable RAG system that doesn’t confuse you with unnecessary math or architecture diagrams.</p><p>If you want hands-on experience, something useful in your resume, and a project that you can later upgrade… this is a great place to begin.</p><h3>Why Build This Project?</h3><p>This is a beginner-friendly project that teaches you core skills used everywhere in real AI engineering:</p><ul><li>Loading &amp; parsing PDFs</li><li>Cleaning and chunking text</li><li>Converting text into embeddings</li><li>Storing embeddings inside a vector database</li><li>Performing similarity search</li><li>Passing retrieved chunks into a model</li><li>Building an interactive UI using Streamlit</li></ul><p>These are the fundamentals behind <strong>RAG apps, AI assistants, document analyzers, and enterprise question-answering systems</strong>.</p><p>Once you understand this flow, you can build almost anything that interacts with text.</p><h3>Tech Stack We’re Using</h3><p>Here’s everything powering PDF Insight AI:</p><ul><li><strong>LangChain</strong> → for chaining prompts, models, and logic</li><li><strong>Gemini (Google Generative AI)</strong> → for generating high-quality answers</li><li><strong>Hugging Face Embeddings</strong> → for turning text into embeddings</li><li><strong>FAISS</strong> → lightweight vector database</li><li><strong>Streamlit</strong> → fast UI for interaction</li><li><strong>PyPDF2</strong> → extracting text from PDFs</li></ul><p>And since you’re learning — each one teaches a real skill that matters in AI engineering.</p><h3>Let’s Break Down the Code (Beginner-Friendly)</h3><p>Below is the updated version of your code with clear explanations.<br> This is not the final architecture — this is your <strong>Part 1</strong> foundation.</p><h3>Importing Libraries and Loading Environment Variables</h3><pre>from langchain_google_genai import ChatGoogleGenerativeAI , GoogleGenerativeAIEmbeddings<br>from langchain_huggingface import HuggingFaceEmbeddings<br>from PyPDF2 import PdfReader<br>from langchain_core.prompts import PromptTemplate<br>from langchain_text_splitters import RecursiveCharacterTextSplitter<br>from langchain_core.output_parsers import StrOutputParser<br>from dotenv import load_dotenv , find_dotenv<br>from langchain_community.vectorstores import FAISS<br>import streamlit as st</pre><pre>load_dotenv(find_dotenv())</pre><p>Nothing fancy yet. We load our libraries and environment variables.</p><h3>Extracting Text from Uploaded PDFs</h3><pre>def get_text(pdf_docs):<br>    text = &#39;&#39;<br>    for pdf in pdf_docs:<br>        pdf_reader = PdfReader(pdf)<br>        for page in pdf_reader.pages:<br>            text += page.extract_text()<br>    return text</pre><p>This function loops through all uploaded PDFs, reads each page, and extracts text.<br> Perfect for beginners — straightforward and magic-free.</p><h3>Creating Chunks With LangChain</h3><pre>def get_chunks(text):<br>    splitter = RecursiveCharacterTextSplitter(<br>        chunk_size = 1000,<br>        chunk_overlap = 200<br>    )<br>    return splitter.split_text(text)</pre><p>Chunking prevents the model from being overloaded with huge documents.<br> It also improves retrieval accuracy.</p><h3>Creating a Vector DB Using FAISS</h3><pre>def get_vector_db(text_chunks):<br>    embeddings = HuggingFaceEmbeddings(<br>        model_name=&quot;sentence-transformers/all-MiniLM-L6-v2&quot;,<br>        model_kwargs={&#39;device&#39;:&#39;cpu&#39;}<br>    )<br>    vector_store = FAISS.from_texts(text_chunks , embedding = embeddings)<br>    vector_store.save_local(&#39;faiss_index&#39;)</pre><p>We use a lightweight, CPU-friendly embedding model — perfect for experimenters.</p><p>The vector DB is saved locally so we can reload it instantly.</p><h3>Prompt Template for RAG</h3><pre>Template = &quot;&quot;&quot;</pre><pre>Template = &quot;&quot;&quot;<br>Here is the context :<br>&lt;context&gt; {context} &lt;/context&gt;The question that must be answered using context:<br>&lt;question&gt; {input} &lt;/question&gt;-Please read through the context carefully. Use this context to answer the user questions.<br>-Provide direct answer using the context<br>-If question is not related to the context then reply with the question or topic is not related in the doc<br>-Do not create a fictional answer<br>-Output response should be in plain english<br>&quot;&quot;&quot;</pre><p>A simple but strict prompt. Great for beginners who want predictable behavior.</p><h3>Building the LangChain Conversational Chain</h3><pre>def get_conversational_chain():<br>    model = ChatGoogleGenerativeAI(model=&#39;gemini-2.0-flash&#39; , temperature=0.3)<br>    prompt = PromptTemplate(template=Template , input_variables = [&#39;context&#39; , &#39;question&#39;])<br>    parser = StrOutputParser()<br>    return prompt | model | parser</pre><p>We connect prompt → model → output parser.<br> This gives us a ready-to-run pipeline.</p><h3>Handling User Queries</h3><pre>def user_input(question):<br>    embeddings = HuggingFaceEmbeddings(<br>        model_name=&quot;sentence-transformers/all-MiniLM-L6-v2&quot;,<br>        model_kwargs={&#39;device&#39;:&#39;cpu&#39;}<br>    )<br>    new_db = FAISS.load_local(&quot;faiss_index&quot; , embeddings, allow_dangerous_deserialization=True)</pre><pre>    docs = new_db.similarity_search(question)<br>    chain = get_conversational_chain()</pre><pre>    response = chain.invoke(<br>        {&quot;context&quot;: docs, &quot;input&quot;: question}, <br>        return_only_outputs=True<br>    )</pre><pre>    st.write(&quot;Reply: &quot;, response)</pre><p>This retrieves relevant chunks from FAISS → sends them to Gemini → displays the answer.</p><p>A simple retrieval-augmented generation workflow.</p><h3>Streamlit UI</h3><pre>def main():<br>    st.set_page_config(&quot;PDF Insight AI&quot;)<br>    st.header(&quot;Chat with PDF&quot;)</pre><pre>    user_question = st.text_input(&quot;Ask a Question from the PDF Files&quot;)</pre><pre>    if user_question:<br>        user_input(user_question)</pre><pre>    with st.sidebar:<br>        st.title(&quot;Menu:&quot;)<br>        pdf_docs = st.file_uploader(<br>            &quot;Upload your PDF Files and Click on the Submit &amp; Process Button&quot;, <br>            accept_multiple_files=True<br>        )<br>        if st.button(&quot;Submit &amp; Process&quot;):<br>            with st.spinner(&quot;Processing...&quot;):<br>                raw_text = get_text(pdf_docs)<br>                text_chunks = get_chunks(raw_text)<br>                get_vector_db(text_chunks)<br>                st.success(&quot;Done&quot;)</pre><pre>main()</pre><p>This gives you:</p><ul><li>A clean sidebar</li><li>A field to ask questions</li><li>PDF uploader</li><li>Processing indicator</li></ul><p>Minimal but very usable.</p><h3>Final Thoughts</h3><p>And that’s Part 1. You now have a working PDF Insight AI app capable of:</p><ul><li>Parsing PDFs</li><li>Chunking and embedding documents</li><li>Storing embeddings in FAISS</li><li>Answering questions using Gemini via RAG</li><li>Running on a clean Streamlit UI</li></ul><p>But this is just the beginning.</p><p>In <strong>Part 2</strong>, we’ll:</p><ul><li>Build a FastAPI backend for better scalability</li><li>Convert the Streamlit app into a cleaner, more polished UI</li><li>Add better error handling and improved prompts</li><li>Possibly upgrade embeddings and vector search quality</li></ul><p>Your foundations are now ready — next we transform this into a production-style project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0d4d285d730" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Text Summarizer Web App with FastAPI, Streamlit, and Google Gemini]]></title>
            <link>https://medium.com/@ladsoham14202sk/building-a-text-summarizer-web-app-with-fastapi-streamlit-and-google-gemini-b0c917f4f272?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0c917f4f272</guid>
            <category><![CDATA[google-gemini]]></category>
            <category><![CDATA[text-summarization]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[ai-project-ideas]]></category>
            <category><![CDATA[fastapi]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 18:40:50 GMT</pubDate>
            <atom:updated>2025-11-11T18:40:50.372Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJ1z-xy32Jok7puQfiM71Q.jpeg" /></figure><p>In a world overflowing with digital information, reading lengthy reports, articles, or research papers just to extract key insights can be exhausting. What if you could get concise, meaningful summaries instantly — powered by AI?</p><p>In this blog, we’ll build a <strong>Text Summarization Web App</strong> using <strong>FastAPI</strong>, <strong>Streamlit</strong>, and <strong>Google Gemini API</strong>, capable of summarizing plain text or uploaded documents (PDF, DOCX, TXT) effortlessly.</p><h3>Project Overview</h3><p>Our <strong>AI Text Summarizer</strong> allows users to:</p><ul><li>Input custom text or upload documents.</li><li>Automatically extract text from files.</li><li>Generate clear, concise summaries using <strong>Gemini 2.0 Flash</strong>, Google’s state-of-the-art language model.</li><li>Display both original content and summarized output via a simple web interface.</li></ul><p>Here’s what powers it:</p><ul><li><strong>Backend:</strong> FastAPI for API endpoints</li><li><strong>Frontend:</strong> Streamlit for the user interface</li><li><strong>AI Model:</strong> Google Gemini API for summarization</li><li><strong>Libraries:</strong> PyPDF2 and python-docx for file processing</li></ul><h3>Tech Stack</h3><p>Component Technology Purpose Backend <strong>FastAPI</strong> Builds RESTful summarization endpoints Frontend <strong>Streamlit</strong> Provides an interactive UI AI Model <strong>Google Gemini 2.0 Flash</strong> Generates text summaries File Handling <strong>PyPDF2</strong>, <strong>python-docx</strong> Extracts text from PDFs and Word documents Config <strong>dotenv</strong> Loads API keys securely</p><h3>How It Works</h3><h3>1. FastAPI Backend Setup</h3><p>The backend has two main endpoints:</p><ul><li>/summarization — summarizes text entered by the user</li><li>/read-doc/ — extracts text from uploaded files (PDF, DOCX, or TXT) and summarizes it</li></ul><p>Example of text summarization endpoint:</p><pre>@app.get(&quot;/summarization&quot;)<br>def summarization(text: str = Query(..., description=&quot;Text to summarize&quot;)):<br>    prompt = &quot;Summarize the following text:\n&quot; + text<br>    response = client.models.generate_content(<br>        model=&#39;gemini-2.0-flash&#39;,<br>        contents=prompt,<br>        config=types.GenerateContentConfig(<br>            temperature=0.1, top_k=1, top_p=0.6<br>        )<br>    )<br>    return {&quot;original_text&quot;: text, &quot;summary&quot;: response.text}</pre><p>Here, generate_content() sends a prompt to Gemini and returns the summary.<br> Parameters like <strong>temperature</strong>, <strong>top_k</strong>, and <strong>top_p</strong> fine-tune the model’s creativity and precision.</p><h3>2. Text Extraction from Files</h3><p>To support multiple file types, the backend uses:</p><ul><li><strong>PyPDF2</strong> for PDFs</li><li><strong>python-docx</strong> for Word documents</li><li>UTF-8 decoding for text files</li></ul><p>Example for PDFs:</p><pre>def extract_text_from_pdf(file_bytes: bytes) -&gt; str:<br>    reader = PyPDF2.PdfReader(BytesIO(file_bytes))<br>    text = &quot;&quot;<br>    for page in reader.pages:<br>        text += page.extract_text() or &quot;&quot;<br>    return text</pre><h3>3. File Upload Endpoint</h3><p>When users upload a file, FastAPI reads its content, identifies the file type, extracts the text, and sends it for summarization.</p><pre>@app.post(&quot;/read-doc/&quot;)<br>async def read_doc(file: UploadFile = File(...)):<br>    content = await file.read()<br>    filename = file.filename.lower()</pre><pre>    if filename.endswith(&#39;.pdf&#39;):<br>        text = extract_text_from_pdf(content)<br>    elif filename.endswith(&#39;.docx&#39;):<br>        text = extract_text_from_doc(content)<br>    elif filename.endswith(&#39;.txt&#39;):<br>        text = extract_text_from_txt(content)<br>    else:<br>        raise HTTPException(status_code=400, detail=&quot;Unsupported file format.&quot;)<br>    <br>    prompt = &quot;Summarize the following text:\n&quot; + text<br>    response = client.models.generate_content(<br>        model=&#39;gemini-2.0-flash&#39;,<br>        contents=prompt,<br>        config=types.GenerateContentConfig(temperature=0.1, top_k=1, top_p=0.6)<br>    )<br>    return {&quot;original_text&quot;: text, &quot;summary&quot;: response.text}</pre><h3>4. Streamlit Frontend</h3><p>For the user interface, <strong>Streamlit</strong> provides a fast and elegant way to interact with the API.<br> The app supports two modes — text input and file upload.</p><pre>st.title(&quot;Text Summarization App&quot;)<br>st.write(&quot;Enter text or upload (TXT, DOCX, PDF) to summarize&quot;)</pre><pre>option = st.radio(&quot;Choose Option&quot;, (&quot;Text&quot;, &quot;Upload&quot;))<br>API_URL = &quot;http://127.0.0.1:8000&quot;</pre><p><strong>Text Input Mode:</strong></p><pre>if option == &#39;Text&#39;:<br>    user_text = st.text_area(&quot;Enter the text here&quot;)<br>    if st.button(&quot;Summarize Text&quot;):<br>        response = requests.get(f&quot;{API_URL}/summarization&quot;, params={&quot;text&quot;: user_text})</pre><p><strong>File Upload Mode:</strong></p><pre>else:<br>    upload_file = st.file_uploader(&quot;Upload a file&quot;, type=[&quot;pdf&quot;, &quot;docx&quot;, &quot;txt&quot;])<br>    if upload_file is not None and st.button(&quot;Summarize File&quot;):<br>        files = {&quot;file&quot;: (upload_file.name, upload_file, upload_file.type)}<br>        response = requests.post(f&quot;{API_URL}/read-doc/&quot;, files=files)</pre><h3>Running the App</h3><h3><strong>Install dependencies</strong></h3><ul><li>pip install fastapi uvicorn streamlit google-genai python-docx PyPDF2 python-dotenv requests</li></ul><h3><strong>Start FastAPI server</strong></h3><ul><li>uvicorn main:app --reload</li></ul><h3><strong>Run the Streamlit interface</strong></h3><ul><li>streamlit run app.py</li><li>Open your browser at <a href="http://localhost:8501/"><strong>http://localhost:8501</strong></a><br> Type or upload your document, and see the summary generated instantly!</li></ul><h3>Conclusion</h3><p>This project is a great example of combining modern AI models with simple web technologies. By integrating <strong>FastAPI</strong>, <strong>Streamlit</strong>, and <strong>Google Gemini</strong>, we built an application that can:</p><ul><li>Summarize large amounts of text efficiently</li><li>Handle multiple document formats</li><li>Provide a user-friendly interface for anyone</li></ul><p>Whether you’re a student learning about NLP or a developer exploring AI-powered applications, this text summarizer is an excellent place to start.</p><h3>What’s Next</h3><p>Here are a few ways to take this project further:</p><ul><li>Add <strong>multi-language summarization</strong> support</li><li>Enable <strong>custom summary length control</strong></li><li>Integrate <strong>authentication</strong> for private access</li><li>Deploy the app to <strong>Render</strong>, <strong>AWS</strong>, or <strong>Google Cloud Run</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0c917f4f272" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Final Report — Google Summer of Code 2025 with Drupal]]></title>
            <link>https://medium.com/@ladsoham14202sk/final-report-google-summer-of-code-2025-with-drupal-56f34d81a459?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/56f34d81a459</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Wed, 27 Aug 2025 06:11:23 GMT</pubDate>
            <atom:updated>2025-08-27T06:11:23.081Z</atom:updated>
            <content:encoded><![CDATA[<h3>Final Report — Google Summer of Code 2025 with Drupal</h3><h3>Introduction</h3><p>I had the incredible opportunity to participate in <strong>Google Summer of Code 2025 (GSoC) with Drupal</strong>. My project focused on building the <strong>AI-Powered Media Caption Generator</strong>, a module that integrates AI-based models to generate intelligent captions for uploaded media, making media management more efficient and engaging within Drupal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OOiGVW9DYHc--viE.jpeg" /></figure><h3>Project Goals</h3><p>The aim of this project was to develop an <strong>AI-Powered Media Caption Generator</strong> for Drupal. The module integrates with AI services to automatically generate meaningful and engaging captions for uploaded media. The broader goal was to streamline content creation, enhance accessibility, and save time for Drupal users by embedding intelligent captioning directly within the CMS.</p><h3>Accomplishments</h3><p>Over the course of the project, the following key milestones were achieved:</p><ul><li>Designed and implemented a <strong>FastAPI backend</strong> integrating <strong>Google Vision API</strong> for image label extraction and Hugging Face/OpenAI models for caption generation.</li><li>Developed a <strong>secure API key system</strong> to control backend access.</li><li>Built a <strong>custom Drupal module UI</strong> that seamlessly communicates with the FastAPI backend.</li><li>Added a <strong>caption customization feature</strong> where users can include emojis in the generated captions.</li><li>Conducted <strong>extensive testing and documentation</strong> to ensure reliability and maintainability of the system.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*XgZ8VZ2FX34Mj9YUle2nrw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*vcC3WwExHELh4ww8v8Er6w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGJUFt6WnoNyoD7ULLWtFg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkAdP1tUGdWwrH7mcWqIfQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6ftvH7LWaKuR-cptiGI7A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKsDYLji6N0QbkjHMv4D-w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRCvqDMrQ0IdSlmy2xGiew.jpeg" /></figure><h3>Current State of the Project</h3><p>The project is now fully functional:</p><ul><li>Users can upload an image in Drupal, which is processed by the backend to generate captions.</li><li>The UI provides caption results with options for emoji inclusion, making it engaging and user-friendly.</li><li>Documentation and testing have been completed, ensuring smooth setup and usage.</li></ul><h3>What’s Left to Do</h3><p>While the core functionality is complete, there is room for future improvements:</p><ul><li>Optimize caption quality through reinforcement learning and adaptive feedback loops.</li><li>Expand support for more AI models and multilingual captions.</li><li>Further refine the Drupal UI for enhanced user experience and scalability.</li></ul><h3>Challenges &amp; Key Takeaways</h3><ul><li>Balancing integration between <strong>multiple AI services</strong> (Google Vision, Hugging Face, OpenAI) required careful design decisions to ensure performance and consistency.</li><li>Creating a <strong>seamless bridge between FastAPI and Drupal</strong> demanded attention to both security and usability.</li><li>Key takeaway: Building production-ready AI features within a CMS requires a mix of <strong>backend engineering, API design, and frontend integration</strong> skills, along with clear documentation for long-term maintainability.</li></ul><h3>Code Repository &amp; Weekly Updates</h3><ul><li>For a detailed breakdown of the progress and weekly updates, you can refer to my blogs:</li><li><a href="https://medium.com/@ladsoham14202sk/from-image-descriptions-to-smart-captions-my-google-summer-of-code-2025-journey-so-far-week-1-2-38ad06e79f0d">Weekly Report: Weeks 1–2</a></li><li><a href="https://medium.com/@ladsoham14202sk/building-the-ai-captioning-api-weeks-3-4-of-gsoc-with-drupal-743890558ccb">Weekly Report: Weeks 3–4</a></li><li><a href="https://medium.com/@ladsoham14202sk/connecting-ai-to-drupal-weeks-5-6-of-gsoc-with-drupal-853da461fcdf">Weekly Report: Weeks 5–6</a></li><li><a href="https://medium.com/@ladsoham14202sk/smarter-captions-with-gemini-and-emojis-weeks-7-8-of-gsoc-with-drupal-34f511238609">Weekly Report: Weeks 7–8</a></li><li><a href="https://medium.com/@ladsoham14202sk/configurable-stable-production-ready-weeks-9-10-of-gsoc-with-drupal-1e237919672a">Weekly Report: Weeks 9–10</a></li></ul><p>All the source code and ongoing development are available on GitHub:<br><a href="https://github.com/SohamLad14/ladsoham-gsoc-caption-generator">GitHub Repository</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56f34d81a459" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Google Summer of Code 2025 Journey with Drupal]]></title>
            <link>https://medium.com/@ladsoham14202sk/my-google-summer-of-code-2025-journey-with-drupal-95727fb00547?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/95727fb00547</guid>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 06:45:05 GMT</pubDate>
            <atom:updated>2025-08-26T08:06:37.649Z</atom:updated>
            <content:encoded><![CDATA[<p>I had the incredible opportunity to participate in <strong>Google Summer of Code 2025 (GSoC) with Drupal</strong>. My project focused on building the <strong>AI-Powered Media Caption Generator</strong>, a module that integrates AI-based models to generate intelligent captions for uploaded media, making media management more efficient and engaging within Drupal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mdAOK2-GJwcVt55c.png" /></figure><h3>Project Overview</h3><p>The <strong>AI-Powered Media Caption Generator</strong> is a custom Drupal module designed to automatically generate rich, contextual captions for uploaded media. It combines multiple AI components into a single workflow:</p><ul><li><strong>Google Vision API</strong> → Extracts objects, entities, and metadata from images.</li><li><strong>Hugging Face/OpenAI models</strong> → Generates descriptive captions based on extracted labels.</li><li><strong>FastAPI backend</strong> → Handles API requests, integrates multiple AI services, and ensures security through API key validation.</li><li><strong>Drupal integration</strong> → Provides a seamless, user-friendly UI inside Drupal, enabling content creators to generate captions without leaving the platform.</li></ul><p>The motivation behind this project was to reduce the manual effort required for writing captions, improve accessibility, and enable more engaging content creation.</p><h3>Work Summary</h3><p>During the course of the project, the work was divided into multiple phases:</p><h3>1. Initial Setup and Backend Development</h3><p>I began by setting up the <strong>FastAPI backend</strong>. The backend served as the foundation of the project, providing secure APIs for communication between Drupal and AI models.</p><ul><li>Implemented API key authentication.</li><li>Integrated Google Vision API for image label extraction.</li><li>Connected Hugging Face/OpenAI models for caption generation.</li><li>Ensured modular design for easy extensibility.</li></ul><h3>2. Caption Generation Workflow</h3><p>Once the backend was ready, I focused on building the <strong>caption generation pipeline</strong>:</p><ul><li>Extracted meaningful keywords and labels from Google Vision.</li><li>Fed these into Hugging Face models for contextual caption creation.</li><li>Added flexibility for multi-model support (Google Vision + Hugging Face + OpenAI).</li><li>Ensured output was structured and ready for UI integration.</li></ul><p>At this stage, initial captions were functional but had some limitations with <strong>length customization and repetitive phrasing</strong>.</p><h3>3. Challenges and Enhancements</h3><p>A key challenge was encountered while enhancing captions. Initially, length customization did not work as expected — the model often generated captions of nearly the same size regardless of user input. To address this:</p><ul><li>Experimented with prompt engineering for Hugging Face.</li><li>Later integrated <strong>Google Gemini API</strong>, which improved flexibility in handling caption length and creativity.</li><li>Added support for emojis to make captions more engaging and social-media friendly.</li></ul><p>This enhancement significantly improved the usability of the captions in real-world scenarios.</p><h3>4. Drupal Module Development and UI Integration</h3><p>Parallel to backend improvements, I worked on the <strong>Drupal module integration</strong>.</p><ul><li>Built a custom Drupal UI where users can upload images and directly generate captions.</li><li>Designed it as a <strong>menu option</strong> within Drupal, ensuring accessibility across the site.</li><li>Implemented seamless communication between Drupal and FastAPI backend.</li><li>Added options for customizable caption generation (length, style).</li></ul><p>This step transformed the backend into a <strong>user-friendly tool for content creators</strong>.</p><h3>Key Outcomes</h3><ul><li>Developed a <strong>fully functional AI-Powered Caption Generator</strong> integrated with Drupal.</li><li>Solved technical challenges related to caption length, diversity, and expressiveness.</li><li>Designed a <strong>modular, extensible backend</strong> that can incorporate new AI services in the future.</li><li>Delivered a <strong>Drupal-ready solution</strong> with UI integration for real-world content workflows.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*XgZ8VZ2FX34Mj9YUle2nrw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*vcC3WwExHELh4ww8v8Er6w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGJUFt6WnoNyoD7ULLWtFg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRCvqDMrQ0IdSlmy2xGiew.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vKsDYLji6N0QbkjHMv4D-w.jpeg" /></figure><h3>Learning and Experience</h3><p>This project was not just about building an AI tool — it was about <strong>understanding how to integrate AI into real-world platforms</strong> like Drupal. I gained valuable experience in:</p><ul><li>Building production-level <strong>FastAPI services</strong>.</li><li>Working with <strong>Google Cloud Vision, Hugging Face, OpenAI, and Gemini APIs</strong>.</li><li>Designing <strong>modular AI pipelines</strong>.</li><li>Drupal module development and frontend-backend communication.</li><li>Writing documentation and community blogs to share progress.</li></ul><p>The experience has deepened my knowledge of both <strong>AI engineering and open-source development practices</strong>.</p><p>For a detailed breakdown of the progress and weekly updates, you can refer to my blogs:</p><ul><li><a href="https://medium.com/@ladsoham14202sk/from-image-descriptions-to-smart-captions-my-google-summer-of-code-2025-journey-so-far-week-1-2-38ad06e79f0d">Weekly Report: Weeks 1–2</a></li><li><a href="https://medium.com/@ladsoham14202sk/building-the-ai-captioning-api-weeks-3-4-of-gsoc-with-drupal-743890558ccb">Weekly Report: Weeks 3–4</a></li><li><a href="https://medium.com/@ladsoham14202sk/connecting-ai-to-drupal-weeks-5-6-of-gsoc-with-drupal-853da461fcdf">Weekly Report: Weeks 5–6</a></li><li><a href="https://medium.com/@ladsoham14202sk/smarter-captions-with-gemini-and-emojis-weeks-7-8-of-gsoc-with-drupal-34f511238609">Weekly Report: Weeks 7–8</a></li><li><a href="https://medium.com/@ladsoham14202sk/configurable-stable-production-ready-weeks-9-10-of-gsoc-with-drupal-1e237919672a">Weekly Report: Weeks 9–10</a></li></ul><p>All the source code and ongoing development are available on GitHub:<br><a href="https://github.com/SohamLad14/ladsoham-gsoc-caption-generator"> GitHub Repository</a></p><h3>Acknowledgments</h3><p>I would like to thank my mentors, the Drupal community, and Google Summer of Code for this wonderful opportunity. Their guidance and feedback helped me stay on track and solve challenges effectively.</p><h3>Conclusion</h3><p>The <strong>AI-Powered Media Caption Generator</strong> has the potential to significantly improve media workflows in Drupal. By leveraging AI, it reduces the time and effort required for caption writing while increasing creativity and accessibility. This project marks the beginning of further exploration in <strong>AI-driven content creation tools within Drupal</strong>, and I look forward to continuing my contributions to the community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95727fb00547" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configurable, Stable & Production-Ready: Weeks 9–10 of GSoC with Drupal]]></title>
            <link>https://medium.com/@ladsoham14202sk/configurable-stable-production-ready-weeks-9-10-of-gsoc-with-drupal-1e237919672a?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e237919672a</guid>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 06:11:52 GMT</pubDate>
            <atom:updated>2025-08-26T06:11:52.357Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gKaXv90WftboeU9Z.png" /></figure><p>After solving caption quality issues with Google Gemini in Weeks 7–8, Weeks 9–10 were about <strong>stabilizing the module, adding configurability, and preparing it for real-world Drupal use</strong>. This phase transformed the caption generator into a <strong>production-ready tool</strong>, complete with alt-text automation, flexible settings, and offline/online operation modes.</p><h3>Activities</h3><h4>1. Module Update &amp; Configurations</h4><ul><li>Added a <strong>configuration form</strong> under Drupal admin → <em>Manage &gt; Configuration &gt; Media Section &gt; Caption Generator</em>.</li><li>Settings included:</li><li>Gemini API Key (optional)</li><li>Default caption length</li><li>Emoji toggle</li><li>Model parameters</li></ul><h4>2. Automatic Alt Text Population</h4><ul><li>When an editor uploads an image in an article, the module automatically:</li><li>Sends it to the Python backend (FastAPI).</li><li>Generates a caption via Hugging Face or Gemini.</li><li>Fills in the <strong>Alt tag</strong> automatically.</li><li>Editors can still manually edit captions before publishing.</li></ul><h4>3. Dual Mode Operation</h4><ul><li><strong>With Gemini API Key</strong> → Captions are richer, longer, and context-aware.</li><li><strong>Without Gemini API Key</strong> → Hugging Face models (BLIP, ViT, GPT-2) generate captions fully offline.</li></ul><h4>4. DDEV Integration</h4><ul><li>Added <strong>custom DDEV commands</strong> for setup and testing:</li><li>ddev install-python-reqs → Install Python dependencies</li><li>ddev preload-models → Cache Hugging Face models locally</li><li>ddev dev-python → Start FastAPI backend inside container</li><li>Ensured smooth containerized development without manual setup.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pa1pg1Q2EgS4m4jSpQRlSg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*XgZ8VZ2FX34Mj9YUle2nrw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*vcC3WwExHELh4ww8v8Er6w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGJUFt6WnoNyoD7ULLWtFg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6ftvH7LWaKuR-cptiGI7A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkAdP1tUGdWwrH7mcWqIfQ.jpeg" /></figure><h3>Tools &amp; Frameworks</h3><ul><li><strong>Drupal 11</strong> (Form API, Service API, Config API)</li><li><strong>FastAPI</strong> backend (Python)</li><li><strong>Hugging Face Transformers</strong> (BLIP, ViT, GPT-2)</li><li><strong>Google Gemini API</strong></li><li><strong>DDEV + Docker</strong></li></ul><h3>Outcomes</h3><ul><li>Fully functional <strong>Drupal 11 caption generator module</strong>.</li><li><strong>Configurable admin panel</strong> for editors &amp; developers.</li><li>Dual support: <em>offline Hugging Face</em> and <em>online Gemini API</em>.</li><li>Automatic <strong>Alt-text generation</strong> directly in Drupal workflows.</li><li>Stable, containerized environment with <strong>DDEV automation</strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e237919672a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smarter Captions with Gemini and Emojis: Weeks 7–8 of GSoC with Drupal]]></title>
            <link>https://medium.com/@ladsoham14202sk/smarter-captions-with-gemini-and-emojis-weeks-7-8-of-gsoc-with-drupal-34f511238609?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/34f511238609</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <category><![CDATA[gsoc-2025]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Tue, 26 Aug 2025 05:59:26 GMT</pubDate>
            <atom:updated>2025-08-26T05:59:26.947Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gH7bTO99EE1bqZ-P.png" /></figure><p>In Weeks 7–8 of my GSoC project with Drupal, I hit a critical roadblock: while the caption generator was functional, the captions themselves were often <strong>flat, repetitive, and ignored user-specified length settings</strong>. Instead of enriching the description, the system just extended the base caption, leading to limited variety. These weeks became about solving this challenge and enhancing the creativity of generated captions.</p><h3><strong>The Challenge</strong></h3><ul><li><strong>Length Issue:</strong> Regardless of whether I requested a short, medium, or long caption, the system produced almost the same text.</li><li><strong>Limited Enrichment:</strong> The model tended to just add more words to the base BLIP caption instead of rephrasing or making it more engaging.</li><li><strong>Need for Creativity:</strong> Captions felt too mechanical and lacked personality.</li></ul><h3><strong>Solution: Integrating Google Gemini</strong></h3><p>To overcome these limitations, I integrated the <strong>Google Gemini API</strong> into the pipeline. Gemini allowed for:</p><ul><li><strong>Length Control:</strong> More reliable generation of captions that respected short, medium, or long settings.</li><li><strong>Better Enrichment:</strong> Instead of just extending, Gemini reformulated captions into fluent, engaging sentences.</li><li><strong>Flexibility:</strong> The API key integration made it easier to switch models for comparison and fallback.</li></ul><h3><strong>Adding Personality: Emojis</strong></h3><p>To make captions more engaging for modern content workflows, I added <strong>emoji support</strong>.</p><ul><li>Emojis were automatically inserted in relevant contexts (e.g., 🏞️ for landscapes, 🐶 for animals, 🍕 for food).</li><li>This gave captions a friendlier, social-media-ready feel.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhkTdRaQYGe-fByXADPFTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vb2g0kbN208aYPhWMUa5og.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hFmQykuWCt1h8ZtS9qWxBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7bmzGmy0sMOybZ5Y9sqxJg.png" /></figure><h3><strong>Tools &amp; Frameworks</strong></h3><ul><li><strong>Google Gemini API</strong> (for creative caption generation)</li><li><strong>FastAPI</strong> (to orchestrate between Hugging Face models and Gemini)</li><li><strong>Hugging Face Transformers</strong> (BLIP, ViT for base understanding)</li></ul><h3><strong>Conclusion</strong></h3><ul><li>Solved the <strong>caption length problem</strong>.</li><li>Generated captions became more <strong>varied, engaging, and human-like</strong>.</li><li>Introduced <strong>emoji-enhanced captions</strong>, making the module fun and useful for real-world content creators.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34f511238609" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting AI to Drupal: Weeks 5–6 of GSoC with Drupal]]></title>
            <link>https://medium.com/@ladsoham14202sk/connecting-ai-to-drupal-weeks-5-6-of-gsoc-with-drupal-853da461fcdf?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/853da461fcdf</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gsoc-2025]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[drupal]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 12:34:29 GMT</pubDate>
            <atom:updated>2025-08-21T12:34:29.599Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rukJBRUGlKiJUc_j.png" /></figure><p>After building the AI captioning API in earlier weeks, Weeks 5–6 were about integration — bringing the backend into Drupal’s ecosystem and enabling a smooth developer experience with containerized workflows.</p><h3>Environment Setup</h3><p>Implemented DDEV, a Docker environment that is ideally suited for Drupal 11 development</p><p>Set up Drupal with DDEV; eschewed local PHP, Composer, MySQL installations</p><p>Installed Drush for command-line tasks (e.g., cache rebuilds) through Composer within the container</p><p>Embedding Python Backend</p><p>Activated Python support within the DDEV web container by changing .ddev/config.yaml</p><p>Installed Python 3, pip, and virtual environment support</p><p>Moved API code into python/ directory within the container</p><p>Created a virtual environment, installed dependencies, and executed FastAPI internally to enable Drupal-to-API communication</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*C8scfbgZRTM8Fgd5.jpeg" /></figure><p>Drupal Module: caption_generator</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*Nxn4asDdwaWV0BgE.jpeg" /></figure><h3><strong>Functionality:</strong></h3><p>· Module enabled through the “Extend” tab allows caption functionality to be added to the article creation form</p><p>· UI improvements include:</p><p>· Caption-length selector</p><p>· Disabled caption output field with interactive “Generate Caption” button</p><p>· Upon request, the uploaded image and chosen options are passed to the Python API and the resulting caption are returned to Drupal</p><p>· This provides a live caption as part of the content creation process.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*BqRzn5ceigLygo3T.jpeg" /></figure><p><strong>Challenges &amp; Learning:</strong></p><p>· <strong>Prompt Design </strong>: Systematic prompts using descriptions and labels highly enhanced caption consistency.</p><p>· <strong>Containerized Integration</strong> : Porting the Python backend to the Drupal container overcame cross-environment communication issues.</p><p>· <strong>Drupal Development</strong> : Development with Drupal’s Form API, service patterns, and dependency injection necessitated meticulous code organization and debugging.</p><p>Tools &amp; Frameworks</p><p>Drupal 11, DDEV, PHP, Composer, Drush</p><p>FastAPI, Uvicorn, Python 3, pip, virtualenv</p><p>Hugging Face Transformers: BLIP, ViT, GPT-2, DeepSeek , Postman</p><p><strong>Conclusion:</strong></p><p>· Developed and deployed a working AI captioning pipeline</p><p>· Implemented a stable FastAPI backend for generating image captions</p><p>· Containerized the solution and connected it to Drupal with DDEV</p><p>· Deployed and built a bespoke Drupal module that connects the backend functionality into the content creation UI</p><p>· Tested overall system workflow from user upload to rendering of captions within Drupal</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=853da461fcdf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building the AI Captioning API: Weeks 3–4 of GSoC with Drupal]]></title>
            <link>https://medium.com/@ladsoham14202sk/building-the-ai-captioning-api-weeks-3-4-of-gsoc-with-drupal-743890558ccb?source=rss-812a63d63616------2</link>
            <guid isPermaLink="false">https://medium.com/p/743890558ccb</guid>
            <category><![CDATA[gsoc-2025]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[google-summer-of-code]]></category>
            <dc:creator><![CDATA[Soham Lad]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 12:32:58 GMT</pubDate>
            <atom:updated>2025-08-21T12:32:58.074Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kOOzb8ObcNdtuRu8.png" /></figure><p>In Weeks 3–4 of my GSoC journey with Drupal, my focus shifted to building a RESTful API that serves as the core of the AI-Powered Media Caption Generator. This API acts as the bridge between image input and intelligent caption output.</p><h3><strong>Activities</strong></h3><ul><li>Implemented a RESTful API using <strong>FastAPI</strong>, accepting an uploaded image and caption-length parameter.</li><li>Designed the captioning pipeline:</li><li><strong>BLIP</strong> to generate the base description.</li><li><strong>ViT (Vision Transformer)</strong> to extract descriptive labels.</li><li>Constructed structured prompts and passed them to <strong>GPT-2 / DeepSeek</strong> for caption refinement.</li><li>Added a <strong>two-stage generation process</strong>: tokenization for structure, refinement for fluency.</li><li>Validated the pipeline using <strong>Postman</strong> for API testing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nGP9WDy2THFCrgSjBRI0zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6n9v3_U8SrjVsg83mprjnA.png" /></figure><h3><strong>Challenges &amp; Learnings</strong></h3><ul><li><strong>Prompt Design:</strong> Carefully combining BLIP outputs with ViT labels in structured prompts led to more consistent captions.</li><li><strong>Two-Stage Generation:</strong> Refinement after tokenization significantly improved fluency.</li><li><strong>API Testing:</strong> Iterative testing in Postman helped ensure stability before integration.</li></ul><h3><strong>Tools &amp; Frameworks</strong></h3><ul><li><strong>FastAPI, Uvicorn, Python 3</strong></li><li><strong>Hugging Face Transformers:</strong> BLIP, ViT, GPT-2, DeepSeek</li><li><strong>Postman</strong> for endpoint validation</li></ul><p><strong>Outcomes</strong><br> By the end of Week 4, I had a fully functional API capable of transforming an image into a meaningful caption, ready to be integrated with Drupal.</p><p><strong>Conclusion:</strong><br> These weeks laid the foundation of the project — the API backbone that will later power seamless caption generation inside Drupal’s content workflows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=743890558ccb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>