<?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[digitalgreen-techblog - Medium]]></title>
        <description><![CDATA[Learn about Digital Green’s efforts in building open source tech components, new innovations, features and team culture. - Medium]]></description>
        <link>https://medium.com/digitalgreen-techblog?source=rss----c63e16f962ee---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>digitalgreen-techblog - Medium</title>
            <link>https://medium.com/digitalgreen-techblog?source=rss----c63e16f962ee---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:01:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/digitalgreen-techblog" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Bridging Fields and Futures: Agricultural Intelligence with FarmerChat-MCP]]></title>
            <link>https://medium.com/digitalgreen-techblog/bridging-fields-and-futures-agricultural-intelligence-with-farmerchat-mcp-5a38ed72b537?source=rss----c63e16f962ee---4</link>
            <guid isPermaLink="false">https://medium.com/p/5a38ed72b537</guid>
            <category><![CDATA[agtech]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[tech4good]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Aakash Singh]]></dc:creator>
            <pubDate>Thu, 15 Jan 2026 14:13:53 GMT</pubDate>
            <atom:updated>2026-01-17T03:14:14.584Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A technical deep-dive into building a unified agricultural data and intelligence system for smallholder farmers by Digital Green</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U48Ty-USgnpK72zYaq621A.png" /></figure><h3>Motivation</h3><p>Imagine a smallholder farmer in Bihar asking a simple question: “<em>When is the best planting date coming next season?</em>”</p><p>To answer this comprehensively, they need:</p><ul><li>Current weather patterns and 7-day forecasts</li><li>Soil composition and nutrient levels</li><li>Groundwater availability and drought status</li><li>What crops her neighbors are successfully growing</li><li>Pest activity in the region</li><li>Terrain elevation for irrigation planning</li><li>Village-level agricultural trends</li></ul><p>Traditionally, each data point lives in a different silo — weather from one API, soil from another, crop intelligence scattered across research papers and so on.</p><blockquote>A farmer would need to be a data scientist to synthesize this information into actionable advice.</blockquote><h3>Solution: Combined intelligence</h3><p>Here’s what that same farmer’s experience can look like today with <strong>FarmerChat-MCP</strong>:</p><pre>Farmer: &quot;Tell me about my farm in Araria. <br>        What should I plant?&quot;</pre><pre>System Response (synthesizing 7 data sources in parallel):</pre><pre>&quot;Your 2-acre farm has excellent silty loam soil (pH 6.8) <br>but faces severe drought conditions (13.5th percentile <br>groundwater).</pre><pre>Current weather: Pleasant winter (21°C), no rain forecast <br>for 7 days. Elevation: 52m (floodplain region).</pre><pre>RECOMMENDATION: Plant wheat (1.5 acres) + drought-tolerant <br>lentils (0.5 acres). Wheat needs only 4–5 irrigations, <br>lentils just 2–3. Your soil composition is ideal for both.</pre><pre>PRIORITY ACTION: Add 8–10 tons farm manure—your organic <br>carbon is critically low (0.1 g/kg).</pre><pre>NEIGHBOR INTELLIGENCE: 320 farmers in your area grow wheat <br>successfully. Most common rotation: wheat → rice. 85 farms <br>grow lentils with good yields.</pre><pre>Pest alert: Fire ants observed 15km away—monitor crop borders.</pre><pre>Expected returns: ₹60,000–70,000 net profit this Rabi season.&quot;</pre><blockquote><strong>One question</strong>. <strong>Seven data sources</strong>. <strong>A comprehensive, actionable farming plan synthesized in seconds.</strong></blockquote><p>The system pulls information from seven different data systems and APIs -all orchestrated through a unified architecture that decides which sources are relevant.</p><p><em>This reduces the data synthesis that would require a farmer hours of research into a single conversational query.</em></p><p>But it goes further.</p><p><strong>Ask about the village, and the system analyzes thousands of farms</strong>:</p><pre>Farmer: &quot;What crops are grown in Bhaisalotan village?&quot;</pre><pre>System Response (processing 4,175 farms across 542 hectares):</pre><pre>&quot;Bhaisalotan Village Agricultural Profile:</pre><pre>Total farms: 4,175 | Area: 542 hectares<br>Average farm size: 0.13 hectares (smallholder dominant)</pre><pre>CROP DISTRIBUTION:<br>  • Sugarcane: 62.4% (~2,600 farms) - dominant cash crop<br>  • Wheat: 18% (~750 farms)<br>  • Rice: 12% (~500 farms)<br>  • Mustard: 5% (~210 farms)</pre><pre>FARMING INTENSITY:<br>  • Single-season farming: 77%<br>  • Multi-cropping: 23%</pre><pre>TOP ROTATION PATTERN: Wheat → Rice (89 farms)</pre><pre>INSIGHT: Heavy sugarcane concentration suggests proximity <br>to sugar mills. Village economy closely tied to this crop.&quot;</pre><p><strong>Ask how your village compares to a neighboring one, and you get data-driven benchmarking</strong>:</p><pre>Farmer: &quot;How does Bhaisalotan compare to Madhopur?&quot;</pre><pre>System Response:</pre><pre>&quot;Village Comparison:</pre><pre>                      Bhaisalotan    Madhopur<br>Multi-cropping rate:  23%            39.5% ✓<br>Crop diversity:       Low            Balanced ✓<br>Dominant pattern:     Sugarcane      Wheat-Rice<br>                      monoculture    rotation</pre><pre>ASSESSMENT: Madhopur demonstrates more sustainable practices:<br>  • Higher farming intensity (39.5% vs 23% multi-cropping)<br>  • Better crop rotation (wheat → rice vs continuous sugarcane)<br>  • Greater risk diversification</pre><pre>RECOMMENDATION: Bhaisalotan farmers could benefit from <br>adopting Madhopur&#39;s wheat-rice rotation pattern for <br>improved soil health and income stability.&quot;</pre><p>The system computes these analyses in real-time — querying satellite APIs, processing thousands of farm boundaries, deduplicating overlapping data, and synthesizing results.</p><p>Let’s deep dive into the details.</p><h3>Model Context Protocol (MCP): The Foundation</h3><p>The architecture that makes this possible is built on Anthropic’s Model Context Protocol.</p><h4>What is MCP?</h4><p>MCP is a standardized interface for AI systems to access external data sources. Before MCP, connecting an AI to a new data source — weather, soil, satellite imagery — required custom integration code for every client-source pair. Each application needed its own implementation.</p><p>MCP inverts this model. You create a “server” once — a program that fetches and formats data from a specific source. Any MCP-compatible AI assistant can use it immediately. Build once, deploy everywhere.</p><h4>Why This Matters for Agriculture</h4><p>Agriculture is inherently multi-dimensional. A sound farming decision requires:</p><ul><li><strong>Environmental context</strong>: weather, soil, water availability</li><li><strong>Biological intelligence</strong>: pest pressure, crop suitability</li><li><strong>Social patterns</strong>: what neighboring farmers grow successfully</li><li><strong>Geopolitical boundaries</strong>: village, district, and state-level trends</li></ul><p>MCP enables specialized servers for each dimension, orchestrated based on query requirements. The same twelve servers power SMS, WhatsApp, web, and Claude Desktop interfaces — without duplicate code.</p><h3>Phase 1: The Core Five Servers</h3><blockquote>We started v0 with the five critical data points every farmer needs.</blockquote><h4>1. Weather Server (Open-Meteo API)</h4><p>“Will it rain this week?” is the most asked agricultural question worldwide.</p><p><strong>What it provides: </strong>Current conditions of temperature, precipitation, wind, humidity and 7-day forecasts with confidence intervals.</p><h4><strong>2. Soil Properties Server (Google Earth Engine)</strong></h4><p>Soil determines what can grow and what inputs are needed. Our server taps into OpenLandMap’s global soil database.</p><p><strong>What it provides: </strong>Texture analysis like clay, sand, silt percentages; acidity, organic content and water holding capacity.</p><h4>3. Groundwater Server (NASA GRACE Satellite)</h4><p>Water is critical and variable input. Our server uses NASA’s GRACE satellite data for subsurface water intelligence.</p><p><strong>What it provides: </strong>Groundwater percentile rankings, soil moistoure level and drought severity classifications along with water storage anomalies.</p><h4>4. Elevation Server (OpenElevation)</h4><p>Terrain height affects irrigation planning, drainage, and crop selection.</p><p><strong>What it provides: </strong>Elevation in meters and feet and relative positioning for drainage planning.</p><h4>5. Pest Observation Server (iNaturalist)</h4><p>Community-reported pest sightings within 50km provide early warning for crop protection.</p><p><strong>What it provides: </strong>Recent insect observations in the area, species identification, distance from farm and observation dates.</p><h3>Phase 2: Soil parameters — iSDA &amp; GEE</h3><p>As we moved from v0 to v1, our research revealed a critical need: <strong>redundancy and resolution.</strong> Relying on a single global API for soil data carries risk. We transitioned to multi-source aggregation, adding the iSDA (Innovative Solutions for Decision Agriculture) API.</p><h4>The iSDA Contribution: High-Granularity Detail</h4><p>Rather than viewing one dataset as superior, it is important to understand the distinct role iSDA plays. While standard global datasets provide essential broad-scale soil classifications, iSDA focuses on high-resolution, African-specific data points designed for plot-level analysis.</p><p><strong>Expanded Parameter Set:</strong></p><p>iSDA captures specific attributes that are often generalized in broader datasets:</p><ul><li><strong>15 Nutrient Profiles:</strong> Including Nitrogen (<em>N</em>), Phosphorus (<em>P</em>), Potassium (<em>K</em>), Calcium (<em>Ca</em>), Magnesium (<em>Mg</em>), Zinc, Iron, Sulfur, and Aluminum.</li><li><strong>Physical Properties:</strong> Bulk density, stone content, and precise texture classification.</li><li><strong>Chemical Indicators:</strong> Cation Exchange Capacity (CEC).</li><li><strong>Historical Context:</strong> 2015–2019 crop patterns and uncertainty estimates for confidence bounds.</li></ul><p>By accessing the 30m data, we can move from general regional advice to specific amendments (e.g., lime and phosphate) required for that exact field.</p><h4>The Aggregation Strategy: Layered Intelligence</h4><p>We moved away from a binary choice between datasets and adopted an <strong>intelligent aggregation</strong> strategy. This approach leverages the strengths of both sources: the high resolution of iSDA for local precision and the broad coverage of Google Earth Engine (GEE) for regional context and validation.</p><p><strong>The Logic:</strong></p><pre>If location is in Africa:<br>    Query both iSDA (30m) and GEE (250m) in parallel<br>    Use iSDA as the primary layer for field-specific metrics<br>    Use GEE as the baseline layer for regional consistency<br>    Return a composite dataset detailing the source resolution<br>Else:<br>    Use GEE (Global coverage)</pre><p>This strategy acknowledges that soil varies significantly over short distances.</p><blockquote>By presenting both the “<strong>field view</strong>” and the “<strong>regional view</strong>,” we can provide farmers with the most complete environmental picture possible.</blockquote><h3>Phase 3: Google DeepMind’s AnthroKrishi API</h3><p>Through Digital Green’s research partnerships, Google DeepMind granted us access to AnthroKrishi — their agricultural understanding API built on satellite imagery and machine learning.</p><h4>What AnthroKrishi Unlocks: Farm-Level Intelligence</h4><p>Previous servers tell us about the environment (weather, soil, water). AnthroKrishi tells us what’s actually happening on farms:</p><ul><li>Crop identification from satellite imagery</li><li>Crop history (what was planted when)</li><li>Farming intensity (single, double, or triple cropping)</li><li>Rotation patterns (crop sequences over time)</li><li>Neighbor intelligence (what nearby farmers grow successfully)</li></ul><blockquote><em>This transforms conversations from </em><strong><em>theoretical</em></strong><em> (“sugarcane</em> grows well in silty loam soil<em>”) to </em><strong><em>empirical</em></strong><em> (“</em>Sugarcane is by far the most prominent crop (62.4% of agricultural area) with 42.6% of your village’s rotation being Sugarcane → Sugarcane (continuous cultivation)<em>”).</em></blockquote><h3>Phase 4: Geopolitical Village — level Intelligence</h3><h4>Farmers think in Villages</h4><p>A farmer asks “What’s grown in Bhaisalotan village?” — not “What’s at 27.42°N, 83.92°E?”</p><p><strong>The challenge</strong></p><p>AnthroKrishi works with 1km × 1km grid squares (S2 cells). Villages are irregular polygons spanning multiple cells. How do we bridge this gap?</p><h4>The Solution: Computational Geometry</h4><p>We developed a pipeline to translate administrative boundaries into queryable satellite data.</p><p>First, we integrated DataMeet’s India Village Boundaries dataset — 72,000+ village polygons with census codes, district assignments, and precise coordinates. When a farmer asks about “Bhaisalotan village,” the system searches 72,000 records for matches and retrieves the exact polygon (100 + coordinate points). We then do tessellation and de-duplication to compress the number of cells covering the village. It is shown pictorially below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*xlSVPfAqDVX_2fcwOwZGDA.png" /><figcaption>Tessellation and Pseudo Random Sampling for Villages of all sizes</figcaption></figure><p><strong>Example from example village — Bhaisalotan:</strong></p><ul><li>7 S2 cells queried → 990 raw farm features</li><li>Deduplication → 450 unique farms</li><li>Boundary filtering → 305 farms actually inside village</li></ul><blockquote>After fetching data, we calculate each farm’s centroid and verify: “<em>Is this point inside Bhaisalotan’s boundary?</em>” This ensures accurate counts — we report Bhaisalotan’s 305 farms, not the region’s 450.</blockquote><h4>The Power: Multi-Level Comparisons</h4><p>This geopolitical intelligence enables comparisons that were impossible before:</p><p><strong>Village vs. Village:</strong></p><pre>Farmer: &quot;Which village farms better—Bhaisalotan or Madhopur?&quot;</pre><pre>System: &quot;Madhopur demonstrates stronger practices:</pre><pre>  Multi-cropping: 39.5% (vs Bhaisalotan&#39;s 23%)<br>  Crop diversity: Higher (rice-wheat rotation vs sugarcane monoculture)<br>  Farm size: 0.18 ha average (vs 0.13 ha)</pre><pre>KEY INSIGHT: Madhopur&#39;s wheat → rice rotation is more <br>sustainable than Bhaisalotan&#39;s continuous sugarcane.&quot;</pre><p><strong>District-Level Intelligence:</strong></p><pre>Query: &quot;What&#39;s grown in Pashchim Champaran district?&quot;</pre><pre>System: &quot;District Overview (1,487 villages, ~889,000 farms):</pre><pre>  Dominant crop: Sugarcane (present in 100% of sampled villages)<br>  Secondary crops: Wheat, rice, mustard</pre><pre>  This is a major sugarcane belt with supporting infrastructure <br>  (sugar mills, canal irrigation) enabling the crop&#39;s dominance.&quot;</pre><blockquote><strong><em>This transforms agricultural extension — instead of anecdotal assessments, farmers and extension agents can see quantified patterns across thousands of villages.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*CHKi3mrIduzk68Wu37NzOw.png" /><figcaption>Geopolitical farm Intelligence</figcaption></figure><h3>The MCP Advantage: Flexibility and Reusability</h3><p>Here’s what makes this architecture powerful:</p><p><strong>1. Multiple clients, same servers:</strong></p><p>We built an agent that can create responses the can be consumed:</p><ul><li>by a chatbot interface for WhatsApp or a custom app</li><li>Alert generation system (notifications when conditions change) on SMS</li><li>Claude Desktop integration (MCP’s native client)</li><li>Claude.ai web interface (through MCP connectors)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*0B8p61B6_tQdHpQepUqiuQ.gif" /></figure><p>The same twelve MCP servers power all four interfaces — no duplicate code.</p><p><strong>2. Easy expansion:</strong></p><p>Adding a new data source (say, market prices) means:</p><ol><li>Build one MCP server (market_prices.py)</li><li>Register it in the system</li><li>Instantly available to all clients</li></ol><p>No modifications to chatbot code, alert logic, or Claude integrations — they automatically discover and use new servers.</p><h3>Looking Forward: The Future of Agricultural Intelligence</h3><p>Historically, agricultural advice came from:</p><ul><li><strong>Government extension officers</strong> (ratio: ~1 per 1,000 farmers)</li><li><strong>Input dealers</strong> (sometimes biased toward selling products)</li><li><strong>Neighboring farmers</strong> (anecdotal, not data-driven)</li></ul><blockquote>Now, any farmer with a phone can access the information and can be served through any channel.</blockquote><blockquote>The real value is in decoupling intelligence that is location aware from user aware which can be scaled by any ecosystem actor working on information dissemination for the farmers.</blockquote><p><em>Special thanks to Google DeepMind for AnthroKrishi access, iSDA for Africa-specific soil data, NASA for GRACE satellite data, and the open-source community (OpenLandMap, Open-Meteo, iNaturalist, OpenElevation) for making this possible.</em></p><p><em>For technical details, code repositories, or partnership inquiries, visit </em><a href="http://www.digitalgreen.org/"><em>www.digitalgreen.org</em></a><em> or reach out to our agricultural technology team.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a38ed72b537" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digitalgreen-techblog/bridging-fields-and-futures-agricultural-intelligence-with-farmerchat-mcp-5a38ed72b537">Bridging Fields and Futures: Agricultural Intelligence with FarmerChat-MCP</a> was originally published in <a href="https://medium.com/digitalgreen-techblog">digitalgreen-techblog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Under the Hood of Farmer.chat: Journey to an optimised, production ready RAG powered Chatbot]]></title>
            <link>https://medium.com/digitalgreen-techblog/under-the-hood-of-farmer-chat-journey-to-an-optimised-production-ready-rag-powered-chatbot-589bf5716e27?source=rss----c63e16f962ee---4</link>
            <guid isPermaLink="false">https://medium.com/p/589bf5716e27</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[retrieval-augmented]]></category>
            <category><![CDATA[agriculture-technology]]></category>
            <dc:creator><![CDATA[Vineet Singh]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 05:59:57 GMT</pubDate>
            <atom:updated>2024-07-08T06:30:20.231Z</atom:updated>
            <content:encoded><![CDATA[<p>In our<a href="https://medium.com/digitalgreen-techblog/unlocking-generative-ai-for-agriculture-farmer-chat-2ae2d62f1946"> previous article</a>, we gave detailed description about functional blocks of <a href="https://farmerchat.digitalgreen.org/">Farmer.chat</a>, an AI-powered chatbot designed to bridge the information gap for extension workers and farmers. We highlighted the value Farmer.chat delivers by providing timely and accurate agricultural knowledge in a user-friendly conversational format. In this article, let’s delve deeper into the journey of creating a production-ready RAG-powered chatbot for Farmer.chat. While there are excellent resources on Medium and all across the web on RAG and advanced RAG techniques, there are few resources which provide practical case study on how to evolve into production ready systems solving real business problems. We hope this provides a case study for the AI community and helps them adopt some of the important points.</p><blockquote><strong>The perspective for the readers is the way to build technical blocks based on the user needs rather than a prescriptive RAG pipeline.</strong></blockquote><h4>Why did we chose RAG to start with?</h4><p>We get this question a lot of times: why we chose RAG and why not a fine tuned model. Although it has been debated at various forums and papers it is worthwhile to spend some time and relate it to the business problem itself. As mentioned in the previous article, the main challenges of agriculture extension in nutshell are:</p><ul><li><strong>Un-organised information:</strong> generic and staggered information makes finding the right answer difficult.</li><li><strong>Context matters:</strong> Farming success depends on local factors and agriculture domain knowledge.</li><li><strong>Accuracy is key:</strong> Bad advice can hurt a farmer’s livelihood and trustworthy information sources are a must.</li></ul><p><a href="https://platform.openai.com/docs/guides/optimizing-llm-accuracy/llm-optimization-context">This article</a> last year on openai gives an interesting quadrant approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U7TlR50UaTy2fK_A" /><figcaption>RAG vs Fine tuning</figcaption></figure><p>The article puts it out clearly:</p><blockquote><strong>Context optimisation:</strong> You need to optimise for context when the model lacks contextual knowledge because it wasn’t in its training set or it requires knowledge of proprietary information. This axis is <strong>where you need RAG.</strong></blockquote><blockquote><strong>LLM optimisation:</strong> You need to optimise the LLM when the model is producing inconsistent results with incorrect formatting, or the tone or style of speech is not correct. This axis <strong>is where you need LLM fine tuning.</strong></blockquote><p>There is an<a href="https://arxiv.org/abs/2401.08406"> in-depth study</a> done in the agriculture domain by the Mircrosoft team. The key conclusions are covered from tables 18–20 in this paper.</p><blockquote>A key observation is that a base model like GPT4 + RAG is almost as good as a fine tuned base model.</blockquote><blockquote>Delta improvement is observed with fine tuned base model + RAG but not consistent.</blockquote><p><strong>RAG is cost effective as compared to fine tuning</strong>. Fine tuning + RAG may be slightly beneficial but if we want relatively good contextual answers, developing a RAG powered chatbot is a faster and cost effective.</p><blockquote>Taking this decision early helped immensely as we will see in the article further. These early decisions are key to success in your technology and product roadmap.</blockquote><p><strong>Note</strong>: we took this decision way back in June 2023 while these in depth study and reports are mostly from the end of 2023 to beginning of 2024.</p><blockquote>In the initial days it is not important to back your decisions with a very thorough study but quick indicators. Validation from studies by others is a further reinforcement and <strong>if it is not in line, one should reconsider the decision</strong>.</blockquote><h4>Agile approach: Build — Test — Deploy — REPEAT</h4><p>We adopted a rigorous “build-test-deploy” cycle within an agile development framework to optimise Farmer.chat. This iterative approach allowed us rapidly prototype, test, and refine the chatbot, ensuring continuous improvement.</p><p>It is important to understand that RAG, though it sounds simple, has many moving parts and a lot of techniques to improve each of those moving parts. <strong>In real world development, we don’t have the luxury of implementing a super refined RAG pipeline in one go. One needs to start simple and focus on one thing at a time.</strong></p><blockquote>One needs to know which part to focus on first to maximise the improvement to effort.</blockquote><p>These decisions are not straightforward and depend on your team structure, strength, type of content, business problem at hand and many factors. Here we present our journey starting with a small team how we upgraded each version and gradually increasing complexity.</p><h4>Version 1: 2 — week sprint</h4><p>Our version 1, almost a year ago, was just two week sprints. Agriculture is a vast subject, we focused on one or two crops in one region and a curated set of questions (50 odd) for those crops for evaluation.</p><p><strong>Key decisions</strong></p><ol><li><strong><em>Messenger platform</em></strong> : we developed bot for two messenger channels, Whatsapp and Telegram. Reason for choosing messenger applications was <strong>ease of onboarding users and familiarity of the users with the interface</strong>. While WA is more widely used, telegram offers simpler APIs to integrate, is free and provides better user experience for multi-modal content. Getting users to install telegram was a one time effort.</li><li><strong><em>Langchain’s Power </em>:</strong> We opted for Langchain, a popular open-source library. Langchain provides powerful tools for building LLM enabled apps using ready to chain of thoughts, agents and configurability to call different LLM or embedding models. Langchain provided the ConversationalRetrievalChain class well suited for RAG.</li><li><strong><em>ChromaDB for Knowledge Storage </em>:</strong> We selected ChromaDB as the vector store. We considered pinecone, but chromadb satisfied the need to have option of self hosting.</li></ol><p><em>Prompt engineering played a crucial role in ensuring that the bot doesn’t answer and start conversing on topics outside agriculture domain.</em> It performed reasonably on the test questions for the crops.</p><blockquote>The test in this version was about the <strong>ability to answer agriculture related questions and not on the completeness, relevance and accuracy</strong>.</blockquote><p>Here is the information flow of the ConversationalRetrievalChain class. <em>Please note that </em><strong><em>this class is now deprecated in langchain and we moved away from langchain after our first version</em></strong><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*ZQ5rVSLxXhR_Jb-s" /><figcaption>Version 1: farmer.chat</figcaption></figure><p><strong>Issues with version 1</strong></p><ol><li><strong>Hallucination</strong>: While this version didn’t answer out of context questions (not related to agriculture), <strong>it did answer the questions which were related to agriculture and the crop but were not covered in the content</strong>.</li><li><strong>Limitation with langchain</strong>: while langchain is an excellent starting point, we realised some limitations like:</li></ol><ul><li>we couldn’t log the rephrased query and we really couldn’t see if it is adding some keywords that cause issues in retrieval</li><li>retrieval method (at least at that point) had two options and in our production environment, the retrieval method that worked had opposite sense to cosine similarity!!</li><li>we found that retrieval method itself when done using directly chroma client provided different and better results as opposed to the one through langchain</li></ul><p>3. <strong>Chromadb in memory problem</strong>: while chromadb is easy to set up, AI native and fast, it is in memory and as the number of bot instances in different regions increased, the cloud compute requirement grew exponentially.</p><p>While hallucination is a business problem the other issues were more technical in nature. However, both were intertwined in the sense that langchain’s limitations didn’t allow us to properly address the issue of hallucination.</p><blockquote>As a result, we decided to <strong>move away</strong> <strong>from langchain</strong> to get better control.</blockquote><p><strong>Please note:</strong> this is not to suggest that langchain is bad. On the contrary, we will advise anyone to <strong>use langchain or llamaindex</strong> if that satisfies your business needs <strong>but suggest testing it thoroughly</strong>.</p><h4>Version 2: focus on fixing hallucination</h4><p>We set up the same flow but with our own calls to LLM and control over the prompts in rephrasing the query based on history as well as generation. Once we got the rephrased query and retrieved chunks, we noticed the cause of hallucination.</p><blockquote>Hallucination in RAG occurs when irrelevant text chunks are passed in generating the answer.</blockquote><p>It is a well known little quirk of LLM. It is good in following <strong>positive instructions</strong> but does not properly <strong>respect negative instructions</strong>, for instance in this case — <em>do not generate answers if the chunks in context are not relevant to the question is </em><strong><em>not respected all the time</em></strong>.</p><p>We looked at each of the moving part and first ruled out what not to focus on:</p><ul><li><strong>Embeddings: </strong>the available embeddings were better but delta improvement was really small as reported on MTEB leaderboard</li><li><strong>Chunking strategy</strong>: although it has significant impact as we see later, there were too many variations and not clear where to start</li><li><strong>Query decomposition</strong>: it does maximise the retrieved text chunks but logically, it will lead to completeness of answer rather than improving the hallucination as the irrelevant chunks would remain as is</li><li><strong>Vectordb: </strong>it was easy to do quick trials and check that there would be some improvement but not much and it is more related to performance</li><li><strong>Augment knowledge base</strong>: quick trials revealed that the GPT models were themselves not providing hallucination free question answer pair and generating the same was not that easy</li></ul><blockquote><strong>We decided rather than more upstream steps, focus on the downstream</strong>. In essence, we want to maximise text chunks with relevant information to be passed on for generation and minimise text chunks with irrelevant information. <strong>Why not just add a filter and rank the retrieved text chunks rather.</strong></blockquote><p>Though there are many algorithms, <strong>we leveraged LLM itself to reflect and reason through and filter/ rank chunks</strong>. The key to evaluate the efficacy was to look at the retrieved chunks for each question and identify which is completely relevant and which is completely irrelevant manually and verify if the results match with LLM.</p><blockquote>With LLM based filtering and ranking, we were able to <strong>correctly filter out 98.3 % of irrelevant chunks on test data</strong>.</blockquote><blockquote><strong>This led to overall improvement in completely factually correct responses from </strong>~ 76 % to ~ 100%<strong> on the test data of 30 odd questions.</strong></blockquote><p>We also changed chromadb in-memory to chromadb client. Here is what the new flow looked like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/0*dbrR-M1zhqWLtT72" /><figcaption>Version 2: farmer.chat</figcaption></figure><p><strong>Issues with version 2</strong></p><ol><li>While chroma db client worked, it is a patch and chroma still doesn’t provide elegant way and we had to look for other options.</li><li><strong>high faithfulness -&gt; high unanswered questions</strong>: what we were able to answer was correct and grounded in the content but it meant a lot of questions now got unanswered !!</li></ol><h4>Version 3: fixing vectorstore db</h4><p>As we had got a positive response initially from the bot, we were required to scale it in different geographies and larger, more complex content. This meant vector store db in chroma which was selected with minimal testing needed thorough analysis.</p><blockquote><strong>This section can be a bit technical and therefore we have provided the complete details </strong><a href="https://docs.google.com/document/d/1vdmd_gRzndoSYL-KnxJApTCwhYZuNVSUPWRA6lAaK7E/edit?usp=sharing"><strong>here</strong></a><strong>. We present the conclusions and results here.</strong></blockquote><p><strong>Benchmark Result Analysis</strong></p><p>The detailed result sheet can be found here<a href="https://docs.google.com/spreadsheets/d/1Fm46hIpGrt94-GJanCiJR5cbfbEdQsbMeacRURMpUng/edit#gid=0"> Vector DB Benchmarking</a> The important points observed from the result sheet are here,</p><blockquote>Qdrant DB is the best performing among all, it has the highest QPS, Highest Recall@100 (at efConstruct 256)</blockquote><blockquote>Vespa and ElasticSearch db are more refined on the memory utilization side, however their latency is on the higher side.</blockquote><p>Here is the revised information flow for version 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/0*qsqCeptbc2fQVnnG" /><figcaption>Version 3: farmer.chat</figcaption></figure><h4>Version 4: fixing unintentional unanswered questions</h4><p>As we enhanced our RAG pipeline, we focused also on creating an auto evaluation pipeline which was benchmarked against human evaluation. Our user research team and product — program teams pointed out that inability to answer questions causes drop off. This was corroborated with the data but what came out further was that around 11% of unanswered questions were the users asking about a different crop than what they have selected and 2–3 % were further remarks (welcome message, exit) which got converted to some question because of chat history. This also resulted in more of a question answering machine than a conversational flow.</p><p>We decided to have a user intent based flow so as to create conversational flow as well as route to the RAG only when the intent is farming related.</p><blockquote>Tests showed that chatgpt-4 achieved 100 % accuracy in user intent classification sample with few shot learning.</blockquote><blockquote><strong>Achieving near 100 % is important</strong> because if this is wrong, it can lead to more absurd answers.</blockquote><p>This was quickly rolled out and led to change in the information flow as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/0*TyRpe92yqiMeQB3n" /><figcaption>Version 4: Farmer.chat</figcaption></figure><h4>Version 5: retrieval error due to common words</h4><p>With more deployment and usage, there were some <strong>issues reported where users’ questions remained unanswered even though it seems correct</strong>.</p><p>A closer inspection of retrieved chunks revealed that certain words which are very frequently used in some text chunks and used in query cause totally irrelevant chunks to be retrieved. Example, <em>what are common varieties of coffee? </em><strong><em>VS </em></strong><em>what are common varieties of coffee in </em><strong><em>Kenya</em></strong><em>?</em></p><p>In this particular case, there are document sections where Kenya comes too often or a phrase which is realted to Kenya like KES. This resulted in irrelevant retrieved text chunks which were rejected by filtering and ranking.</p><blockquote>The fix to this we added another LLM call to shrink and simplify the query to basic theme for retrieval.</blockquote><p>This added another block in version 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/0*Q7rlBzi78nU5YAou" /><figcaption>Version 5: Farmer.chat</figcaption></figure><h4>Version 6: Semantic chunking</h4><p>One of the key limitations with RAG is you can know <strong>if the answer is correct by looking at the text chunks</strong> passed at generation step but <strong>it is hard to ascertain if the answer is complete</strong> because there could be text chunks that have been missed.</p><p>Plainly speaking:</p><blockquote>We can be sure that <strong>whatever answered is correct</strong> but can we be sure that <strong>whatever can be answered is answered</strong>.</blockquote><p>The latter depends on the context recall which can vary depending on the content and query. Context recall measures what percentage of relevant text chunks are retrieved on an average. To calculate the same, <strong>one needs to know how many relevant chunks are there in the first place</strong>.</p><p>One thing that we considered initially and literature suggests is having a good chunking strategy. We had quickly implemented linear chunking and though it works, it is not the best way. What if we can group together chunks based on topics so that if that topic is asked about, the entire chunk gets extracted. There is a<a href="https://github.com/FullStackRetrieval-com/RetrievalTutorials/blob/main/tutorials/LevelsOfTextSplitting/5_Levels_Of_Text_Splitting.ipynb"> great jupyter notebook</a> describing five levels of chunking by<a href="https://x.com/GregKamradt"> Greg Kamradt</a>. We request reader to read through the notebook and watch the associated video. We decided to implement semantic chunking (level four). This approach doesn’t rely on LLM but just on calculating the cosine similarity between the adjacent sentences.</p><blockquote>Intuitively, semantic chunking is simply saying that <strong>if the topic changes the similarity distance between new sentence will see a sudden jump with the previous sentence(s)</strong>.</blockquote><p>This makes sense. However, we had to split the tables and images. We had tried out grobid earlier which is widely used for scientific documents but it didn’t work on our content. We found<a href="https://github.com/Unstructured-IO/unstructured"> untructerd-io</a> as way better and though it misses out on captions of the images or tables, it is able to reasonably extract the text.</p><blockquote>Having a good pdf parser suitable for your content is necessary for semantic chunking.</blockquote><p>Once we were able to do semantic chunking, we used it to create chunks and their respective topics.</p><p>This resulted in yet another change in the information flow of RAG.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*5I_P7djXnzo5eRqS" /><figcaption>Verison 6: farmer.chat</figcaption></figure><blockquote>It is important to understand shift in the evaluation beyond <strong>RAGAS</strong></blockquote><p>Our focus was earlier on <strong>factual correctness and relevance</strong>. Now, let us assume that there are certain questions from the users which can be answered and certain questions that can’t be answered. And let us assume there are some factually correct answers and factually incorrect answers. This creates a two by two matrix as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*qBIcGJQl_tXqfKmY" /><figcaption>Evaluation: focusing on RAGAS</figcaption></figure><p>If we are looking at RAGAS framework on faithfulness and relevance, we are trying to maximise the upper half while minimise the lower half.</p><p>What if we change the y axis of the quadrant as is answered and is not answered, creating a revised confusion matrix for RAG as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/0*PjWFvpYl1qqp93kG" /><figcaption>Evaluation: focus on what is answered</figcaption></figure><p><strong>In this revised approach, we maximise the first and third quadrant such that it is factually correct.</strong> This provides a clear definition of hallucination and retrieval error if what can be answered is answered provided it is factually correct.</p><blockquote>It is important to relook at your evaluation criteria as per the business needs.</blockquote><blockquote>Our overall metric became multiplication of percentage faithful sentence and percentage answered.</blockquote><blockquote>With semantic chunking we were able to reduce the number of unanswered questions to nearly half.</blockquote><h4>Our journey: In a nutshell</h4><p>Our journey involved multiple version iterations, each focusing on specific optimisation goals:</p><ul><li><strong>Version 1:</strong> A rapid prototype built using LangChain to demonstrate core functionalities. While functional, it highlighted limitations in complexity.</li><li><strong>Version 2:</strong> Focused on addressing “hallucination” (generating irrelevant responses). We moved away from LangChain.</li><li><strong>Version 3:</strong> Optimised the Vector Database (Vectordb) for efficient information retrieval.</li><li><strong>Version 4:</strong> Streamlined user intent flow routes to minimise unanswered questions. This improved user experience as well.</li><li><strong>Version 5:</strong> Implemented “shrink query for retrieval” to handle complex or edge-case queries.</li><li><strong>Version 6:</strong> Employed semantic chunking to group sentences realted to topics together, reducing unanswered questions.</li></ul><h4>The road ahead</h4><p>Our work on Farmer.chat continues. In the next article, we’ll explore <strong>how we employed automated evaluation techniques to accelerate</strong> the iteration process and further optimise Farmer.chat for real-world impact.</p><p>We currently have many LLM calls and there are ways we have optimised it for latency in the acceptable range. There are further enhancements under way to decrease latency and cost. We would be exploring the same in detail in future articles. Stay tuned.</p><h4>Gratitude</h4><p>We are grateful to our donors and projects which made this work possible, in particular AIEP and GAIA project by Bill and Melinda Gates Foundation and GIZ.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=589bf5716e27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digitalgreen-techblog/under-the-hood-of-farmer-chat-journey-to-an-optimised-production-ready-rag-powered-chatbot-589bf5716e27">Under the Hood of Farmer.chat: Journey to an optimised, production ready RAG powered Chatbot</a> was originally published in <a href="https://medium.com/digitalgreen-techblog">digitalgreen-techblog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Generative AI for Agriculture: Farmer.chat]]></title>
            <link>https://medium.com/digitalgreen-techblog/unlocking-generative-ai-for-agriculture-farmer-chat-2ae2d62f1946?source=rss----c63e16f962ee---4</link>
            <guid isPermaLink="false">https://medium.com/p/2ae2d62f1946</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[generative-ai-solution]]></category>
            <category><![CDATA[agriculture-technology]]></category>
            <dc:creator><![CDATA[Vineet Singh]]></dc:creator>
            <pubDate>Fri, 31 May 2024 10:56:14 GMT</pubDate>
            <atom:updated>2024-05-31T10:56:14.292Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/u/1ac150b0b18b">Rajsekar</a> <a href="https://medium.com/u/f02a5c1a841e">Waseempasha</a> <a href="https://medium.com/u/d8fe58a55d77">Ramaskanda</a> <a href="https://medium.com/u/d6fa51cfd62d">Sanjeev Mishra</a> <a href="https://medium.com/u/227a37d4a4c2">Jayasankar G K</a></p><p>At <a href="https://digitalgreen.org/">Digital Green</a>, we are passionate about empowering smallholder farmers, who play a critical role in global food security. Timely access to accurate information is essential for these farmers to make informed decisions and improve their yields. However, farmers and agriculture extension workers often face challenges in accessing the right information which is timely and contextual due to the scattered agricultural data. <a href="http://famrer.chat/">Farmer.chat</a>, our AI-powered chatbot, aims to bridge this gap by offering extension workers and farmers a smarter tool to access and share crucial agricultural knowledge which is trustworthy, contextual and in the local language in multiple channels.</p><p>While farmer.chat is relatively recent innovation, Digital Green has been at the forefront of innovations in agriculture extension for more than a decade and a half. Our journey started with farmer first approach: capturing and curating locally made videos, facilitating screenings in farmer groups and enabling them with software tools for feedback and data collection.</p><blockquote>Through our interventions, we were able reduce the cost of adoption of agriculture practice from $35 to $3.5.</blockquote><p>Over the last fifteen years, we have been able to reach 6.3 Mn farmers, through a network of &gt; 100K agriculture extension agents which has resulted in estimated 24% increase in income.</p><p>While these numbers are impressive, we still have to push the envelop. There are estimated 500 Mn smallholder farmers globally and agriculture extension agents who interact with farmers at typically in the ratio of 1:1000. Reaching the agriculture extension workers and farmers through partnership and technology remains the key.</p><h4>Challenges of agricultural extension</h4><p>Imagine an extension worker in a rural village, helping a farmer struggling with a crop disease. To provide the best advice, they need to juggle a vast amount of information — from local soil conditions to government regulations on pesticides. But sifting through research papers, policy documents and websites can be time-consuming, especially when a farmer needs a quick answer.</p><p>Here’s the problem in a nutshell:</p><ul><li><strong>Unorganised information:</strong> There’s a lot of agricultural data out there, but it is generic and staggered and farmer being a practitioner, finding the right answer can be like searching for a needle in a haystack.</li><li><strong>Context matters:</strong> Farming success depends on local factors like soil type and weather. Conversational interface helps narrow down the question to the specific context.</li><li><strong>Accuracy is key:</strong> Bad advice can hurt a farmer’s livelihood. Extension workers need trustworthy information sources not only for the farmers but for themselves to gain confidence and reaffirm their knowledge.</li></ul><h4>Unlocking Answers in the Field: Smarter Tools</h4><p>We have experimented with chatbots to augment our work for long but with the advances of generative AI, these AI tools can be game-changers. We immediately saw the potential of developing intelligent chatbots powered by <a href="https://www.promptingguide.ai/research/rag">Retrieval-Augmented Generation (RAG)</a> on approved, curated information. These intelligent chatbots can utilise advancement in generative AI to enable:</p><ul><li><strong>Fast answers:</strong> GenAI outperforms conventional ways of ingesting unstructured content formats in docs, pdfs, crop tables, images, videos etc. Chatbots can quickly find the most relevant information based on a farmer’s question.</li><li><strong>Conversational flow:</strong> GenAI can be trained to drive a conversational flow to narrow down the problem. This enables gathering necessary contextual information on one hand and generating byte sized relevant responses on the other.</li><li><strong>Reliable sources:</strong> RAG enabled chatbots can be linked and trained to generate answers grounded in databases of officially approved agricultural content, guaranteeing accurate and trustworthy advice for farmers.</li></ul><p>By empowering extension workers with smarter tools, the agentic RAG-enabled chatbots can help bridge the knowledge gap between farmers and the information they need to succeed.</p><blockquote>Our findings point to potential of decreasing cost of adoption further from $3.5 to $0.35</blockquote><p>In this article, we present a detailed description of information flow in <a href="https://farmerchat.digitalgreen.org/">farmer.chat</a>.</p><h4>Farmer.chat overview</h4><p><a href="https://farmerchat.digitalgreen.org/">Farmer.chat</a> is an end to end solution that can be deployed by any organisation for enhancing outreach to the farmers . It is highly customisable and can be plugged in IVR or messenger or an app and can ingest any kind of structured or unstructured knowledge source.</p><p>In the span of over a year, we have continuously evolved our product. In this small timeframe we have been able to:</p><blockquote>Reached more than 16k extension workers</blockquote><blockquote>Answering &gt; 200k questions</blockquote><blockquote>&gt; 6 languages , 40 value chain crops</blockquote><blockquote>~ Zero biases or toxic responses</blockquote><p>Here is an example of advanced agent driven chatbot:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FXhqzekbhZ4cDjh63nY%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FXhqzekbhZ4cDjh63nY&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcHNnOTAyNG10a3F6b3Bra2VlMWF2MTV4Znh2cjBnM29hbDJpMTZzcCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FXhqzekbhZ4cDjh63nY%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/67574bd063e21c93b5c0e113fd6cd2f2/href">https://medium.com/media/67574bd063e21c93b5c0e113fd6cd2f2/href</a></iframe><p>This is what it happens here if you pay closer look. The user starts with a query seeking a resource: video on wheat rust. The bot understands and presents the relevant video link. The user further asks about the specific chemical for seed treatment . The bot gets the chemical from <strong><em>what is being spoken in the video. </em></strong>The user further asks about the weather without specifying the necessary information like the location. The bot understands that the <strong><em>information is incomplete and prompts back </em></strong>to the user to share location. The user enters the location in free form (if you notice, makes a grammatical error). The bot is able to extract the district name and responds in a structured and readable weather summary. The user further asks about the possibility of pest and disease attack and it looks in the PDF documents and respond with the previously extracted weather information.</p><blockquote>This is how a GenAI powered intelligent bot seamlessly uses different tools: video search, video generated answers, weather API and answer generation from PDF.</blockquote><p>Next, let’s look how farmer.chat works under the hood, step by step.</p><h4>Step 1: Knowledge base builder</h4><p>This is the heart of the system. It is what powers the entire bot by ingesting content and datasets from different sources.</p><p>Here are the functional blocks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zq26EB5PJwckQgoxvm1foQ.png" /><figcaption>Knowledge base builder: powered by <a href="http://farmstack.co/">FarmStack</a></figcaption></figure><p>This is a web interface powered by FarmStack, which is a digital public good developed by Digital Green and currently enabling DPI like kadp.kalro.org.</p><p>The key components of knowledeg base builder are:</p><ul><li><strong>Connectors: </strong>act as pathways that allow the knowledge base builder to ingest various types of data from outside (eg, Googel drive, youtube)</li><li><strong>Content processing engine: </strong>the ingested data is processed and transformed into a format suitable for the knowledge base and involves auto summarisation, content categorisation, auto tagging</li><li><strong>Semantic chunking: </strong>the organised files with metadata are processed with sentences similar in meaning grouped together in text chunks</li><li><strong>Vector db creation: </strong>each text chunk is converted into vector representation using an embedding model</li><li><strong>Video processing: </strong>auto transcription and translation to create description of the videos</li><li><strong>Video indexing:</strong> LLM to generate description of videos and automated sections</li></ul><p>Using the above components, the knowledge base builder serves to ingest, organise and convert the data into vectordb format which can be used by AI application.</p><h4><strong>Step 2: AI modules</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxrK4OXn1QUGzjANz9pZKQ.png" /><figcaption>AI modules: augmenting the knowledge base builder</figcaption></figure><p>This is the module which is the brain of the system. It is where the query of the user is understood, processed, the necessary information to respond to the user query is obtained and the apt response is generated that is grounded in the knowledge base.</p><p><strong><em>2.1 Response Generator (RAG):</em></strong></p><p>This sub-module utilises a Retrieval-Augmented Generation (RAG) approach to create a response for the user. It is what ensures that the information delivered is grounded in the content and not outside.</p><p>RAG as many are aware of combines two broad streams:</p><ul><li><strong>Information retrieval:</strong> Searching the knowledge base for relevant information that matches the user’s query. This involves calling the vector database API created in knowledge base builder to get necessary text chunks.</li><li><strong>Generation:</strong> Using the retrieved information in the text chunks and the user query, the generator calls LLM and generates a human-like response that addresses the user’s needs.</li></ul><p><strong><em>2.2 Query Orchestration (Generative AI agent)</em>:</strong></p><p>This sub-module leverages large language model (LLM) to process the user query and plan what steps need to be taken. There are three main components:</p><ul><li><strong>Planning and reasoning agent:</strong> understand what user is trying to ask and which tools can be used to answer the user question.</li><li><strong>Execution agent:</strong> call the specific tools with necessary parameters so as to synthesise the responses.</li><li><strong>Tooling service:</strong> Use the API end points to create tools and their description that the LLM can use.</li></ul><blockquote>This sub module is the core to create conversational flow and helps narrow down the user input.</blockquote><p><strong><em>2.3 Local Language &amp; Voice ( Traditional AI):</em></strong></p><p>This sub-module employs language and ASR modules to:</p><ul><li><strong>Detect language :</strong> Identify the language used in the user query.</li><li><strong>Translation:</strong> If necessary, translate the query into a language understood by the system.</li><li><strong>Speech recognition (for voice queries):</strong> Convert spoken user queries into text.</li><li><strong>Text to speech: </strong>to convert the final response to an audio note.</li></ul><h4>Step 3: Integrating with frontend system</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8epmSjWRweoVhQoLlAbuQ.png" /><figcaption>Final system: enabling responses</figcaption></figure><p>Finally, we have the frontend API handlers consisting of two main modules:</p><p><strong><em>3.1 User Interaction</em></strong></p><p>The process starts with a user interacting with the chatbot through various channels like a messenger app, IVR (Interactive Voice Response) system, or even a mobile application.</p><p><strong><em>3.2 Frontend API handlers</em></strong></p><p>This module handles the user interface (UI) aspects of the chatbot. It ensures a smooth user experience by tailoring the interaction based on the chosen platform (messenger, IVR, etc.)</p><h4>Step 4: Plugging it all back in knowledge base</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qelwszS_MEanDv14PkbUEA.png" /><figcaption>farmer.chat flow of information</figcaption></figure><p>Although the bot can function with the flow in step 3, the major addition here is feedback of all the conversations back to knowledge base builder.</p><blockquote>It is important that the conversations with associated logs are fedback in the knowledge base that can be reviewed manually to curate golden question — answers.</blockquote><p><strong><em>4.1 Conversation Logs:</em></strong></p><p>The system keeps track of user interactions and chatbot responses. These conversation logs are valuable for:</p><ul><li><strong>Reviewing and Refining Responses:</strong> Human evaluators can analyze logs to identify areas where chatbot responses can be improved.</li><li><strong>Generating Golden Q/A Pairs:</strong> Subject matter experts in the field of language, climate, gender, agronomy, extension can co-create high-quality interactions from the logs as question-and-answer pairs. These “golden” Q/A pairs are then used to further train and improve the LLMs used for query orchestration and response generation.</li></ul><p><strong><em>4.2 Analytics:</em></strong></p><p>This module provides real-time insights into the performance of the chatbot system. These insights can be used to:</p><ul><li>Identify areas for improvement in content.</li><li>Monitor user engagement.</li><li>Track the effectiveness of the chatbot in answering user queries.</li></ul><h4><strong>Conclusion</strong></h4><p>This article we presented the flow of information to make <a href="http://farmer.chat/">farmer.chat</a> come to life. The generative AI space is evolving fast and so are we. This is just the overview and in the next articles we will take you to deeper dive into each of the modules. Stay tuned!!!</p><h4><strong>Big Thanks</strong></h4><p>To our gracious donors and government partners for making this possible.</p><p>To the readers!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ae2d62f1946" width="1" height="1" alt=""><hr><p><a href="https://medium.com/digitalgreen-techblog/unlocking-generative-ai-for-agriculture-farmer-chat-2ae2d62f1946">Unlocking Generative AI for Agriculture: Farmer.chat</a> was originally published in <a href="https://medium.com/digitalgreen-techblog">digitalgreen-techblog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>