<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chameera De Silva</title>
    <description>The latest articles on DEV Community by Chameera De Silva (@chameera).</description>
    <link>https://dev.to/chameera</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F682391%2Fac9e8fe2-2e68-4816-b8e5-5ff1c1045ff7.jpg</url>
      <title>DEV Community: Chameera De Silva</title>
      <link>https://dev.to/chameera</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chameera"/>
    <language>en</language>
    <item>
      <title>Inside Databases: BSTs, B-Trees, &amp; LSM Trees</title>
      <dc:creator>Chameera De Silva</dc:creator>
      <pubDate>Thu, 15 May 2025 07:11:59 +0000</pubDate>
      <link>https://dev.to/chameera/inside-databases-bsts-b-trees-lsm-trees-39ko</link>
      <guid>https://dev.to/chameera/inside-databases-bsts-b-trees-lsm-trees-39ko</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzlq32yoqwo3f7h1kgvx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flzlq32yoqwo3f7h1kgvx.png" alt="Database Internals: BSTs, B-Trees, and LSM Trees" width="800" height="533"&gt;&lt;/a&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I choose to expand my knowledge of how data management works behind the scenes in databases and data warehouses after gaining experience in data engineering and software development. I recommend everyone to be cautious of data structures and algorithms (DSA) and hardware specifics, often sprinkled with hardware terminology.&lt;/p&gt;

&lt;p&gt;In late 2020, When I started my data engineering/software development journey as an intern into the space of databases, I felt like a fish out of water. I was neither a specific computer science major nor a math specialist, just a stubborn curiosity and a job that demanded I figure it out. Terms like "BST," "B-tree," and "LSM tree" hit me like a wall of jargon and confusion, leaving me wondering if I’d ever crack the code. But here’s the thing: once I got my hands dirty with these concepts, they went from intimidating to downright fascinating. First I solved some leetcode problems with my go-to language Python and felt little confidence about these concepts except deep in my soul I wanted to apply real world use cases directly with the work that I was doing. But I knew that these are the backbone powering banks backend databases to day-to-day queue services which we use in decoupled systems.&lt;/p&gt;

&lt;p&gt;In this article, I’ll try to explain three main parts in database design: &lt;strong&gt;Binary Search Trees (BSTs)&lt;/strong&gt;, &lt;strong&gt;B-Trees&lt;/strong&gt;, and &lt;strong&gt;Log-Structured Merge Trees (LSM Trees)&lt;/strong&gt;. I’ll walk you through each one with relatable analogies (famous bookshelves and mailrooms example), simple Python snippets, and real-world tie-ins to systems like PostgreSQL and Cassandra. Whether you’re an engineer or just leveling up, this is your backstage pass to how databases &lt;em&gt;really&lt;/em&gt; work.&lt;/p&gt;




&lt;h3&gt;
  
  
  Binary Search Trees (BSTs): The Wobbly Bookshelf
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faodflpu3tx698pwvt9k2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faodflpu3tx698pwvt9k2.png" alt="Binary Search Trees (BSTs) diagram: Example: Wobbly Bookshelf" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember that moment when you first understood how a perfectly organized library could make finding any book a breeze? That intuitive A-to-Z system, where you can quickly narrow down your search? That's the core idea behind a &lt;strong&gt;Binary Search Tree (BST)&lt;/strong&gt;. Think of it as a digital bookshelf where each new book (or piece of data) gets placed precisely: titles that come earlier in the alphabet go to the left, and those that come later go to the right. It feels elegant, almost magical. In the best-case scenario, finding the book you need takes logarithmic time, O(log n), a remarkably efficient way to search.&lt;/p&gt;

&lt;p&gt;Let's see a quick peek at how this looks in Python:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;BST Code&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class BSTNode:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None

def bst_insert(root, key):
    if root is None:
        return BSTNode(key)
    if key &amp;lt; root.key:
        root.left = bst_insert(root.left, key)
    else:
        root.right = bst_insert(root.right, key)
    return root

def bst_search(root, key):
    if root is None or root.key == key:
        return root
    if key &amp;lt; root.key:
        return bst_search(root.left, key)
    else:
        return bst_search(root.right, key)

# Build a BST and search for 17:
root = None
for k in [15, 10, 20, 8, 12, 17, 25]:
    root = bst_insert(root, k)
node = bst_search(root, 17)
print("Found" if node else "Not found")  # Expected: Found

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s cool:&lt;/strong&gt; It’s fast for in-memory tasks like sorting a list or building a quick lookup table. But here’s where I hit a wall when I first played with it: if you add books in order (say, 1, 2, 3…), your shelf turns into a leaning tower of Pisa. Suddenly, finding anything takes O(n) time, like rifling through a stack of unsorted papers. That’s why databases don’t lean on plain BSTs for disk-based work, those random disk hops are a performance killer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; BSTs are a great starting point for learning, but they’re too fragile for the heavy lifting databases demand.&lt;/p&gt;




&lt;h3&gt;
  
  
  B-Trees: The Library That Scales
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegm48scmelcob0x0787d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegm48scmelcob0x0787d.png" alt="B-Trees diagram: The Library That Scales" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, imagine you’re not just managing a bookshelf but a full-blown library. You’ve got floors, sections, and shelves galore, each holding dozens of books, neatly organized. That’s a &lt;strong&gt;B-tree&lt;/strong&gt;: a beefed-up tree where every "shelf" (node) can store tons of keys, keeping the whole structure short and balanced. It’s like a librarian’s dream: no matter how many books you add, finding one never takes more than a few steps.&lt;/p&gt;

&lt;p&gt;In databases like PostgreSQL, B-trees rule the indexing game. Why? They’re built for the disk. Each node aligns with a disk page (think 4KB or 8KB), so a single read grabs a bunch of keys at once, slashing the number of trips to storage.&lt;/p&gt;

&lt;p&gt;Here’s a stripped-down B-tree in Python:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;b-tree code&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class BTreeNode:
    def __init__(self, t, leaf=False):
        self.t = t  # minimum degree (here t=2)
        self.keys = []
        self.children = []
        self.leaf = leaf

    def split_child(self, index):
        child = self.children[index]
        new_node = BTreeNode(self.t, leaf=child.leaf)
        mid = self.t - 1
        median = child.keys[mid]
        # Move keys after median to new node
        new_node.keys = child.keys[mid+1:]
        child.keys = child.keys[:mid]
        if not child.leaf:
            new_node.children = child.children[mid+1:]
            child.children = child.children[:mid+1]
        self.children.insert(index+1, new_node)
        self.keys.insert(index, median)

    def insert_non_full(self, key):
        i = len(self.keys) - 1
        if self.leaf:
            self.keys.append(None)
            while i &amp;gt;= 0 and key &amp;lt; self.keys[i]:
                self.keys[i+1] = self.keys[i]
                i -= 1
            self.keys[i+1] = key
        else:
            while i &amp;gt;= 0 and key &amp;lt; self.keys[i]:
                i -= 1
            i += 1
            if len(self.children[i].keys) == 2*self.t - 1:
                self.split_child(i)
                if key &amp;gt; self.keys[i]:
                    i += 1
            self.children[i].insert_non_full(key)

class BTree:
    def __init__(self, t):
        self.root = BTreeNode(t, leaf=True)
        self.t = t

    def insert(self, key):
        r = self.root
        if len(r.keys) == 2*self.t - 1:
            s = BTreeNode(self.t, leaf=False)
            s.children.append(r)
            s.split_child(0)
            self.root = s
        self.root.insert_non_full(key)

    def traverse(self):
        def _traverse(node):
            res = []
            for i, k in enumerate(node.keys):
                if not node.leaf:
                    res.extend(_traverse(node.children[i]))
                res.append(k)
            if not node.leaf:
                res.extend(_traverse(node.children[len(node.keys)]))
            return res
        return _traverse(self.root)

# Example usage:
bt = BTree(t=2)
for x in [10, 20, 5, 6, 12, 30, 7, 17]:
    bt.insert(x)
print(bt.traverse())  # Should print [5, 6, 7, 10, 12, 17, 20, 30]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s a champ:&lt;/strong&gt; It guarantees O(log n) performance, even when the library grows massive. Splits happen when a shelf overflows, but the tree stays balanced, perfect for &lt;strong&gt;OLTP&lt;/strong&gt; workloads like processing payments or updating user profiles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The catch:&lt;/strong&gt; Those splits can mean random disk writes, which old-school hard drives hate. Still, for most database tasks, B-trees are the unsung heroes keeping things snappy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world vibe:&lt;/strong&gt; In PostgreSQL, B-tree leaf nodes (over 99% of the index) point straight to your data rows. It’s like a library where the top floors guide you, but the ground floor’s where the action is.&lt;/p&gt;




&lt;h3&gt;
  
  
  LSM Trees: The Mailroom Hustle
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fav1670w0r985v79j9i8d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fav1670w0r985v79j9i8d.png" alt="LSM Trees: The Mailroom Hustle/ system design" width="720" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s switch gears. You’re running a mailroom, and letters are flooding in faster than you can file them. Instead of sorting each one on the spot, you toss them into a bin (memory), sort them quickly, and then batch-file them into cabinets later. That’s an &lt;strong&gt;LSM Tree&lt;/strong&gt;: it’s all about handling a deluge of writes without breaking a sweat.&lt;/p&gt;

&lt;p&gt;Used in databases like Cassandra and RocksDB, LSM trees batch new data in memory (a "memtable"), then flush it to disk as sorted chunks (SSTables). Background merging keeps it tidy over time.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Python snippet showing an LSM-like process of buffering and merging&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Simulate an LSM tree with flush and compaction
threshold = 3
memtable = []
sstables = []

def flush():
    sstables.append(sorted(memtable))
    memtable.clear()

def insert(key, value):
    memtable.append((key, value))
    memtable.sort(key=lambda x: x[0])
    if len(memtable) &amp;gt;= threshold:
        flush()

def compact():
    if len(sstables) &amp;gt;= 2:
        a = sstables.pop(0)
        b = sstables.pop(0)
        merged = sorted(a + b, key=lambda x: x[0])
        sstables.insert(0, merged)

# Example usage:
for k in [10, 5, 20, 1, 15, 12]:
    insert(k, f"val{k}")
# After inserts, flushes produce sorted SSTables
print("SSTables before compact:", sstables)
compact()  # merge the two oldest SSTables
print("SSTables after compact:", sstables)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Output might be:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSTables before compact: [[(5, 'val5'), (10, 'val10'), (20, 'val20')], [(1, 'val1'), (12, 'val12'), (15, 'val15')]]
SSTables after compact: [[(1, 'val1'), (5, 'val5'), (10, 'val10'), (12, 'val12'), (15, 'val15'), (20, 'val20')]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why it’s clutch:&lt;/strong&gt; Writes are sequential, append-only, so they’re blazing fast, even on spinning disks. It’s a dream for &lt;strong&gt;write-heavy&lt;/strong&gt; setups like logging or streaming data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off:&lt;/strong&gt; Reads might need to peek at multiple spots (memory, disk files), slowing them down. Bloom filters help, but LSM trees still favor writes over reads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Takeaway:&lt;/strong&gt; If your app’s drowning in writes, LSM trees are your lifeline.&lt;/p&gt;




&lt;h3&gt;
  
  
  Hardware: The Silent Game-Changer
&lt;/h3&gt;

&lt;p&gt;Here’s a nugget I learned the hard way: your hardware calls the shots. On old HDDs, random writes (like B-tree splits) are a nightmare, think 10ms per hop. LSM trees sidestep this with sequential writes, making them HDD darlings. SSDs, though? They handle random access better, so B-trees can flex their muscles, especially for reads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick tip:&lt;/strong&gt; Match your data structure to your storage. HDDs love LSM; SSDs play nice with both.&lt;/p&gt;




&lt;h3&gt;
  
  
  OLTP vs. OLAP:  Battlefield
&lt;/h3&gt;

&lt;p&gt;Not all workloads are created equal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OLTP (e.g., e-commerce):&lt;/strong&gt; Small, fast transactions, think adding an item to your cart. B-trees shine here with quick lookups.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OLAP (e.g., analytics):&lt;/strong&gt; Big, sweeping queries, like monthly sales reports. Columnar stores (often with LSM-inspired merging) crush it by scanning fast.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-world twist:&lt;/strong&gt; ClickHouse’s MergeTree blends LSM-style merging with columnar storage, making analytics a breeze.&lt;/p&gt;




&lt;h3&gt;
  
  
  In the Wild: PostgreSQL and Beyond
&lt;/h3&gt;

&lt;p&gt;PostgreSQL leans hard on B-trees. its default index is a masterclass in balance. But for write-crazy workloads, LSM-based systems like Cassandra steal the show. And in analytics land, columnar stores like Parquet or ClickHouse use sorted chunks (LSM vibes) to zip through queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro move:&lt;/strong&gt; Peek under your database’s hood. It’ll guide you to the right tool for the job.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion: Own the Gears
&lt;/h3&gt;

&lt;p&gt;From shaky BSTs to sturdy B-trees to write-happy LSM trees, these structures are the heartbeat of databases. Here’s your cheat sheet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BSTs:&lt;/strong&gt; Fun to learn, but don’t bet the farm on them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;B-trees:&lt;/strong&gt; Your go-to for balanced performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LSM trees:&lt;/strong&gt; Write fast, worry about reads later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next time you’re wrestling with a slow query or a data pipeline, think about what’s spinning the wheels. Tinker with the code, test the trade-offs, and make it yours. That’s the engineer’s edge.&lt;/p&gt;




</description>
      <category>database</category>
      <category>dataengineering</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>Bridging the Gap: Building a Tea Plantation Assistant for the Sri Lankan Tea plantation</title>
      <dc:creator>Chameera De Silva</dc:creator>
      <pubDate>Wed, 12 Mar 2025 14:15:38 +0000</pubDate>
      <link>https://dev.to/chameera/bridging-the-gap-building-a-tea-plantation-assistant-for-the-sri-lankan-tea-plantation-4li7</link>
      <guid>https://dev.to/chameera/bridging-the-gap-building-a-tea-plantation-assistant-for-the-sri-lankan-tea-plantation-4li7</guid>
      <description>&lt;p&gt;As someone passionate about problem-solving, I noticed a significant gap in the Sri Lankan tea industry:&lt;br&gt;&lt;br&gt;
Tea estate owners struggle to access and manage essential documents and information.  &lt;/p&gt;

&lt;p&gt;So, I built an &lt;strong&gt;AI-powered Tea Plantation Assistant&lt;/strong&gt;—a chatbot that simplifies information retrieval for tea industry stakeholders. 🚀  &lt;/p&gt;

&lt;p&gt;In this blog, I'll walk you through how I went from analyzing raw data to a &lt;strong&gt;fully functional AI chatbot&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Whether you're a &lt;strong&gt;developer&lt;/strong&gt; or &lt;strong&gt;tea industry professional&lt;/strong&gt;, this step-by-step guide will help you understand the impact of AI in agriculture.  &lt;/p&gt;




&lt;h2&gt;
  
  
  🌱 Step 1: Data Collection &amp;amp; Preprocessing
&lt;/h2&gt;

&lt;p&gt;The foundation of this assistant is &lt;strong&gt;structured data&lt;/strong&gt; from official tea industry documents.  &lt;/p&gt;

&lt;p&gt;To make the chatbot useful, I needed a &lt;strong&gt;clean dataset&lt;/strong&gt;. I built a pipeline that:&lt;br&gt;&lt;br&gt;
✅ Scrapes and processes relevant documents&lt;br&gt;&lt;br&gt;
✅ Cleans and structures the text for efficient retrieval  &lt;/p&gt;

&lt;p&gt;Check out the GitHub repo:&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://github.com/chameeradesilva/ai-assistant-tri" rel="noopener noreferrer"&gt;ai-assistant-tri (Data Preprocessing)&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;Even if you're not a coder, imagine this as &lt;strong&gt;organizing thousands of tea reports into a well-labeled library&lt;/strong&gt;. 📚  &lt;/p&gt;




&lt;h2&gt;
  
  
  🎨 Step 2: Designing the Chatbot UI with Gradio
&lt;/h2&gt;

&lt;p&gt;Once the data was ready, I built a &lt;strong&gt;user-friendly chatbot UI&lt;/strong&gt; using &lt;a href="https://gradio.app/" rel="noopener noreferrer"&gt;Gradio&lt;/a&gt;.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Why Gradio?
&lt;/h3&gt;

&lt;p&gt;✅ Quick to set up&lt;br&gt;&lt;br&gt;
✅ Clean, minimalistic interface&lt;br&gt;&lt;br&gt;
✅ Great for AI-powered applications  &lt;/p&gt;

&lt;p&gt;I customized the UI to &lt;strong&gt;align with a tea plantation theme&lt;/strong&gt;, making it &lt;strong&gt;accessible to non-tech users&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://github.com/chameeradesilva/Chatbot-Gradio" rel="noopener noreferrer"&gt;Chatbot UI Repo (Gradio)&lt;/a&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Step 3: Adding AI &amp;amp; Knowledge Retrieval
&lt;/h2&gt;

&lt;p&gt;The core of the assistant is &lt;strong&gt;retrieval-augmented generation (RAG)&lt;/strong&gt; using:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LangChain&lt;/strong&gt; for intelligent query processing
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pinecone&lt;/strong&gt; for storing and retrieving relevant documents
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This enables the chatbot to:&lt;br&gt;&lt;br&gt;
✅ Understand &lt;strong&gt;tea-related questions&lt;/strong&gt; using Google Generative AI&lt;br&gt;&lt;br&gt;
✅ Retrieve the most &lt;strong&gt;relevant&lt;/strong&gt; tea industry information&lt;br&gt;&lt;br&gt;
✅ Generate &lt;strong&gt;clear and useful&lt;/strong&gt; responses  &lt;/p&gt;

&lt;p&gt;For developers: This is a &lt;strong&gt;LangChain-powered RetrievalQA chain&lt;/strong&gt; optimized for real-world tea industry applications. 🍃  &lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Step 4: Deploying the Working Demo
&lt;/h2&gt;

&lt;p&gt;The final step was making this assistant &lt;strong&gt;publicly available&lt;/strong&gt; for testing.&lt;br&gt;&lt;br&gt;
I deployed the chatbot on &lt;strong&gt;HuggingFace Spaces&lt;/strong&gt;:  &lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;Live Demo&lt;/strong&gt;: &lt;a href="https://huggingface.co/spaces/DeChameera/sri-lankan-tea-chatbot" rel="noopener noreferrer"&gt;Sri Lankan Tea Chatbot&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;Now, &lt;strong&gt;anyone&lt;/strong&gt; can ask industry-related questions and receive &lt;strong&gt;instant AI-generated answers&lt;/strong&gt;!  &lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Conclusion
&lt;/h2&gt;

&lt;p&gt;This project started with a &lt;strong&gt;real-world problem&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
&lt;em&gt;Stakeholders in the Sri Lankan tea industry struggle to access critical information.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;By leveraging &lt;strong&gt;AI, LangChain, and Gradio&lt;/strong&gt;, I built a chatbot that:&lt;br&gt;&lt;br&gt;
✅ Makes information &lt;strong&gt;instantly accessible&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
✅ Bridges the gap between &lt;strong&gt;technology &amp;amp; traditional industries&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
✅ Showcases how AI can &lt;strong&gt;revolutionize agriculture&lt;/strong&gt; 🌍  &lt;/p&gt;

&lt;p&gt;If you're curious about AI in agriculture, &lt;strong&gt;explore the code and try the demo!&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Let’s innovate together. 🚀  &lt;/p&gt;




&lt;h3&gt;
  
  
  📌 Resources &amp;amp; Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;🗂 &lt;strong&gt;Data Collection &amp;amp; Preprocessing:&lt;/strong&gt; &lt;a href="https://github.com/chameeradesilva/ai-assistant-tri" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🎨 &lt;strong&gt;Gradio Chatbot UI:&lt;/strong&gt; &lt;a href="https://github.com/chameeradesilva/Chatbot-Gradio" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🤖 &lt;strong&gt;Live Chatbot Demo:&lt;/strong&gt; &lt;a href="https://huggingface.co/spaces/DeChameera/sri-lankan-tea-chatbot" rel="noopener noreferrer"&gt;HuggingFace&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;💡 &lt;strong&gt;What do you think about AI in agriculture?&lt;/strong&gt; Drop your thoughts in the comments!  &lt;/p&gt;

</description>
      <category>ai</category>
      <category>chatbot</category>
      <category>agriculture</category>
      <category>langchain</category>
    </item>
    <item>
      <title>Survivorship Bias in Data Engineering</title>
      <dc:creator>Chameera De Silva</dc:creator>
      <pubDate>Sat, 08 Apr 2023 21:23:06 +0000</pubDate>
      <link>https://dev.to/chameera/survivorship-bias-in-data-engineering-2pn4</link>
      <guid>https://dev.to/chameera/survivorship-bias-in-data-engineering-2pn4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwhlnvipodi0gxxn5j1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwhlnvipodi0gxxn5j1d.png" alt="Survivorship Bias" width="758" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Are you tired of seeing the context of data engineering stories and how they lead to success? Well, be ready to dig deeper into the world of &lt;strong&gt;"Survivorship bias in data engineering"&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;So the term "Survivorship bias" was initiated by the statistician "Abraham Wald" at Columbia University, who started the analysis of the research and development on World War II combat aircraft and specifically recommended places for reinforcement against enemy attacks.&lt;/p&gt;

&lt;p&gt;First, let's see the major problem here: data getting generated every millisecond, customer touchpoints, and whatever happens worldwide. Every time, it leaves a digital footprint, as you might think right now. Oh yes, data engineering has helped to gain a massive amount of data from a technical perspective, called "data pipelines," leading to remarkable findings and business success. But haven't you heard about numerous failed small-scale and large-scale projects that never make it to the spotlight? They do not get talked about because, well, they are failures.&lt;/p&gt;

&lt;p&gt;However, there will be more! As we focus on the term Survivorship bias here, the data ecosystem that exists and how we used to train machine learning models come into the limelight. Mostly, we focus only on the data that leads to successful models, neglecting the rest of the data to cut the mustard. So, the machine learning models will basically learn from a biased dataset.&lt;/p&gt;

&lt;p&gt;Now, I know what you are thinking: "Is there a better way" or "What can we do other than the usual process". Well, first, stop thwarting the projects that are so-called "failed" and give a little attention to where they have gone wrong and try to learn from them. Again, it's better to perceive than to do what we usually do because divergent thinking can be more mindful and involves actively seeking out examples of failed projects.&lt;/p&gt;

&lt;p&gt;Currently, we are living in the hype cycle of AI; it's essential to keep an eye on where we are heading, and in terms of solution bias, we can welcome the chaos and unpredictable data engineering. It's hard to depend on only the success stories, and you must be prepared to divert and cope when things go wrong. And hey, maybe we can even find some humor in the failures along the way.&lt;/p&gt;

&lt;p&gt;Folks, I hope you got some sense of the not-so-glamorous side of data engineering. But do not discourage you. Always welcome failure; try to intercept it and learn from it. No one knows your failed project will lead to something amazing (or at least a good laugh).&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
