<?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[softplus-publication - Medium]]></title>
        <description><![CDATA[Softplus has been created by Sigmoid Public Association, intended to stand a place for sharing and promoting with the readers our knowledge, experience and intentions in themes related to Artificial Intelligence and Machine Learning. - Medium]]></description>
        <link>https://medium.com/softplus-publication?source=rss----a424aa5c9f96---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>softplus-publication - Medium</title>
            <link>https://medium.com/softplus-publication?source=rss----a424aa5c9f96---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 12:16:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/softplus-publication" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The “Smart Debate”: How to Combine LLM Cascades with Multi-Agent Collaboration]]></title>
            <link>https://medium.com/softplus-publication/the-smart-debate-how-to-combine-llm-cascades-with-multi-agent-collaboration-e3f84bc984e7?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/e3f84bc984e7</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Valerian Cecan]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 13:48:21 GMT</pubDate>
            <atom:updated>2026-03-23T09:17:43.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZ4NUDz3VVnUkDuP6W1cFg.png" /></figure><p>A dive into building a multi-stage reasoning architecture that filters simple tasks to reserve high-tier compute for the most complex.</p><p>In <a href="https://medium.com/softplus-publication/smaller-smarter-cheaper-rethinking-llm-orchestration-for-cost-efficiency-5e9e20517ea5"><strong>Article 1</strong></a>, we learned how to save money by escalating tasks through a hierarchy of models until a quality threshold was met. In <a href="https://medium.com/softplus-publication/debate-club-smaller-models-vs-monolith-llms-66f4492af4b3"><strong>Article 2</strong></a>, we learned that two heads (smaller models) are often better than one (a monolith).</p><p>This article introduces a <strong>Hybrid Orchestration System</strong>. This architecture combines the cost-efficiency of a cascade with the high-reasoning output of a debate, ensuring that computational resources are allocated precisely according to the complexity of the task.</p><h3>The Problem with Static Workflows</h3><p>Most AI implementations rely on a single logic path, which leads to two primary inefficiencies:</p><ul><li><strong>The Risk of Linear Cascading:</strong> A complex task might be passed to a large model that still hallucinates because its reasoning was never internally verified or challenged.</li><li><strong>The Risk of Constant Debating:</strong> Running multiple agents for a simple query is computationally wasteful. Using three models to answer a factual query that a single 7B model can solve increases latency and cost without adding value.</li></ul><h3>Introducing the “Debate-Triggered Cascade”</h3><p>This represents the <strong>core architecture</strong> of our system. In this model, the <strong>Cascade</strong> provides the foundational skeletal structure, while the <strong>Debate</strong> serves as the critical quality gate at every level of the process.</p><p><strong>The Workflow:</strong></p><ol><li><strong>Initiating a Debate:</strong> The process starts by triggering a debate between smaller, efficient models.</li><li><strong>Validator Oversight:</strong> A dedicated validator checks the answers. If the output does not meet the required quality threshold, the system flags it for escalation.</li><li><strong>Contextual Escalation:</strong> The data, along with the previous debate reviews, is sent to a new level of the cascade featuring larger, higher-reasoning models.</li><li><strong>Strategic Evolution:</strong> We began with a 3-level cascade (<strong>v1</strong>). After observing the success of stronger models (<strong>v2</strong>), we evolved the system into <strong>v3</strong> by adding two smaller initial levels. This allowed us to test if we could capture accuracy even earlier in the chain to maximize cost savings.</li></ol><h3>Performance Analysis and Results</h3><p>Our testing across three versions (<strong>C</strong>omplex <strong>W</strong>ork <strong>F</strong>low v1, v2, and v3) reveals how the Hybrid Orchestration System impacts both quality and data hygiene.</p><h3>Quality Benchmarks: Average Verdict Scores</h3><p>The <strong>Avg Verdict Score</strong> (where 50% is the tie baseline) shows the stability of each architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*WgMAeG3XT_WBGsQskebJ3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*cAQ4M1ovLkC09C6cMgMM9g.png" /><figcaption>Figure 1: System-Wide Performance</figcaption></figure><ul><li><strong>CWF v1 (45.4%):</strong> Our initial 3-level baseline showed consistent performance but stayed slightly below the tie threshold.</li><li><strong>CWF v2 (52.0%):</strong> By employing stronger models in the 3-level structure, we achieved the highest quality peak. This version proved that raw reasoning power at each level yields the most consistent wins.</li><li><strong>CWF v3 (43.2%):</strong> While the average score dipped, v3 represents our “Reasoning Budget” in action. By allowing smaller models to handle the front-end (Levels 1 &amp; 2), we filtered out simple tasks, reserving the heavy lifting for the final stages.</li></ul><h3>2. Efficiency by Cascade Level</h3><p>The distribution of wins across levels tells the real story of cost-saving:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyzLKHyoI-auwP3-gghxvQ.png" /><figcaption>Figure 2: Win Rate and Efficiency Trends Across Cascade Architectures</figcaption></figure><h3>The Stagnation of CWF v1</h3><p>In the initial <strong>CWF v1</strong> architecture, the system functioned as a bottlenecked generalist with an <strong>average cost of $0.0076 per question</strong>. <strong>Level 3</strong> was heavily overloaded, capturing <strong>67.9%</strong> of all traffic but delivering only a <strong>35% win rate</strong>. This suggests a weak validator that failed to push complex tasks upward, forcing mediocre responses onto the majority of users. While <strong>Level 4</strong> showed a brief performance bump to <strong>48%</strong>, the “Final Boss” at <strong>Level 5</strong> was a total failure, with the win rate dropping back to <strong>34%</strong>. In this version, escalation was a financial sinkhole; you paid a premium for a larger model that performed worse than the level below it, yielding a system that was cheap but qualitatively stagnant.</p><h3>The Cost of Brute Force in CWF v2</h3><p>With <strong>CWF v2</strong>, we attempted to solve the quality gap by forcing intelligence into every layer. By using 70B+ models, we saw <strong>Level 5</strong> emerge as a success story with a <strong>60% win rate</strong>. However, this brute-force approach was economically unsustainable, ballooning the <strong>average cost to $0.011236</strong> — a nearly <strong>47% increase</strong> over v1. While the system relied heavily on this final level to secure its wins, it lacked internal agility. <strong>Level 4</strong> performed identically to <strong>Level 3</strong> at a <strong>35% win rate</strong>, making it a redundant step that added latency without value. You were achieving quality, but at the cost of extreme over-provisioning — using a sledgehammer to crack every nut that made it past the first gate.</p><h3>The Success of the v3 Purification Pipeline</h3><p>The breakthrough in <strong>CWF v3</strong> came from the strategic introduction of <strong>Levels 1 and 2</strong>, bringing the <strong>average cost back down to $0.008393</strong>. These levels successfully “processed” a massive volume of data, acting as a high-speed junior filter that cleared out approximately <strong>55%</strong> of the queue. Although their individual win rates were low at <strong>13%</strong> and <strong>33%</strong>, they allowed the system to “fail fast” and preserve the reasoning budget. The mid-tier managers at <strong>Levels 3 and 4</strong> then handled the medium-complexity noise, maintaining a steady performance near <strong>29%</strong>.</p><p>By the time a task finally reached <strong>Level 5</strong>, the input had been thoroughly purified. The <strong>120B model</strong> was no longer a workhorse; it became a specialized consultant, seeing only the hardest <strong>16.5%</strong> of tasks. This resulted in a peak performance of a <strong>77% win rate</strong> — more than double the effectiveness of the final stage in v1. The decisive nature of these wins is underscored by a record-low <strong>9% tie rate</strong>, proving that v3 ensures your most expensive model is only activated for tasks where it holds a massive, unassailable competitive advantage without the price tag of total brute force.</p><h3>The Evolution: How We Tuned the Engine</h3><p>We didn’t just add more models; we changed the topology of how they talk to each other. Here is how the configurations shifted from v1 to v3.</p><h4>v1: The Homogeneous Generalist</h4><p>In our initial configuration, we aimed for a balanced mid-tier chain. We utilized models in the <strong>20B–50B</strong> parameter range, such as <strong>OpenAI GPT OSS 20B</strong>, <strong>Gemma 3 27B</strong>, and <strong>Qwen 3 32B</strong>.</p><p>The strategy was to move from cheaper entry-level models to slightly more complex ones, like <strong>Hermes 4 70B</strong> or <strong>GPT-5 Nano</strong> at the final stage. However, because the “reasoning delta” between these levels was narrow, the system often hit a performance ceiling. We were paying for more parameters, but the models were effectively providing the same perspective, leading to the “Regression” seen in our performance data.</p><h4>v2: The Brute Force Intelligence</h4><p>For v2, we drastically shifted the baseline. We removed the smaller models and started the debate at <strong>Level 3</strong> using heavyweights like <strong>Llama 3.1 70B</strong> and <strong>Qwen 2.5 32B</strong>. By the time a query reached the end of the chain, it was being handled by monolithic architectures like <strong>DeepSeek Chat V3.1</strong> (a 671B MoE) and <strong>OpenAI GPT-OSS 120B</strong>.</p><p>While this achieved high accuracy, it was a “sledgehammer” approach. Using a 70B model as an entry-level worker created a massive cost floor. We were getting high-quality answers, but we were over-provisioning intelligence for tasks that didn’t require it.</p><h4>v3: The Strategic Hybrid</h4><p>This final iteration represents our most sophisticated topology. We extended the cascade to 5 levels to create a wider <strong>Reasoning Gap</strong>.</p><ul><li><strong>The Entry Tier (Level 1):</strong> We introduced highly efficient “filter” models like <strong>Llama 3.1 8B</strong>. At an input cost of only <strong>$0.017</strong>, these models act as a high-speed logic gate to clear out simple tasks.</li><li><strong>The Filtering Bridge (Levels 2–4):</strong> We transitioned through mid-tier specialists like <strong>DeepSeek v3.2</strong> and <strong>Mistral Small 3.2 24B</strong> to “purify” the incoming data.</li><li><strong>The Final Boss (Level 5):</strong> We reserved the elite <strong>OpenAI GPT-OSS 120B</strong> and <strong>Qwen3 Coder Next</strong> for the very end.</li></ul><p>By widening the gap between the first and last level, we ensured that every escalation was a meaningful jump in intelligence. This configuration allowed us to drop the average cost significantly from v2 while hitting a <strong>77% win rate</strong> at the final stage.</p><h3>Conclusion: The Reasoning Budget</h3><p>The shift from v1 to v3 proves that high-performance AI is an orchestration challenge rather than a simple model-selection task. Mastery of the Reasoning Budget requires treating intelligence as a finite resource to be managed with surgical precision. By optimizing the entry tier with high-speed filters like the 8B models in v3, the system successfully offloads 55% of the total volume. While these junior models have lower individual win rates, their primary function is to protect the budget and clear out the noise.</p><p>This architecture ensures that the input is thoroughly purified before it reaches a “Final Boss” like GPT-OSS 120B. The record-breaking 77% win rate seen in v3 is not just a result of model size, but of task-model alignment; the most expensive resource is reserved exclusively for the distilled, high-complexity tasks it was built to solve. Ultimately, v3 delivers nearly double the final-stage effectiveness of v1 while maintaining a lean average cost of $0.0083. The most successful AI systems of the future will not be defined by the size of their monolith, but by the strategic efficiency of their filters.</p><p>This project was made possible with the support of the Innovate Moldova Programme, financed by Sweden and the United Kingdom.</p><p>Made with ❤️ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3f84bc984e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/the-smart-debate-how-to-combine-llm-cascades-with-multi-agent-collaboration-e3f84bc984e7">The “Smart Debate”: How to Combine LLM Cascades with Multi-Agent Collaboration</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debate Club: Smaller Models vs. Monolith LLMs]]></title>
            <link>https://medium.com/softplus-publication/debate-club-smaller-models-vs-monolith-llms-66f4492af4b3?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/66f4492af4b3</guid>
            <category><![CDATA[multi-agent-systems]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Valerian Cecan]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 13:46:32 GMT</pubDate>
            <atom:updated>2026-03-23T09:17:24.960Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EdqdKQ9N7Av4F55YUIsMNQ.png" /></figure><p>A data-driven analysis of orchestrated smaller-model networks vs. monolithic scaling.</p><h3>At a Glance: The Results</h3><ul><li><strong>The Wall:</strong> Monolithic scaling is yielding diminishing returns; frontier AI is becoming too expensive for sustainable development.</li><li><strong>The Shift:</strong> We moved from “One Big Brain” to a room of “Squabbling Specialists” using a 4-phase debate protocol.</li><li><strong>The Victory:</strong> Our multi-agent system achieved a <strong>56.2% win rate</strong> over GPT-4.1, proving that a “Special Forces” team (MiniMax, Qwen, DeepSeek, GPT-OSS) can out-reason the giant.</li><li><strong>The Economics:</strong> High-IQ reasoning no longer requires a <strong>$8.00/M token</strong> monolith; orchestration delivers superior results for a fraction of the cost.</li></ul><h3>Introduction</h3><p>The AI world has a new religion: <strong>Bigger is Better!</strong></p><p>GPT, Claude, Gemini - the race is on to build the largest, most powerful monolithic model. Want better performance? Throw more parameters, more data, more compute at the problem. It’s worked so far, but at what cost?</p><p>The reality is that brute-force scaling is hitting a wall in both cost and performance. The compute required to train and operate frontier models has become astronomically expensive, restricting state-of-the-art AI to a handful of massive tech companies. For developers, this translates to heavy, unavoidable API costs. More importantly, we are starting to see diminishing returns: simply adding more parameters no longer guarantees a proportional leap in reasoning.</p><p><strong>But what if there’s a smarter way?</strong></p><p>What if, instead of relying on a single monolith, we orchestrated a network of smaller, specialized models? By forcing them to critique each other’s outputs and debate their reasoning, could they synthesize a superior result?</p><p>That is the core of <strong>Multi-Agent Debate (MAD) systems.</strong> In this experiment, we put the “Hive Mind” to the ultimate test.</p><h3>The Hypothesis</h3><p>Smaller models, working together through structured debate, can match or exceed GPT — with lower cost and zero vendor lock-in.</p><h3>The Experiment</h3><p>Four models, one challenger: GPT-4.1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*kI98gfQ7XBbpuQ_JMQA4tA.png" /><figcaption><strong>Table 1:</strong> Comparative Pricing Analysis — Monolithic GPT-4.1 vs. Sparse Committee Models ($/M tokens).</figcaption></figure><h4>Model Selection: Why these four?</h4><p>A debate is only as useful as the diversity of its participants. To maximize performance while keeping inference costs low, we selected four models based on two distinct architectural profiles:</p><p><strong>The Coders (High-Precision Muscle):</strong> We chose <strong>MiniMax M2.5</strong>, a model trained for complex digital environments with a high 80.2% score on SWE-Bench Verified, to handle agentic workflows. To support it, we added <strong>Qwen3-Coder-Next</strong>, an open-weight model optimized for coding. Its sparse MoE design (80B total / 3B active) allows it to deliver performance comparable to much larger models while keeping costs low.</p><p><strong>The Generalists (The Broad Reasoners):</strong> For logic and criticism, we brought in <strong>DeepSeek-V3.1</strong>, a hybrid reasoning model with a 128K context window. Finally, we included <strong>GPT-OSS-120B</strong>, a 117B-parameter MoE designed for high-reasoning production use. By activating only 5.1B parameters per pass, it provides the logical connective tissue needed for the debate.</p><p><strong>The Strategy: Sparse but Specialized</strong> Every model in this committee is architecturally “sparse.” By using models that only activate a fraction of their total parameters during a response, we can run a four-model “Hive Mind” for a lower total compute cost than a single, dense 400B+ parameter monolith.</p><h3>The Proving Ground: Why Arena-Hard-Auto v2.0?</h3><p>Static, multiple-choice benchmarks are no longer enough. To truly test these models, we chose <strong>Arena-Hard-Auto v2.0</strong>, an automated evaluation tool boasting the highest correlation to human preference on the Chatbot Arena leaderboard.</p><p>Instead of simple tests, V2.0 challenges models with <strong>750 real-world user queries</strong> — 500 focused on complex math and open-ended software engineering, and 250 on creative writing. We selected this benchmark because it is specifically designed to maximize “separability,” meaning it exposes the true capability gap between standard open-weight models and frontier giants. By using this arena, we ensured the debate was tested on raw technical accuracy, not just the ability to sound smart.</p><h3>The Pre-Debate Baseline</h3><p>Each model ran through the LLM Arena Hard benchmark — a rigorous test suite covering reasoning, coding, factual accuracy, and more.</p><p>Here’s how each performed alone against GPT-4.1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-dZ-03r9uyFwTQTYLhzNpQ.png" /><figcaption><strong>The Pre-Debate Baseline:</strong> Head-to-head performance of individual models against GPT-4.1. The sea of red shows exactly why smaller models struggle in isolation.</figcaption></figure><p>As the chart makes painfully clear, the Monolith still dominates the 1v1 arena. Look at that heavy ceiling of red (GPT-4.1 wins).</p><p>MiniMax M-2.5 puts up the most valiant fight, scraping together a ~44% win rate, while DeepSeek v3.1 trails just behind at nearly 40%. They are brilliant, but they can’t quite land the knockout blow. Then there is the massive GPT-OSS 120B model, which gets absolutely steamrolled, winning barely 15% of its matchups. It’s a harsh reminder that simply stacking parameters doesn’t guarantee elite reasoning capabilities.</p><p>However, look closely at the grey bands — the ties. There is a solid 13–16% margin across the board where these smaller models are matching the frontier giant blow-for-blow. The raw intelligence is in there; it just lacks the consistency and self-correction of a monolithic powerhouse.</p><p>On their own, these models are good. But against GPT-4.1? They aren’t even in the same league.</p><p><strong>Until they start talking.</strong></p><h3>The Rules of Engagement</h3><p>We didn’t just ask these models the same question and average out the results. AI models are natural people-pleasers; if you want the truth, you have to force them to fight for it.</p><p>We engineered a brutal, four-phase protocol designed to strip away hallucinations and expose weak logic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-A5APdiPPz1zZt4x4aHBg.png" /><figcaption><strong>The Architecture:</strong> The 4-stage protocol that forces smaller models to collaborate, critique, and synthesize.</figcaption></figure><ul><li><strong>Phase 1: Initial Response.</strong> Each model receives the prompt and generates an answer in isolation. This ensures their raw intellect is captured without outside influence.</li><li><strong>Phase 2: Cross-Examination.</strong> All initial answers are shared in a collective context. Each model then acts as a critic, specifically identifying mathematical errors, logical flaws, or coding hallucinations in the other responses.</li><li><strong>Phase 3: Refinement.</strong> Forced to confront these critiques, the models revise their work. They absorb valid feedback and rebuild their responses into a hardened second draft.</li><li><strong>Phase 4: Final Selection.</strong> A validator agent reviews the refined drafts and the debate history to select the single most accurate response as the final output.</li></ul><p><strong>The Rosters</strong> To find the exact tipping point of performance versus cost, we didn’t just run the full courtroom. We tested different “legal teams” to see who could punch above their weight:</p><ul><li><strong>The Full Committee:</strong> All 4 models.</li><li><strong>The Trio:</strong> 3 models (dropping the GPT-OSS).</li><li><strong>The Power Duo:</strong> Just DeepSeek + Qwen Coder.</li></ul><h3>The Judge: No Home-Field Advantage</h3><p>Here is a dirty little secret about AI benchmarks: they often use the <em>same</em> LLM to evaluate its own outputs. It is essentially letting the defendant serve as the judge.</p><p>This creates a massive “self-preference bias.” An AI will almost always prefer the cadence, formatting, and logic of its own writing, which inevitably skews the results toward the monolith being tested.</p><p>To keep the trial completely honest, we needed an outsider. We used <strong>Gemini 2.5</strong> as a neutral, third-party arbiter for all pairwise comparisons. By bringing in a frontier model from a completely rival ecosystem, we guaranteed a truly independent verdict.</p><h3>The Debate Results</h3><p>With the baseline established and our unbiased judge ready, we brought the models together to debate. We ran the “Complex Workflow” (our full committee) against the monolithic giant.</p><p>The Full Committee (all 4 models) vs. GPT-4.1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bzvfOGUW6u1o9Qifr7lpQ.png" /><figcaption><strong>The Hive Mind Strikes Back:</strong> The full multi-agent debate system achieves a 56.2% win rate against GPT-4.1, completely flipping the standalone baseline</figcaption></figure><h4>The Verdict: The Monolith Bleeds</h4><p>The results weren’t just an incremental improvement; they were a total paradigm shift. When forced to defend their logic, critique their peers, and rewrite their flaws, the smaller models became a giant-slayer.</p><p>Our multi-agent committee didn’t just match the frontier model — it beat it. The combined setup secured a strong 56.2% win rate, leaving GPT-4.1 victorious in only 26.5% of the matchups. The monolith was effectively outperformed by a coordinated team of smaller, specialized models.</p><h4>The Anatomy of a Victory</h4><p>But <em>how</em> did they win? The right side of the chart — the <strong>Best Worker Model Distribution</strong> — reveals exactly who carried the team to the finish line:</p><ul><li><strong>The Heavy Lifters:</strong> qwen3-coder-next (36.1%) and minimax-m2.5 (32.1%) were the undeniable MVPs. When the dust settled after the cross-examination phase, these two models were consistently forging the sharpest, most accurate final answers.</li><li><strong>The Redemption Arc:</strong> Remember gpt-oss-120b? In our standalone tests, it was an embarrassment, winning a pathetic ~15% of its matches. But look at it now. Framed by the debate protocol, it bounced back to supply nearly <strong>30% of the winning answers</strong>. It turns out, even a clumsy giant can be brilliant if you give it a good editor.</li><li><strong>The Harsh Critic:</strong> deepseek-chat-v3.1 almost completely disappeared from the winner&#39;s podium, contributing a measly 2.4% of the final answers. While its raw generation might not have won the jury over, its true value was likely in Phase 2: acting as a ruthless critic that forced the other three models to elevate their game.</li></ul><p>For the first time, we saw “budget” models producing reasoning chains that felt elite. But there was a catch. While the Hive Mind was smarter, it was also hungrier, and the API bills were starting to stack up.</p><h3>The Optimization Game: Trimming the Fat</h3><p>Let’s be honest: running four high-end models through a multi-round debate is like hiring a full law firm to answer a text message. It’s highly effective, but the invoice is terrifying.</p><p>We needed to find the “Sweet Spot” — the minimum number of brains required for maximum IQ. We started cutting the roster to see exactly where the performance would fall off a cliff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QKWujOYLXI9h8XtrRDx7Og.png" /><figcaption><strong>The “Goldilocks” Trio:</strong> Dropping the bloated 120B model maintains a 50% win rate while letting our top two models shine.</figcaption></figure><p><strong>The Trio (The “Goldilocks” Zone):</strong> By dropping the gpt-oss-120 model, we found a high-performance middle ground. This three-model roster still secured a 50.0% win rate against GPT-4.1. In this setup, MiniMax M2.5 and Qwen3-Coder-Next split the heavy lifting almost perfectly — providing roughly 46% of winning answers each — while DeepSeek continued to act as the editor. We maintained dominance over the monolith but slashed costs dramatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLRvRxp_hHn_ROow3OCjSg.png" /><figcaption><strong>The Power Duo:</strong> Just DeepSeek and Qwen teaming up to secure a decisive 47.5% win rate against the frontier giant.</figcaption></figure><p><strong>The Power Duo (DeepSeek + Qwen):</strong> When stripped down to just two models, the system remained surprisingly effective, achieving a 47.5% win rate. In this intimate setup, Qwen3-Coder-Next became the primary workhorse, forging 66.7% of the winning answers, while DeepSeek provided the remaining third as the essential reviewer.</p><p>This was our “Aha!” moment. Even stripped of half its roster, the Debate Club <em>still</em> beats the Monolith. It proves a fundamental law of the new AI frontier: Multi-agent systems aren’t about throwing every model you have at a problem; they’re about curating the right committee for the job.</p><h3>The Trade-Off: The Cost of Certainty</h3><p>Let’s address the elephant in the room.</p><p>Debate takes more calls. More tokens. More time.</p><p>A single GPT-4.1 query is one inference. Our debate club runs initial answers + cross-examinations + refinements + final validation. That is a massive multiplier on API calls per single question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*UvpeyrUrIQK9M6vdwmEcrg.png" /><figcaption><strong>The Cost of Certainty:</strong> While the full committee (v4) is expensive, the Power Duo (v2) delivers superior reasoning for just a fraction of a penny more than GPT-4.1.</figcaption></figure><p>Look at the yellow line. That is the true cost of the “Hive Mind.”</p><p>While GPT-4.1 coasts along at a highly optimized, flat rate of <strong>$0.0059</strong> per question (the dashed blue line), our multi-agent frameworks charge a premium for their superior reasoning:</p><ul><li><strong>The Full Committee (v4):</strong> To achieve that elite 56.2% win rate, you are paying <strong>$0.0181</strong> per prompt — more than <em>triple</em> the cost of the monolith. If you are running millions of queries a day, that invoice will break you.</li><li><strong>The Trio (v3):</strong> Still pricey at <strong>$0.0148</strong>, but it secures a decisive 50.0% win rate.</li><li><strong>The Power Duo (v2):</strong> This is where the magic happens. At <strong>$0.0067</strong>, our two-model committee costs just <em>eight-tenths of a cent</em> more than GPT-4.1. For that microscopic premium, you flip a losing matchup into a dominant <strong>47.5%</strong> win rate.</li></ul><h4><strong>The Latency Tax</strong></h4><p>Beyond the API costs, there is the latency tax. The Monolith streams its answer to you instantly. The Debate Club takes time to argue. If you are building a customer service chatbot that needs to reply in 500 milliseconds, the multi-agent system is the wrong tool for the job.</p><p>But if you are generating complex system architecture, analyzing legal contracts, or writing production-grade code where a single hallucination costs thousands of dollars?</p><p>Suddenly, paying an extra penny and waiting a few extra seconds for an airtight, peer-reviewed answer isn’t just a trade-off. <strong>It’s a bargain.</strong></p><h3>Conclusion: The Future is Orchestrated</h3><p>The AI industry is obsessed with size, but the “One Big Brain” era is ending.</p><p>By forcing smaller, specialized models to debate, we proved that a curated team can outsmart a giant like GPT-4.1 — and do it for just a fraction of a penny more per prompt.</p><p>It’s time to stop treating AI models like omniscient oracles and start treating them like employees:</p><ul><li><strong>For fast, low-stakes tasks:</strong> The single-call monolith is still king.</li><li><strong>For high-stakes, complex tasks:</strong> Multi-agent debate is the undisputed champion.</li></ul><p>The next major advancement in AI won’t necessarily come from building larger monolithic models. It will come from orchestration. The highest level of reasoning performance is no longer limited to a single standalone model.</p><p>It’s the room itself.</p><p>The next article from this series will explore what can be obtained from a cascade of models that collaborate and debate each other, and whether they can provide acceptable outcomes for complex questions. Stay tuned!</p><p>This project was made possible with the support of the Innovate Moldova Programme, financed by Sweden and the United Kingdom.</p><p>Made with ❤️ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66f4492af4b3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/debate-club-smaller-models-vs-monolith-llms-66f4492af4b3">Debate Club: Smaller Models vs. Monolith LLMs</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smaller, Smarter, Cheaper? Rethinking LLM Orchestration for Cost Efficiency]]></title>
            <link>https://medium.com/softplus-publication/smaller-smarter-cheaper-rethinking-llm-orchestration-for-cost-efficiency-5e9e20517ea5?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/5e9e20517ea5</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Tue, 03 Mar 2026 10:55:06 GMT</pubDate>
            <atom:updated>2026-03-18T20:16:21.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aP9Av72mu5jkyMXckEPrnQ.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>In the era of AI, large language models are widely used in everyday life, answering coding questions, generating creative content, or providing information-heavy responses. Advanced systems have demonstrated remarkable capabilities that serve as an assistance with decision-making tasks.</p><p>These powerful models come with significant computational and financial costs. While some models are free to use or offer a freemium option, for advanced features, advanced usage often requires paid plans.</p><p>At Sigmoid, this question led to a practical and economically driven hypothesis: for simpler tasks, could smaller, cheaper models be used instead of large, premium models, while still delivering valid and useful answers?</p><p>As a result, an experiment was run to orchestrate multiple smaller models that collaborate within a structured workflow, delegating complexity only when necessary.</p><p>The primary purpose of this experiment is to design and evaluate a collaborative flow of smaller and more cost-efficient AI models that together could produce high-quality responses.</p><p>The key objectives of the experiment are: <br>- achieve equivalent performance at a lower cost, or <br>- achieve better performance at a similar cost; <br>- reduce computational resource consumption; <br>- design an intelligent model orchestration workflow.</p><p>Given a user query, the system first routes the task to a lower-tier, cost-efficient LLM to generate an initial response. The generated output is then evaluated by a dedicated Judge LLM that performs a structured assessment, producing a quality score, a validity verdict, and diagnostic feedback. If the response satisfies predefined acceptance criteria, it is returned immediately, enabling early termination and cost efficiency. Otherwise, the judge’s feedback is incorporated into a refined prompt that includes the original query, the prior response, and the structured critique. This refined prompt is passed to a stronger model in the cascade, and the evaluation–refinement cycle repeats. Escalation continues until either a response meets the acceptance threshold or the highest-capability model is used, a moment when the best answer is returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*V8Q6f8xE7RPofNMWbpcYTg.jpeg" /><figcaption>Fig.1: Flowchart for the Simple Flow Architecture</figcaption></figure><h3><strong>Experiment #1</strong></h3><p>In the first run of the experiment, five different agents were tested as workers:<br>- Worker 1: Meta Llama 3.1 8B (8 billion parameters | $0.02/M input tokens | $0.05/M output tokens)<br>- Worker 2: Microsoft Phi-4 (14 billion parameters | $0.06/M input tokens | $0.14/M output tokens)<br>- Worker 3: Qwen 3 32B (32 billion parameters | $0.08/M input tokens | $0.24/M output tokens)<br>- Worker 4: Meta Llama 3.1 70B (70 billion parameters | $0.40/M input tokens$0.40/M | output tokens)<br>- Worker 5: NVIDIA Llama 3.3 Nemotron Super 49B v1.5 (49 billion parameters | $0.10/M input tokens | $0.40/M output tokens)</p><p>The evaluation was carried out using Google Gemini 2.5 Flash Lite Preview (September 2025), which acted as the judge. The agents’ answers to Arena Hard Auto v2 benchmark questions were compared against OpenAI’s ChatGPT 4.1, serving as the baseline reference.</p><p>At a glance, as shown in Fig. 2, GPT-4.1 won 149 out of 189 matchups, with Simple Flow V1 winning 14 and 26 ending in a tie. The average arena score of 0.541 reflects GPT-4.1’s consistent advantage. Despite this quality gap, Simple Flow achieved a 57% reduction in cost per query, with 19.6% of queries resolved within the first two levels alone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xpRH-nUlnjvz1-OCdsfFAQ.png" /><figcaption>Fig.2: Benchmark Results of the Simple Flow v1 vs ChatGPT 4.1</figcaption></figure><p>Fig. 3 breaks down the quality-cost relationship in more detail. The cost dynamic is most visible at the extremes. Queries resolved at Level 1 cost an average of just $0.0001, roughly 80 times cheaper than the GPT-4.1 baseline, though GPT-4.1 won 93.8% of those evaluations (15 out of 16). Even Level 3, which handled the plurality of queries, came in at $0.0026, about one-third the baseline cost, with GPT-4.1 still winning 80.0% of those matchups. Notably, GPT-4.1’s win rate does narrow as the cascade escalates to stronger models: from 93.8% at Level 1 down to 72.2% at Level 5. It is worth mentioning that since the flow is incremental, the price at an upper level is cumulative, also including the prices from the lower levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8P5NuDBBUkeWnavZjBJrhA.png" /><figcaption>Fig.3: Quality and Cost Trade-off Across the Cascade</figcaption></figure><p>Fig. 4 takes a closer look at how the judge evaluated Simple Flow’s responses. 70.4% of cases (133 out of 189) received a GPT ≫ SF verdict (A&gt;&gt;B), with the distribution of arena scores skewed heavily in GPT-4.1’s favour. The cumulative cost curve, however, confirms the 57% savings hold consistently across the full benchmark run, meaning Simple Flow is a cheaper system, even if not a higher-quality one on these benchmark questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*He3Ss76asoztmoudFSaHig.png" /><figcaption>Fig.4: Judge Verdict and Score Breakdown</figcaption></figure><p>The cascade’s efficiency is most clearly illustrated in Fig. 5. Of the 189 questions, 16 (8.5%) were resolved at Level 1, 21 (11.1%) at Level 2, and 75 (39.7%) at Level 3, meaning nearly 60% of all queries were handled before the two largest and most expensive models were ever invoked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IrNkepYodlyWbw5W7OmF3g.png" /><figcaption>Fig.5: Cascade Efficiency and Funnel</figcaption></figure><p>An interesting secondary finding relates to answer length in Fig. 6. GPT-4.1 produced answers averaging 3,534 characters, while Simple Flow’s cascade produced answers averaging 1,188 characters. Despite its conciseness, Simple Flow’s answers were judged as lower quality in the majority of cases, suggesting that for the hard-prompt benchmark used here, more detailed responses tend to score better with the judge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nm0plUJaCxfLWeX0WBvWA.png" /><figcaption>Fig.6: Answer Length of Simple Flow vs ChatGPT 4.1</figcaption></figure><h3><strong>Experiment #2</strong></h3><p>Based on the results, it was decided to run the same experiment again, but with a different configuration of working agents in the hope of obtaining better results:<br>- Worker 1: Meta Llama 3.1 8B (8 billion parameters | $0.02/M input tokens | $0.05/M output tokens)<br>- Worker 2: Mistral Small 3.2 24B (24 billion parameters | $0.06/M input tokens | $0.18/M output tokens)<br>- Worker 3: Qwen 3 32B (32 billion parameters | $0.08/M input tokens | $0.24/M output tokens)<br>- Worker 4: Meta Llama 3.1 70B (70 billion parameters | $0.40/M input tokens$0.40/M | output tokens)<br>- Worker 5: DeepSeek V3.1 (37 billion parameters | $0.15/M input tokens | $0.75/M output tokens)</p><p>At first glance, in Fig. 7, Simple Flow V2 achieved a 41.6% cost reduction compared to the GPT-4.1 baseline. The quality picture remained similar to V1: GPT-4.1 won 76 out of 98 match-ups (77.6%), with Simple Flow V2 winning only 7 (7.1%) and 15 (15.3%) ending in a tie. The average Arena score of 0.538 reflects a distribution skewed heavily toward GPT-4.1, with 80 of 98 verdicts being A≫B (a strong win for the baseline).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VNw9ZWykK2LWqcIRe-XDCA.png" /><figcaption>Fig.7: Benchmark Results vs ChatGPT 4.1</figcaption></figure><p>Fig. 8 breaks down the relationship between cost and quality across each escalation level. Queries resolved early are dramatically cheaper, with Level 1 averaging just $0.00021 per query, roughly 97% cheaper than the GPT-4.1 baseline, and Level 2 coming in at $0.00132, still 84% below baseline. Level 3 averaged $0.00405, approximately half the GPT-4.1 cost. Crucially, however, the cost advantage disappears at the top of the cascade. Level 5, reached by 17 queries, averaged $0.01023, more expensive than the GPT-4.1 baseline, while still losing the majority of those evaluations. This is a key difference from V1, where the top-tier model at least remained cost-competitive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzfPrSGAZmBGJnYtDYNFzg.png" /><figcaption>Fig.8: Quality and Cost Trade-off Across the Cascade</figcaption></figure><p>Despite the quality challenges, the cascade’s structural efficiency held up well (Fig. 9). The judge accepted Simple Flow’s response before exhausting the full pipeline in 70 out of 98 questions. Of these, 7 were resolved at Level 1, 17 at Level 2, and 32 at Level 3, meaning 57.1% of all queries were resolved by Level 3, before the two most expensive workers were ever invoked. An additional 7 queries were resolved at Level 4, and 7 at Level 5.<br>The remaining 28 queries were never accepted by the judge, even after all five levels, with the highest-capability model’s output returned as the final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FWUrIv0mH30RKQE7tpKzjw.png" /><figcaption>Fig.9: Cascade Efficiency</figcaption></figure><h3>Experiment #3</h3><p>The previous experiment raised an important structural question: does a longer cascade actually pay off, or do the gains from early termination get cancelled out by expensive tail queries?</p><p>To test this, the experiment was run a third time with a simplified three-model configuration:</p><p>- Worker 1: Qwen 3 32B (32 billion parameters | $0.08/M input tokens | $0.24/M output tokens)<br>- Worker 2: Meta Llama 3.1 70B (70 billion parameters | $0.40/M input tokens$0.40/M | output tokens)<br>- Worker 3: DeepSeek V3.1 (37 billion parameters | $0.15/M input tokens | $0.75/M output tokens)</p><p>It is importan to note that having a smaller number of levels, the overall cost of the upper levels should diminish because we have fewer levels to account for.</p><p>As shown in Fig. 10, Simple Flow achieved a 30.9% cost reduction compared to the GPT-4.1 baseline. The quality picture marks a dramatic shift from all previous runs: Simple Flow won 84 out of 146 matchups (57.5%), with GPT-4.1 winning only 32 (21.9%) and 30 (20.5%) ending in a tie. This is the first configuration in which Simple Flow outright wins the majority of matchups against GPT-4.1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OhY9n0OaZMkHjMOA1F9Cig.png" /><figcaption>Fig.10: Benchmark Results of the Simple Flow v2 (3 levels) vs ChatGPT 4.1</figcaption></figure><p>Fig. 11 breaks down the relationship between cost and quality across each escalation level. Level 1 averages just $0.0026 per query, though GPT-4.1 still wins 26% of evaluations at this tier. Level 2 comes in at $0.0087 and wins 73.6% of matchups. By Level 3, the cost advantage has essentially evaporated, yet Simple Flow still wins 62.5% of those matchups — making the top of the cascade genuinely competitive on quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTEuOOqh06B6QIa3PHFLxw.png" /><figcaption>Fig.11: Quality and Cost Trade-off Across the Cascade</figcaption></figure><p>Fig. 12 takes a closer look at how the judge evaluated Simple Flow’s responses. The arena score distribution is now in favor of Simple Flow, with 86 negative-score verdicts versus 32 positive-score verdicts. The cumulative cost curve confirms the 30.9% savings hold consistently across the full benchmark run. For the first time, Simple Flow is both the cheaper and the higher-quality system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z58d_OnC1Y4roM0BnRD50w.png" /><figcaption>Fig.12: Jugde Verdict and Score Breakdown</figcaption></figure><p>The cascade’s structural efficiency is illustrated in Fig. 13. Of the 146 questions, 78 (53.4%) were resolved at Level 1 alone, more than half of all queries handled by the smallest, cheapest model. A further 54 (37.0%) were resolved at Level 2, and only 14 (9.6%) escalated to Level 3. This means 90.4% of queries were resolved without ever reaching the most expensive model. A total of 22 queries (15.1%) were never accepted by the judge, with the Level 3 output returned as the final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrI8qkN8deDTX0d4nV9wMw.png" /><figcaption>Fig.13: Cascade Efficiency</figcaption></figure><p>An interesting finding emerges in Fig. 14. Unlike V1, where Simple Flow produced answers averaging just 1,188 characters, shorter than GPT-4.1’s 3,534, the 3-level configuration produces answers averaging 7,228 characters, nearly double GPT-4.1’s 3,569. This verbosity is most pronounced at Levels 2 and 3, where the cascade’s iterative refinement produces longer, more detailed responses. Unlike the V1 finding where conciseness correlated with lower quality, here the combination of length and refinement drives genuinely better outcomes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpi7CNiUSmyhOpCf6mLfWQ.png" /><figcaption>Fig.14: Answer Length of Simple Flow vs ChatGPT 4.1</figcaption></figure><h3>Conclusion</h3><p>The experiments proved that unsophisticated questions can be answered correctly by a flow of models that are both smaller and cheaper, a result which is comparable with the answers from OpenAI’s ChatGPT 4.1. Further configurations and matches of models, as well as structured output via Pydantic, can be explored for enhanced outcomes.</p><p>The next article from this series will explore what can be obtained from a cascade of models that collaborate and debate each other, and whether they can provide acceptable outcomes for complex questions. Stay tuned!</p><p>This project was made possible with the support of the Innovate Moldova Programme, financed by Sweden and the United Kingdom.</p><p>Made with ❤️ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e9e20517ea5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/smaller-smarter-cheaper-rethinking-llm-orchestration-for-cost-efficiency-5e9e20517ea5">Smaller, Smarter, Cheaper? Rethinking LLM Orchestration for Cost Efficiency</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Virtual Environments with Anaconda]]></title>
            <link>https://medium.com/softplus-publication/guide-to-virtual-environments-with-anaconda-4ad15bfb38e3?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/4ad15bfb38e3</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[anaconda]]></category>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Eduard Balamatiuc]]></dc:creator>
            <pubDate>Wed, 11 Sep 2024 18:19:40 GMT</pubDate>
            <atom:updated>2024-09-11T18:19:40.174Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*iPbwiMG3YkEIWfrjemTzdw.png" /></figure><p>Virtual environments are isolated spaces on your computer where you can install and manage specific versions of Python and various packages without affecting your system-wide installations.</p><blockquote>In other words, it’s like <strong>boxes</strong> that help you organize all your <strong>clothes</strong> (where <strong>boxes</strong> are the virtual environments and the <strong>clothes</strong> are your libraries and others)</blockquote><p>Anaconda is a powerful distribution of Python and R programming languages for scientific computing, data science, and machine learning. One of its key features is the ability to create and manage virtual environments.</p><blockquote>In other words, it’s a tool that can help you manage virtual environments easily.</blockquote><h3>Why are Anaconda and virtual environments useful?</h3><ul><li><strong><em>Isolate project dependencies</em></strong></li></ul><blockquote>Every box is dedicated to one thing, basically the running shoes will never get into the wedding related box.</blockquote><ul><li>Avoid version conflicts between different projects</li></ul><blockquote>Let’s say you have two of the same pair of shoes, the first one you always use for running and the second one for going out. Even if it’s the same model, you differentiate them in separate boxes.</blockquote><ul><li>Easily share and reproduce development environments</li></ul><blockquote>Your style is really nice, and when you want to share it, it’s easy, because you have everything separated already in boxes you can just list the clothes from the “going out” box to your friend, and now you have matching outfits!</blockquote><ul><li>Simplify package management</li></ul><blockquote>It’s just intuitive and everything fits well, you don’t waste time on finding the right clothes, you are <strong><em>ON FIRE.</em></strong></blockquote><h3>Downloading and Installing Anaconda</h3><p>First, let’s get our hands on this amazing closet organizer. Head over to the <a href="https://www.anaconda.com/download">Anaconda download page</a></p><p>Choose the Anaconda that fits your room (operating system) — they have versions for Windows, macOS, and Linux closets. Go for the Python 3.X version; it’s like choosing the latest organizer model.</p><h4><strong>Step-by-step installation guide</strong></h4><p><strong>Windows:</strong><br>1. Double-click the downloaded .exe file to launch the installer.<br>2. Choose “Install for me only” unless you have admin rights and want to install for all users.<br>3. Select an installation location or use the default.<br>4. In the Advanced Options, check “Add Anaconda to my PATH environment variable” for easier command-line access.<br>5. Click “Install” and wait for the process to complete.</p><p><strong>macOS:</strong><br>1. Double-click the downloaded .pkg file to launch the installer.<br>2. Follow the prompts, agreeing to the license terms.<br>3. Choose “Install for me only” unless you want to install for all users (requires admin rights).<br>4. Select an installation location or use the default.<br>5. On the “Destination Select” screen, ensure your main drive is selected.<br>6. Click “Install” and enter your password if prompted.</p><p><strong>Linux:</strong><br>1. Open a terminal window.<br>2. Navigate to the directory containing the downloaded file.<br>3. Run the following command, replacing `your-anaconda-installer.sh` with the actual filename:</p><pre>bash your-anaconda-installer.sh</pre><p>4. Follow the prompts, agreeing to the license terms.<br>5. Choose an installation location or use the default.<br>6. When asked if you want to initialize Anaconda3, type “yes” for easier setup.</p><p>After installation, open a new terminal or command prompt window to ensure the changes take effect by running the following command:</p><pre>conda --version</pre><h3>Using Anaconda (the bare minimum)</h3><h4>Listing Environments</h4><p>To see all your Anaconda environments:</p><pre>conda env list</pre><p>This command shows you all the environments you’ve created, with the active one marked with an asterisk (*).</p><h4>Creating a New Environment</h4><p>To create a new environment with a specific Python version:</p><pre>conda create -n thenameofyourenv python=3.x</pre><p>Replace `thenameofyourenv` with your desired environment name and `3.x` with the Python version you need (e.g., 3.8, 3.9, etc.).</p><h4>Activating an Environment</h4><p>To start using an environment:</p><pre>conda activate thenameofyourenv</pre><p>Replace `thenameofyourenv` with the name of the environment you want to activate.</p><h4><strong>Deactivating an Environment</strong></h4><p>When you’re done working in an environment:</p><pre>conda deactivate</pre><h4>Installing Packages from a Requirements File</h4><p>If you have a `requirements.txt` file with a list of packages, just make sure you activate your environment and then run:</p><pre>pip install -r requirements.txt</pre><p>Remember to always activate the correct environment before installing or managing packages. This ensures that you’re working within the intended isolated environment.</p><p>This article is not meant for in-depth explanation and showing you all of the features available, but just a really fast way of understanding the topic so that you can apply it instantly!</p><p>Let’s connect! <a href="https://www.linkedin.com/in/eduard-balamatiuc/">Eduard Balamatiuc | LinkedIn</a></p><p>Made with ❤ by Sigmoid. Follow us: <a href="https://www.facebook.com/sigmoidAI">Facebook</a>/<a href="https://www.instagram.com/sigmo.ai/">Instagram</a>/<a href="https://www.linkedin.com/company/sigmoid/posts/?feedView=all">LinkedIn</a>:</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ad15bfb38e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/guide-to-virtual-environments-with-anaconda-4ad15bfb38e3">Guide to Virtual Environments with Anaconda</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advancements in Object Detection: A Comprehensive Analysis of Two-Stage Models]]></title>
            <link>https://medium.com/softplus-publication/advancements-in-object-detection-a-comprehensive-analysis-of-two-stage-models-7a3d6ec2bddb?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/7a3d6ec2bddb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[two-stage-models]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Sun, 07 Jul 2024 16:12:54 GMT</pubDate>
            <atom:updated>2024-07-12T11:49:58.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*LnzACGn9tUG46udviAM1hQ.png" /></figure><h4>Abstract</h4><p>The concept of object detection, an important task in Computer Vision, might not be well-known to the daily users of technology, but it has various applications in real-life problems. In this article, we will describe the magic behind object detection algorithms, primarily focusing on two-stage models. The research methodology consists of an analysis of two-stage models, highlighting their architecture. The research question is: what are the architectures, advantages, and limitations of two-stage models in object detection?</p><p><strong>Keywords:</strong> Object Detection, Two-Stage Models, R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN, CNN</p><h4><strong>Introduction</strong></h4><p>Object detection is a Computer Vision problem that detects visual items of specific kinds (animals, humans) in digital pictures like photographs or video frames. The purpose of object detection is to create computational models that answer the most basic question that computer vision applications have: “What things are there and where are they?”¹</p><p>For humans, object detection is an effortless task, because it was there throughout their whole evolution. However, for machines, object detection is a complex challenge to be tackled and significant efforts have been done to develop such algorithms. Among these, an important role was played by two-stage models, that offer enhanced accuracy in object detection tasks compared to one-stage models. In the following paragraphs, we will discuss the architecture, functionality, and effectiveness of two-stage models in Computer Vision.</p><h4>What are two-stage models?</h4><p>Two-stage models are Machine Learning models that locate objects in an image and predict their class in two steps. The first step is a regression problem while the second one is a classification problem².</p><p>The first step is a <strong>Regional Proposal Network (RPN)</strong> that scans the regions in an image and proposes them as candidates to be recognized as objects.</p><p>The second step is a <strong>Classifier</strong> that receives as input the regions proposed by the RPN and tries to classify them into an object class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4s4WRGxRQsKW9R01xNqRA.png" /><figcaption><strong>Fig.1</strong> Two-stage detector architecture (Source: <a href="https://www.mdpi.com/1424-8220/23/21/8981">https://www.mdpi.com/1424-8220/23/21/8981</a>)</figcaption></figure><p>The two-stage model pioneer is R-CNN, whose limitations were improved by the Fast R-CNN and Faster R-CNN models. Later Mask R-CNN was created for enhanced accuracy and faster predictions.</p><h4>What is R-CNN?</h4><p>Region-based Convolutional Neural Network (R-CNN) is a type of deep learning architecture that works by proposing a region-of-interest (RoI), extracting features with CNN, and classifying those regions based on the extracted features.</p><p>More concretely, the R-CNN consists of the following four steps:</p><ol><li><strong>Region Proposals</strong>: The first step involves generating region proposals using a method like Selective Search. This step identifies potential regions in an image that may contain objects. Typically, around 2000 region proposals are generated for each image.</li><li><strong>Feature Extraction</strong>: Each region proposal is then resized to a fixed size (e.g., 224×224 pixels) and passed through a pre-trained CNN to extract features. This CNN acts as a feature extractor, producing a fixed-length feature vector for each region.</li><li><strong>Classification</strong>: The extracted feature vectors are then fed into a set of Support Vector Machines (SVMs), where each SVM is trained to classify a specific object category. These SVMs determine the presence of objects within the proposed regions.</li><li><strong>Bounding Box Regression</strong>: To improve localization accuracy, a bounding box regressor is applied to refine the coordinates of the proposed regions. This step adjusts the bounding boxes to better fit the objects³.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*m_gGw6vtHrBG2Ud_.png" /><figcaption>Fig.2 R-CNN Architecture (Source: <a href="https://towardsdatascience.com/r-cnn-fast-r-cnn-faster-r-cnn-yolo-object-detection-algorithms-36d53571365e">https://towardsdatascience.com/r-cnn-fast-r-cnn-faster-r-cnn-yolo-object-detection-algorithms-36d53571365e</a>)</figcaption></figure><p>R-CNN can handle many object classes, but it is computationally expensive, which leads to resource and time consumption. Depending on the training manner, it might have to classify, for example, 2000 region proposals per image which leads to increased training time. Each part of the model requires training separately and cannot be paralleled. As well, the testing time of inference is approximately 50 seconds per image. These drawbacks led to the introduction of the next model.</p><h4>What is Fast R-CNN?</h4><p>Fast R-CNN resulted as an improvement over R-CNN that addresses the computational inefficiency of the original method. It achieves this by using a single CNN to process the entire image and generate the ROIs rather than running the CNN on each ROI individually.</p><p>The Fast R-CNN algorithm includes:</p><ol><li><strong>Region proposal:</strong> In this step, a set of ROIs is generated using a method such as selective search or edge boxes.</li><li><strong>Feature extraction:</strong> A CNN extracts features from the entire image.</li><li><strong>ROI pooling:</strong> The extracted features are then used to compute a fixed-length feature vector for each ROI. This is done by dividing the ROI into a grid of cells and max-pooling the features within each cell.</li><li><strong>Classification and bounding box regression: </strong>The fixed-length feature vectors for each ROI are fed into two fully connected (FC) layers: one for classification and one for bounding box regression. The classification FC layer predicts the object’s class within the ROI, while the bounding box regression FC layer predicts the refined bounding box coordinates for the object⁴.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3wT_MFDeQfdtPs5y.png" /><figcaption><strong>Fig.3</strong> <em>Fast R-CNN architecture (Source: </em><a href="https://www.geeksforgeeks.org/fast-r-cnn-ml/">https://www.geeksforgeeks.org/fast-r-cnn-ml/</a>)</figcaption></figure><p>Since we don’t have to pass 2000 region proposals for each image and the ConvNet operation is done only once per image, this algorithm is more time efficient. Yet, it still uses the selective search algorithm which is slow and it takes around 2 seconds per image to detect objects, which sometimes does not work properly with large real-life datasets⁵. To solve this issue, the implementation of next model was necessary.</p><h4>What is Faster R-CNN?</h4><p>Faster R-CNN is an extension of Fast R-CNN. It reduces the computational cost of object detection by using a single CNN to generate both the ROIs and the features for each ROI, rather than using a separate CNN for each task, as in Fast R-CNN.</p><p>The Faster R-CNN pipeline can be divided into four main steps:</p><ol><li><strong>Feature extraction: </strong>A CNN extracts features from the entire image.</li><li><strong>Region proposal:</strong> A set of ROIs is generated using a fully convolutional network (FCN) that processes the extracted features.</li><li><strong>ROI pooling:</strong> The extracted features are then used to compute a fixed-length feature vector for each ROI using the same ROI pooling process as in Fast R-CNN.</li><li><strong>Classification and bounding box regression: </strong>The fixed-length feature vectors for each ROI are fed into two separate FC layers: one for classification and one for bounding box regression. The classification FC layer predicts the object’s class within the ROI, while the bounding box regression FC layer predicts the refined bounding box coordinates for the object⁴.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*wysTH2z4Y-T3bYTt.jpeg" /><figcaption><strong>Fig.4</strong> <em>Faster R-CNN architecture (Source: </em><a href="https://towardsdatascience.com/faster-r-cnn-for-object-detection-a-technical-summary-474c5b857b46">https://towardsdatascience.com/faster-r-cnn-for-object-detection-a-technical-summary-474c5b857b46</a>)</figcaption></figure><p>Faster-RCNN has maintained its definite advantages in terms of detection accuracy. However, Faster-RCNN has some shortcomings such as it has not reached real-time detection. The way of getting region boxes before classification needs a huge amount of computations⁶. This limitation has led to another advanced approach, discussed next.</p><h4>What is Mask R-CNN?</h4><p>Mask R-CNN is a deep learning model that combines object detection and instance segmentation. It is an extension of the Faster R-CNN architecture.</p><p>The key innovation of Mask R-CNN lies in its ability to perform pixel-wise instance segmentation alongside object detection. This is achieved through the addition of an extra “mask head” branch, which generates precise segmentation masks for each detected object⁷.</p><p>The architecture of Mask R-CNN is built upon the Faster R-CNN architecture, with the addition of an extra “mask head” branch for pixel-wise segmentation.</p><p>The overall architecture can be divided into several key stages:</p><ol><li><strong>Backbone and RPN network:</strong> These networks run once per image to give a set of region proposals. Region proposals are regions in the feature map that contain the object.</li><li><strong>Classification and bounding box prediction</strong>: Each proposed region can be of different sizes whereas fully connected layers in the networks always require a fixed size vector to make predictions. The size of these proposed regions is fixed by using either RoI pool (which is very similar to MaxPooling) or RoIAlign method⁸.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*MuXglFj2ScGpjnte.png" /><figcaption><strong>Fig.5</strong> Mask R-CNN architecture (Source: <a href="https://developers.arcgis.com/python/guide/how-maskrcnn-works/">https://developers.arcgis.com/python/guide/how-maskrcnn-works/</a>)</figcaption></figure><p>The implementation of Mask R-CNN enables fine-grained pixel-level boundaries for accurate and detailed instance segmentation. As well it can also handle overlapping objects, which can make semantic segmentation models confuse pixels from different instances of the same class. However, this model is computationally expensive and requires memory resources which can increase with the number of classes and the resolution of masks⁹.</p><p><strong>Conclusion</strong></p><p>Two-stage models have come a long way and have had positive growth based on the lack of each ancestor. From R-CNN to Mask R-CNN, these models started from the same goal, to detect objects, and have been improved to become more efficient, faster, and to require fewer resources. By pursuing these future directions, two-stage object detection models can continue to evolve, providing efficient and accurate solutions across various fields.</p><p>Bibliography</p><p>[1]: <a href="https://www.tasq.ai/glossary/two-stage-detector/">https://www.tasq.ai/glossary/two-stage-detector/</a></p><p>[2]: <a href="https://www.machinelearningatscale.com/p/computer-vision">https://www.machinelearningatscale.com/p/computer-vision</a></p><p>[3]: <a href="https://www.geeksforgeeks.org/how-does-r-cnn-work-for-object-detection/">https://www.geeksforgeeks.org/how-does-r-cnn-work-for-object-detection/</a></p><p>[4]: <a href="https://www.shiksha.com/online-courses/articles/object-detection-using-rcnn/">https://www.shiksha.com/online-courses/articles/object-detection-using-rcnn/</a></p><p>[5]: <a href="https://medium.com/analytics-vidhya/object-detection-algorithms-r-cnn-vs-fast-r-cnn-vs-faster-r-cnn-3a7bbaad2c4a">https://medium.com/analytics-vidhya/object-detection-algorithms-r-cnn-vs-fast-r-cnn-vs-faster-r-cnn-3a7bbaad2c4a</a></p><p>[6]: <a href="https://www.researchgate.net/publication/346764538_A_brief_review_and_challenges_of_object_detection_in_optical_remote_sensing_imagery">https://www.researchgate.net/publication/346764538_A_brief_review_and_challenges_of_object_detection_in_optical_remote_sensing_imagery</a></p><p>[7]: <a href="https://blog.roboflow.com/mask-rcnn/">https://blog.roboflow.com/mask-rcnn/</a></p><p>[8]: <a href="https://developers.arcgis.com/python/guide/how-maskrcnn-works/">https://developers.arcgis.com/python/guide/how-maskrcnn-works/</a></p><p>[9]: <a href="https://www.linkedin.com/advice/3/how-does-mask-r-cnn-improve-segmentation-accuracy">https://www.linkedin.com/advice/3/how-does-mask-r-cnn-improve-segmentation-accuracy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a3d6ec2bddb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/advancements-in-object-detection-a-comprehensive-analysis-of-two-stage-models-7a3d6ec2bddb">Advancements in Object Detection: A Comprehensive Analysis of Two-Stage Models</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gradio: Simplifying GUI Creation for Machine Learning]]></title>
            <link>https://medium.com/softplus-publication/gradio-simplifying-gui-creation-for-machine-learning-9ba19efc0eb4?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/9ba19efc0eb4</guid>
            <category><![CDATA[gradio]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[gui]]></category>
            <dc:creator><![CDATA[Mihaela Catan]]></dc:creator>
            <pubDate>Sun, 07 Jul 2024 16:04:55 GMT</pubDate>
            <atom:updated>2024-07-12T11:50:43.182Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*g_qZoo7LWG2OPgfwCoBLXg.png" /></figure><h4>Abstract</h4><p>The integration of Machine Learning models into user-friendly applications plays an important role in enhancing usability and accessibility. The creation of a Graphical User Interface is a major step into deploying the models, because it allows interaction and data input.</p><p>Gradio is an open-source package that bridges this gap for Python Developers. This paper explores the functionalities of Gradio, demonstrating how it enables the construction of GUIs with minimal coding effort. It answers the question: “How can one easily create a GUI for Machine Learning models without extensive application development background?”</p><p>Through specific examples, this article aims to demonstrate the straightforward process of building GUIs with Gradio.</p><p><strong>Keywords: </strong>Application development, Gradio, Graphical User Interface (GUI), Machine Learning, Model deployment, Python, User-friendly applications</p><h4>Introduction</h4><p>When working with Machine Learning models, there is a variety of models and options to choose from. Depending on the data and the goal one wants to achieve, the user might choose a model for classification or regression, one oriented on Natural Language Processing or Computer Vision. Yet, one more important step that ensures the usability of models is the creation of a Graphical User Interface.</p><p>A graphical user interface (GUI) is a digital interface in which a user interacts with graphical components such as icons, buttons, and menus. Such an interface can be obtained by creating a computer, mobile, or web application which would include the Machine Learning model. However such products require knowing additional programming languages and frameworks. To address this challenge and to ensure that individuals who code in Python can easily construct a GUI, Gradio has been developed.</p><h4>What is Gradio?</h4><p>Gradio is an open-source Python package that allows programmers to quickly build a demo or web application for their machine learning model, API, or any arbitrary Python function. One of the most exciting parts is that they can then share a link to their demo or web application in just a few seconds using Gradio’s built-in sharing features¹.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iXS3S4G8e-V-3r7T" /><figcaption><strong>Fig.1</strong> Gradio (Source: <a href="https://pypi.org/project/gradio/">https://pypi.org/project/gradio/</a>)</figcaption></figure><h4><strong>Why choose Gradio?</strong></h4><p>Gradio supports various applications, from showcasing machine learning models to debugging and deploying data science workflows. It integrates with the Python ecosystem, providing real-time feedback and becoming an ideal choice for Python developers seeking to enhance their projects with user-friendly GUIs.</p><h4><strong>Get started</strong></h4><p>Note: For the tutorial, I will use Google Colab.</p><p><strong>Install Gradio</strong></p><p>Create a new code block and run:</p><pre>!pip install gradio</pre><p>Next, import Gradio:</p><pre>import gradio as gr</pre><p>Now we are ready to proceed further!</p><p><strong>How to create your first interfaces?</strong></p><p>Gradio offers the flexibility to handle different types of input and output, including text, images, audio, and video.</p><p>For our initial application, we will use the text functionality. We will create a new code block where we will write:</p><pre>def greet(name):<br>    return &quot;Hello, &quot;+ name + &quot;!&quot;<br><br>iface = gr.Interface(<br>    fn=greet,<br>    inputs=gr.Textbox(info=&quot;Input your name&quot;, placeholder=&quot;Name&quot;, label=&quot;Name&quot;),<br>    outputs=gr.Textbox(label=&quot;Message&quot;),<br>)<br><br>iface.launch()</pre><p>The gr.Interface method is used to create a user interface for the greet function. It accepts several parameters: the function itself (greet), the type of input elements to present (gr.Textbox in our scenario, whose value is sent as a parameter to the greet function), and the type of output to display (gr.Textbox here, which displays the value returned by the greet function).</p><p>The final product should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*8FJc53PsDRuUfgPokAqGwg.gif" /><figcaption><strong>Fig.2</strong> The output of the greet function</figcaption></figure><p>Next, we will create another application that takes input from the user and returns a sentence based on the input.</p><pre>def build_sentence(season, weather, temperature, enjoy_weather):<br>    sentence = f&quot;In {season}, with {weather} weather and {temperature} degrees Celsius outside, you {&#39;enjoy&#39; if enjoy_weather == &#39;Yes&#39; else &#39;do not enjoy&#39;} the weather.&quot;<br>    return sentence<br><br>iface = gr.Interface(<br>    fn=build_sentence,<br>    inputs=[<br>        gr.Dropdown(choices=[&#39;Winter&#39;, &#39;Spring&#39;, &#39;Summer&#39;, &#39;Autumn&#39;], info=&quot;Select the season&quot;, label=&quot;Season&quot;),<br>        gr.Dropdown(choices=[&#39;freezing&#39;, &#39;warm&#39;, &#39;hot&#39;, &#39;cold&#39;], info=&quot;Select the weather&quot;, label=&quot;Weather&quot;),<br>        gr.Slider(minimum=-30, maximum=60, step=2, info=&quot;How many degrees Celsius are outside?&quot;, label=&quot;Temperature&quot;),<br>        gr.Radio([&#39;Yes&#39;, &#39;No&#39;], info=&quot;Do you enjoy the weather?&quot;, label=&quot;Emotion&quot;)<br>    ],<br>    outputs=gr.Textbox(label=&quot;Sentence&quot;)<br>)<br><br>iface.launch()</pre><p>In this code, we create an interface for a function named build_sentence that constructs a sentence about weather conditions based on input parameters such as season, weather type, temperature, and whether the user enjoys the weather or not.</p><p>The interface includes dropdown menus, gr.Dropdown, for selecting the season (Winter, Spring, Summer, Autumn) and the weather type (freezing, warm, hot, cold). Additionally, a slider, gr.Slider, allows users to specify the temperature in degrees Celsius, ranging from -30 to 60 in steps of 2. This interface also provides radio buttons, gr.Radio, to indicate whether the user enjoys the weather (Yes or No).</p><p>All these inputs are sent as parameters to the build_sentence function which creates a string that is returned to the interface and displayed as output.</p><p>The final product looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*itNsX6T952vvo8aBCSTirA.gif" /><figcaption><strong>Fig.3</strong> The output of the make_sentence function</figcaption></figure><p>For more examples, you can refer to the documentation of Gradio, available <a href="https://www.gradio.app/guides/quickstart">here</a>.</p><p><strong>How to use Gradio for Machine Learning?</strong></p><p>As mentioned above, Gradio is a great tool to create GUI for Machine Learning tools. To exemplify this, let’s work on a real dataset.</p><p>For this project, I will use the Mushroom Classification dataset².</p><p>Import the necessary libraries and load the dataset:</p><pre># Import libraries<br>import numpy as np<br>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn  as sns<br>import gradio as gr<br>import pickle</pre><pre># Load dataset<br>dataset = pd.read_csv(&#39;/content/mushrooms.csv&#39;)<br>dataset.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xV35YcBWWHef9Srk_O5b3A.png" /><figcaption><strong>Fig.4</strong> The head of the dataset</figcaption></figure><p>The dataset consists of 23 columns:</p><ul><li><strong>class: </strong>edible = e, poisonous = p;</li><li><strong>cap-shape:</strong> bell = b, conical = c, convex = x, flat = f, knobbed = k, sunken = s;</li><li><strong>cap-surface:</strong> fibrous = f, grooves = g, scaly = y, smooth = s;</li><li><strong>cap-color:</strong> brown = n, buff = b, cinnamon = c, gray = g, green = r, pink = p, purple = u, red = e, white = w, yellow = y;</li><li><strong>bruises:</strong> bruises = t, no = f;</li><li><strong>odor:</strong> almond = a, anise = l, creosote = c, fishy = y, foul = f, musty = m, none = n, pungent = p, spicy = s;</li><li><strong>gill-attachment:</strong> attached = a, descending = d, free = f, notched = n;</li><li><strong>gill-spacing:</strong> close = c, crowded = w, distant = d;</li><li><strong>gill-size: </strong>broad = b, narrow = n;</li><li><strong>gill-color:</strong> black = k, brown = n, buff = b, chocolate = h, gray = g, green = r, orange = o, pink = p, purple = u, red = e, white = w, yellow = y;</li><li><strong>stalk-shape: </strong>enlarging = e, tapering = t;</li><li><strong>stalk-root:</strong> bulbous = b, club = c, cup = u, equal = e, rhizomorphs = z, rooted = r, missing = ?;</li><li><strong>stalk-surface-above-ring:</strong> fibrous = f, scaly = y, silky = k, smooth = s;</li><li><strong>stalk-surface-below-ring:</strong> fibrous = f, scaly = y, silky = k, smooth = s;</li><li><strong>stalk-color-above-ring: </strong>brown = n, buff = b, cinnamon = c, gray = g, orange = o, pink = p, red = e, white = w, yellow = y;</li><li><strong>stalk-color-below-ring: </strong>brown = n, buff = b, cinnamon = c, gray = g, orange = o, pink = p, red = e, white = w, yellow = y;</li><li><strong>veil-type:</strong> partial = p, universal = u;</li><li><strong>veil-color:</strong> brown = n, orange = o, white = w, yellow = y;</li><li><strong>ring-number:</strong> none = n, one = o, two = t;</li><li><strong>ring-type: </strong>cobwebby = c, evanescent = e, flaring = f, large = l, none = n, pendant = p, sheathing = s, zone = z;</li><li><strong>spore-print-color: </strong>black = k, brown = n, buff = b, chocolate = h, green = r, orange = o, purple = u, white = w, yellow = y;</li><li><strong>population: </strong>abundant = a, clustered = c, numerous = n, scattered = s, several = v, solitary = y;</li><li><strong>habitat: </strong>grasses = g, leaves = l, meadows = m, paths = p, urban = u, waste = w, woods = d.</li></ul><p>I am interested in predicting whether a mushroom is edible or not.</p><p>I will skip some steps such as checking for NaN values or duplicate rows as this is outside the scope of this paper, but the full code is available on GitHub³.</p><p>I can get the statistical summary of this dataset using:</p><pre>dataset.describe()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vhfFn47M51ji_Wn2vTZraA.png" /><figcaption><strong>Fig.5</strong> Statistical summary of the dataset</figcaption></figure><p>However, for large datasets, this is hard to read. We can improve this by creating an interface in Gradio that allows analyzing each column separately.</p><pre># Define a function to generate summary statistics for a specified column<br>def summary_statistics(column_name):<br>    summary = dataset[column_name].describe()  # Generate descriptive statistics for the selected column<br>    return summary.to_dict()  # Convert the pandas Series to a dictionary and return it<br><br># Get a list of column names from the dataset<br>column_names = dataset.columns.tolist()<br><br># Set up a Gradio interface<br>iface = gr.Interface(<br>    fn=summary_statistics,  # Function to call when inputs change<br>    inputs=gr.Dropdown(choices=column_names, label=&quot;Column&quot;, info=&quot;Select Column&quot;),  # Dropdown to select a column<br>    outputs=gr.JSON(label=&quot;Summary Statistics&quot;),  # Output field to display summary statistics as JSON<br>    live=True  # Allow live updates while selecting different columns<br>)<br><br># Launch the Gradio interface<br>iface.launch()</pre><p>This code creates a tool to analyze data columns interactively. It defines a function summary_statistic that computes and displays descriptive statistics for a selected column in a dataset. Using inputs, it sets up a dropdown menu where users can choose a column to analyze. When selected, the function computes statistics and displays them in a user-friendly JSON format. The interface looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9wjTgVYLOh_U147XphGrg.png" /><figcaption><strong>Fig.6</strong> Statistical summary of each column using Gradio</figcaption></figure><p>For the univariate analysis, we can create for each column individually a plot. For example, we will create a histogram for the class column:</p><pre>sns.histplot(dataset[&#39;class&#39;])<br>plt.xlabel(&quot;Class&quot;)<br>plt.ylabel(&quot;Count&quot;)<br>plt.title(&quot;Distribution of Mushrooms by Class&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YGLssnxoRF3SyK5wkKxJ8w.png" /><figcaption><strong>Fig.7</strong> Distribution of the mushrooms by class</figcaption></figure><p>But it would take a bit of time to plot individually for each column such a histogram. Gradio can help us to create an interface to visualize each column in a more time-efficient way.</p><pre># Define a function to plot a histogram for a specified column<br>def plot_column(column_name):<br>    plt.figure(figsize=(10, 6)) # Set up the figure size<br>    sns.histplot(dataset[column_name], kde=False) # Plot the histogram using seaborn<br>    plt.title(f&#39;Distribution of Mushrooms by {column_name}&#39;) # Set the plot title<br>    plt.xlabel(column_name) # Set the label for the x-axis<br>    plt.ylabel(&#39;Count&#39;) # Set the label for the y-axis<br>    plt.xticks(rotation=90) # Rotate x-axis labels for better readability<br>    plt.tight_layout() # Ensure the plot layout is tight<br>    return plt.gcf() # Return the current figure<br><br># Get a list of column names from the dataset<br>column_names = dataset.columns.tolist()<br><br># Set up a Gradio interface<br>iface = gr.Interface(<br>    fn=plot_column, # Function to call when inputs change<br>    inputs=gr.Dropdown(choices=column_names, label=&quot;Select Column&quot;),  # Dropdown to select a column<br>    outputs=gr.Plot(), # Output field to display the plot<br>    live=True # Allow live updates while selecting different columns<br>)<br><br># Launch the Gradio interface<br>iface.launch()</pre><p>This code defines a function plot_column that uses seaborn (sns) to plot histograms based on the selected column chosen as input at inputs. The Gradio interface allows users to choose a column from a dropdown menu and see its histogram instantly. The final result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kdEwUduRDoefyNvUuLrioQ.png" /><figcaption><strong>Fig.8</strong> Plotting histograms using Gradio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHlS-AjVioLUk4wRq40M_w.png" /><figcaption><strong>Fig.9</strong> Plotting histograms using Gradio</figcaption></figure><p>For the multivariate analysis, we can also add a new input for the hue, which will help us visualize better specific characteristics of this dataset.</p><pre># Define a function to plot a count plot with hue<br>def plot_count(column1, hue_column):<br>    plt.figure(figsize=(12, 6)) # Set up the figure size<br>    sns.countplot(x=dataset[column1], hue=dataset[hue_column]) # Plot countplot using seaborn<br>    plt.title(f&#39;Count Plot of {column1} with Hue {hue_column}&#39;) # Set the plot title<br>    plt.xticks(rotation=45) # Rotate x-axis labels for better readability<br>    plt.tight_layout() # Ensure the plot layout is tight<br>    return plt.gcf() # Return the current figure<br><br># Get a list of column names from the dataset<br>column_names = dataset.columns.tolist()<br><br># Set up a Gradio interface<br>iface = gr.Interface(<br>    fn=plot_count, # Function to call when inputs change<br>    inputs=[gr.Dropdown(choices=column_names, label=&quot;Column 1&quot;), # Dropdown to select the first column<br>            gr.Dropdown(choices=column_names, label=&quot;Hue Column&quot;)], # Dropdown to select the hue column<br>    outputs=gr.Plot(), # Output field to display the plot<br>    live=True # Allow live updates while selecting different columns<br>)<br><br># Launch the Gradio interface<br>iface.launch()</pre><p>This code sets up an interactive tool to plot count plots with a specified column (Column 1) on the x-axis and another column (Hue Column) as a distinguishing factor (hue) using seaborn (sns). Users select columns from dropdown menus in the Gradio interface to visualize how categories in Column 1 are distributed based on categories in Hue Column. The interface has the following aspect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMb3yJEYCkJrWCombB7KtQ.png" /><figcaption><strong>Fig.10</strong> Plotting countplots using Gradio</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TI4cX3tyeNUDQPmMOj_WqA.png" /><figcaption><strong>Fig.11</strong> Plotting countplots using Gradio</figcaption></figure><p>Now that the visualization part is over, it’s time to build our model.</p><p>We will prepare the data by splitting it into the X and y set, where X contains all columns except ‘class’ and y contains only the target column — ‘class’.</p><pre># Separate features (X) and target variable (y) from the dataset<br>X = dataset.drop([&#39;class&#39;], axis=1) # X contains all columns except &#39;class&#39;<br>y = dataset[&#39;class&#39;] # y contains only the &#39;class&#39; column</pre><p>Since the dataset contains categorical data, we will apply One-Hot Encoding on X and LabelEncoder() on y.</p><pre># Convert categorical variables into dummy variables<br>X = pd.get_dummies(X)<br>X.head()</pre><pre>from sklearn.preprocessing import LabelEncoder <br>encoder = LabelEncoder()  # Create an instance of LabelEncoder<br>y = encoder.fit_transform(y) # Transform the target variable (y) into numerical labels</pre><p>We will save the column names of data frame X into a file. These names will serve as reference points during the interface creation process.</p><pre>with open(&#39;column_names.txt&#39;, &#39;w&#39;) as file:<br>    file.write(&#39;\n&#39;.join(X.columns))</pre><p>Split the dataset into the Train set and Test set.</p><pre>from sklearn.model_selection import train_test_split  <br># Split the dataset into training and testing sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1)</pre><p>To predict the values, we will use the Logistic Regression model from the Scikit-learn library.</p><pre>from sklearn.linear_model import LogisticRegression<br>model = LogisticRegression()  # Create an instance of LogisticRegression<br># Train the Logistic Regression model<br>model.fit(X_train, y_train)</pre><p>To be able to use the interface without fitting the model and the encoder each time, we will save them into pickle files and we will import them when necessary.</p><pre>pickle_out = open(&quot;classifier.pkl&quot;, mode=&quot;wb&quot;) # Open a file named &quot;classifier.pkl&quot; in write-binary mode (&#39;wb&#39;)<br>pickle.dump(model, pickle_out) # Serialize (pickle) the trained model (model) and write it to the file<br>pickle_out.close() # Close the pickle file</pre><pre>pickle_out = open(&quot;encoder.pkl&quot;, mode=&quot;wb&quot;) # Open a file named &quot;encoder.pkl&quot; in write-binary mode (&#39;wb&#39;)<br>pickle.dump(encoder, pickle_out) # Serialize (pickle) the encoder object (encoder) and write it to the file<br>pickle_out.close() # Close the pickle file</pre><p>Now we have all the necessary tools to build our interface.</p><p>Load all the necessary files and define the columns:</p><pre># Load the model<br>with open(&quot;/content/classifier.pkl&quot;, &quot;rb&quot;) as pickle_in:<br>    model = pickle.load(pickle_in)<br><br># Load the encoder<br>with open(&quot;/content/encoder.pkl&quot;, &quot;rb&quot;) as pickle_in:<br>    encoder = pickle.load(pickle_in)<br><br># Load dataset<br>dataset = pd.read_csv(&#39;/content/mushrooms.csv&#39;)<br><br># Define column names from the original dataset for the interface<br>columns = dataset.columns.drop(&#39;class&#39;).tolist()<br><br># Define column names based on the one-hot encoded dataset<br>with open(&#39;/content/column_names.txt&#39;, &#39;r&#39;) as file:<br>    columns_fit = file.read().splitlines()</pre><p>The script first loads the pre-trained machine learning model and the encoder, which were saved in theclassifier.pkl and encoder.pkl files respectively. It then loads the mushroom dataset into a Pandas DataFrame and defines column names based on both the original dataset and the one-hot encoded format used during training, retrieved from the column_names.txt file.</p><pre># Function to preprocess input data<br>def preprocess_input(input_data):<br>    input_dict = {col: 0 for col in columns_fit}     # Initialize an input dictionary with all columns set to 0<br>    index = 0<br>    for element in input_data: # Iterate through each element in input_data and set corresponding keys to 1 in input_dict<br>        input_dict[f&quot;{columns[index]}_{element}&quot;] = 1<br>        index += 1<br>    return pd.DataFrame([input_dict]) # Create a DataFrame from the input dictionary<br><br># Function to predict class<br>def predict_class(*inputs):<br>    inputs_list = []<br>    for input in inputs: # Gather all inputs into a list<br>        inputs_list.append(input)<br>    input_data = preprocess_input(inputs_list) # Preprocess the input data<br>    prediction = model.predict(input_data) # Predict using the trained model<br>    predicted_class = encoder.inverse_transform(prediction)[0] # Convert predicted label index back to the original class label<br>    return predicted_class<br><br># Define Gradio interface<br>iface = gr.Interface(<br>    fn=predict_class, # Function to be executed when inputs are provided<br>    inputs=[gr.Dropdown(label=col, choices=dataset[col].unique().tolist()) for col in columns], # Dropdowns for selecting input values<br>    outputs=gr.Textbox(label=&quot;Predicted Class&quot;), # Textbox to display the predicted class<br>    title=&#39;\U0001F344 Mushroom Edibility Prediction&#39;, # Title of the Gradio interface<br>    description=&#39;Predict if a mushroom is edible or poisonous based on its characteristics.&#39; # Description of the Gradio interface<br>)<br><br># Launch Gradio interface<br>iface.launch() </pre><p>To make predictions, the script includes a function preprocess_input that preprocesses user-selected mushroom characteristics received as input from inputs into a format compatible with the model and respects the one-hot encoded format on which the model was trained.</p><p>Another function, predict_class, predicts whether the mushroom is edible or poisonous based on the data frame received from the preprocess_input function, using the loaded model, and provides a human-readable prediction using the inverse_transform() method of the encoder. This result is returned to the Gradio interface which displays it as output. The final result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mzG84rLj6xHyRCIjNoPz0g.png" /></figure><p><strong>Conclusion</strong></p><p>In this project, we successfully implemented interactive interfaces using Gradio to enhance data handling and user interaction in Machine Learning. These interfaces streamline data management tasks, significantly improving accessibility and efficiency. Gradio’s intuitive features not only simplify complex processes but also highlight its capability to save time</p><h4>Bibliography</h4><p>[1] <a href="https://www.gradio.app/guides/quickstart">https://www.gradio.app/guides/quickstart</a></p><p>[2] <a href="https://www.kaggle.com/datasets/uciml/mushroom-classification">https://www.kaggle.com/datasets/uciml/mushroom-classification</a></p><p>[3] <a href="https://github.com/MihaelaCatan04/Gradio-Tutorial.git">https://github.com/MihaelaCatan04/Gradio-Tutorial.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba19efc0eb4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/gradio-simplifying-gui-creation-for-machine-learning-9ba19efc0eb4">Gradio: Simplifying GUI Creation for Machine Learning</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The new Object Detection model YOLOv9 in action: A Swift Guide to Training on Your Data]]></title>
            <link>https://medium.com/softplus-publication/the-new-object-detection-model-yolov9-in-action-a-swift-guide-to-training-on-your-data-2f81215ad021?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/2f81215ad021</guid>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[yolov9]]></category>
            <dc:creator><![CDATA[Eduard Balamatiuc]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 08:40:55 GMT</pubDate>
            <atom:updated>2024-03-12T16:55:34.222Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*dsqLVzoPkQVxnRN_UV-tng.png" /><figcaption>Figure 0: The New Object Detection Model YOLOv9 In Action cover</figcaption></figure><h3>Updates on the new YOLOv9 model</h3><p>For those who don’t know, there is a new member in the YOLO family of models. In February of 2024 a new paper titled “YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information” was released, you can find the entire content <a href="https://arxiv.org/pdf/2402.13616.pdf">here</a> if you want to get into more depth, but here is a quick overview:</p><blockquote>The core of the solution is the introduction of Programmable Gradient Information (PGI) and a new lightweight network architecture known as Generalized Efficient Layer Aggregation Network (GELAN).</blockquote><blockquote><strong>Programmable Gradient Information (PGI)</strong>: The paper introduces <strong>PGI</strong> as a method to mitigate the loss of information as data passes through the layers of deep neural networks. <strong>PGI</strong> ensures that complete input information is available for the target task to calculate the objective function, allowing reliable gradient information to be obtained for network weight updates.</blockquote><blockquote><strong>Generalized Efficient Layer Aggregation Network (GELAN)</strong>: <strong>GELAN</strong> is designed based on gradient path planning and aims to optimize parameter utilization. This architecture demonstrates superior results in lightweight models, particularly when combined with <strong>PGI</strong>, showing better performance in object detection tasks on the MS COCO dataset compared to existing state-of-the-art methods.</blockquote><blockquote><strong>Superior Performance</strong>: The combination of <strong>GELAN</strong> and <strong>PGI</strong> on MS COCO dataset-based object detection has shown to outperform other methods, particularly in terms of parameter utilization and accuracy, even surpassing models pre-trained on large datasets.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AkBT5x6OH-LvZqtz.png" /><figcaption>Figure 1: Performance on MS COCO Object Detection Dataset(image from the <a href="https://github.com/WongKinYiu/yolov9?ref=blog.roboflow.com">official YOLOv9 repo</a>)</figcaption></figure><h3>Hands-on interaction with the new YOLOv9</h3><p>All theory is great but let’s get to the real stuff already. In this section, I will show you how to utilize the new model on your Custom Dataset using <strong>Roboflow </strong>based on the following <a href="https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolov9-object-detection-on-custom-dataset.ipynb?ref=blog.roboflow.com">notebook</a><strong>. </strong>Here are the steps:</p><h4>Make sure that your runtime type is set to <strong>GPU:</strong></h4><p>You can check that by selecting <strong>Runtime &gt; Change runtime type, </strong>and make sure that the GPU option is selected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*GA4ggQD0C4mNnYRSqmq4lw.png" /><figcaption>Figure 2: Change runtime type option (screenshot taken from colab)</figcaption></figure><p>Now run the following parts to confirm that we are using the right machine type and to make it easier to utilize our dataset.</p><pre>!nvidia-smi<br>import os<br>HOME = os.getcwd()<br>print(HOME)</pre><h4>Setup and installations</h4><p>The time has come to <em>clone the YOLOv9 repo</em>, and <em>install the roboflow library</em> so that we can easily download our dataset directly in the notebook, and <em>download the model weights.</em></p><pre>!git clone https://github.com/SkalskiP/yolov9.git<br>%cd yolov9<br>!pip install -r requirements.txt -q<br>!pip install -q roboflow<br>!wget -P {HOME}/weights -q https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-c.pt<br>!wget -P {HOME}/weights -q https://github.com/WongKinYiu/yolov9/releases/download/v0.1/yolov9-e.pt<br>!wget -P {HOME}/weights -q https://github.com/WongKinYiu/yolov9/releases/download/v0.1/gelan-c.pt<br>!wget -P {HOME}/weights -q https://github.com/WongKinYiu/yolov9/releases/download/v0.1/gelan-e.pt<br>!ls -la {HOME}/weights</pre><blockquote>Further in the notebook, you can try the pre-trained models on some example data and see how they behave, but since the goal of this article is custom data we will skip this part and go straight into that part!</blockquote><h4>Create your Roboflow Dataset</h4><p>The next step is creating the custom dataset that you would like to work with.</p><blockquote>Just as a mention, is not mandatory to use roboflow, as long as the file structure of the train and test data corresponds to the YOLOv9 file structure criteria you could do it manually as well on your computer. I encourage enthusiastic readers to do that but for this article, we will continue using Roboflow since it offers an easier interaction.</blockquote><p>Go to the Roboflow <em>Projects </em>page and select <strong>Create New Project.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDvd4yev02wITyT8XUYlbw.png" /><figcaption>Figure 3: Screenshot of the Roboflow Projects page</figcaption></figure><p>Then you will be redirected to the <em>Creation page, </em>make sure to fill in all the details that are requested, here is an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*p58bFm44_IbRCg-7zCg74Q.png" /><figcaption>Figure 4: Screenshot of the Roboflow Creation Project page</figcaption></figure><p>From this point on, I will use one of my projects that I already created before, but every detail should be the same on your side. You will be asked to upload the data of your dataset, so make sure you add all the relevant images there and click <strong>Upload</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vfbPbkaLfd6wDFEUFcL7g.png" /><figcaption>Figure 5: Screenshot of the Roboflow Project Upload page</figcaption></figure><p>Next, you will have to annotate your images. It’s quite straightforward:</p><p><strong>You select the image.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYDMuzBUZPaMiayR2fWdvQ.png" /><figcaption>Figure 6: Screenshot of the Roboflow Annotation page</figcaption></figure><p><strong>Using the tooltip you create the box around the correct object.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BUO-zDecOcAIiGthnti_8A.png" /><figcaption>Figure 7: Screenshot of the Roboflow Annotation editor</figcaption></figure><p><strong>Then you assign the corresponding class to the selected box.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rfs3UGGo0ANzSXIEIOWeiA.png" /><figcaption>Figure 8: Screenshot of the Roboflow Annotation editor class selector</figcaption></figure><p>The next step is the generation phase, you have to create a version, here make sure to configure all the preprocessing and augmentation steps that you feel are relevant to your specific case, and go further.</p><blockquote>I will not go into too much depth about the options but feel free to click around and to from different version of your dataset!</blockquote><p>Once you’re done with selecting your options click <strong>Create.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l78UMulDGiRJ19yj8EV4PQ.png" /><figcaption>Figure 9: Screenshot of the Roboflow Generation page</figcaption></figure><p>Great! Now you have a dataset version to utilize, here is how it looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*1STbDGSUBv7AbPYg88mYYQ.png" /><figcaption>Figure 10: Screenshot of the Roboflow Dataset information</figcaption></figure><p>Now select the <strong>Export Dataset </strong>option in the upper right corner, check the <em>show download code </em>option and the <em>YOLOv9 </em>format, then press continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*KmDj3AM6ZgE1wbOBKczcqA.png" /><figcaption>Figure 11: Screenshot of the Roboflow Export window</figcaption></figure><p>You will be provided a download code, copy it, and paste it into the following section from the notebook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZrAkyjnlZVdfUJm4oEmRQ.png" /><figcaption>Figure 12: Colab Notebook cell for downloading the roboflow project</figcaption></figure><blockquote>As a mention, make sure that you don’t share the code from there with others, it’s based on your personal account, and there might be some security issues because of it.</blockquote><p>After running the above cell you should have all the data in the notebook session. Great job so far!</p><h4>Let’s train hard</h4><p>Finally, now we need to train our custom model, set up your parameters based on your project needs, and change the batch size, number of epochs, and image resolution sizes accordingly:</p><pre>%cd {HOME}/yolov9<br><br>!python train.py \<br>--batch 16 --epochs 25 --img 640 --device 0 --min-items 0 --close-mosaic 15 \<br>--data {dataset.location}/data.yaml \<br>--weights {HOME}/weights/gelan-c.pt \<br>--cfg models/detect/gelan-c.yaml \<br>--hyp hyp.scratch-high.yaml</pre><p>The training process might take some time depending on the size of your dataset and the parameter configuration that you chose. So in the meantime, you can enjoy some coffee.</p><h4>Check this out, we got results!</h4><p>To look at how our model did during the training part here is the code snippet to plot a cool metrics graph. I will showcase my results and metrics but don’t expect them to be great since my dataset was quite small and poor, the goal was just to showcase the possibility of training the new model so if you provide a good dataset you shouldn’t have any issue.</p><pre>from IPython.display import Image<br><br>Image(filename=f&quot;{HOME}/yolov9/runs/train/exp/results.png&quot;, width=1000)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_74e_ZQlnvS7DqbTQ-uPkw.png" /><figcaption>Figure 13: Personal model results after training</figcaption></figure><p>And how can we go without a confusion matrix?</p><pre>from IPython.display import Image<br><br>Image(filename=f&quot;{HOME}/yolov9/runs/train/exp/confusion_matrix.png&quot;, width=1000)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YNsq882Cc0jTdJWm_ZXrqg.png" /><figcaption>Figure 14: Personal model confusion matrix after training</figcaption></figure><p>If you want to check out the predictions of the model, you can do that this way:</p><pre>from IPython.display import Image<br><br>Image(filename=f&quot;{HOME}/yolov9/runs/train/exp/val_batch0_pred.jpg&quot;, width=1000)</pre><h3>This was it!</h3><p>That’s how you train the new YOLOv9 Model. This article was inspired by the <a href="https://arxiv.org/pdf/2402.13616.pdf">YOLOv9 paper</a> in combination with the custom <a href="https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolov9-object-detection-on-custom-dataset.ipynb?ref=blog.roboflow.com">training colab notebook</a> developed by the guys from Roboflow.</p><p>Let’s connect on LinkedIn:</p><p><a href="https://www.linkedin.com/in/eduard-balamatiuc/">Eduard Balamatiuc | LinkedIn</a></p><p>Made with ❤ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f81215ad021" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/the-new-object-detection-model-yolov9-in-action-a-swift-guide-to-training-on-your-data-2f81215ad021">The new Object Detection model YOLOv9 in action: A Swift Guide to Training on Your Data</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Document Vectorization with LTUVectorizer and LTUTransformer]]></title>
            <link>https://medium.com/softplus-publication/document-vectorization-with-ltuvectorizer-and-ltutransformer-a2f01aa001df?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/a2f01aa001df</guid>
            <category><![CDATA[molda]]></category>
            <category><![CDATA[ltu-vectorization]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[vectorization]]></category>
            <category><![CDATA[tf-idf]]></category>
            <dc:creator><![CDATA[Sclifos Tudor]]></dc:creator>
            <pubDate>Tue, 23 Jan 2024 08:27:01 GMT</pubDate>
            <atom:updated>2024-01-23T08:27:01.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sw5gtMLWOTBIk5Hfx03U6g.png" /></figure><p>This article provides a fast introduction to the LTUVectorizer and LTUTransformer modules from the Molda library. You will learn how these algorithms can be implemented and how they work.</p><p><strong>Article Summary</strong></p><p>Vectorization is a key method in Natural Language Processing (NLP) that enables computers to efficiently comprehend and interpret human language. By converting text input into numerical vectors, vectorization makes NLP systems more effective and precise. This allows algorithms to process, understand, and extract valuable language-based information. A well-known vectorization formula is TF-IDF vectorization, but this article introduces another vectorizer called LTU.</p><p><strong>LTU Formula</strong></p><p>LTU transformation is calculated using the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*q8gUQ6D14w8SWdI61WPqGg.png" /></figure><p>where fᵢⱼ denotes the target term frequency in a particular document, fⱼ the total document frequency, nⱼ the number of documents containing the target term, and N the total number of documents.</p><p><strong>Getting Started</strong></p><p>Follow these steps to get started with LTUVectorizer and LTUTransformer:</p><p>1. <strong>Prepare Your Environment</strong>: Before you begin, make sure you have a virtual environment set up for your project. If not, create and activate a virtual environment:</p><pre>python -m venv myenv<br>source myenv/bin/activate # On Windows: .\myenv\Scripts\activate</pre><p>2. <strong>Install Requirements</strong>: Inside your virtual environment, install the required packages:</p><pre>pip install molda numpy</pre><p>3. <strong>Import the Methods</strong>: Use the following code to import the module:</p><pre>from molda import LTUVectorizer</pre><p>The difference between a Vectorizer and a Transformer is the input. The Transformer uses a count matrix as input, while the Vectorizer uses some text.</p><p>4. <strong>Get Data</strong>: To test the methods we need some sample documents. Here is an example:</p><pre>document = [<br>&#39;&#39;&#39;I love my dog<br>and I like to pet him.&#39;&#39;&#39;,<br>&#39;I love my cat!&#39;,<br>&quot;I like to pet my cat.&quot;,<br>&quot;I enjoy playing with both, cats and dogs.&quot;<br>]</pre><p>5. <strong>Instantiate the vectorizer</strong>: With just 2 lines of code we get a sparse matrix from the document:</p><pre>vectorizer = LTUVectorizer()<br>sparse_matrix = vectorizer.fit_transform(document)</pre><p>The output is an LTU-weighted sparse matrix that can be easily transformed into a simple matrix using numpy library:</p><pre>print(sparse_matrix)<br><br>(0, 7) 1.4242701385551153<br>(0, 11) 1.122910936582831<br>(0, 8) 1.122910936582831<br>(0, 0) 1.122910936582831<br>(0, 4) 1.4242701385551153<br>(0, 10) 0.9090931800308315<br>(0, 9) 1.122910936582831<br>(1, 2) 1.122910936582831<br>(1, 10) 0.9090931800308315<br>(1, 9) 1.122910936582831<br>(2, 13) 1.4242701385551153<br>(2, 2) 1.122910936582831<br>(2, 11) 1.122910936582831<br>(2, 8) 1.122910936582831<br>(2, 10) 0.9090931800308315<br>(3, 5) 1.4242701385551153<br>(3, 3) 1.4242701385551153<br>(3, 1) 1.4242701385551153<br>(3, 14) 1.4242701385551153<br>(3, 12) 1.4242701385551153<br>(3, 6) 1.4242701385551153<br>(3, 0) 1.122910936582831</pre><p>6. <strong>Parameters</strong>: The main 3 parameters of the Vectorizer are stop_words, smooth_idf, and sublinear_tf:</p><ul><li>stop_words : {`english`}, list, default=None</li></ul><p>This parameter will remove all the English stop words from the resulting tokens. Only English is supported.</p><pre>vectorizer_stop_words = LTUVectorizer(stop_words=&quot;english&quot;)<br>sparse_matrix_stop_words = vectorizer_stop_words.fit_transform(document)<br>print(sparse_matrix_stop_words)<br><br>(0, 7) 1.1159507448271522<br>(0, 5) 1.1159507448271522<br>(0, 2) 1.4154420178615919<br>(0, 6) 1.1159507448271522<br>(1, 0) 1.1159507448271522<br>(1, 6) 1.1159507448271522<br>(2, 0) 1.1159507448271522<br>(2, 7) 1.1159507448271522<br>(2, 5) 1.1159507448271522<br>(3, 3) 1.4154420178615919<br>(3, 1) 1.4154420178615919<br>(3, 8) 1.4154420178615919<br>(3, 4) 1.4154420178615919<br>```</pre><ul><li>smooth_idf : bool, default=True</li></ul><p>Smooth idf weights by adding one to document frequencies, as if an extra document was seen containing every term in the collection exactly once. Prevents zero divisions.</p><pre>vectorizer_smooth_idf = LTUVectorizer(smooth_idf=False)<br>sparse_matrix_smooth_idf = vectorizer_smooth_idf.fit_transform(document)<br>print(sparse_matrix_smooth_idf)<br><br>(0, 7) 1.7735971602918106<br>(0, 11) 1.258420201767527<br>(0, 8) 1.258420201767527<br>(0, 0) 1.258420201767527<br>(0, 4) 1.7735971602918106<br>(0, 10) 0.9570609997952424<br>(0, 9) 1.258420201767527<br>(1, 2) 1.258420201767527<br>(1, 10) 0.9570609997952424<br>(1, 9) 1.258420201767527<br>(2, 13) 1.7735971602918106<br>(2, 2) 1.258420201767527<br>(2, 11) 1.258420201767527<br>(2, 8) 1.258420201767527<br>(2, 10) 0.9570609997952424<br>(3, 5) 1.7735971602918106<br>(3, 3) 1.7735971602918106<br>(3, 1) 1.7735971602918106<br>(3, 14) 1.7735971602918106<br>(3, 12) 1.7735971602918106<br>(3, 6) 1.7735971602918106<br>(3, 0) 1.258420201767527</pre><ul><li>sublinear_tf : bool, default=False</li></ul><p>Apply sublinear tf scaling, i.e. replace tf with 1 + log(tf)</p><pre>vectorizer_sublinear_tf = LTUVectorizer(sublinear_tf=True)<br>sparse_matrix_sublinear_tf = vectorizer_sublinear_tf.fit_transform(document)<br>print(sparse_matrix_sublinear_tf)<br><br>(0, 7) 1.3476661267766539<br>(0, 11) 1.062515453813376<br>(0, 8) 1.062515453813376<br>(0, 0) 1.062515453813376<br>(0, 4) 1.3476661267766539<br>(0, 10) 0.8601978316094646<br>(0, 9) 1.062515453813376<br>(1, 2) 1.062515453813376<br>(1, 10) 0.8601978316094646<br>(1, 9) 1.062515453813376<br>(2, 13) 1.3476661267766539<br>(2, 2) 1.062515453813376<br>(2, 11) 1.062515453813376<br>(2, 8) 1.062515453813376<br>(2, 10) 0.8601978316094646<br>(3, 5) 1.3476661267766539<br>(3, 3) 1.3476661267766539<br>(3, 1) 1.3476661267766539<br>(3, 14) 1.3476661267766539<br>(3, 12) 1.3476661267766539<br>(3, 6) 1.3476661267766539<br>(3, 0) 1.062515453813376</pre><p><strong>Next Steps</strong></p><p>Now that you’ve successfully created the sparse matrix, feel free to play with the parameters of the constructor. You can also incorporate it in a pipeline with scikit-learn modules.</p><p>For more information, visit the GitHub page: <a href="https://github.com/SigmoidAI/molda">https://github.com/SigmoidAI/molda</a> or reach out to our community.</p><p>If you are interested in other topics like computer vision, check this article:</p><p><a href="https://medium.com/softplus-publication/neural-style-transfer-creating-artistic-masterpieces-with-deep-learning-00483b5e6b51">Neural Style Transfer: Creating Artistic Masterpieces with Deep Learning</a></p><p><strong>If you want to connect, check out my LinkedIn:</strong></p><p><a href="https://www.linkedin.com/in/tudor-sclifos-ba3346185/">Tudor Sclifos | LinkedIn</a></p><p>Made with ❤ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2f01aa001df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/document-vectorization-with-ltuvectorizer-and-ltutransformer-a2f01aa001df">Document Vectorization with LTUVectorizer and LTUTransformer</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Recommendation System Algorithms: From Classic to Cutting-Edge]]></title>
            <link>https://medium.com/softplus-publication/exploring-recommendation-system-algorithms-from-classic-to-cutting-edge-8d1c2c94f5e4?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/8d1c2c94f5e4</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Valerian Cecan]]></dc:creator>
            <pubDate>Sat, 20 Jan 2024 16:09:42 GMT</pubDate>
            <atom:updated>2024-01-20T16:09:42.591Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*80HijweCYvH1i-bMr0nQ5Q.png" /></figure><h3>Introduction</h3><p>In the past, people generally purchased products recommended to them by their friends or the people they trusted. This is how people used to make purchasing decisions when there was doubt about a product. But since the advent of the Internet, we are so used to ordering online and streaming music and movies that we are constantly creating data in the back end. A recommendation engine uses that data and different algorithms to recommend the most relevant items to users. It initially captures the past behavior of a user, and then it recommends items for future purchase or use.</p><p>There are many different types of recommendation engines, the following are the most commonly used and widely recognized in various industries, and each of them is explored in this article.</p><ul><li><strong>Content-based filtering</strong></li><li><strong>Collaborative-based filtering</strong></li><li><strong>Deep learning recommendation system</strong></li><li><strong>Graph-Based recommendation system</strong></li></ul><h3>Content-Based Filtering</h3><p>The content-based filtering method is a recommendation algorithm that suggests items similar to the ones the users have previously selected or shown interest in. It can be recommended based on the actual content present in the item. For example, as shown in Figure 2, a new article is recommended based on the text present in the articles</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*a4hScSGe2G762WtX78i0xg.png" /><figcaption>Figure 1- Content-Based Filtering</figcaption></figure><p>Let’s take a peek at how Netflix suggests what you might want to watch. Imagine they have two special lists: one for what you like (profile) and one for all their shows (item). To match these lists, they use a simple trick called “cosine similarity.”, formula is shown in Figure 2.2. It’s like measuring how close two things are. They check how similar your likes are to the details of the shows. If your likes and a show’s details are similar, Netflix suggests it. This helps them recommend stuff you’re likely to enjoy, based on what you’ve liked before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/0*SFeeQ43mnIehPPnx" /><figcaption>Figure 2- Cosine Similarity formula</figcaption></figure><p>The major<strong> downside</strong> to this recommendation engine is that all suggestions fall into the same category, and it becomes somewhat monotonous. As the suggestions are based on what the user has seen or liked, we’ll never get new recommendations that the user has not explored in the past.</p><h3>Collaborative-Based filtering</h3><p>In collaborative-based filtering recommendation engines, a user-to-user similarity is also considered, along with item similarities, to address some of the drawbacks of content-based filtering. Simply put, a collaborative filtering system recommends an item to user A based on the interests of a similar user B. Figure 3.1 shows a simple working mechanism of collaborative-based filtering</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*AsbMg3LOMSsExCIL8XbeVQ.png" /><figcaption>Figure 3.1- Collaborative-based filtering</figcaption></figure><p>The similarity between users can be calculated again by the technique mentioned earlier. A <strong>user-item matrix</strong> is created individually for each customer(Figure 3.2), which stores the user’s preference for an item. Taking the same example of Netflix’s recommendation engine, the user aspects like previously watched and liked titles, ratings provided (if any) by the user, frequently watched genres, and so on are stored and used to find similar users. Once these similar users are found, the engine recommends titles that the user has not yet watched but users with similar interests have watched and liked. This type of filtering is quite popular because it is only based on a user’s past behavior, and no additional input is required. It’s used by many major companies, including Amazon, Netflix, and American Express.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*OL80PTi135OTquxATAKO-A.png" /><figcaption>Figure 3.2- User-Item matrix</figcaption></figure><h3><strong>There are two types of collaborative filtering algorithms:</strong></h3><ol><li><strong>User-User Collaborative Filtering</strong>: This method finds similarities between users and suggests items based on what similar users have liked in the past. It’s effective but demands extensive computations and time due to the need for user-pair information and similarity calculations. It’s resource-intensive, especially for large customer bases, unless a parallel system is in place.</li><li><strong>Item-Item Collaborative Filtering</strong>: Here, instead of similar users, the focus is on similar items. An item similarity matrix is created based on a user’s past selections, and recommendations come from this matrix of similar items. This approach is computationally more efficient because the item similarity matrix stays constant over time. This makes recommendations quicker for new customers.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*5AgFWbQopyi8DPT9qj9cmw.png" /><figcaption>Figure 3.3 User-Based vs Item-Based fultering</figcaption></figure><p>One of the <strong>drawbacks</strong> of this method happens when no ratings are provided for a particular item; then, it can’t be recommended. Reliable recommendations can be tough to get if a user has only rated a few items.</p><h3>DeepLearning Recommendation System</h3><p>Various companies use deep neural networks (DNNs) to enhance the customer experience, especially if it’s unstructured data like images and text. If you’re new to the concept of deep learning, fear not! Here is a beginner-friendly article about <a href="https://medium.com/@Sumeet_Agrawal/introduction-to-deep-learning-4410c5fb5a9a">introduction to deep learning</a>, designed to provide you with the fundamentals without overwhelming you with technical jargon. The following are some types of deep learning–based recommender systems.</p><ul><li>Autoencoder based</li><li>Restricted Boltzmann</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*N_yNW8bsSZqDSAaQ1DtdPQ.png" /><figcaption>Figure 4.1 Deep Learning Recommender System</figcaption></figure><h4>Autoencoder Based Recommendation:</h4><p><em>What is it?</em> Autoencoders, a class of deep learning models, are designed to encode and decode data. In the context of recommendation systems, autoencoders learn to represent users and items in a compressed form, capturing intricate data patterns, let’s explore the elements captured in Figure 4.2. This involves training an autoencoder to reconstruct input data, such as user-item interactions, and using these learned representations to generate recommendations. Autoencoders <strong>excel</strong> at revealing hidden features and relationships that might elude traditional methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6EHqmR3UOjhv1T6wOlh0xw.png" /><figcaption>Figure 4.2 Autoencoder-based Recommendation System</figcaption></figure><p>Compared to traditional methods, autoencoders offer a more nuanced understanding of user preferences and item attributes. Their ability to capture latent patterns and hidden connections leads to improved recommendations that align with individual tastes. Unlike some conventional approaches, autoencoders adapt effectively to intricate and evolving user behaviors, resulting in higher recommendation accuracy.</p><p>Autoencoders, while powerful, can be computationally demanding. Training deep learning models requires substantial resources, and fine-tuning the architecture can be complex. In comparison to simpler methods, implementing autoencoders might involve a steeper learning curve. Additionally, for extremely sparse datasets, the performance of autoencoders can be hindered, making them less suitable for scenarios with minimal user-item interactions.</p><h4>Restricted Boltzmann Machines (RBMs) in Recommendations:</h4><p>First, let’s start with the Boltzmann machine (BM). BM is a type of unsupervised neural network. Three distinct features characterize BM as illustrated in Figure 4.3.</p><ul><li>No output layers</li><li>No direction between the connection</li><li>Each neuron is densely connected, even between input nodes (visible nodes).</li></ul><p>When applied to recommendation systems, RBMs are adept at uncovering latent patterns from user-item interactions. They model interactions as binary values, with hidden nodes representing latent factors. RBMs shine in collaborative filtering scenarios, even when faced with sparse data. Their prowess lies in dissecting intricate user preferences and item attributes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*Y5TK2jJt8nLWqQ8wshlDcg.png" /><figcaption>Figure 4.3 Boltzmann Machine</figcaption></figure><p>Compared to straightforward methods, RBMs <strong>excel</strong> in scenarios with sparse data. They adeptly uncover latent factors that contribute to user preferences, leading to enhanced recommendations. RBMs can capture intricate connections that simpler techniques might miss, resulting in more accurate personalized suggestions.</p><p>Training RBMs can be computationally intensive, especially when dealing with large datasets. Their probabilistic nature requires careful parameter tuning, and their implementation might demand a deeper understanding of probabilistic modeling compared to more straightforward techniques. For less complex data scenarios, the benefits of RBMs might not be fully realized, making them potentially overkill.</p><h3>Graph-Based Recommendation Systems</h3><p>In graph-based recommendation systems, knowledge graph structures represent relationships between users and items. A knowledge graph is the structure of a network of interconnected datasets, enriched with semantics, an example is related in Figure 5.1. The graph structure, when visualized, has three primary components; nodes, edges, and labels. The edge of the link defines the relationship between two nodes/entities, where each node can be any object, user, item, place, and so forth. The underlying semantics provide an additional dynamic context to the defined relationships, enabling more complex decision-making</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*VINmk0C4SJCWzGP1-INQnA.png" /><figcaption>Figure 5.1 User-item Interaction Graph</figcaption></figure><h4>Advantages of Graph-Based Recommendations</h4><p>Graph-based recommendation systems excel in modeling diverse user-item interactions, providing personalized suggestions by considering network influence, addressing cold start challenges, and revealing unexpected recommendations.</p><h4>Limitations of Graph-Based Recommendations:</h4><p>Despite their benefits, graph-based systems face scalability issues, struggle with sparse data, and rely heavily on data quality. They may also encounter challenges in recommending new items and involve complex model design.</p><h3>Conclusion.</h3><p>Recommender systems have a rich history, originating in the late 1970s with systems like Grundy. Since their commercial introduction in the early 1990s, they have gained prominence due to their financial benefits and time-saving advantages. Notably, Netflix’s recommendation engine stands as a prominent example of its impact. The increasing demand for reliable recommender systems across domains underscores the need for ongoing research and innovation. These systems effectively streamline decision-making, benefiting businesses and users alike. The mentioned book serves as a comprehensive guide to building recommender systems in Python, offering a spectrum of methods for developers and practitioners. Ultimately, this field’s growth relies on continuous exploration and deeper understanding, as highlighted by the book’s contribution to advancing recommendation engine concepts and implementations.</p><h3>Source:</h3><p><a href="https://link.springer.com/book/10.1007/978-1-4842-8954-9#toc">Applied Recommender Systems with Python</a></p><p>Let’s connect on <a href="https://www.linkedin.com/in/valerian-cecan/"><strong>LinkedIn</strong></a></p><p><strong>Made with ❤️ by Sigmoid.</strong></p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d1c2c94f5e4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/exploring-recommendation-system-algorithms-from-classic-to-cutting-edge-8d1c2c94f5e4">Exploring Recommendation System Algorithms: From Classic to Cutting-Edge</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speech Recognition]]></title>
            <link>https://medium.com/softplus-publication/speech-recognition-897a9473c5e2?source=rss----a424aa5c9f96---4</link>
            <guid isPermaLink="false">https://medium.com/p/897a9473c5e2</guid>
            <category><![CDATA[language]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tudorgavriliuc ]]></dc:creator>
            <pubDate>Sat, 20 Jan 2024 10:51:10 GMT</pubDate>
            <atom:updated>2024-01-20T10:51:10.841Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*HBH01l8AvECp3FCkAz-lMw.png" /><figcaption>Speech Recognition article by Tudor Gavriliuc</figcaption></figure><p>Speech recognition is not just about the algorithms we apply to get a list of words from an audio file. It is a complex topic that includes several key ideas and in the following article, I will cover the most important one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*maJZiBKfUy9jZeiY.png" /></figure><p><strong>Keywords:</strong></p><p>Amplitude, Frequency, Vocal Cords, Phoneme.</p><p>[1]: The<strong> vocal cords</strong> (also called vocal folds) are two bands of smooth muscle tissue found in the larynx (voice box). The vocal cords vibrate and air passes through the cords from the lungs to produce the sound of your voice.</p><p>[2]:<strong> Amplitude </strong>is<strong> </strong>the maximum extent of a vibration or oscillation, measured from the position of equilibrium.</p><p>[3]:<strong> Frequency</strong> represents the number of times something happens within a particular period, or the fact of something happening often or a large number of times.</p><p>[4]: A <strong>phoneme</strong> is any of the perceptually distinct units of sound in a specified language that distinguishes one word from another, for example, <em>p</em>, <em>b</em>, <em>d</em>, and <em>t</em> in the English words <em>pad</em>, <em>pat</em>, <em>bad</em>, and <em>bat</em>.</p><h3>How do sounds appear?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJF8rlKuSoFM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJF8rlKuSoFM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJF8rlKuSoFM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e039424be4bfc2a2e9e98e72c0aee79/href">https://medium.com/media/6e039424be4bfc2a2e9e98e72c0aee79/href</a></iframe><blockquote>Voice and speech are fundamental to human communication, produced by a sophisticated interplay of bodily functions. The unique sound of one’s voice originates from the vocal folds in the larynx, or voice box, which vibrate when air from the lungs is forced through them. This process begins with breathing: the diaphragm contracts to pull air into the lungs, then relaxes to push it out, setting the stage for voice production. When speaking, this airflow causes the vocal folds to come together and vibrate, creating sound. In contrast, speech is the transformation of these sounds into distinct, recognizable patterns through the coordinated movement of muscles in the head, throat, chest, mouth, nasal cavity, and abdomen. Together, these intricate processes allow us to convey thoughts, feelings, and ideas, showcasing the complexity and importance of voice and speech in our daily lives.</blockquote><p>The primary source of speech sounds in most languages is the human vocal tract. It consists of the lungs, larynx (voice box), pharynx, oral cavity (mouth), and nasal cavity. Different speech sounds are produced by manipulating airflow, vocal cord¹ vibrations, and the shape of the vocal tract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/0*Mqx9bNxzLtNWWm1B.jpg" /></figure><h3>From analog to digital representation</h3><p>The first step in analog-to-digital conversion is sampling, where the continuous analog speech signal is converted into discrete samples taken at regular intervals.</p><p>Analog sound is a continuous waveform that directly represents the variations in air pressure caused by sound vibrations. In the context of audio, analog signals are often electrical voltage fluctuations that mimic the original sound wave. Analog audio technology has been in use for centuries and includes mechanisms like vinyl records, cassette tapes, and analog telephony.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/0*gV2fwL7Cnn2nUSeQ" /><figcaption>Sound Wave Representation</figcaption></figure><p>Digital sound is a representation of sound in discrete, numerical form. Digital audio technology involves converting analog sound waves into a series of discrete samples, which are then encoded and stored as binary data (0s and 1s). Digital audio is used in formats like CDs, MP3s, and streaming services.</p><p>The sampling rate, such as 8 kHz or 16 kHz, determines how frequently these samples are taken, representing the original analog signal more accurately in the digital domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XZVgqEPxKKkAD2_T.png" /></figure><p>After sampling the analog signal, the next step is quantization. This involves converting each sampled value from the continuous amplitude² range into a discrete digital value using binary numbers. The bit depth determines the number of bits used to represent each sample, with higher bit depths providing more precision but requiring more storage and resources. Common bit depths in speech recognition are 8, 16, and 24 bits. The digital values are then encoded into formats like PCM, used widely in speech recognition. The result is a digital signal composed of discrete samples, which can be stored or processed by speech recognition algorithms.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FJARmZM4FH8Q%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DJARmZM4FH8Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FJARmZM4FH8Q%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/80c86f4e23d16712fb85f16f5fbb1371/href">https://medium.com/media/80c86f4e23d16712fb85f16f5fbb1371/href</a></iframe><blockquote>This song guessing game utilizes the mathematical concept of the Fourier transform to analyze and reconstruct songs. A WAV file of a song, essentially a 1D array representing speaker displacement over time, serves as the starting point. The Fourier transform then decomposes this wave into its constituent sine waves, each with its own frequency and amplitude, allowing visualization of the song’s frequency spectrum. For discrete audio files, a Discrete Fourier transform is used, resulting in a bar chart-like frequency spectrum. The game progressively reveals the song by sorting these frequencies by amplitude and gradually reintroducing them, starting with the most influential ones. This process reshapes the wave closer to the original song with each step, making the song more recognizable.</blockquote><h3>Fast Fourier Transform (FFT)</h3><p>Speech signals are time-varying, and the information about the sounds and phonemes⁴ is often encoded in the frequency³ domain. FFT allows us to transform the speech signal from the time domain to the frequency domain, revealing the specific frequencies and their magnitudes present in the signal.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FG7XL-7rj45M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DG7XL-7rj45M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FG7XL-7rj45M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d39a11a0bb542a17c80ba6144c9704d6/href">https://medium.com/media/d39a11a0bb542a17c80ba6144c9704d6/href</a></iframe><h3>Feature Extraction</h3><p>The crucial speech recognition process of feature extraction includes breaking down the digital voice signal into a collection of significant and representative features. These characteristics act as inputs to voice recognition algorithms, enabling them to efficiently recognize and distinguish between various spoken words or phonemes. The following steps are commonly involved in the feature extraction process:</p><p>Prerequirements: The digital voice signal may go through some preprocessing stages to improve its quality and reduce noise before feature extraction. Filtering, normalizing, and silence elimination are common preprocessing methods.</p><p>Frame blocking is the process of breaking up a continuous digital speech output into smaller, overlapping frames. A brief segment of the signal, often lasting 20 to 30 milliseconds, makes up each frame. When frames overlap, the flow of information is maintained.</p><p><a href="https://jonathan-hui.medium.com/speech-recognition-feature-extraction-mfcc-plp-5455f5a69dd9">Speech Recognition — Feature Extraction MFCC &amp; PLP</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WAglcc3gCTs9M3U5.png" /></figure><h3>Acoustic Modeling</h3><p><strong>Input</strong>:</p><p>A speech signal.</p><p><strong>Output:</strong></p><p>A recognized sequence of phones (the basic unit of speech).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FU0XtE4_QLXI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DU0XtE4_QLXI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FU0XtE4_QLXI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cebd0007fbdcdbd89189ed1336540d8a/href">https://medium.com/media/cebd0007fbdcdbd89189ed1336540d8a/href</a></iframe><blockquote>Hannes and Rodolphe created a workshop on speech recognition, diving into the technology behind it without prior expertise. Their video, aimed at simplifying the concept, starts by explaining the conversion of human-produced analog sounds into digital data through microphones. This process involves capturing sound waves, chopping them into blocks, and digitizing them, visualizing them using spectrograms that display frequency, intensity, and time. The core of speech recognition is decoding these digital sounds into meaningful language, focusing on the smallest sound units called phonemes and their variations, allophones. The video covers two main techniques used in speech recognition software: the Hidden Markov Model, which reconstructs speech by analyzing phoneme sequences using statistical probabilities, and Neural Networks, which mimic brain function and adapt over time to recognize speech patterns, including unique voices and emotions. Combining these two techniques forms a hybrid model, leveraging their respective strengths to enhance speech recognition.</blockquote><p>In voice recognition systems, acoustic models are a particular kind of machine-learning model. The model is trained to identify the acoustic features of human speech and provide an appropriate text transcription. Huge datasets of spoken words, phrases, and sentences are often used to train acoustic models that ‘map’ the sounds of human speech.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*m3_Md3JZtdphcXoV.jpg" /></figure><h3>Hidden Markov Model ( HMM)</h3><p>A Hidden Markov Model (HMM) is a mathematical model that deals with sequences of observations, where each observation is tied to a hidden state. The model uses probabilities to transition between states and emit observations. It’s commonly used in tasks like speech recognition or DNA sequence analysis. The HMM’s goal is to find the best sequence of hidden states that explains the observed data. It learns from training data and is used for decoding sequences in various applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oMeN9_rQoU-1XHHT.jpg" /></figure><h4><strong>Example of how we can implement HMM</strong></h4><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>from hmmlearn import hmm<br>  <br># Define the state space<br>states = [&quot;Word0&quot;, &quot;Word1&quot;, &quot;Word2&quot;, &quot;Word3&quot;]<br>n_states = len(states)<br>  <br># Define the observation space<br>observations = [&quot;Loud&quot;, &quot;Soft&quot;]<br>n_observations = len(observations)<br>  <br># Define the initial state distribution<br>start_probability = np.array([0.8, 0.1, 0.1, 0.0])<br>  <br>+transition_probability = np.array([[0.7, 0.2, 0.1, 0.0],<br>                                    [0.0, 0.6, 0.4, 0.0],<br>                                    [0.0, 0.0, 0.6, 0.4],<br>                                    [0.0, 0.0, 0.0, 1.0]])<br>  <br># Define the observation likelihoods<br>emission_probability = np.array([[0.7, 0.3],<br>                                  [0.4, 0.6],<br>                                  [0.6, 0.4],<br>                                  [0.3, 0.7]])<br>  <br># Fit the model<br>model = hmm.CategoricalHMM(n_components=n_states)<br>model.startprob_ = start_probability<br>model.transmat_ = transition_probability<br>model.emissionprob_ = emission_probability<br>  <br># Define the sequence of observations<br>observations_sequence = np.array([0, 0, 0, 0, 1, 1, 0, 1]).reshape(-1, 1)<br>  <br># Predict the most likely hidden states<br>hidden_states = model.predict(observations_sequence)<br>print(&quot;Most likely hidden states:&quot;, hidden_states)<br>  <br># Plot the results<br>sns.set_style(&quot;darkgrid&quot;)<br>plt.plot(hidden_states, &#39;-o&#39;, label=&quot;Hidden State&quot;)<br>plt.legend()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*iRHbXf7_CMmAJCQabvMgoA.png" /></figure><ul><li>In our case (“Speech recognition”) observation is the audio file that we take as input, and the states are the [phonemes, words] we need to find out.</li></ul><h3>Language Modeling</h3><ul><li>A language model is a probabilistic model that assigns probabilities to any sequence of words.</li><li>A good language model has to assign high probabilities to well-performed sentences.</li></ul><p><strong>Statistical Approach (N-grams):</strong></p><ul><li>Traditional language models, like N-gram models, estimate the likelihood of a word based on its previous N-1 words.</li><li>The model calculates probabilities of word sequences based on the frequency of co-occurrences in the training data.</li><li>For example, a bigram model predicts the next word based on the previous word, while a trigram model considers the previous two words.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/0*p-1qQop7WVESKaKF.png" /></figure><h3><strong>Decoding</strong></h3><ul><li>Combine the outputs of the acoustic model and the language model to decode the most likely transcription for the given audio.</li><li>Apply algorithms like Viterbi or beam search to find the best sequence of words that match the audio features.</li></ul><p><em>The code below shows how the Viterbi algorithm works in the context of speech recognition.</em></p><pre># Define possible observations and states<br>obs = (&quot;sound1&quot;, &quot;sound2&quot;, &quot;sound3&quot;)<br>states = (&quot;Word1&quot;, &quot;Word2&quot;)<br><br># Define initial state probabilities<br>start_p = {&quot;Word1&quot;: 0.6, &quot;Word2&quot;: 0.4}<br># Define transition probabilities between states<br>trans_p = {<br>    &quot;Word1&quot;: {&quot;Word1&quot;: 0.7, &quot;Word2&quot;: 0.3},<br>    &quot;Word2&quot;: {&quot;Word1&quot;: 0.4, &quot;Word2&quot;: 0.6},<br>}<br># Define emission probabilities of observations from states<br>emit_p = {<br>    &quot;Word1&quot;: {&quot;sound1&quot;: 0.5, &quot;sound2&quot;: 0.4, &quot;sound3&quot;: 0.1},<br>    &quot;Word2&quot;: {&quot;sound1&quot;: 0.1, &quot;sound2&quot;: 0.3, &quot;sound3&quot;: 0.6},<br>}<br># Define the Viterbi algorithm function<br>def viterbi(obs, states, start_p, trans_p, emit_p):<br>    V = [{}]  # Initialize Viterbi matrix<br>    # Initialization for t = 0<br>    for st in states:<br>        V[0][st] = {&quot;prob&quot;: start_p[st] * emit_p[st][obs[0]], &quot;prev&quot;: None}<br>    # Run Viterbi for t &gt; 0<br>    for t in range(1, len(obs)):<br>        V.append({})<br>        for st in states:<br>            max_tr_prob = V[t - 1][states[0]][&quot;prob&quot;] * trans_p[states[0]][st] * emit_p[st][obs[t]]<br>            prev_st_selected = states[0]<br>            for prev_st in states[1:]:<br>                tr_prob = V[t - 1][prev_st][&quot;prob&quot;] * trans_p[prev_st][st] * emit_p[st][obs[t]]<br>                if tr_prob &gt; max_tr_prob:<br>                    max_tr_prob = tr_prob<br>                    prev_st_selected = prev_st<br>            max_prob = max_tr_prob<br>            V[t][st] = {&quot;prob&quot;: max_prob, &quot;prev&quot;: prev_st_selected}<br>    # Print the Viterbi matrix<br>    for line in dptable(V):<br>        print(line)<br>    # Backtrack to find the most likely sequence of states<br>    opt = []<br>    max_prob = 0.0<br>    best_st = None<br>    for st, data in V[-1].items():<br>        if data[&quot;prob&quot;] &gt; max_prob:<br>            max_prob = data[&quot;prob&quot;]<br>            best_st = st<br>    opt.append(best_st)<br>    previous = best_st<br>    # Follow the backtrack till the first observation<br>    for t in range(len(V) - 2, -1, -1):<br>        opt.insert(0, V[t + 1][previous][&quot;prev&quot;])<br>        previous = V[t + 1][previous][&quot;prev&quot;]<br>    # Print the result<br>    print(&quot;The steps of states are &quot; + &quot; &quot;.join(opt) + &quot; with the highest probability of %s&quot; % max_prob)<br># Define a function to print the Viterbi matrix as a table<br>def dptable(V):<br>    yield &quot; &quot; * 5 + &quot;     &quot;.join((&quot;%3d&quot; % i) for i in range(len(V)))<br>    for state in V[0]:<br>        yield &quot;%.7s: &quot; % state + &quot; &quot;.join(&quot;%.7s&quot; % (&quot;%lf&quot; % v[state][&quot;prob&quot;]) for v in V)<br># Call the Viterbi function with defined parameters<br>viterbi(obs, states, start_p, trans_p, emit_p)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*y8ebU16xLAAqcCbe5Sz1Fg.png" /><figcaption>Output</figcaption></figure><h4><strong>A simple approach to speech recognition</strong></h4><pre># Import required libraries<br>from gtts import gTTS  # For text-to-speech synthesis<br>import os<br>from os import path<br>from deep_translator import GoogleTranslator  # For text translation<br>import speech_recognition as sp  # For speech recognition<br><br># Define a class named &#39;translator&#39;<br>class translator:<br>    # Constructor with &#39;language&#39; as a parameter<br>    def __init__(self, language):<br>        self.language = language<br>    # Method to capture audio input using a microphone<br>    def get_audio(self):<br>        mic = sp.Microphone(device_index=0)  # Microphone initialization<br>        r = sp.Recognizer()  # Speech recognizer initialization<br>        with mic as source:<br>            print(&quot;Spuneti acum&quot;)  # Prompt for user to speak<br>            audio = r.listen(source)  # Listen for audio input<br>        try:<br>            c = r.recognize_google(audio, language=&quot;ro-RO&quot;)  # Recognize spoken text using Google&#39;s API<br>        except:<br>            print(&quot;Something go wrong&quot;)  # Error message if recognition fails<br>        return c  # Return recognized text<br>    # Method to translate the provided text<br>    def translate(self, c):<br>        # Translate the text using GoogleTranslator with the target language specified in the constructor<br>        translated = GoogleTranslator(source=&#39;auto&#39;, target=self.language).translate(c)<br>        print(translated)  # Print translated text<br>        return translated  # Return translated text<br>    # Method to convert translated text to voice and play it<br>    def voice(self, trans):<br>        # Convert translated text to speech using gTTS (Google Text-to-Speech)<br>        myobj = gTTS(text=trans, lang=self.language, slow=False)<br>        myobj.save(&quot;welcome.mp3&quot;)  # Save the generated speech as an audio file<br>        os.system(&quot;welcome.mp3&quot;)  # Play the saved audio file<br><br># Create an instance of &#39;translator&#39; with target language &#39;en&#39; (English)<br>Ion = translator(&#39;en&#39;)<br># Capture audio input from the user<br>c = Ion.get_audio()<br># Translate the captured text<br>trans = Ion.translate(c)<br># Convert the translated text to speech and play it<br>Ion.voice(trans)<br># Note: Instead of using a microphone, the code can also be modified to read from an existing audio file.</pre><p>In the code above we have created a simple translator based on a speech recognition algorithm. In our class <em>translator, </em>we have 3 methods.</p><p>The first method is responsible for recognizing the speech and saving it as an audio file.</p><p>The second method is responsible for translating the audio file according to the required language and saving it in an audio new file using the GoogleTranslator library.</p><p>The last method plays the audio file using gTTS library.</p><blockquote><strong>Conclusion</strong></blockquote><p>In conclusion, speech recognition stands as a remarkable technological achievement that bridges the gap between human communication and machines. With the ability to convert spoken language into textual representation, speech recognition has revolutionized the way we interact with technology and has opened doors to a plethora of applications across industries.</p><p>If you liked the article, let’s connect on <a href="https://www.linkedin.com/in/tudor-gavriliuc/">LinkedIn</a>.</p><p>Made with ❤️ by Sigmoid.</p><p>Follow us on Facebook, Instagram, and LinkedIn:</p><p><a href="https://www.facebook.com/sigmoidAI">https://www.facebook.com/sigmoidAI</a></p><p><a href="https://www.instagram.com/sigmo.ai/">https://www.instagram.com/sigmo.ai/</a></p><p><a href="https://www.linkedin.com/company/sigmoid/">https://www.linkedin.com/company/sigmoid/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=897a9473c5e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/softplus-publication/speech-recognition-897a9473c5e2">Speech Recognition</a> was originally published in <a href="https://medium.com/softplus-publication">softplus-publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>