<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kumaramangalam on Medium]]></title>
        <description><![CDATA[Stories by Kumaramangalam on Medium]]></description>
        <link>https://medium.com/@kumaramangalamv?source=rss-4a7edd93cd27------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QEJ4EbNnGVljCMztZWCs8w.jpeg</url>
            <title>Stories by Kumaramangalam on Medium</title>
            <link>https://medium.com/@kumaramangalamv?source=rss-4a7edd93cd27------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:33:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kumaramangalamv/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Prompt Engineering — Best Practices]]></title>
            <link>https://medium.com/@kumaramangalamv/prompt-engineering-best-practices-cf6caf22f906?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf6caf22f906</guid>
            <category><![CDATA[prompt-engineering]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Wed, 10 Sep 2025 12:15:52 GMT</pubDate>
            <atom:updated>2025-09-10T12:15:52.812Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prompt Engineering — Best Practices</h3><p>Today, prompt engineering is widely used across enterprises to build Generative AI based solutions.</p><p>It is the process of building effective prompts fulfilling the business objective.</p><p><strong>Prompt Design Strategies</strong></p><p>i) Clear and concise Instructions</p><p>ii) Divide complex tasks to subtasks</p><p>iii) Mention what is required and what is not required (Constraints)</p><p>iv) Simple language</p><p>v) Ask for justifications (or reasonings)</p><p>vi) Few shot or zero shot examples</p><p>Simplify the solution by dividing it into multiple steps. Prompt Chaining can be used where output of one prompt is passed to another .</p><p><strong>Few good resources:</strong></p><p><a href="https://arxiv.org/pdf/2406.06608">https://arxiv.org/pdf/2406.06608</a> — The Prompt Report: A Systematic Survey of Prompt Engineering Techniques</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf6caf22f906" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Intelligent IVR System with Advanced Conversational AI and LLM Agents]]></title>
            <link>https://medium.com/@kumaramangalamv/building-an-intelligent-ivr-system-with-advanced-conversational-ai-and-llm-agents-90b274e98af2?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/90b274e98af2</guid>
            <category><![CDATA[ivr-services]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llm-agent]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Tue, 04 Jun 2024 04:24:44 GMT</pubDate>
            <atom:updated>2024-06-05T21:46:35.856Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s world, providing efficient customer service is crucial. Traditional IVR systems often struggle with understanding complex queries. Advanced conversational AI and large language models (LLMs) can enhance IVR capabilities. This post explores building IVR system using technologies like Retrieval Augmented Generation (RAG), Whisper speech models, vector databases, the Langchain framework, LLMs like LLama3 or Mistral 7B, and specialized LLM agents. The applications in banking where customers seek account information is also highlighted.</p><h3>Understanding the Core Components</h3><p>Let us see the core components we will be using:</p><ol><li><strong>Retrieval Augmented Generation (RAG)</strong>: RAG combines retrieval-based and generation-based methods to generate responses. It retrieves relevant information from a database and uses a language model to generate coherent responses.</li><li><strong>Whisper </strong>: Using OpenAI’s Whisper ASR and Text-to-Speech (TTS) systems such as gTTS (Google Text to Speech ) or pyttsx3 that converts textual responses into spoken output.</li><li><strong>Vector Databases (FAISS or Pinecone or Milvus)</strong>: These databases store and retrieve document embeddings, enabling efficient information retrieval.</li><li><strong>Langchain Framework</strong>: A framework that manages the flow of conversation and integrates various components. with LLMs (LLama3 or Mistral 7b or OpenAI GPT3.5 etc)</li><li><strong>LLM Agents</strong>: Specialized agents powered by large language models designed to handle specific tasks and queries efficiently. Ex: SQL Agent</li></ol><h3>Building the IVR System</h3><p>Building IVR system involves the following steps</p><ol><li><strong>Voice Processing:</strong> Integrating Automatic Speech Recognition (ASR) to convert spoken input into text. Whisper ASR is a suitable choice for this task.</li><li><strong>Core Conversational Engine:</strong> Utilizing the Langchain framework to manage conversational flow, leveraging the Llama2 LLM and LLM agents for response generation.</li><li><strong>Information Retrieval</strong>: Using FAISS or Pinecone for efficient information retrieval from the knowledge base.</li><li><strong>Database Management:</strong> Storing FAQ and other related information in a database (PostgreSQL or MongoDB).</li><li><strong>IVR API Integration</strong>: Integrating with IVR platforms like Twilio or Asterisk for handling telephony services.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*LuIt7pScA8fbnHf1a9aJ1Q.png" /><figcaption>Components of IVR system</figcaption></figure><h3>Implementing the System</h3><ol><li><strong>Voice Processing: </strong>Whisper ASR converts spoken input into text, which is then processed by the core system. Whisper TTS converts the text response from the system back into spoken output.</li><li><strong>Core Conversational Engine:</strong> The Langchain framework manages the flow of conversation, utilizing the Llama2 LLM and LLM agents to generate appropriate responses.</li><li><strong>Information Retrieval: </strong>RAG utilizes FAISS or Pinecone to retrieve relevant information from the knowledge base.</li><li><strong>Database Management:</strong> A database (PostgreSQL or MongoDB) stores the FAQ and other necessary data for the system.</li><li><strong>IVR API Integration:</strong> Twilio or Asterisk handles the IVR interactions, integrating the voice processing and conversational engine with telephony services.</li></ol><h3>Application in the Banking Domain</h3><p>One of the most impactful applications of an advanced IVR system is in the banking sector. Customers often call their banks to inquire about account balances, recent transactions, loan information, and other services. An AI-driven IVR system with LLM agents can provide a seamless and efficient way for customers to get the information they need without waiting for a human representative.</p><h4>Example Scenario</h4><p>A customer calls the bank’s IVR system and asks, “What is my current account balance?” The system processes the voice input using Whisper ASR, converts the speech to text, and sends the query to the conversational engine. The Langchain framework, leveraging the Llama2 LLM and specialized LLM agents, understands the query and retrieves the relevant information from the database. The system then uses Whisper TTS to convert the text response back to speech, informing the customer of their current balance.</p><h3>Conclusion</h3><p>By integrating advanced AI components and LLM agents into the IVR system, its capabilities can be significantly enhanced, providing users with a more natural and efficient interaction experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90b274e98af2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimization Techniques in Data Science: A Comprehensive Overview (Part 2)]]></title>
            <link>https://medium.com/@kumaramangalamv/optimization-techniques-in-data-science-a-comprehensive-overview-part-2-9962f5632114?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/9962f5632114</guid>
            <category><![CDATA[optimization-techniques]]></category>
            <category><![CDATA[retail]]></category>
            <category><![CDATA[genetic-algorithm]]></category>
            <category><![CDATA[evolutionary-algorithms]]></category>
            <category><![CDATA[application]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Fri, 24 May 2024 17:37:54 GMT</pubDate>
            <atom:updated>2024-07-08T20:41:50.767Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will cover about <strong>Derivative-Free Optimization</strong> techniques and <strong>Application of Optimization Techniques Across Various Fields</strong> such as Finance, Retail, Healthcare etc.</p><h3>Derivative-Free Optimization</h3><p>Derivative-free optimization (DFO) solves optimization problems where the objective function’s derivatives are unavailable, unreliable, or expensive to compute. Unlike gradientbased methods that leverage derivatives to find minima (or maxima), DFO methods rely solely on function value evaluations to navigate the search space. One common category of derivative-free methods is Direct Search methods.</p><p>These methods explore the parameter space by evaluating the objective function at selected points. They typically maintain a set of candidate solutions and iteratively update these solutions based on the function evaluations. Examples of direct search methods include the Nelder-Mead method and the Hooke-Jeeves pattern search method</p><p>Another category is Model-Based methods, which construct a surrogate model of the objective function based on the function evaluations. The surrogate model is then used to guide the search for the optimal solution. Examples of model-based methods include Bayesian optimization and surrogate optimization techniques.</p><h3>Evolutionary Algorithms</h3><p>Evolutionary algorithms are a class of derivative-free optimization methods inspired by the process of natural selection. These algorithms maintain a population of candidate solutions and evolve them over generations using mechanisms like mutation, crossover, and selection. The goal is to find the optimal solution by exploring a wide range of possibilities and gradually improving the population. Some popular evolutionary algorithms include Genetic Algorithms, Differential Evolution, Particle Swarm Optimization, Simulated Annealing.</p><h3>a) Genetic Algorithm</h3><p>Genetic algorithms (GAs) are inspired by the principles of natural selection and genetics. They are used to find optimal solutions to complex problems by mimicking the process of natural evolution. Genetic algorithms are particularly useful for optimization problems where traditional algorithms are impractical due to the large search space or complex fitness landscapes.</p><p>They start with a population of potential solutions encoded as chromosomes. Each chromosome represents a candidate solution to the problem. GAs use a fitness function to evaluate the quality of each chromosome. Based on their fitness, chromosomes are selected to reproduce, creating offspring through crossover and mutation. This process mimics the natural selection of the fittest individuals. Over successive generations, the population evolves towards better solutions.</p><p>In ML, GAs can be used for various tasks, including feature selection, model optimization, and hyperparameter tuning. For feature selection, GAs can be used to search through the space of possible feature subsets to find the subset that maximizes the performance of ML model. This is particularly useful when dealing with high-dimensional data, as GAs can efficiently explore the large feature space. In model optimization, GAs can be used to find the optimal architecture or parameters for a machine learning model. This can involve searching for the best set of hyperparameters for a model (e.g., learning rate, number of hidden units) to maximize performance.</p><h3>b) Differential Evolution (DE)</h3><p>Differential Evolution (DE) is a population-based optimization algorithm that is often used to solve optimization problems over continuous domains. DE is inspired by the process of natural selection and survival of the fittest. It starts with a population of candidate solutions (vectors) and iteratively improves these solutions by combining and mutating them.</p><p>DE also performs the same tasks like GA’s such as parameter tuning, feature selection, and hyperparameter optimization. The main difference between Differential Evolution (DE) and Genetic Algorithms (GAs) lies in their approach to creating new candidate solutions and maintaining diversity in the population.</p><h3>c) Particle Swarm Optimization (PSO)</h3><p>Particle Swarm Optimization (PSO) is inspired by the social behaviour of bird flocking or fish schooling. In PSO, each candidate solution is represented as a particle in a high-dimensional space. The particles move through the search space, and their movements are influenced by their own best-known position and the best-known position of the entire swarm. PSO is effective for optimizing functions with many local optima.</p><p>PSO is used in Machine Learning for various tasks, including feature selection, parameter optimization, and model selection. PSO is particularly effective for optimization problems with continuous or real-valued parameters and has been successfully applied in areas such as neural network training, clustering, and classification.</p><h3>d) Simulated Annealing</h3><p>Simulated Annealing (SA) is a method for optimizing functions inspired by metallurgical annealing, where a material is heated and then slowly cooled to enhance its stability. SA aims to find the best solution to a problem by exploring a wide search space and occasionally accepting suboptimal solutions.</p><p>SA is particularly useful for optimization problems with a large search space and complex landscapes, where it may be difficult to find the global optimum using other methods. It is often used in combinatorial optimization problems, such as the traveling salesman problem and the job scheduling problem</p><h3>Application of Optimization Techniques Across Various Fields</h3><p>Optimization methods are crucial in various sectors, improving decision-making and operational efficiency. This segment outlines the primary uses of optimization in finance, retail, healthcare, logistics, and supply chain management.</p><h3>a) Finance</h3><p>With respect to Finance, Portfolio Optimization involves finding the optimal allocation of assets in an investment portfolio to maximize returns while minimizing risk. Optimization algorithms, such as genetic algorithms, can explore a vast combination of asset weights, considering constraints like budget limits and risk tolerance. The objective function includes metrics like Sharpe ratio or expected return, and the optimization process aims to find the portfolio that offers the best trade-off between risk and return.</p><p>Financial institutions use optimization techniques to develop and refine risk models that accurately assess and quantify financial risks. These models play a crucial role in guiding decisions related to lending, investments, and capital allocation. Optimization algorithms estimate model parameters such as volatility and correlation, based on historical data, and optimize risk measures like Value at Risk (VaR) or Expected Shortfall (ES).</p><p>Optimization is also applied to enhance trading strategies, aiming to maximize profits while minimizing transaction costs. Techniques like particle swarm optimization or genetic algorithms can optimize the parameters of trading strategies, including entry and exit points, position sizing, and risk management rules, to improve overall performance.</p><h3>b) Retail</h3><p>In the retail sector, optimization methods play a crucial role in enhancing various operational aspects, including demand prediction, pricing strategies, and inventory control.</p><p>These methods enable retailers to streamline operations, cut costs, and boost customer satisfaction. In demand forecasting, optimization algorithms such as Adam, SGD are employed in ML or DL models to predict future product demand by analysing historical data, market trends, and other variables, which helps the retailers to maintain appropriate inventory levels, by reducing instances of stockouts and excess inventory.</p><p>As a part of Price Optimization, retailers utilize optimization algorithms to determine the best prices for their products. These algorithms consider the attributes such as competitor pricing, customer characteristics, and buying patterns to establish prices that maximize profits while remaining competitive in the market.</p><p>Optimization techniques are used to build recommendation engines that suggest relevant products to customers based on their preferences, past purchases, and browsing behaviour. Collaborative filtering algorithms, such as matrix factorization, can be optimized to minimize the error between predicted and actual user ratings, improving the accuracy and relevance of recommendations.</p><h3>c) Healthcare</h3><p>In healthcare, optimization techniques are crucial for improving various aspects of operations, including resource allocation, treatment planning, and scheduling. These techniques help healthcare providers improve patient outcomes, reduce costs, and optimize the use of resources</p><p>As a part of resource allocation, optimization algorithms such as GAs are used to allocate resources such as hospital beds, staff, and equipment efficiently to meet patient demand and improve overall efficiency. Treatment plans for patients are also optimized based on their medical history, condition, and treatment goals. Optimization techniques also play a crucial role in accelerating drug discovery by exploring vast chemical spaces and identifying promising compounds.</p><h3>d) Logistics and Supply Chain</h3><p>With respect to route optimization, efficient route planning is essential for minimizing transportation costs, reducing delivery times, and improving customer satisfaction.</p><p>Optimization algorithms, such as the Traveling Salesman Problem (TSP) solvers or vehicle routing problem (VRP) algorithms, can be used to find the optimal routes for delivery vehicles. These algorithms consider factors like distance, traffic conditions, vehicle capacity, and time windows to generate routes that minimize total travel time or distance while meeting delivery constraints. Optimizing warehouse layout and inventory placement can significantly impact the efficiency of order fulfilment processes.</p><p>Optimization techniques can be applied to determine the optimal location of products within the warehouse, considering factors like product velocity, picking frequency, and storage requirements. Algorithms like genetic algorithms or simulated annealing can be used to optimize the warehouse layout, minimizing picking distances and maximizing space utilization.</p><p>Efficient supply chain network design involves identifying the optimal location and capacity of facilities, including warehouses, distribution centres, and manufacturing plants.</p><p>Models like mixed-integer linear programming (MILP) solve the facility location and allocation problems. These models consider factors like transportation costs, facility costs, customer demand, and service level requirements to determine the network configuration that minimizes total cost while meeting customer needs.</p><p>In conclusion, optimization techniques are foundational in Data Science, crucial for solving complex problems. Gradient-based methods like SGD, Momentum, and Adam optimize machine learning models effectively. Derivative-free methods, such as Genetic Algorithms and Differential Evolution, are valuable when derivatives are unavailable. These techniques find applications in finance, retail, healthcare, logistics, and supply chain management, improving operations and decision-making. Optimization is a powerful tool that empowers businesses to achieve impactful results across industries.</p><h3>References</h3><p>[1] I. Goodfellow, Y. Bengio, and A. Courville, “Deep Learning,” [Online]. Available: <a href="http://www.deeplearningbook.org/contents/optimization.html.">http://www.deeplearningbook.org/contents/optimization.html.</a></p><p>[2] Wikipedia, “Mathematical Optimization”, [Online]. Available: <a href="https://en.wikipedia.org/wiki/Mathematical_optimization.">https://en.wikipedia.org/wiki/Mathematical_optimization.</a></p><p>[3] R. K. Arora, “Optimization: Algorithms and Applications,” CRC Press, 2015.</p><p>[4] S. Sun, Z. Cao, H. Zhu, and J. Zhao, “A Survey of Optimization Methods From a Machine Learning Perspective,” IEEE Transactions on Cybernetics, vol. 50, no. 8, pp. 3668–3681, Aug. 2020, doi: 10.1109/TCYB.2019.2950779.</p><p>[5] S. Bhandari, K. Sahay, and R. Singh, “Optimization Techniques in Modern Times and Their Applications,” 2018, pp. 1–4, doi: 10.1109/IEECON.2018.8712308.</p><p>[6] S. Ruder, “An overview of gradient descent optimization algorithms,” arXiv preprint arXiv:1609.04747, 2016. [Online]. Available: <a href="https://arxiv.org/abs/1609.04747.">https://arxiv.org/abs/1609.04747.</a></p><p>[7] A. E. Eiben and J. E. Smith, “Introduction to Evolutionary Computing,” Springer, 2015.</p><p>[8] T. Alam, S. Qamar, A. Dixit, and M. Benaida, “Genetic Algorithm: Reviews, Implementations, and Applications,” [Online]. Available: <a href="https://arxiv.org/abs/2007.12673.">https://arxiv.org/abs/2007.12673.</a></p><p>[9] S. Chopra and P. Meindl, “Supply Chain Management: Strategy, Planning, and Operation,” 6th ed., Pearson, 2016.</p><p>[10] M. Gen and R. Cheng, “Genetic Algorithms and Engineering Optimization,” John Wiley &amp; Sons, 2000.</p><p>[11] G. Cornuejols, “Optimization Methods in Finance,” 2006.</p><p>[12] “An Overview of Digital Commons,” Kennesaw State University, [Online]. Available: <a href="https://digitalcommons.kennesaw.edu/cgi/viewcontent.cgi?article=1060&amp;context=egr_srdn.">https://digitalcommons.kennesaw.edu/cgi/viewcontent.cgi?article=1060&amp;context=egr_srdn.</a></p><p>[13] Google Developers, “Vehicle Routing Problem (VRP),” [Online]. Available: <a href="https://developers.google.com/optimization/routing/vrp.">https://developers.google.com/optimization/routing/vrp.</a></p><p>[14] A. Larni-Fooeik, “Stochastic portfolio optimization: A regret-based approach on volatility risk measures: An empirical evidence from The New York stock market,” [Online]. Available: <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11034657/">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11034657/</a></p><p>[15] “From Reactive to Proactive: AI in Retail Demand Forecasting,” Nexocode, [Online]. Available: <a href="https://nexocode.com/blog/posts/retail-demand-forecasting/">https://nexocode.com/blog/posts/retail-demand-forecasting/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9962f5632114" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimization Techniques in Data Science: A Comprehensive Overview (Part 1)]]></title>
            <link>https://medium.com/@kumaramangalamv/optimization-techniques-in-data-science-a-comprehensive-overview-part-1-dae20acaa3da?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/dae20acaa3da</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sgd-with-momentum]]></category>
            <category><![CDATA[optimization-techniques]]></category>
            <category><![CDATA[adam-optimizer]]></category>
            <category><![CDATA[sgd]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Fri, 24 May 2024 17:29:24 GMT</pubDate>
            <atom:updated>2024-05-24T17:29:24.326Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction</h3><p>Optimization in the context of Data Science refers to the process of finding the most effective solution from a set of available alternatives to minimize or maximize the objective function, specific to a task. Optimization is foundational to many areas of Data Science such as Machine Learning (ML), Artificial Intelligence (AI), Operations Research, and Statistics.</p><p>There are various optimization techniques such as Gradient based, Derivative free optimizations that are tailored to address the unique challenges across various Data Science applications.</p><p>Gradient based optimization techniques are widely used in Machine Learning for optimizing neural network models in order to find the optimal parameter weights as part of training the model. Some of the algorithms include Stochastic Gradient Descent, Momentum, AdaGrad, RMSProp, Adam etc. These techniques calculate the gradient of the loss function with respect to the model parameters.</p><p>This blog covers detailed explanation of these algorithms with an emphasis on how they operate, their advantages, and the specific contexts in which they work well. Each of these optimization techniques has its strengths and is suited for specific kinds of problems, making the choice of optimization method an important consideration in the design and implementation of data science solutions.</p><p>Apart from Gradient-based techniques, Derivative free optimization methods are particularly used in optimization problems where gradient information is difficult to compute or does not exist. These methods include Direct Search methods and Model based methods. Evolutionary algorithms typically fall under the category of Derivative free methods that explore the parameter space by evaluating the objective function at selected points, without using derivative information.</p><p>These Algorithms are inspired by the process of natural selection which include Genetic Algorithms, Differential Evolution, and Particle Swarm Optimization, Simulated Annealing etc. use mechanisms such as mutation, crossover, and selection to find optimal solutions where the objective function is discontinuous, non-differentiable, or highly complex.</p><p>The blog also covers the details and working of these algorithms in Data Science. In addition to the technical details of the algorithms, the report also covers application of optimization across various fields such as finance, retail, healthcare, logistics and supply chain.</p><p>For Example, in finance, optimization techniques are used for portfolio optimization, where the goal is to maximize returns while minimizing risk, subject to various constraints like budget limits or risk exposure limits. Algorithms like genetic algorithms can be used to explore a wide range of portfolio combinations to find the optimal mix of assets.</p><p>In Retail, optimization helps in demand forecasting, price optimization, and inventory management. Techniques such as Particle Swarm Optimization and Genetic Algorithms can optimize the supply chain, reducing costs and improving customer satisfaction by ensuring products are available when they are needed.</p><p>In Logistics and Supply Chain Management, optimization is used for route planning to minimize travel time or distance, inventory management to balance holding costs against stockout risks, and scheduling to maximize efficiency in production and delivery processes.</p><h3>2. Background</h3><p>Optimization is a fundamental concept that helps in solving complex problems across various disciplines, including mathematics, engineering, research, economics, and computer science. It involves finding the best solution or set of parameters from a set of possible options, with the goal of maximizing or minimizing a specific objective function, subject to given constraints or limitations.</p><p>Optimization can be traced back to 300 BC, when the Greek mathematician Euclid evaluated the minimum distance between point and a line and in the 17th century, French mathematician, Pierre de Fermat showed that the gradient of function vanishes at the maximum or minimum point. Throughout the 18th, 19th, and 20th centuries, various optimization techniques, such as the calculus of variations, least squares method, linear programming, and nonlinear programming etc. are being developed and modified.</p><p>In general, Optimization is divided into two categories such as Discrete Optimization and Continuous Optimization, based on whether the variables are continuous are discrete. The major subfields include convex programming, Integer programming, Quadratic programming, Nonlinear programming, Stochastic Programming, Robust optimization, Combinatorial optimization, Stochastic optimization, Heuristics, Metaheuristics, space mapping etc. The impact of optimization techniques extends beyond individual disciplines, with its interdisciplinary role in transforming different industries such as manufacturing, aerospace, agriculture, biology, thermal engineering, airlines, finance, and numerous other fields, leading to more efficient processes, cost savings and innovative solutions</p><p>In the realm of Data Science, optimization plays a crucial role in parameter estimation, feature selection, model tuning, and hyperparameter optimization, which are essential for enhancing the performance of ML and AI, Reinforcement learning, Metalearning algorithms. Furthermore, optimization techniques are widely used in Statistics for hypothesis testing, model selection, and data fitting, as well as in Operations Research for optimizing decision making processes in areas such as supply chain management, logistics, retail and resource allocation etc. These applications emphasize the versatility and importance of optimization in driving impactful outcomes in Data Science</p><p>Moreover, advancement in algorithms and computational resources such as GPU, cloud environments, has led to development of efficient and faster optimization algorithms that can handle large scale datasets and complex models.</p><p>In the next sections, the various optimization techniques in Data Science, related to Gradient Based and Derivative Free methods will be explored.</p><h3>3. Gradient Based Optimization</h3><p>Most machine learning algorithms can be framed as an optimization problem aimed at finding the extremum of an objective function. This process begins by defining objective functions, which serve as the basis for various ML techniques.</p><p>Gradient-based optimization methods stand out as a prominent approach in optimizing ML models, such as linear regression and neural networks. These methods, including Gradient Descent (GD), Stochastic Gradient Descent (SGD), Momentum, AdaGrad, RMSProp, and Adam, play a pivotal role in determining the optimal parameter weights by calculating the gradient of the loss or objective or cost function with respect to the model parameters and iteratively refine the weights till convergence or a specific criterion. Optimization algorithms that use only the gradient, such as gradient descent, are called first-order optimization algorithms. Optimization algorithms that also use the Hessian matrix, such as Newton’s method, are called second-order optimization algorithms.</p><h3>3.1 Gradient Descent Approach</h3><p>Gradient Descent algorithm is used to minimize an objective function (that measures the difference between the predicted output of a model and the actual output) by iteratively moving towards the direction of the steepest descent (negative gradient) of the function.</p><p>The algorithm begins with the initialization of the model’s weights or parameters, θ, either randomly or with predefined values. Next, the gradient of the objective function, J(θ), is computed with respect to the parameters. To minimize the objective function, the parameters are then adjusted in the direction opposite to the gradient. These steps are repeated until convergence is achieved or for a specified number of epochs. The update rule for Gradient Descent is expressed as θ = θ — α ∇ J(θ), where ∇ J(θ) is the gradient of the objective function and α (alpha) is the learning rate, which is a hyperparameter. A large learning rate can cause the algorithm to overshoot the minimum and fail to converge, while a small learning rate can lead to slow convergence.</p><p>Gradient Descent technique is easy to implement and understand. It is particularly effective for convex functions, where it reliably converges to the global minimum. However, GD can be slow to converge, especially for high-dimensional data or functions with complex surfaces. In non-convex optimization, GD is susceptible to getting trapped in local minima, making it difficult to find the optimal solution. Additionally, GD requires the computation and storage of gradients for all training examples, which can be computationally expensive for large datasets.</p><p>Despite these limitations, GD is a common choice for optimization in problems where the objective function is smooth and differentiable, such as linear and logistic regression, and shallow neural networks. To address some of the challenges faced by GD, variations such as Stochastic Gradient Descent, Momentum, AdaGrad, RMSProp, and Adam have been developed.</p><h3>3.2 Stochastic Gradient Descent (SGD)</h3><p>SGD is the most used optimization algorithm used to minimize an objective function by iteratively updating the parameters of a model based on the gradient of the objective function computed on a single training example. Unlike traditional Gradient Descent, which computes the gradient using the entire training dataset, SGD calculates the gradient using only one training example at a time, making it computationally efficient and suitable for large datasets and for non-convex optimization problems.</p><p>The algorithm begins with the initialization of the model parameters using random values based on a weight initialization criterion. The training dataset is shuffled, and for each 4 training example (x, y) in the dataset, the gradient of the objective function ∇J(θ; x, y) is computed with respect to the model parameters using the current training example. The model parameters are then updated iteratively until convergence is achieved.</p><p>The update rate for Stochastic Gradient Descent can be expressed as</p><h4>θ = θ — α ∇ J (θ; x, y)</h4><p>Due to its stochastic nature, SGD may converge to a suboptimal solution or oscillate around the minimum, especially when the learning rate is too high. This noise in convergence can make it difficult to determine when the algorithm has truly converged. Learning can be slow, especially in the face of high curvature, small but consistent gradients, or noisy gradients.</p><h3>3.3 Momentum</h3><p>Momentum algorithm is used to accelerate SGD in the relevant direction and dampen oscillations. The momentum algorithm accumulates an exponentially decaying moving average of past gradients and continues to move in their direction. The momentum algorithm introduces a variable 𝑣 that represents the velocity of the parameters in parameter space. This velocity is updated as an exponentially decaying average of the negative gradient. This concept is analogous to a physical particle moving through space under the influence of a force (the negative gradient), with the velocity representing the momentum of the particle. The momentum γ, which is a hyperparameter, determines how quickly the contributions of previous gradients decay.</p><p>The update rule for the velocity is given by 𝑣 ← γ 𝑣 — α ∇ J(θ), where α is the learning rate.</p><p>Momentum introduces an additional hyperparameter that needs to be tuned and, in some cases, momentum may cause the optimizer to overshoot the minimum of the objective function, especially if the momentum term is too high. This can lead to oscillations around the minimum or divergence.</p><h3>3.4 SGD with Momentum</h3><p>This algorithm extends the standard SGD algorithm by adding a momentum term that accelerates the update in the relevant direction and dampens oscillations. This momentum term is a moving average of gradients and helps the algorithm to continue in the current direction, especially when gradients change direction frequently. As a result, SGD with momentum converges faster and can escape shallow local minima.</p><h3>3.5 AdaGrad</h3><p>The Adagrad algorithm adapts the learning rates of individual model parameters by scaling them inversely proportional to the square root of the sum of all historical squared values of the gradient. The parameters with larger partial derivatives of the loss function will have a more rapid decrease in their learning rate, while parameters with smaller partial derivatives will have a relatively smaller decrease in their learning rate. This adaptive learning rate mechanism allows Adagrad to make greater progress in the more gently sloped directions of parameter space.</p><p>The adaptive learning rate mechanism makes it particularly effective for sparse data sets where certain features may rarely occur. The accumulation of squared gradients in the denominator can lead to a premature and excessive decrease in the effective learning rate, especially in deep learning models. This can result in slower convergence or poor performance in some cases.</p><h3>3.6 RMSProp</h3><p>The RMSProp algorithm modifies AdaGrad to perform better in the nonconvex setting by changing the gradient accumulation into an exponentially weighted moving average, giving more weight to recent gradients. The learning rate for each parameter is then scaled by the inverse square root of this moving average</p><p>RMSProp can perform better than Adagrad in non-convex optimization and its performance can be sensitive to the choice of hyperparameters, especially the decay rate parameter 𝛽 and the initial learning rate 𝛼. RMSProp can help stabilize the training process, especially in deep learning models where finding a good learning rate schedule can be challenging.</p><h3>3.7 Adam</h3><p>Adam (Adaptive Moment Estimation) is an adaptive learning rate optimization algorithm that combines elements of RMSProp and momentum. The name “Adam” stands for “adaptive moments,” highlighting its ability to adaptively adjust learning rates based on past gradients. Adam incorporates momentum directly as an estimate of the first-order moment of the gradient, using exponential weighting. This differs from RMSProp, where momentum is applied to rescaled gradients, lacking a clear theoretical motivation. Adam includes bias corrections for both the first-order moments (momentum term) and the second-order moments to account for their initialization at the origin. This helps in reducing bias, especially early in training. Adam is generally robust to the choice of hyperparameters, making it easier to use compared to some other optimization algorithms.</p><p>The algorithm begins by initializing the parameters, setting the first and second moment estimates to zero, and defining a small constant for numerical stability. During each iteration, the gradient of the objective function is computed. The first moment estimate is updated with exponential decay, followed by updating the second moment estimate with exponential decay. The bias-corrected first and second moment estimates are then computed. Finally, the parameters are updated using the bias-corrected estimates and adaptive learning rates</p><p>Adam requires storing and updating additional moments for each parameter, leading to increased computational complexity. It is commonly used in training deep neural network models due to its efficiency and robustness. It is suitable for a wide range of optimization problems, including both convex and non-convex problems. Adam has been shown to converge faster than other optimization algorithms in many cases, especially in deep learning models.</p><p>Choosing the right optimization algorithm for training deep models depends on factors such as algorithm performance, model complexity, available computational resources, and hyperparameter tuning expertise. Popular algorithms like SGD, SGD with momentum, RMSProp, AdaGrad, and Adam are commonly used, with the choice often based on the familiarity with the algorithm and the ease of hyperparameter tuning. Experimentation with multiple algorithms and hyperparameter settings is performed to find the best fit for a specific problem and dataset.</p><p>In the next blog, we will cover about Derivative-Free Optimization techniques and Application of Optimization Techniques Across Various Fields such as Finance, Retail, Healthcare etc.</p><h3>References</h3><p>[1] I. Goodfellow, Y. Bengio, and A. Courville, “Deep Learning,” [Online]. Available: <a href="http://www.deeplearningbook.org/contents/optimization.html.">http://www.deeplearningbook.org/contents/optimization.html.</a></p><p>[2] Wikipedia, “Mathematical Optimization”, [Online]. Available: <a href="https://en.wikipedia.org/wiki/Mathematical_optimization.">https://en.wikipedia.org/wiki/Mathematical_optimization.</a></p><p>[3] R. K. Arora, “Optimization: Algorithms and Applications,” CRC Press, 2015.</p><p>[4] S. Sun, Z. Cao, H. Zhu, and J. Zhao, “A Survey of Optimization Methods From a Machine Learning Perspective,” IEEE Transactions on Cybernetics, vol. 50, no. 8, pp. 3668–3681, Aug. 2020, doi: 10.1109/TCYB.2019.2950779.</p><p>[5] S. Bhandari, K. Sahay, and R. Singh, “Optimization Techniques in Modern Times and Their Applications,” 2018, pp. 1–4, doi: 10.1109/IEECON.2018.8712308</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dae20acaa3da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meta Learning methods]]></title>
            <link>https://medium.com/@kumaramangalamv/meta-learning-methods-48a673b657b7?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/48a673b657b7</guid>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Sat, 30 Mar 2024 00:00:13 GMT</pubDate>
            <atom:updated>2024-03-30T00:00:13.314Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Meta-learning</strong>, also known as “learning to learn,” focuses on developing models that can quickly adapt and learn new tasks with minimal forgetting of previously learned knowledge. Model learns from a distribution of tasks or a dataset containing multiple tasks to extract common knowledge or patterns across tasks and use that knowledge to generalize well to new tasks</p><p>The common approaches to meta-learning include <strong>Metric-based, Model-based, and Optimization-based.</strong></p><p><strong>Metric-Based — </strong>goal is to design a metric that can capture the underlying structure or similarity relationships within the data.</p><p>Ex: i) <strong>Convolutional Siamese Neural Network</strong> proposed by Koch, Zemel &amp; Salakhutdinov (2015) to perform one shot image classification</p><p>ii) <strong>Matching Networks</strong>, introduced by Vinyals in 2016, are designed for one-shot learning scenarios, and the key idea is to learn a similarity metric between examples to perform classification.</p><p>iii) <strong>Relational Networks</strong>, proposed by Santoro in 2018, aim to enable explicit reasoning about the relationships between examples in few-shot learning.</p><p>Idea is to leverage the power of deep relational reasoning to make accurate predictions</p><p>iv) <strong>Prototypical Networks</strong>, proposed by Snell are designed to address few-shot learning problems by employing the notion of prototypes. The main idea is to represent each class by a prototype, which is the mean of the embedded feature vectors of the examples in that class.</p><p><strong>Model Based:</strong></p><p>Model-based meta-learning focuses on learning an explicit model or algorithm for updating the model’s parameters.</p><p>Ex: i) Memory-Augmented Neural Networks</p><p>ii)Meta Networks</p><p><strong>Optimization Based: </strong>Optimization-based meta-learning methods, also known as gradient-based meta-learning, are a category of meta-learning approaches that focus on directly optimizing model parameters through gradient-based optimization. These methods aim to learn a set of initial parameters that can be quickly adapted to new tasks or domains using gradient updates.</p><p>Ex: i)<strong>MAML</strong> (Model-Agnostic Meta-Learning) :</p><p>MAML, introduced by Finn in 2017, learns an initialization of the model parameters that allows for fast adaptation to new tasks. It does this by jointly optimizing the initial parameters across multiple tasks</p><p>ii)<strong>Reptile</strong> : It aims to learn an initialization of the model parameters that can be rapidly adapted to new tasks by simply taking a few steps in the direction of the first order gradients</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48a673b657b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hallucination in LLMs]]></title>
            <link>https://medium.com/@kumaramangalamv/hallucination-in-llms-e4b31532961c?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4b31532961c</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llm-hallucinations]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Fri, 29 Mar 2024 22:26:22 GMT</pubDate>
            <atom:updated>2024-03-29T22:33:42.847Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, let us the understand about the hallucination that happen with LLMs . We will also see about how to detect, mitigate hallucinations.</p><p>Before that , let us understand the different terms/jargons associated with LLMs functionality, such as Hallucination, Confabulation, Grounding, Factuality, Intrinsic &amp; Extrinsic Hallucination.</p><p>{Ref: <a href="https://arxiv.org/abs/2202.03629">https://arxiv.org/abs/2202.03629</a>}</p><p><strong>Hallucination </strong>in psychology refers to a sensory perception error where individuals perceive things that aren’t present.</p><p>In the context of language models, hallucination refers to the phenomenon where a language model generates text that’s not consistent with reality or the provided context. This can occur during tasks such as text generation, summarization, or question-answering, where the model produces outputs that seem reasonable but are actually false or unrelated to the given context.</p><p>In psychology, Confabulation involves the generation of false memories, where individuals recall events that never happened.</p><p><strong>Confabulation </strong>in language models refers to generating text based on ‘false memories’ from their training data, leading to the production of information that seems derived from a factual basis but is actually false.</p><p><strong>Grounding</strong> indicates that the text output of a model can be directly attributed to the provided prompt, context, or its training data, which may include a wide range of sources like web pages, books, etc. Ex: Retrieval Augmented Generation</p><p><strong>Factuality </strong>ensures that the text generated by the model is consistent with reality, regardless of whether it can be directly traced back to specific input or training data.</p><p>The difference between hallucination and confabulation highlights the differences between inaccuracies in perception and memory — either through the generation of text without any foundation in the provided input, or through the mention of new details from flawed internal information.</p><p>On the other hand, the contrast between grounding and factuality focuses on the origin of the generated content — whether it can be linked back to particular inputs and the model’s training, or whether it really represents truths and established facts of the real world.</p><p><strong>Intrinsic Hallucinations</strong>: These occur when a language model generates content that directly conflicts with the information provided in the source material. This means the output contains details or claims that are different to what is mentioned in the input data, leading to contradictions and inaccuracies.</p><p><strong>Extrinsic Hallucinations</strong>: These happen when a language model produces content that, although not directly conflicting with the input data, cannot be traced back or verified by it. The generated information lacks a direct foundation in the source content, making it unverifiable and misleading.</p><p><strong>Example</strong>:</p><p>Generative QA:</p><p><strong>Intrinsic</strong></p><p>Question: dow jones industrial average please?</p><p>Answer: The Dow Jones Industrial Average (DJIA) is an index of 30 major U.S.stock indexes. The DJIAwas created in 1896 by Charles Dow, a statistician and editor of The Wall Street Journal. The index was first published in the mid- 1880s, and was last updated on May 26,1896.</p><p><strong>Extrinsic</strong></p><p>Question: definition of sadduction</p><p>Answer: Sadducees. noun. The definition of a sadducee is a person who acts in a deceitful or duplicitous manner. An example of a Sadduceee is a politician who acts deceitfully in order to gain political power.1 a member of a Jewish sect that was active during the Second Temple.</p><p>From <a href="https://arxiv.org/pdf/2202.03629.pdf">https://arxiv.org/pdf/2202.03629.pdf</a></p><h3><strong>Detecting Hallucination in LLMs</strong></h3><p><strong>Tracing Knowledge in LLMs</strong>: This method involves tracking where the model’s information comes from, distinguishing between information directly learned from training data and that generated from the model’s generalized knowledge. By pinpointing the origin of model outputs, it becomes possible to identify and address hallucinations.</p><p><strong>Model Introspection</strong>: This strategy trains models to assess their own certainty regarding the information they generate. By enabling models to recognize and indicate their own uncertainty, potential hallucinations can be flagged before being presented as factual.</p><p><strong>Probing/Readout Techniques:</strong> Exploring the internal workings of LLMs can reveal insights into when a model might be generating unfounded content. This approach focuses on examining the model’s internal state to determine when it is making inferential leaps that could lead to hallucinations.</p><p>{Ref : <a href="https://arxiv.org/abs/2202.05262">https://arxiv.org/abs/2202.05262</a> , <a href="https://arxiv.org/abs/2304.13734">https://arxiv.org/abs/2304.13734</a>}</p><h3><strong>Mitigating Hallucination in LLMs</strong></h3><p><strong>Pre-training intervention</strong>: Improving the quality, diversity, and accuracy of the training data can significantly reduce hallucinations. This involves carefully selecting and preprocessing data to ensure it reflects a wide range of accurate information, minimizing inaccuracies that could lead models to learn and replicate false patterns.</p><p><strong>Retrieval augmentation</strong>: Enhancing LLMs with Retrieval-Augmented Generation (RAG) techniques, where the model can access a database of facts or documents to support its generation process, ensures that outputs can be directly supported by existing knowledge, thereby reducing hallucinations.</p><p><strong>Fine-tuning with Human Feedback: </strong>Utilizing human feedback to fine-tune LLMs can greatly improve their difference between factual and hallucinated content. This can involve showing the model examples of accurate versus inaccurate outputs and adjusting the model based on human judgments of correctness.</p><p><strong>Supervised Fine Tuning</strong>: Utilizing the supervised data to fine tune pretrained LLM can improve model reliability specific to domain knowledge and reduce hallucinations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4b31532961c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grounding of LLMs (RAG Approach)]]></title>
            <link>https://medium.com/@kumaramangalamv/grounding-of-llms-rag-approach-9f42ec84c9c6?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f42ec84c9c6</guid>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[retrieval-augmented]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 22:37:21 GMT</pubDate>
            <atom:updated>2024-05-24T18:07:16.248Z</atom:updated>
            <content:encoded><![CDATA[<p>Grounding involves supplementing large language models (LLMs) with specialized, use-case specific information that goes beyond the LLM’s pre-trained knowledge base.</p><p>Although LLMs possess a broad spectrum of knowledge, their understanding is general and not customized for individual scenarios. To generate outputs that are both precise and relevant, it’s essential to equip LLMs with the relevant information tailored to the particular context at hand. Here, we are leveraging the reasoning capability of LLMs by including contextual information in the prompt.</p><p>In order to perform Grounding , the primary technique that we can use is Retrieval Augmented Generation (RAG), a process for retrieving information relevant to a task, providing it to the language model along with a prompt, and relying on the model to use this specific information when responding.</p><p>It is important to understand the need of RAG using LLMs over building models from scratch using Deep Learning techniques. Before the advent of LLMs , it was necessary to create distinct task-specific models for various applications. This approach demanded large volumes of labeled data, making the data annotation process extremely tedious.</p><p>In RAG, we obtain the relevant data from the query-specific domain-specific text and provide it to the LLM along with the prompt. This prompt can be changed to better suit domain-specific applications like Question Answering system , Conversational Bot, Tagging (Classification, NER), Summarization , Web Scraping etc.</p><p>The key components in RAG architecture are Embedding model, Vector Database, LLM (Opensource or Paid one).</p><p>There are various frameworks such as Langchain, LlamaIndex, Semantic Kernel etc. that help us to build these applications using LLMs, Embedding models and vector databases.</p><p>In this blog, let us use Langchain framework to build a Question Answering system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40XL99tkvxtxusBp5pIMCw.png" /><figcaption>RAG Architecture</figcaption></figure><p><strong>How does RAG really work…?</strong></p><p>If we have a contextual document in PDF format, this file is split into chunks, and these chunks are indexed, converted into embeddings, and stored in a vector database. A similarity check is performed between the embeddings of the input query and the chunks in the vector database. The top ‘k’ chunks are retrieved from the vector store and then fed into a Large Language Model (LLM) along with the original query. This step is crucial because it allows the LLM to consider not just the query itself but also the context provided by the most relevant document chunks.</p><p>The components in the system</p><p>• Embedding Model: This model converts text data into dense vector representations. These embeddings capture the semantic meaning of the text, allowing for effective retrieval of relevant information.</p><p>Vector Database: This database stores the embeddings and enables efficient retrieval of relevant documents based on similarity searches.</p><p>• LLM (Large Language Model): The LLM generates responses using the retrieved information along with the prompt. The LLM can be an open-source model (Llama2, Mistral 7B etc.) or a proprietary one (e.g., GPT-3, GPT-4)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f42ec84c9c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing Fetal Health Monitoring: Leveraging YOLOv7 for Ultrasound Image Analysis]]></title>
            <link>https://medium.com/@kumaramangalamv/detection-of-anatomical-bounds-from-fetus-ultrasound-images-using-yolov7-architecture-c23d8231157a?source=rss-4a7edd93cd27------2</link>
            <guid isPermaLink="false">https://medium.com/p/c23d8231157a</guid>
            <category><![CDATA[medical-image-processing]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[ultrasound]]></category>
            <category><![CDATA[yolo]]></category>
            <dc:creator><![CDATA[Kumaramangalam]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 21:19:06 GMT</pubDate>
            <atom:updated>2024-03-25T04:00:18.185Z</atom:updated>
            <content:encoded><![CDATA[<p>Ultrasound imaging is a key technique used to assess the growth, development, and overall well-being of a fetus throughout pregnancy. However, the complexity and subtlety of these images often require the expertise of specialized medical professionals for accurate interpretation.</p><p>To enhance this process and explore possibilities for remote, at-home fetal monitoring, this PoC employs the YOLOv7-tiny model, tailored to identify and outline anatomical features in fetal ultrasound images.</p><h4><strong>Dataset</strong></h4><p><strong>Fetus Phantom Ultrasound dataset (FPUS23) </strong><a href="https://arxiv.org/pdf/2303.07852.pdf"><strong>[2]</strong></a>, is a comprehensive collection of 9455 images (size: 672*389 ,containing anatomical bounds for 4 classes heads, abdomen, arms, legs) specifically designed for fetal ultrasound analysis. The authors of the dataset collected the images using a fetus phantom at 23 weeks gestation, instead of actual human fetuses, thereby circumventing the regulations associated with healthcare data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*AglH4jrCwWI8dqRVPuMSjQ.png" /></figure><h4><strong>Approach</strong></h4><p>It involves training the YOLOv7-tiny model from scratch (and also finetuning it using pretrained weights) on FPUS23 dataset, for objection detection of anatomical bounds. Extensive hyperparameter tuning is also performed to optimize model’s performance, specific to Ultrasound images.</p><p>The architecture consists of lightweight backbone network of convolutional layers to extract hierarchical feature maps at 3 different scales. The model head then fuses these multi-scale features using a bottom-up path with up sampling and lateral connections. This allows objects to be detected at multiple scales by applying custom detection layers to the fused pyramid features. Finally, convolutional layers generate the output detection boxes along with class predictions and bounding box regressions to detect objects in the input image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Wd-ai3QCojEl41UUx81Zcw.png" /><figcaption>Network architecture diagram of YOLOv7. (Ref: <a href="https://www.researchgate.net/figure/The-network-architecture-diagram-of-YOLOv7_fig4_370991194">https://www.researchgate.net/figure/The-network-architecture-diagram-of-YOLOv7_fig4_370991194</a>)</figcaption></figure><p>The architecture is designed to be fast and efficient by using this feature pyramid network with a small, optimized backbone and detection head.</p><p>Additionally, the Yolov7-tiny model architecture is also modified with respect to depth and width of the layers to capture the intricate patterns in the data. The performance of the enhanced YOLOv7 -tiny model against the baseline results obtained from a Faster R-CNN model, which was developed by the authors of the FPUS23 dataset.</p><h4><strong>Data Preparation</strong></h4><p>This step converts the images and their corresponding annotations, originally in XML files and marked using the Computer Vision Annotation Tool (CVAT), into a format compatible with the YOLO model. This format typically includes the coordinates of the bounding box’s center, its width and height, and the class label.</p><h4><strong>Data Preprocessing</strong></h4><p>Several filtering techniques were evaluated to enhance the quality of the images in the FPUS23 dataset. These included <strong>Averaging, Gaussian Blurring, Median Blurring, and Bilateral Blurring</strong>. After thorough testing and comparison of these methods, the Median filter was chosen as the most effective for preprocessing and these images are used for few sets of experiments.</p><p>On the top of this, several other preprocessing steps are handled by YOLO model based on the parameters set. The dataset is then split into train, validation and test sets in 70:15:15 ratio before the experimentation part.</p><h4>Training</h4><p>A diverse range of experiments were carried out to thoroughly evaluate the performance of the YOLOv7-tiny model on the FPUS23 dataset, with different training approaches and configurations:</p><ul><li><strong>Using Pretrained Weights: </strong>The objective was to assess how well the model could adapt its pre-learned features to ultrasound images. This model is trained for 77 epochs.</li><li><strong>Training From Scratch: </strong>To observe how the model learns and adapts when it is exclusively exposed to the FPUS23 dataset from the beginning of its training. This model is trained for 213 epochs</li><li><strong>Training From Scratch with Modified Hyperparameters and Preprocessed Images with median blur:</strong> The HSV image augmentation parameter was set to a value of 0, while other parameters such as mixup and mosaic augmentation, momentum, translation, and learning rate were maintained at their original values, as adjustments to these parameters resulted in a decrease in performance. This model is trained for 75 epochs.</li><li><strong>Using Pretrained Weights with Modified Hyperparameters and Preprocessed Images :</strong> The above mentioned approach was also applied while utilizing pretrained weights. This model is trained for 109 epochs For all the above training approaches, Mean Average Precision is considered as evaluation metric in addition with Precision and Recall.</li></ul><p>For all the above training approaches, Mean Average Precision is considered as evaluation metric in addition with Precision and Recall.</p><p>Let us check the results..</p><p>Using Pretrained Weights:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*X9j5_5fthVkrsJwJi4mGwQ.png" /></figure><p>The model achieves a high precision (P) across all classes, with the head detection being particularly high at 0.996.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aAihz47UUe7EWBKTAgUTiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRz7tffd8oBjUTs1XBDybQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Azn7cO9AWsn37OORhmEUA.png" /></figure><p>The results of the above experiments with respect to evaluation metric mAP seem to be same without any significant difference.</p><p>However, with median blur preprocessing and hyperparameter change in effect, the training time gets significantly reduced with the model reaching its optimal performance more rapidly at around 31st epoch</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*_DbV_f1IgaHTA_nLC1Ldog.png" /></figure><p>whereas, it took around 70 epochs for the model which is run from scratch with the images which are not preprocessed and hyperparameter changes are not done.</p><p>The model trained from scratch with default hyperparameters can be considered as best model based on the evaluation metric mAP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*wxuJCqzrAW73Dmaf5e3ESQ.png" /><figcaption>Results from the best model on few test images</figcaption></figure><h4>Few Observations..</h4><ul><li>Some of the models are not trained for longer epochs because of resources constraints. But the training is done till proper accuracies are obtained.</li><li>Given this, all the different models will outperform the baseline model when trained for longer epochs.</li><li>The YOLOv7 seems to better because of its speed during inference and it can be easily integrated with Ultrasound scanner for faster processing of images and for instant results.</li><li>The models can be tested on real world dataset from hospitals to check its effectiveness and more advanced YOLO models such as YOLO-NAS and objection detection algorithms such as Detectron can be tested for their effectiveness as continuing research.</li><li>The backbone of the YOLO model can be changed and can be tested as a future research item ,but this might be complex as it involves changing the YOLOv7 model (or the variants of YOLO) code as a whole completely</li></ul><h4>Conclusion</h4><p>The YOLOv7 model shows promise for real-time, efficient fetal ultrasound image processing, potentially facilitating faster and instant results when integrated with ultrasound scanners. Future research could explore the model’s effectiveness on real-world hospital datasets and test more advanced YOLO models and object detection algorithms.</p><h4><strong>Bibliography</strong></h4><ol><li><a href="https://github.com/bharathprabakaran/FPUS23">https://github.com/bharathprabakaran/FPUS23</a></li><li>“<strong>FPUS23: An Ultrasound Fetus Phantom Dataset with Deep Neural Network Evaluations for Fetus Orientations, Fetal Planes, and Anatomical Features</strong>” Bharath Srinivas Prabakaran, Paul Hamelmann, Erik Ostrowski, Muhammad Shafique. <a href="https://arxiv.org/abs/2303.07852">https://arxiv.org/abs/2303.07852</a></li><li>“<strong>YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors.</strong>” Chien-Yao Wang, Alexey Bochkovskiy, Hong-Yuan Mark Liao. <a href="https://arxiv.org/abs/2207.02696">https://arxiv.org/abs/2207.02696</a></li><li><a href="https://github.com/WongKinYiu/yolov7?tab=readme-ov-file">https://github.com/WongKinYiu/yolov7?tab=readme-ov-file</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c23d8231157a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>