<?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 Saurav Mehta on Medium]]></title>
        <description><![CDATA[Stories by Saurav Mehta on Medium]]></description>
        <link>https://medium.com/@sauravmehta818?source=rss-11b00bfe33d1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*n8KOej5-EMgioAEXWw4epA.jpeg</url>
            <title>Stories by Saurav Mehta on Medium</title>
            <link>https://medium.com/@sauravmehta818?source=rss-11b00bfe33d1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:38:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sauravmehta818/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[Getting Started with RAG: Building Your First App with Ollama, Spring Boot, and React]]></title>
            <link>https://sauravmehta818.medium.com/getting-started-with-rag-building-your-first-app-with-ollama-spring-boot-and-react-cfbefaa895a2?source=rss-11b00bfe33d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfbefaa895a2</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Saurav Mehta]]></dc:creator>
            <pubDate>Sun, 24 Aug 2025 08:45:32 GMT</pubDate>
            <atom:updated>2025-08-24T08:45:32.502Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWiotPvCNa4wJUbf-wN8nw.png" /></figure><p>🔗 <strong>GitHub Repository</strong><br> You can find the full project code here: <a href="https://github.com/The-Billu-Badmash/rag-bot.git"><em>https://github.com/The-Billu-Badmash/rag-bot.git</em></a></p><blockquote>⚠️ <strong>Disclaimer</strong><br> This project is still <strong>under development</strong>. The file structure and implementation may change as the project evolves. The current version is meant for <strong>learning and experimentation</strong>.</blockquote><ol><li>Introduction to RAG<br>- What is RAG?<br>- Why it matters in modern AI</li><li>History of RAG (Evolution of the Idea)<br>- Early LLM limitations (hallucinations, lack of factual grounding)<br>- Early retrieval methods in Information Retrieval (TF-IDF, BM25)<br>- Rise of neural embeddings (Word2Vec → BERT → Sentence Transformers)<br>- 2020: Facebook AI introduces RAG (Retrieval-Augmented Generation)<br>- From research → practical adoption in chatbots, search, assistants<br>- How RAG became mainstream with vector DBs (Pinecone, Weaviate, pgvector, etc.)</li><li>Understanding the Tech Stack<br>- Ollama<br>- Spring Boot<br>- React<br>- H2 Database</li><li>System Architecture Overview</li><li>Setting Up the Environment</li><li>Vector Database &amp; Embeddings<br>- What are embeddings?<br>- What is a vector?<br>- Cosine similarity &amp; other distance metrics<br>- Why cosine similarity is most used in RAG</li><li>Conclusion</li></ol><h3>1. Introduction to RAG</h3><h4>- What is RAG?</h4><p>RAG stands for <strong>Retrieval-Augmented Generation</strong>. It is a method that combines two things:</p><p><strong>Retrieval</strong> — finding useful information from an external source (like a database or documents).</p><p><strong>Generation</strong> — using a language model (like LLaMA, GPT, etc.) to create a natural language answer.</p><p>In simple terms, RAG means: <em>“Instead of only depending on the model’s memory, we also give it extra knowledge from outside to answer better.”</em></p><p>For example: If you ask a normal AI model, <em>“Who is the CEO of SAP?”</em>, it might guess wrong if it was not trained with the latest data. But with RAG, the system first searches your documents or the internet, finds the latest CEO’s name, and then the model uses that info to give you the correct answer.</p><h4>- Why it matters in modern AI?</h4><ul><li><strong>Reduces hallucination</strong>: AI sometimes makes up facts. RAG lowers this by grounding answers in real data.</li><li><strong>Keeps information fresh</strong>: Models are trained on fixed data. RAG lets you connect them to your own documents, APIs, or updated databases.</li><li><strong>Domain-specific knowledge</strong>: You can teach AI about your company data, research papers, or private files without retraining the whole model.</li><li><strong>Better trust</strong>: When answers come from your actual data, users can rely on them more.</li></ul><p>In short, RAG makes AI <strong>smarter, reliable, and up-to-date</strong> by mixing the power of search with the creativity of language models.</p><h3>2. History of RAG (Evolution of the Idea)</h3><h4>- Early LLM limitations (hallucinations, lack of factual grounding)</h4><p>Large Language Models (LLMs) like GPT or LLaMA are trained on fixed data. Once training is done, they:</p><ul><li><strong>Can’t update knowledge easily</strong> → If something changes (e.g., new CEO, new law), they don’t know it.</li><li><strong>Hallucinate</strong> → They sometimes make up facts because they try to “sound correct” even without real knowledge.</li><li><strong>Lack grounding</strong> → They don’t know where their answers come from, which lowers trust.</li></ul><p>Example: If you ask <em>“Who won the 2025 Cricket World Cup?”</em> to a model trained only until 2023, it will <em>guess</em>, not <em>know</em>.</p><h4>- Early Retrieval Methods in Information Retrieval</h4><p>Before neural networks, search engines used classical methods:</p><ul><li><strong>TF-IDF (Term Frequency — Inverse Document Frequency)</strong> → Counts how often a word appears in a document compared to others.</li><li><strong>BM25</strong> → A more refined scoring algorithm that measures how relevant a document is to a query.</li></ul><p>These methods worked well for keyword search, but:</p><ul><li>They only matched words, not meanings.</li><li>Couldn’t capture synonyms or context (<em>“car” vs. “automobile” looked different</em>).</li></ul><h4>- Rise of Neural Embeddings</h4><p>Then came <strong>neural embeddings</strong> → a way to represent words, sentences, and documents as <strong>vectors</strong> (lists of numbers).</p><ul><li><strong>Word2Vec (2013)</strong> → First step: words like “king” and “queen” appeared close in vector space.</li><li><strong>BERT (2018)</strong> → Context-aware embeddings (understands that “bank” in <em>river bank</em> ≠ <em>money bank</em>).</li><li><strong>Sentence Transformers (2019–2020)</strong> → Whole sentences mapped into vectors, making similarity search much more accurate.</li></ul><p>This shift meant: we could now <strong>search by meaning, not just keywords</strong>.</p><h4>- 2020: Facebook AI Introduces RAG</h4><p>In 2020, Facebook AI Research published the <strong>RAG paper (Retrieval-Augmented Generation)</strong>. <a href="https://research.facebook.com/publications/retrieval-augmented-generation-for-knowledge-intensive-nlp-tasks/"><em>Original RAG Paper (2020, Facebook AI)</em></a></p><ul><li>Idea: Instead of relying only on what the LLM “remembers,” combine it with a <strong>retriever</strong> that fetches facts from a knowledge base.</li><li>The retriever finds top-k relevant documents.</li><li>The generator (LLM) uses those documents as context to give a grounded answer.</li></ul><p>This was the <strong>birth of RAG</strong> as a formal technique.</p><h4>- From Research → Practical Adoption</h4><p>After the paper, the idea spread quickly:</p><ul><li><strong>Chatbots</strong> that answer from your company’s knowledge base.</li><li><strong>Search assistants</strong> that summarize results instead of giving raw links.</li><li><strong>Customer support bots</strong> that retrieve answers from documentation.</li></ul><p>RAG bridged the gap between <strong>search engines</strong> and <strong>language models</strong>.</p><h4>- RAG Becomes Mainstream with Vector Databases</h4><p>Once embeddings got powerful, storing them became important. That’s where <strong>vector databases</strong> came in:</p><ul><li><strong>Pinecone, Weaviate, Milvus, pgvector</strong> made it easy to store billions of embeddings.</li><li>They allow <strong>fast similarity search</strong> (find the closest vectors using cosine similarity).</li><li>This made RAG practical at scale — from startups to big enterprises.</li></ul><p>Example today: When you ask a chatbot <em>“Summarize our last project report”</em>, the system retrieves the most relevant chunks from your documents (via vector DB), then gives you an answer that feels both fluent and factual.</p><h3>3. Understanding the Tech Stack</h3><p>Our <strong>RAG-Bot</strong> application is built using three main technologies: <strong>Ollama, Spring Boot, and React</strong>. Each of them plays a unique role in making the chatbot work. Let’s break them down.</p><h4>- Ollama — The AI Brain</h4><p>Ollama is where all the <strong>AI magic</strong> happens. It lets us run large language models (like <em>LLaMA 3</em>) directly on our machine. In our application:</p><ul><li>We use <strong>nomic-embed-text</strong> for embeddings. This means whenever a user asks a question, we convert it into a vector (numbers) so the system can “search by meaning.”</li><li>We use <strong>llama3</strong> for generating answers. Once we find the most relevant information, Ollama uses it to write a natural and human-like response.</li></ul><h4>- Spring Boot — The Middle Manager</h4><p>Spring Boot is our <strong>backend service</strong> written in Java. It acts like the <strong>manager</strong> that connects the user interface with the AI brain. In our application, Spring Boot does the following:</p><ul><li>Receives the question from React.</li><li>Calls Ollama to generate embeddings for the question.</li><li>Searches the stored vectors (our knowledge base) to find the most relevant text.</li><li>Passes both the question and the retrieved text back to Ollama for final answer generation.</li><li>Sends the answer back to React to display.</li></ul><h4>- React — The Friendly Face</h4><p>React is the <strong>frontend</strong> of our application. This is what users actually see and interact with. In our RAG-Bot:</p><ul><li>The user types a question in the chat box.</li><li>React sends that question to Spring Boot through an API call.</li><li>React displays the answer it gets back from Spring Boot in a chat-style interface.</li></ul><h4>- H2 Database — The Lightweight Store</h4><p>Our RAG-Bot doesn’t use a heavy external database like PostgreSQL or Pinecone. Instead, we’ve added <strong>H2 Database</strong> as a dependency in the Spring Boot project.</p><blockquote><strong>What is H2?</strong></blockquote><ul><li>H2 is a lightweight, in-memory relational database.</li><li>It runs inside the Spring Boot application (no external setup needed).</li><li>Perfect for beginners and quick prototypes.</li></ul><blockquote><strong>Why we used H2?</strong></blockquote><ul><li><strong>Simplicity</strong> → No installation or configuration required.</li><li><strong>Integrated</strong> → Runs inside Spring Boot, so everything is self-contained.</li><li><strong>Good for learning</strong> → Lets us focus on the RAG pipeline without worrying about database setup.</li></ul><blockquote><strong>How it works in our RAG-Bot:</strong></blockquote><ol><li>When we process documents, their embeddings (vectors) are stored in H2 tables.</li><li>When a user asks a question, we embed the query and run a similarity search on the stored vectors inside H2.</li><li>The most relevant text chunks are retrieved and passed back to Ollama for answer generation.</li></ol><h3>4. System Architecture Overview</h3><p>Our app has <strong>two flows</strong>:</p><ol><li><strong>Ingestion</strong> (load documents → chunk → embed → store)</li><li><strong>Question-Answer</strong> (user asks → retrieve → generate → show)</li></ol><blockquote><strong>Components (who does what)</strong></blockquote><h4><strong>1. React (Frontend UI)</strong></h4><ul><li>Chat screen. Sends questions to backend and shows answers, sources.</li></ul><h4><strong>2. Spring Boot (Backend API + Orchestrator)</strong><br> REST endpoints:</h4><ul><li>POST /ingest → accepts files/text, splits into chunks, calls embeddings, stores in DB.</li><li>POST /ask → takes a query, finds similar chunks, calls LLM, returns answer (+sources).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--R5Dxp5ibNqpSShVv2LLA.png" /></figure><p>Services inside:</p><ul><li><strong>Embedding Service</strong> (calls Ollama’s embedding model nomic-embed-text)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*coVEDBnymUzbad5jSAshXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xXp56ekXgIyoTNu64w_M9A.png" /></figure><ul><li><strong>Retrieval Service</strong> (similarity search over stored vectors)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtlpAiNw44qk9JbhoZDE2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7w8fruqpkFjvQNuJL_QvMg.png" /></figure><ul><li><strong>Generation Service</strong> (calls Ollama LLM llama3 with context)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XSL8JmSeHfqojpRO3_njvw.png" /></figure><h4><strong>3. Ollama (LLM Engine)</strong></h4><ul><li><strong>Embeddings</strong>: nomic-embed-text (turns text into vectors)</li><li><strong>LLM</strong>: llama3 (writes the final answer)</li></ul><h4><strong>4. H2 Database (Lightweight store)</strong></h4><ul><li>Holds your <strong>chunks</strong>, <strong>metadata</strong>, and <strong>embeddings</strong> (as arrays/serialized bytes/JSON string).</li></ul><h3>High-level Flow (sequenceDiagram)</h3><h4>Ingestion Flow (documents → vectors → DB)</h4><pre> participant User<br> participant React<br> participant Spring as Spring Boot<br> participant Embed as Ollama (Embeddings)<br> participant H2 as H2 DB<br>----------------------------------------------<br> User-&gt;&gt;React: Upload docs / paste text<br> React-&gt;&gt;Spring: POST /ingest<br> Spring-&gt;&gt;Spring: Chunk text (e.g., 500–1000 tokens)<br> Spring-&gt;&gt;Embed: Embed each chunk (nomic-embed-text)<br> Embed →&gt;Spring: Vectors<br> Spring-&gt;&gt;H2: Save {doc_id, chunk_text, vector, metadata}<br> Spring →&gt;React: Ingestion OK (count, stats)</pre><h4>Question-Answer Flow (query → retrieve → generate)</h4><pre> participant User<br> participant React<br> participant Spring as Spring Boot<br> participant Embed as Ollama (Embeddings)<br> participant H2 as H2 DB<br> participant LLM as Ollama (llama3)<br>-------------------------------------------<br> User-&gt;&gt;React: Ask a question<br> React-&gt;&gt;Spring: POST /ask {query}<br> Spring-&gt;&gt;Embed: Embed query<br> Embed →&gt;Spring: query_vector<br> Spring-&gt;&gt;H2: Load candidate vectors/chunks<br> Spring-&gt;&gt;Spring: Compute similarity (cosine) top-k<br> Spring-&gt;&gt;LLM: Prompt = [context chunks + user query]<br> LLM →&gt;Spring: Grounded answer<br> Spring →&gt;React: {answer, sources}<br> React →&gt;User: Show answer + source snippets</pre><h3>5. Setting Up the Environment</h3><h4>Prerequisites — quick checks</h4><pre>git - version<br>java -version # Java 17+ recommended<br>node -v<br>npm -v<br>curl - version</pre><h4>1) Install and run Ollama</h4><ul><li>Install Ollama (from ollama.com → download installer).</li><li>Start the local server:</li></ul><pre>ollama serve</pre><ul><li>Pull the models we use:</li></ul><pre>ollama pull llama3<br>ollama pull nomic-embed-text</pre><h4>2) Get the project code</h4><pre>cd %USERPROFILE%<br>mkdir code &amp;&amp; cd code<br>git clone https://github.com/The-Billu-Badmash/rag-bot.git<br>cd rag-bot</pre><h4>3) Backend (Spring Boot)</h4><p><strong>3.1 Configure H2 + app ports</strong></p><ul><li>backend/src/main/resources/application.properties</li></ul><pre>spring.application.name=rag-boot<br>server.port=8080<br>spring.datasource.url=jdbc:h2:file:./ragdb;DB_CLOSE_DELAY=-1;MODE=PostgreSQL<br>spring.datasource.username=sa<br>spring.datasource.password=<br>spring.sql.init.mode=always<br>spring.sql.init.schema-locations=classpath:schema.sql<br>spring.jpa.hibernate.ddl-auto=none<br>spring.h2.console.enabled=true<br>spring.h2.console.path=/h2<br>llm.base-url=http://localhost:11434/v1<br>llm.chat-model=llama3<br>llm.embed-model=nomic-embed-text<br>app.cors.allowed-origins=http://localhost:5173</pre><p><strong>3.2 Start the backend</strong></p><pre>Windows : <br>cd backend<br>.\mvnw.cmd spring-boot:run<br><br>macOS/Linux :<br>cd backend<br>./mvnw spring-boot:run</pre><p>You should see the app on:</p><ul><li>Backend: <a href="http://localhost:8080/">http://localhost:8080/</a></li><li>H2 console: http://localhost:8080/h2<br> JDBC URL: jdbc:h2:file:./ragdb, <strong>User:</strong> sa, <strong>Password:</strong> <em>empty</em></li></ul><p><strong>3.3 Backend smoke tests</strong></p><pre># health (if you exposed one)<br>curl http://localhost:8080/actuator/health<br><br># ask API (example)<br>curl -X POST http://localhost:8080/ask ^<br>  -H &quot;Content-Type: application/json&quot; ^<br>  -d &quot;{\&quot;query\&quot;:\&quot;What is RAG?\&quot;}&quot;</pre><p><em>Expect a JSON answer. If it hangs, confirm </em><em>ollama serve is running.</em></p><h4><strong>4) Frontend (React)</strong></h4><pre>cd rag-ui<br>npm install<br>npm run dev</pre><p>Open <strong>React dev server</strong>: <a href="http://localhost:5173/">http://localhost:5173</a></p><h4><strong>5) End-to-end test</strong></h4><ol><li><em>Keep </em><strong><em>Ollama</em></strong><em> running in a terminal (</em><em>ollama serve).</em></li><li><em>Backend is running on </em><strong><em>8080</em></strong><em>.</em></li><li><em>Frontend is running on </em><strong><em>5173</em></strong><em>.</em></li><li><em>In the UI, ask: “Explain Retrieval-Augmented Generation in one line.”<br> You should see a response.</em></li></ol><p><em>Optional: open </em><strong><em>H2 console</em></strong><em> at </em><em>http://localhost:8080/h2 and check your tables (</em><em>documents, </em><em>chunks, etc.) after ingestion.</em></p><h4><strong>6) Useful sample API calls</strong></h4><blockquote><strong>Ingestion</strong> (if you wired /ingest for raw text) :</blockquote><pre>curl -X POST http://localhost:8080/ingest \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{<br>        &quot;docId&quot;:&quot;intro&quot;,<br>        &quot;text&quot;:&quot;RAG mixes retrieval with generation to ground answers.&quot;<br>      }&#39;</pre><blockquote><strong>Ask :</strong></blockquote><pre>curl -X POST http://localhost:8080/ask \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;query&quot;:&quot;What is RAG?&quot;}&#39;</pre><h4><strong>7) Port map (defaults)</strong></h4><ul><li><em>Spring Boot: </em><em>8080</em></li><li><em>H2 console: </em><em>8080/h2</em></li><li><em>Ollama: </em><em>11434</em></li><li><em>React: </em><em>5173</em></li></ul><h3>6. Vector Database &amp; Embeddings</h3><p>When building a RAG application, one of the most important steps is to <strong>connect language models with external knowledge</strong>. That connection happens through <strong>embeddings</strong> and <strong>vector databases</strong>. Let’s break this down step by step.</p><h4>- What are Embeddings?</h4><p>Embeddings are a way to convert <strong>text into numbers</strong> so that computers can understand and compare meaning.</p><ul><li>Example: The sentence <em>“I love programming”</em> might become something like: [0.12, -0.85, 0.47, …]</li><li>These numbers capture the <strong>meaning</strong> of the text, not just the words.</li><li>If two pieces of text have similar meanings, their embeddings will be <strong>close</strong> to each other in vector space.</li></ul><p>In our RAG-Bot, Ollama’s <strong>nomic-embed-text</strong> model creates embeddings for both the user’s query and the document chunks we store.</p><h4>- What is a Vector?</h4><p>A <strong>vector</strong> is simply a list (or array) of numbers.</p><ul><li>In math, vectors describe direction and magnitude.</li><li>In AI, vectors describe the <strong>semantic meaning</strong> of words or sentences.</li></ul><p>Imagine a <strong>map of ideas</strong>:</p><ul><li>“Car” and “Automobile” will be close on the map (similar meaning).</li><li>“Car” and “Banana” will be far apart (different meaning).</li></ul><p>Each document chunk in our app is stored as a <strong>vector</strong> inside the H2 database, along with the original text.</p><h4>- Cosine Similarity &amp; Other Distance Metrics</h4><p>Once we have embeddings, we need a way to measure <strong>how close</strong> two vectors are. There are different ways to do this:</p><blockquote><strong>Cosine Similarity (most common in RAG)</strong></blockquote><ul><li>Measures the <strong>angle</strong> between two vectors.</li><li>Range: <strong>-1 to 1</strong>.</li><li>1 → vectors point in the same direction (very similar).</li><li>0 → no relation.</li><li>-1 → opposite meaning.</li><li>Formula:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*TTSml735DyOFlCoYa31fjA.png" /></figure><p>Example: <em>“AI is smart”</em> vs. <em>“Artificial intelligence is clever”</em> → cosine similarity close to <strong>1</strong>.</p><blockquote><strong>Euclidean Distance</strong></blockquote><ul><li>Measures the <strong>straight-line distance</strong> between two vectors.</li><li>Works like measuring distance on a map.</li></ul><blockquote><strong>Manhattan Distance</strong></blockquote><ul><li>Measures distance in a <strong>grid-like path</strong> (like walking city blocks).</li></ul><blockquote><strong>Dot Product</strong></blockquote><ul><li>Simple multiplication of vectors, sometimes used in similarity scoring.</li></ul><h4>- Why Cosine Similarity is Most Used in RAG</h4><ul><li>In RAG, we care about <strong>direction (meaning)</strong> more than the length (magnitude) of vectors.</li><li>Cosine similarity focuses on <strong>angle</strong> between vectors, ignoring size.</li><li>Works well when embeddings are normalized (scaled consistently).</li><li>More stable than Euclidean for text-based vectors.</li></ul><p>That’s why in our Spring Boot backend, we compute <strong>cosine similarity</strong> between the query vector and document vectors stored in H2, and then pick the <strong>top-k</strong> closest chunks as context for the LLM.</p><pre>  public static float cosine(float[] a, float[] b) {<br>    double dot = 0, na = 0, nb = 0;<br>    for (int i = 0; i &lt; a.length; i++) {<br>      dot += a[i]*b[i]; na += a[i]*a[i]; nb += b[i]*b[i];<br>    }<br>    return (float)(dot / (Math.sqrt(na) * Math.sqrt(nb) + 1e-9));<br>  }</pre><h3>7. Conclusion</h3><p>In this blog, we walked through the journey of building a <strong>RAG (Retrieval-Augmented Generation) chatbot</strong> from scratch using <strong>Ollama, Spring Boot, React, and H2 Database</strong>.</p><ul><li>We started with the <strong>concept of RAG</strong> — why it matters and how it reduces hallucination by grounding answers in real data.</li><li>We looked at the <strong>history of RAG</strong> — from early keyword search methods (TF-IDF, BM25) to embeddings and the formal RAG approach introduced by Facebook AI in 2020.</li><li>We understood the <strong>tech stack</strong> of our application — Ollama as the AI brain, Spring Boot as the manager, React as the face, and H2 as the lightweight memory.</li><li>We saw the <strong>system architecture</strong> and how each component communicates.</li></ul><p>The key idea is simple: <strong><em>Don’t just let the model guess. Give it the right knowledge, and it will answer smarter.</em></strong></p><p>Application Demo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aX7zL1yGPNkJfmphtW0dCQ.png" /><figcaption>Video Link : <a href="https://youtu.be/RfLT1p-2rSY">https://youtu.be/RfLT1p-2rSY</a></figcaption></figure><ul><li><a href="https://youtu.be/RfLT1p-2rSY">https://youtu.be/RfLT1p-2rSY</a></li></ul><p>If you enjoyed this blog or have any suggestions, feel free to drop a comment below. Don’t forget to hit the 👏🏽 like button — it really motivates me to write more beginner-friendly AI guides!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfbefaa895a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Website Content Conversational with NLWeb: My Hands-On Walkthrough]]></title>
            <link>https://sauravmehta818.medium.com/making-website-content-conversational-with-nlweb-my-hands-on-walkthrough-3278b59f3c62?source=rss-11b00bfe33d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3278b59f3c62</guid>
            <category><![CDATA[openai-gpt-4]]></category>
            <category><![CDATA[natural-language-process]]></category>
            <category><![CDATA[microsoft-nlweb]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <category><![CDATA[vector-search]]></category>
            <dc:creator><![CDATA[Saurav Mehta]]></dc:creator>
            <pubDate>Thu, 22 May 2025 09:38:46 GMT</pubDate>
            <atom:updated>2025-05-22T09:51:15.256Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide to turning RSS feeds and semi-structured data into an AI-powered conversational interface using NLWeb and GPT-4</h4><blockquote>Related Topics / Also Known As:</blockquote><ul><li>NLWeb to build Natural Language Interfaces for RSS and schema.org websites</li><li>Turning any website into a chat-friendly experience using NLWeb</li><li>Using NLWeb to make website content searchable with AI</li><li>Creating conversational UI for structured and semi-structured content</li><li>Using GPT-4 and vector DBs to power natural language web experiences</li></ul><p>While exploring GenAI open source repositories, I came across an open-source project by Microsoft called <a href="https://github.com/microsoft/NLWeb"><strong>NLWeb</strong> </a>— and it instantly caught my attention.</p><p>After digging through the documentation and source code, I was amazed by the concept and functionality it offers. The experience of setting it up, breaking it down, and understanding how it actually works turned out to be both technical and enlightening. In this blog, I’ll walk you through what NLWeb is, how it works, and how I used it to turn a static dataset into a conversational, AI-powered experience.</p><h3>Why NLWeb Matters</h3><p>We all know how <strong>HTML revolutionized</strong> the way we interact with information online. It gave data a <strong>visual and structural meaning</strong>. But what if we could give websites a <strong>conversational meaning</strong>?Let’s take a real example:</p><blockquote><em>On Amazon, we often search for a product, apply filters, scroll endlessly — and finally realize that it’s either out of stock or not available.</em></blockquote><p>Wouldn’t it be better to just <strong>ask</strong>:</p><blockquote><em>“Is there any wireless mouse under ₹800 that works with MacBook?”</em></blockquote><p>That’s where <a href="https://github.com/microsoft/NLWeb"><strong>NLWeb</strong></a><strong> </strong>steps in. It enables a new way to interact with web data — through <strong>natural language</strong>, using the power of LLMs (Large Language Models), vector databases, and a clean API interface called <strong>MCP (Model Context Protocol)</strong>.</p><h3>What is NLWeb?</h3><p><a href="https://github.com/microsoft/NLWeb">NLWeb</a> is an open-source framework from Microsoft that:</p><ul><li>Allows users to <strong>ask questions</strong> in natural language</li><li>Searches structured or semi-structured data (like RSS, schema.org, JSON)</li><li>Uses <strong>vector search + LLM</strong> to generate answers</li><li>Responds using the <strong>MCP protocol</strong>, so that AI agents and frontends can parse it meaningfully</li></ul><p>In short:</p><blockquote><em>It turns any semi-structured web content into a </em><strong><em>searchable, conversational agent.</em></strong></blockquote><h3>The Technologies Behind NLWeb</h3><p>Here’s what powers <a href="https://github.com/microsoft/NLWeb">NLWeb</a>:</p><ul><li><strong>Vector DBs</strong>: Qdrant, Milvus, Snowflake Cortex, Azure AI Search</li><li><strong>LLMs</strong>: OpenAI, DeepSeek, Gemini, Inception, Claude</li><li><strong>Data inputs</strong>: RSS feeds, schema.org JSON, plain JSON, semi-structured web content</li><li><strong>MCP</strong>: A simple protocol like REST, but designed for AI agent interactions</li><li><strong>HTTP-based</strong>: All communication is over standard HTTP POST requests</li></ul><p>It is cross-platform, lightweight, and scalable — from laptops to data centers.</p><h3>My Hands-On Experience</h3><p>I ran <a href="https://github.com/microsoft/NLWeb">NLWeb</a> locally on Windows and used it to load a <strong>real podcast RSS feed</strong>. Here’s what I did:</p><ul><li><strong>Cloned the repository</strong> and set up a Python virtual environment.</li></ul><pre>git clone https://github.com/microsoft/NLWeb<br>cd NLWeb</pre><ul><li>Create a <strong>virtual python environment</strong> and activate it.</li></ul><pre>python -m venv myenv<br>source myenv/bin/activate    # Or on Windows: myenv\Scripts\activate</pre><ul><li>Install the dependencies. Note that this will also install the local vector database requirements so you don’t need to install them separately.</li></ul><pre>cd code<br>pip install -r requirements.txt</pre><ul><li>Copy the .env.template file to a new .env file and update the API key you will use for your LLM endpoint of choice.</li></ul><pre>cp .env.template .env</pre><ul><li>Update your config files (located in the code/config folder) to make sure your preferred providers match your .env file. There are three files that may need changes.</li><li>config_llm.yaml: Update the first line to the LLM provider you set in the .env file. By default it is Azure OpenAI. You can also adjust the models you call here by updating the models noted. By default, we are assuming 4.1 and 4.1-mini.</li><li>config_embedding.yaml: Update the first line to your preferred embedding provider. By default it is Azure OpenAI, using text-embedding-3-small.</li><li>config_retrieval.yaml: Update this to qdrant_local for this exercise. By default, this is Azure AI Search.</li></ul><blockquote>Embedding provider (config_embedding.yaml)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RkKJWEV0cyo2ftPo5eBlEQ.png" /><figcaption>config_embedding.yaml (I am using <strong>OpenAI</strong> for text embedding)</figcaption></figure><blockquote>LLM provider (config_llm.yaml)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aP9s9dSf6fZbDkm1AzxQkQ.png" /><figcaption>config_llm.yaml (I am using <strong>OpenAI</strong> for LLM)</figcaption></figure><blockquote>Database provider (config_retrieval.yaml)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVJvTz6em7wVHc9rO6pJ9w.png" /><figcaption>config_retrieval.yaml (qdrant_local for DB)</figcaption></figure><blockquote>Open AI Platform API (.env)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jx4txIAim7hRFIMgq8zY3Q.png" /><figcaption><strong>Copy and paste</strong> the generated key from OpenAI</figcaption></figure><h3>You Need Paid API Access</h3><p>To use <strong>GPT-4</strong> or <strong>embedding models</strong> in your own applications like <a href="https://github.com/microsoft/NLWeb"><strong>NLWeb</strong></a>, it’s important to know that the <strong>OpenAI API is not free</strong>. While OpenAI offers limited free usage for new users, any <strong>real or production-level usage</strong> requires adding credits to your account.</p><p>In my case, I <strong>recharged my OpenAI account with $5</strong> to test if <a href="https://github.com/microsoft/NLWeb">NLWeb</a> works correctly with GPT-4 and embeddings. After the recharge, the API calls started working smoothly, confirming that <a href="https://github.com/microsoft/NLWeb">NLWeb</a> was successfully communicating with OpenAI services.</p><p>You can add credits from your OpenAI dashboard:<br> 🔗 <a href="https://platform.openai.com/account/billing">https://platform.openai.com/account/billing</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEvT0HNRQaSo0LYKZDZ12w.png" /><figcaption>Open AI API Dashboard</figcaption></figure><p>After setting up everything, <strong>now let’s</strong> load some data in our local vector database to test with. <br>I am using this website : https://libsyn.com/<br>RSS Feed : <a href="https://rss.app/feed/xSmZRGfDPCTinNd7">https://rss.app/feed/xSmZRGfDPCTinNd7</a></p><pre>python -m tools.db_load &lt;RSS URL&gt; &lt;site-name&gt;<br>python -m tools.db_load https://feeds.libsyn.com/121695/rss Behind-the-Tech</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IzxImB5rNXJzsRwN2U4fHA.png" /><figcaption>Loading Data Locally</figcaption></figure><ul><li>Start your NLWeb server (again from the ‘code’ folder):</li></ul><pre>python app-file.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7G9c2DjTMUJ8g8NKRX1jGg.png" /><figcaption>Running NLWeb Server</figcaption></figure><ul><li>Then open your browser at: <a href="http://localhost:8000/%E2%80%9D">http://localhost:8000/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDfz-Lp0HsjytcxIxVaH-Q.png" /><figcaption>NLWeb UI (You can modify and <strong>improve</strong> it)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3F3cqH7rz1fZ5lyGymwGQ.png" /><figcaption>NLWeb Workings</figcaption></figure><blockquote><strong>Started asking questions like:</strong></blockquote><ul><li>“Which episode talks about AI in healthcare?”</li><li>“Who was the guest in the most recent episode?”</li></ul><p><a href="https://github.com/microsoft/NLWeb">NLWeb</a> returned precise, context-rich answers — generated by GPT — using the content it had ingested and embedded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78RySf31qEwyPNotToyT5A.png" /><figcaption>My LLM usage after asking 2 questions</figcaption></figure><h3>The /mcp Endpoint: How It Works</h3><p><a href="https://github.com/microsoft/NLWeb">NLWeb</a> exposes an HTTP endpoint (/mcp) where clients can send a POST request like:</p><pre>{<br>  &quot;query&quot;: &quot;What is the latest episode about?&quot;,<br>  &quot;site&quot;: &quot;Behind-the-Tech&quot;,<br>  &quot;mode&quot;: &quot;generate&quot;<br>}</pre><p>The server processes it using vector search + LLM and replies with:</p><pre>{<br>  &quot;query_id&quot;: &quot;xyz123&quot;,<br>  &quot;results&quot;: [<br>    {<br>      &quot;url&quot;: &quot;...&quot;,<br>      &quot;name&quot;: &quot;AI in Creativity&quot;,<br>      &quot;description&quot;: &quot;Kevin Scott discusses...&quot;,<br>      &quot;schema_object&quot;: {<br>        &quot;@type&quot;: &quot;PodcastEpisode&quot;,<br>        &quot;name&quot;: &quot;AI in Creativity&quot;<br>      }<br>    }<br>  ]<br>}</pre><h3>What Makes It Impressive</h3><ul><li>It’s not just a chatbot — it’s a full <strong>Retrieval-Augmented Generation (RAG)</strong> system</li><li>It supports <strong>agent interoperability</strong> via MCP</li><li>It uses <strong>schema.org</strong>, <strong>RSS</strong>, etc. to keep responses semantically rich</li><li>It’s <strong>modular and pluggable</strong> — you can swap in different LLMs, vector DBs, etc.</li></ul><h3>Final Thoughts</h3><p><a href="https://github.com/microsoft/NLWeb">NLWeb</a> is a powerful example of what conversational AI can do <strong>beyond chatbots</strong>. It turns your static content into an intelligent, conversational interface. Whether you’re running a blog, podcast, product catalog, or documentation site — NLWeb gives you a working, hackable starting point to bring AI-native interfaces to your content.</p><blockquote><em>Want to make your website talk back? Try </em><a href="https://github.com/microsoft/NLWeb"><em>NLWeb</em></a><em>.</em></blockquote><p>Let me know if you’d like to see the full setup guide, or how I plan to extend this further!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3278b59f3c62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VPNs 101: A Beginner’s Guide to Online Privacy]]></title>
            <link>https://sauravmehta818.medium.com/vpns-101-a-beginners-guide-to-online-privacy-699b8add7195?source=rss-11b00bfe33d1------2</link>
            <guid isPermaLink="false">https://medium.com/p/699b8add7195</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[vpn]]></category>
            <dc:creator><![CDATA[Saurav Mehta]]></dc:creator>
            <pubDate>Sat, 28 Dec 2024 20:39:39 GMT</pubDate>
            <atom:updated>2024-12-29T05:46:30.488Z</atom:updated>
            <content:encoded><![CDATA[<p>The field of computer organization and architecture is one of the fastest-growing areas in technology. Its increasing complexity spans multiple domains, often requiring a lifetime of study to fully master.</p><p>To simplify this vast field, I categorize it into three main components based on their functions:</p><ol><li><strong>Processing</strong></li><li><strong>Storage</strong></li><li><strong>Networking</strong></li></ol><p>While each of these areas is deep enough to earn multiple PhDs, my goal with this series is to explore and share insights into these fascinating topics. As this is my first blog post, I want to clarify that I am not yet an expert in any of these domains. However, I believe that sharing knowledge and perspectives fosters a valuable environment for learning and discussion.</p><p>To kick things off, I’ll dive into an essential topic within networking: <strong>Virtual Private Networks (VPNs).</strong></p><p><strong>1. What is a VPN?</strong></p><p>A <strong>VPN (Virtual Private Network)</strong> is a technology that creates a secure, encrypted connection over the internet, allowing users to transmit data privately and securely by masking their IP address and hiding their online location.</p><p>Before we discuss how a VPN works, it’s essential to understand the fundamental concept of how the modern internet operates.</p><p><strong>2. The Client-Server Architecture</strong></p><p>For simplicity, this blog will focus on the <strong>client-server architecture</strong>, although the principles apply to other architectures, such as peer-to-peer (P2P).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*-C4dZP9-AJiM7Fl8zL9tmg.jpeg" /><figcaption>Simple client-server architecture diagram</figcaption></figure><p>In the client-server architecture, all activities on our device involve a server. Here, we act as clients seeking information, while the server provides that information. Servers not only deliver information but also store our IP addresses for geolocation-based content sharing.</p><p>When <strong>data packets</strong> leave our <strong>Network Interface Card (NIC)</strong>, they contain both the sender’s IP and a port, as well as the receiver’s IP and a port in the header, along with the data itself.</p><p>These data packets are routed through multiple routers, which use a process called <strong>Network Address Translation (NAT)</strong> to translate private IP addresses into public IP addresses. (Please note that NAT and routing are beyond the scope of this topic.)</p><p>When our data packets reach the server, the server extracts the data, retrieves the sender’s IP address, and sends the information back to the sender’s IP address, effectively completing the communication cycle.</p><p><strong>3. The Problem</strong></p><p>The issue with this approach is the <strong>middlemen</strong> who monitor our data packets and activities, logging them in their systems. Unfortunately, governments have substantial control over these middlemen: the <strong>Internet Service Providers (ISPs).</strong> All of your data packets must route through ISP servers, giving them the ability to observe your activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HjQchBrYG4bzDM4QBucH6w.jpeg" /><figcaption>Diagram of a normal working network</figcaption></figure><p>Furthermore, the server that serves you information also records your data and IP address for geo-location purposes. Thanks to intergovernmental policies, this data can be shared with your government or third parties.</p><p><strong>4. The Solution</strong></p><p>The solution is straightforward: use a <strong>VPN!</strong> A VPN consists of two parts: the <strong>VPN client</strong> and the <strong>VPN server.</strong> Most VPN providers have servers located in various countries around the world.</p><p>As we discussed earlier, ISPs act as middlemen between our devices and the server. However, the VPN client now serves as a middleman between us and the ISP — this is where the real change occurs.</p><p>Before your data leaves the NIC, it gets encrypted and wrapped into a new data packet created by the VPN client. This new data packet will have the VPN server’s address as the receiver instead of the actual intended server, effectively acting as a <strong>proxy.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*oBmN3I8F_mkpD2WRmtCP5w.jpeg" /><figcaption>Working diagram of a VPN proxy</figcaption></figure><p>The VPN server then decrypts the data packet, retrieves the original data packet, and redirects the request to the intended server, all while ensuring no logs of your activity are stored.</p><p><strong>5. VPN Protocols</strong></p><p>VPN companies utilize various protocol algorithms to secure connections. These protocols define how data is transmitted securely between the VPN client and VPN server, establishing a protected communication channel known as a <strong>VPN tunnel.</strong> Some popular protocols include:</p><ul><li><strong>OpenVPN</strong>: Highly secure and open-source, widely supported.</li><li><strong>WireGuard</strong>: Known for its speed and lightweight design.</li><li><strong>IKEv2/IPsec</strong>: Excellent for mobile devices due to its stability during network changes.</li></ul><p>Each protocol has its strengths, and many VPN providers allow users to choose one based on their needs.</p><p><strong>6. Conclusion</strong></p><p>With a VPN:</p><ul><li>The server will never know your true geolocation.</li><li>Your ISP will not have access to your search history or the websites you visit.</li><li>Governments and third parties will remain unaware of your online activities.</li></ul><p>In summary, using a VPN is a critical step in maintaining your online privacy and security. Take time to explore reputable VPN providers, evaluate their features, and choose one that aligns with your privacy needs.</p><p><em>Stay tuned for more blog posts in this series as we dive deeper into computer organization and architecture!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=699b8add7195" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>