<?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 Arka Mukherjee on Medium]]></title>
        <description><![CDATA[Stories by Arka Mukherjee on Medium]]></description>
        <link>https://medium.com/@arka.m00kherjee?source=rss-44ae271e3b36------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PkrZ3l7xBi4ZZdJr</url>
            <title>Stories by Arka Mukherjee on Medium</title>
            <link>https://medium.com/@arka.m00kherjee?source=rss-44ae271e3b36------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:36:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arka.m00kherjee/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Zero-Cost RAG Pipeline with Spring AI 2.0, Ollama, and Pinecone]]></title>
            <link>https://medium.com/@arka.m00kherjee/building-a-zero-cost-rag-pipeline-with-spring-ai-2-0-ollama-and-pinecone-ac6935146418?source=rss-44ae271e3b36------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac6935146418</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[pinecone]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[spring-ai]]></category>
            <dc:creator><![CDATA[Arka Mukherjee]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 18:52:10 GMT</pubDate>
            <atom:updated>2026-07-20T18:52:22.680Z</atom:updated>
            <content:encoded><![CDATA[<p>How I built a production-shaped Retrieval-Augmented Generation service in Java — with local open-source models, a free-tier vector database, and no LLM API bill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07nPhfSv8q0BL5pc55oHRg.png" /></figure><p>Most RAG tutorials start the same way: “First, grab your OpenAI API key.” That’s fine for a demo, but if you’re a Java developer who wants to actually understand the moving parts of a RAG system — chunking, embedding, vector search, prompt augmentation — running everything through a paid black box teaches you less than you’d think, and costs you money while doing it.</p><p>So I built the whole thing on a zero-cost stack:</p><ul><li><strong>Spring Boot 4.0.6 + Spring AI 2.0</strong> for the application framework and RAG plumbing</li><li><strong>Ollama</strong> running locally, serving <strong>Mistral</strong> as the chat model and <strong>nomic-embed-text</strong> as the embedding model — both open source, both free</li><li><strong>Pinecone’s free tier</strong> as the managed vector store</li><li><strong>Apache Tika</strong> for parsing real-world documents (PDF, DOCX, HTML, TXT)</li></ul><p>The full source is on GitHub: <a href="https://github.com/ArkaMukherjee/spring-ai-rag-pinecone">ArkaMukherjee/spring-ai-rag-pinecone</a></p><p>In this post I’ll walk through the architecture, the key Spring AI abstractions that make this surprisingly compact, and a few gotchas that will save you an afternoon of debugging.</p><h3>The Architecture</h3><p>The pipeline has two independent flows: <strong>ingestion</strong> (getting knowledge in) and <strong>retrieval + generation</strong> (getting answers out).</p><pre>┌──────────────┐   embed    ┌────────────────┐<br> ingest  ─────▶ │  Ingestion   │ ─────────▶ │    Pinecone    │<br>(text/file)     │   Service    │  (Ollama)  │  vector store  │<br>                └──────────────┘            └────────────────┘<br>                                                    ▲  similarity<br>                                                    │  search<br>                ┌──────────────┐   retrieve         │<br> question ────▶ │     Rag      │ ───────────────────┘<br>                │   Service    │ ── augment ──▶ Mistral (Ollama) ──▶ answer + sources<br>                └──────────────┘</pre><p><strong>Ingestion flow:</strong> a document comes in as raw text or a file upload. Apache Tika extracts the text, Spring AI’s TokenTextSplitter chunks it into ~800-token pieces, Ollama&#39;s nomic-embed-text turns each chunk into a 768-dimension vector, and the vectors land in a Pinecone index along with their metadata.</p><p><strong>Query flow:</strong> a question arrives, gets embedded with the same model, Pinecone returns the top-K most similar chunks, and those chunks are injected into the prompt sent to Mistral. The response comes back with the answer <em>and</em> the source chunks that grounded it — so the caller can always see why the model said what it said.</p><h3>Why This Particular Stack?</h3><p><strong>Ollama</strong> is the piece that makes this genuinely free. It runs open-source models locally with a single ollama pull, exposes a simple HTTP API, and Spring AI has a first-class starter for it. Mistral 7B is a sweet spot for local inference: capable enough for grounded Q&amp;A, small enough to run on a decent laptop.</p><p><strong>nomic-embed-text</strong> is one of the best open embedding models you can run locally. It produces 768-dimension vectors and consistently punches above its weight on retrieval benchmarks.</p><p><strong>Pinecone</strong> handles the part you <em>don’t</em> want to run locally: the vector index. The free tier gives you a serverless index that’s more than enough for a personal knowledge base, and Spring AI’s Pinecone vector store abstraction means you never touch the Pinecone SDK directly.</p><p><strong>Apache Tika</strong> is the unsung hero. Real documents aren’t clean text files — they’re PDFs with weird encodings, Word documents, HTML exports. Tika normalizes all of it behind one parser, so the ingestion endpoint can accept nearly anything.</p><h3>The Spring AI Magic: QuestionAnswerAdvisor</h3><p>The core of the RAG behavior is almost embarrassingly small thanks to Spring AI’s <strong>advisor</strong> model. An advisor intercepts a ChatClient call and augments it — and QuestionAnswerAdvisor does exactly what a RAG pipeline needs: it embeds the incoming question, runs a similarity search against the vector store, and stuffs the retrieved chunks into the prompt before the model ever sees it.</p><p>One design decision worth highlighting: I attach the advisor <strong>per request</strong>, not globally. That’s because two of the most important RAG tuning knobs — topK (how many chunks to retrieve) and the similarityThreshold (how relevant a chunk must be to qualify) — shouldn&#39;t be hardcoded. Callers can pass them on every call:</p><p>json</p><pre>POST /api/rag/chat<br>{<br>  &quot;question&quot;: &quot;Does Spring AI support Pinecone?&quot;,<br>  &quot;topK&quot;: 4,<br>  &quot;similarityThreshold&quot;: 0.5<br>}</pre><p>And the response always carries its receipts:</p><p>json</p><pre>{<br>  &quot;answer&quot;: &quot;Yes, Spring AI supports Pinecone as a vector store.&quot;,<br>  &quot;sources&quot;: [<br>    { &quot;id&quot;: &quot;…&quot;, &quot;text&quot;: &quot;Spring AI supports Pinecone…&quot;, &quot;score&quot;: 0.82 }<br>  ]<br>}</pre><p>Returning sources with scores isn’t just a nice-to-have. In any serious RAG deployment, it’s how you debug retrieval quality — if the answers are bad, the first question is always “what did the model actually see?”</p><h3>The API Surface</h3><p>Three endpoints cover the whole lifecycle:</p><p><strong>POST /api/ingest/text</strong> — push raw text with a source label and arbitrary metadata. Useful for notes, snippets, or programmatic ingestion from other systems.</p><p><strong>POST /api/ingest/file</strong> — multipart upload for PDF, DOCX, HTML, TXT and anything else Tika can parse (capped at 25 MB). The response tells you how many chunks were produced, which is a quick sanity check on your splitter settings.</p><p><strong>POST /api/rag/chat</strong> — ask a question, get a grounded answer with sources.</p><p>Plus Spring Boot Actuator at /actuator/health and /actuator/metrics, because a RAG service is still a service.</p><h3>Configuration</h3><p>Everything is environment-driven, so the same jar runs on a laptop or in a container without changes:</p><p>VariableDefaultPurposeOLLAMA_BASE_URLhttp://localhost:11434Ollama serverOLLAMA_CHAT_MODELmistralChat modelOLLAMA_EMBEDDING_MODELnomic-embed-textEmbedding modelPINECONE_API_KEY<em>(required)</em>Pinecone authPINECONE_INDEXrag-indexIndex namePINECONE_NAMESPACEdefaultNamespace</p><p>Getting started is four commands:</p><p>bash</p><pre>ollama pull mistral<br>ollama pull nomic-embed-text<br>export PINECONE_API_KEY=your-key-here<br>./mvnw spring-boot:run</pre><h3>Three Gotchas That Will Save You an Afternoon</h3><p><strong>1. The embedding dimension must match the index dimension — exactly.</strong> nomic-embed-text produces 768-dimension vectors, so the Pinecone index must be created with dimension <strong>768</strong> (cosine metric recommended). Get this wrong and you&#39;ll see cryptic upsert failures rather than a clear error. And if you ever swap embedding models, you need a new index — you can&#39;t mix vector spaces.</p><p><strong>2. Disable auto-pull for models.</strong> By default, Spring AI’s Ollama integration can pull missing models at startup. That sounds convenient, but it means your app can block for minutes downloading gigabytes on first boot — terrible in a container environment. I set pull-model-strategy: never and pull the models out-of-band. Startup stays fast and predictable.</p><p><strong>3. Keep the chat temperature low.</strong> For grounded Q&amp;A, creativity is the enemy. Mistral runs at temperature 0.2 here, which keeps it anchored to the retrieved context instead of improvising. RAG works best when the model treats the retrieved chunks as the source of truth, not as inspiration.</p><h3>Project Layout</h3><p>The structure is deliberately boring — the kind of layout any Spring developer can navigate in thirty seconds:</p><pre>src/main/java/com/example/rag/<br>├── RagPipelineApplication.java     # Spring Boot entry point<br>├── config/RagConfig.java           # ChatClient + system prompt<br>├── controller/                     # REST endpoints + error handling<br>├── dto/                            # request/response records<br>└── service/<br>    ├── IngestionService.java       # chunk + embed + store<br>    └── RagService.java             # retrieve + generate</pre><p>Two services, two controllers, one config class. That’s the entire RAG pipeline. The heavy lifting — embedding calls, vector store operations, prompt augmentation — is all delegated to Spring AI abstractions, which is exactly where it belongs.</p><h3>Closing Thoughts</h3><p>The biggest takeaway from building this: <strong>RAG is no longer exotic infrastructure.</strong> With Spring AI 2.0, the retrieval-augmentation loop that used to require Python glue code and a stack of custom prompt templates is now a first-class citizen in the Java ecosystem — advisors, vector store abstractions, document readers and all.</p><p>And the zero-cost angle isn’t just about saving money. Running Mistral and nomic-embed-text locally means your documents never leave your machine during embedding or inference — only vectors go to Pinecone. For anyone experimenting with RAG on internal or sensitive documents, that’s a meaningful property, not just a cost optimization.</p><p>The full code is here: <a href="https://github.com/ArkaMukherjee/spring-ai-rag-pinecone"><strong>github.com/ArkaMukherjee/spring-ai-rag-pinecone</strong></a> — clone it, point it at your own Pinecone index, and you’ll have a working RAG API in under ten minutes.</p><p>If you build something on top of it, I’d love to hear about it in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac6935146418" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Agents Aren’t a Python Monopoly: Building a Multi-Agent Trip Planner in Java with Embabel]]></title>
            <link>https://medium.com/@arka.m00kherjee/ai-agents-arent-a-python-monopoly-building-a-multi-agent-trip-planner-in-java-with-embabel-44d7f4e46fbc?source=rss-44ae271e3b36------2</link>
            <guid isPermaLink="false">https://medium.com/p/44d7f4e46fbc</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[embabel]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Arka Mukherjee]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 07:32:28 GMT</pubDate>
            <atom:updated>2026-07-10T07:32:28.990Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How enterprise Java teams can bring agentic AI into the stack they already run, test, and trust — no polyglot rewrite required.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hN_ras5ub6bzDhgnKINnsw.jpeg" /></figure><p>I’ll be honest — I don’t write or post often. But I’ve been experimenting with something over the past few weeks that I genuinely felt was worth putting into words.</p><p>It started with a question that’s been nagging me for a while:</p><blockquote><strong><em>Why does “building with AI” automatically mean “switching to Python”?</em></strong></blockquote><p>If you follow the agentic AI space, the ecosystem seems to speak one language. LangChain, CrewAI, AutoGen, LangGraph — Python, Python, Python. The tutorials are Python. The demos are Python. The hiring posts are Python.</p><p>But here’s the reality most enterprise engineers live in: <strong>the systems that actually run the world’s banks, insurers, mortgage platforms, and pension funds are overwhelmingly Java.</strong> Decades of robust, battle-tested, compliance-hardened JVM code that isn’t going anywhere — nor should it.</p><p>So the real question isn’t <em>“should we rewrite in Python to do AI?”</em></p><p>It’s <em>“how do we bring agentic AI </em><strong><em>into</em></strong><em> the Java stack we already trust?”</em></p><p>That’s where <strong>Embabel</strong> comes in.</p><h3>What Is Embabel?</h3><p>Embabel is an open-source agent framework for the JVM, created by <strong>Rod Johnson</strong> — yes, the creator of Spring. That lineage matters, because Embabel feels like what Spring did for enterprise Java twenty years ago, applied to the agentic era:</p><ul><li><strong>Strongly-typed agents.</strong> Goals, actions, inputs, and outputs are real Java/Kotlin types — not stringly-typed prompt soup.</li><li><strong>Deterministic planning.</strong> Embabel uses <strong>GOAP (Goal-Oriented Action Planning)</strong> — an AI planning algorithm from the gaming world — to decide <em>which</em> agent action to run <em>when</em>, based on preconditions and effects. The LLM handles reasoning inside actions; the framework handles orchestration.</li><li><strong>Native Spring integration.</strong> Agents are Spring beans. Dependency injection, familiar testing patterns, existing observability — it all just works.</li><li><strong>LLMs where they add value, plain Java where they don’t.</strong> Deterministic business logic stays deterministic. That’s exactly what regulated industries need.</li></ul><p>If you’ve ever tried to explain to a risk or compliance team why your “AI workflow” is a chain of untyped prompts with no guaranteed execution path, you’ll immediately understand why this design philosophy matters.</p><h3>The Experiment: A Multi-Agent Trip Planner</h3><p>To put Embabel through its paces, I built a <strong>multi-agent trip-planner application</strong> — a deliberately relatable use case that still exercises real orchestration patterns.</p><p>The full source code is here: 👉 <a href="https://github.com/ArkaMukherjee/multi-agent-orchestration-embabel"><strong>github.com/ArkaMukherjee/multi-agent-orchestration-embabel</strong></a></p><h3>The Idea</h3><p>A user says something like:</p><blockquote>“Plan me a 5-day trip to Kerala in December, mid-range budget, I love backwaters and local food.”</blockquote><p>Behind the scenes, multiple specialized agents collaborate:</p><ol><li><strong>Destination Research Agent</strong> — gathers context about the destination, season, and traveler preferences.</li><li><strong>Itinerary Planning Agent</strong> — builds a day-by-day plan from the research output.</li><li><strong>Budget &amp; Logistics Agent</strong> — sanity-checks the plan against budget constraints and travel feasibility.</li><li><strong>Composer Agent</strong> — assembles everything into a polished, final itinerary.</li></ol><p>The key point: <strong>I never wrote the orchestration logic imperatively.</strong> I declared what each agent <em>can do</em> (actions), what it <em>needs</em> (input types), and what the system should <em>achieve</em> (goals). Embabel’s GOAP planner figured out the execution path.</p><h3>What the Code Looks Like</h3><p>Here’s the flavor of it (simplified for readability):</p><p>java</p><pre>@Agent(description = &quot;Plans complete trips based on traveler preferences&quot;)<br>public class TripPlannerAgent {</pre><pre>    @Action<br>    public DestinationResearch researchDestination(TripRequest request) {<br>        // LLM-powered research, returning a strongly-typed result<br>        return ai()<br>            .withLlm(OpenAiModels.GPT_4)<br>            .createObject(<br>                &quot;Research &quot; + request.destination() +<br>                &quot; for a trip in &quot; + request.month() + &quot;...&quot;,<br>                DestinationResearch.class<br>            );<br>    }</pre><pre>    @Action<br>    public DayByDayItinerary buildItinerary(TripRequest request,<br>                                            DestinationResearch research) {<br>        // The planner knows this action depends on DestinationResearch —<br>        // so it automatically runs researchDestination first.<br>        ...<br>    }</pre><pre>    @AchievesGoal(description = &quot;Produce a complete, budget-checked trip plan&quot;)<br>    @Action<br>    public TripPlan composeFinalPlan(DayByDayItinerary itinerary,<br>                                     BudgetAssessment budget) {<br>        ...<br>    }<br></pre><p>Notice what’s happening:</p><ul><li>Every input and output is a <strong>plain Java record/class</strong>. Your IDE understands it. Your tests understand it. Your compiler catches mistakes.</li><li>The <strong>dependency graph is implicit in the types</strong>. buildItinerary needs a DestinationResearch — so the planner schedules researchDestination before it. No manual DAG wiring, no brittle prompt chains.</li><li>The @AchievesGoal annotation tells the planner what &quot;done&quot; looks like. Everything else is derived.</li></ul><p>This is the part that genuinely surprised me. It’s less “prompt engineering framework” and more “<strong>Spring for agents</strong>” — declarative, typed, and testable.</p><h3>Why This Matters for Java Legacy Estates</h3><p>Here’s the strategic takeaway — and honestly, the reason I decided to write this post.</p><p>Most large enterprises are sitting on <strong>massive Java estates</strong>: core banking systems, loan origination platforms, claims engines, payment rails. The pressure to “add AI” is enormous. The typical options on the table are:</p><ol><li><strong>Stand up a parallel Python stack.</strong> New team, new deployment pipeline, new security review, new operational burden — and a network boundary between your AI logic and your domain logic.</li><li><strong>Buy a black-box AI product.</strong> Fast, but you lose control, and integration with your domain model is usually shallow.</li><li><strong>Bring agents into the JVM.</strong> Reuse your existing services, repositories, domain objects, security context, and observability — and layer intelligence <em>on top of</em> what already works.</li></ol><p>Embabel makes option 3 realistic. Your existing service classes can become agent actions. Your existing DTOs become agent inputs and outputs. Your existing Spring Security, monitoring, and CI/CD pipelines apply unchanged.</p><p>For teams in <strong>regulated industries</strong> — banking, insurance, mortgage, pensions — this is a big deal:</p><ul><li><strong>Auditability:</strong> GOAP planning gives you a deterministic, inspectable execution plan — not an opaque LLM deciding your workflow on a whim.</li><li><strong>Testability:</strong> Typed actions are unit-testable with the JUnit/Mockito patterns your team already knows.</li><li><strong>Incremental adoption:</strong> You don’t rewrite the loan platform. You add one agent that reads from it.</li></ul><p>Modernization without migration. That’s the pattern.</p><h3>The Bigger Point</h3><p>The narrative that “AI = Python” is a snapshot of <em>where the tooling started</em>, not a law of nature. The JVM ecosystem is catching up fast — Spring AI, LangChain4j, and now Embabel for full agentic orchestration.</p><p>If you’re a Java engineer who’s been watching the agentic AI wave from the sidelines, feeling like you’d need to abandon your stack to participate: <strong>you don’t.</strong> The abstractions you already value — strong typing, dependency injection, testability, deterministic behavior — turn out to be exactly what production-grade agents need.</p><p>The JVM isn’t watching the AI wave. It’s building on it.</p><h3>Explore the Code</h3><p>The complete multi-agent trip-planner implementation is on GitHub:</p><p>🔗 <a href="https://github.com/ArkaMukherjee/multi-agent-orchestration-embabel"><strong>https://github.com/ArkaMukherjee/multi-agent-orchestration-embabel</strong></a></p><p>Clone it, run it, break it, extend it. And if you’re building agentic systems on Java — I’d genuinely love to hear what’s working (and what isn’t) for you. Drop a comment or connect with me.</p><p><em>Arka Mukherjee is a Senior Technical Lead with 13+ years of experience building enterprise systems in the BFSI domain, currently focused on agentic AI architectures on the JVM — Spring AI, MCP, RAG pipelines, and multi-agent orchestration.</em></p><p><strong>Tags:</strong> Java Artificial Intelligence Spring Boot Software Architecture Agentic AI</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44d7f4e46fbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>