<?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 mukund kannan on Medium]]></title>
        <description><![CDATA[Stories by mukund kannan on Medium]]></description>
        <link>https://medium.com/@mukund-kannan?source=rss-e519163e4c8f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nJDfUr9gFsgtmZhPqZcRvQ.jpeg</url>
            <title>Stories by mukund kannan on Medium</title>
            <link>https://medium.com/@mukund-kannan?source=rss-e519163e4c8f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:35:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mukund-kannan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building LLM Applications — Advanced Techniques and Tips]]></title>
            <link>https://mukund-kannan.medium.com/building-llm-applications-advanced-techniques-and-tips-b0a9d657821b?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0a9d657821b</guid>
            <category><![CDATA[llmops]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-ml-development]]></category>
            <category><![CDATA[gen-ai-for-business]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 11:40:09 GMT</pubDate>
            <atom:updated>2024-08-06T06:01:47.799Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building LLM Applications — A Practitioners Guide and Tips</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mbGrQphaiWaUeQbZ" /><figcaption>Photo by <a href="https://unsplash.com/@scdisilviabrazzoduro?utm_source=medium&amp;utm_medium=referral">Silvia Brazzoduro</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the <a href="https://mukund-kannan.medium.com/basic-llm-application-development-approaches-6aebc38555c2">previous article, </a>we examined the basic approaches to building LLM applications. These approaches are still evolving and receiving enhancements through tweaks and the application of different technologies. Let us explore some of the latest advances along with some application patterns.</p><p>Before starting on a use case it is better to spend the time to better understand the domain specific knowledge corpus that will be used over the LLM and the desired outcome — such as the following:</p><ol><li>Q&amp;A — Multiple &amp; wide domains, large document dataset</li><li>Q&amp;A — Single, narrow domain, large document dataset, sparse content</li><li>Q&amp;A — Single, narrow domain, small dataset, dense content</li><li>Q&amp;A — Real time web search (not really prepared upfront like the usual RAG approach) and response</li><li>Summarization — narrow domain and summarizing document content</li><li>Language translation</li></ol><blockquote><strong>Note: </strong>When we refer to Q&amp;A, we do not mean just chatbot use cases. Zero-shot or multi-shot Q&amp;A can offer essential insights for downstream applications to benefit from. For instance, by forcing the LLM to format the Q&amp;A output in a predefined JSON format, a downstream application can easily consume and process it.</blockquote><p>This upfront analysis &amp; categorization step will help in making some critical decisions in the subsequent steps as we shall see through the article.</p><p>Let us begin with the simplest scenario of extracting essential insights from a small set of documents — a corporate policy Q&amp;A for a large company. These companies typically have multiple policy documents (e.g travel, HR manual, compensation policy, code of conduct, business expense policy). This domain is narrow with a small document repository, making it suitable for a simple RAG system.</p><p>In implementing simple RAG cases, the chunking strategy is crucial.</p><ul><li>Start with a simple sliding window with overlap. Experiment with various combination of chunk size and overlap size</li><li>Playing around with chunk size and chunk overlap could make a difference in the overall performance in RAG systems.</li><li>Next level improvements could come from chunking based on semantic boundaries rather than arbitrary character/token sizes.</li><li>Contextualization by adding relevant text or metadata could boost relevancy quite a bit. For example, some of the documents may have a paragraph title followed by lengthy text. While chunking, this text would be split into multiple splits without the title. The context provided by the title should be included in all the splits.</li></ul><p>Creating effective prompts is also critical. Prompt engineering, though not covered here, plays a significant role. For more insights, I recommend reading <a href="https://www.linkedin.com/pulse/ai-agents-prompt-engineering-thoughts-l-ravichandran-junpc/?trackingId=ihXDMu5PSZeRadUywuD7Kw%3D%3D">this </a>article by L Ravichandran, which provides a thorough walkthrough of various prompt engineering techniques.</p><h4>Chunking</h4><p>While dealing with large corpus, applying the right preprocessing techniques before chunking is critical. This typically involves duplicates, cleaning and standardizing the documents. The experience gained from traditional search and retrieval systems with large corpora is invaluable in this step.</p><p>In cases where the document corpus is quite large and the useful content is sparse, larger chunk sizes and smaller overlaps might be better. Where feasible, removal of unnecessary content from the documents before chunking will boost the relevancy of the responses.</p><p>Where the documents are of different types (HTML, PDF, DOC, XLS etc.), specific chunking strategies need to be designed for each. LLM orchestrators such as LangChain offer basic splitters out of the box. Even within these formats, there are numerous subtypes based on business scenarios and document structures, which would require tailored treatment. Over time, developing a classifier model to identify the sub-type and the right chunking strategy would ensure effective processing of the newer documents as they are added to the corpus.</p><h4>GraphDB</h4><p>When the corpus is large and contains complex relationships between specific entities, documents, and chunks, a GraphDB can be considered as the RAG backend, either in place of or alongside vector databases. Graph RAGs provide more relevant information by leveraging the richer representation of these complex relationships. They can outperform vector DB-based RAGs on queries requiring multi-dimensional joining of information across documents. For example, a Graph RAG implementation could simplify queries like “What is the average positive sentiment score for African American, male lead actors?” in a movie review dataset.</p><p>Graph RAGs can also utilize bidirectional traversal to address the reversal curse issue, where LLMs underperform for weaker relationships. In “The Reversal Curse” paper, the authors illustrate this with the example: <em>“Who is Tom Cruise’s mother? [A: Mary Lee Pfeiffer]” and the reverse “Who is Mary Lee Pfeiffer’s son?”. GPT-4 correctly answers questions like the former 79% of the time, compared to 33% for the latter.</em> A graph-based architecture could potentially mitigate this issue.</p><p>Some advanced architectures suggest storing embedding values within the vertices, thereby combining the strengths of both technologies.</p><h4>HyDE</h4><p>If you have a dense corpus where vector search fails to pull out relevant results because the chunks are too syntactically similar, then the prompting needs to be more elaborate and often dynamically generated. In such cases, a new approach called HyDE (Hypothetical Document Embeddings) can be utilized. HyDE can be seen as an enhanced RAG with a dynamic prompt augmentation technique.</p><p>In HyDE, the query and prompt combination is sent to an LLM engine without the domain-specific inputs from the vector engine. The LLM is instructed to provide an answer, which may contain factual inaccuracies due to the missing domain context, but it is more likely be syntactically closer in context. This response is then sent to the embeddings engine to generate an embedding, which is subsequently used by the vector search to retrieve real documents containing accurate answers. With the addition of the LLM, the querying part of the RAG process will be as illustrated in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-S8pHM-MjH8SzXdFXuKdg.jpeg" /><figcaption>Figure: HyDE</figcaption></figure><p>In short, the relevance ranking process is offloaded to a system that utilizes the generated answer, which contains rich syntactically similar content. This approach helps to better generalize and improve the retrieval of relevant chunks.</p><h4>RAFT</h4><p>An approach called RAFT (Retrieval Augmented Fine Tuning) was proposed, where fine-tuning is done so that the model learns to answer queries like a student taking an open-book exam, comfortably navigating and synthesizing answers from available resources. The training follows a supervised learning method, using samples that include a complete combination of query, document set, response, and chain-of-thought reasoning explanations. The document set for training consists of both relevant documents (golden documents) and irrelevant ones (distractor documents). The resulting model learns to generate the best response based on the provided context (query, response, CoT steps, and document set), rather than solely relying on the model’s internal knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zw0hj822WtF6LX_kmBEXHQ.jpeg" /><figcaption>Illustration from the original RAFT paper (Link in the reference section below)</figcaption></figure><p>Couple of interesting points to note in RAFT.</p><ul><li>Fine-tuning with a combination of golden and distractor documents, rather than just golden documents, increases response accuracy. Maintaining a specific proportion of golden documents within the overall training dataset positively impacts accuracy during inference.</li><li>Training datasets should include some samples with no golden documents (i.e., none of the documents in the context are relevant to the response). The proportion of training sets with to without golden documents is a hyperparameter (P as a %) that should be tuned during training. Having all sets with golden documents (P=100) has consistently shown to be less accurate compared to having P&lt;100.</li></ul><h4>Some critical tips</h4><p>1. <strong>Licensing Terms:</strong> When choosing open-source foundation models, carefully review the licensing terms under which they are released. Some models, such as MPT-7B, are only available for non-commercial use, while others have copyleft requirements that may not be suitable for large corporations.</p><p>2. <strong>Model Selection:</strong> If concise output is required, rather than simply duplicating sentences from the original corpus, encoder-decoder models are preferable. Decoder-only models have simpler architectures, are less resource-intensive, and require less data to train but might produce outputs that do not fully match the desired context. Encoder-decoder models, while heavier and requiring more hardware and data to train, can provide more contextually relevant outputs. It’s important to note that despite their simplicity, many popular models like GPT, Llama, and Gemini are decoder-only.</p><p>3. <strong>Token Usage Monitoring:</strong> Keep a close eye on token usage. Agentic or LLM orchestration frameworks can make numerous calls to LLM models, leading to unexpected costs. Continuous monitoring (LLM observability ) is essential to manage and mitigate these expenses.</p><p>4. <strong>Development Roadmap</strong>: Given the resource demands of these models, consider the following path for developing your LLM application:</p><p>4.1. <strong>Establish the Pipeline:</strong> Start by setting up the pipeline (referred to as MLOps/LLMOps). This includes training, deploying, and testing, along with necessary evaluations. In LLMs, having a robust pipeline is often more crucial than in traditional AI/ML applications.</p><p>4.2. <strong>Prioritize Critical Evals:</strong> Focus on eval metrics that have the most significant impact on key business metrics. Finding the right evals may be a process, so begin with a set of evals that seem appropriate rather than getting bogged down in finding the perfect ones from the start.</p><p>4.3. <strong>Adapt Pipeline Complexity:</strong> The complexity of the LLM pipeline can vary based on the use case. For simpler scenarios, a full-featured orchestrator that selects the ideal LLM model based on syntactical needs may not be necessary. However, an automated feedback loop for evaluation is essential in almost all cases.</p><p>4.4. <strong>Explore techniques gradually in increasing levels of implementation complexity</strong></p><ul><li>Start with RAG combined with prompt engineering and optimizations (e.g., DSpy) and experiment with different chunking strategies.</li><li>Explore advanced RAG techniques like HyDE</li><li>If the complexities in relationships justify, consider using GraphDB in place or or alongside a vector DB</li><li>Implement RAG with fine tuning like RAFT</li><li>If all other approaches fail, consider pre-training, but do so only after thorough consideration and evaluation of its feasibility, budget constraints, skill set availability and project timelines.</li></ul><h4>References</h4><ol><li>RAG with Graph database — Open AI cookbook: <a href="https://cookbook.openai.com/examples/rag_with_graph_db">https://cookbook.openai.com/examples/rag_with_graph_db</a></li><li>The Reversal Curse: LLMs trained on “A is B” fail to learn “B is A” by Lukas Berglund et al. — <a href="https://arxiv.org/abs/2309.12288">https://arxiv.org/abs/2309.12288</a></li><li>RAFT: Adapting Language Model to Domain Specific RAG by Tianjun Zhang et al. — <a href="https://arxiv.org/abs/2403.10131">https://arxiv.org/abs/2403.10131</a></li><li>Precise Zero-Shot Dense Retrieval without Relevance Labels by Luyu Gao et al. <a href="https://arxiv.org/pdf/2212.10496v1">https://arxiv.org/pdf/2212.10496v1</a></li><li>AI Engineering and Prompt Engineering Thoughts LinkedIn article by L Ravichandran <a href="https://www.linkedin.com/pulse/ai-agents-prompt-engineering-thoughts-l-ravichandran-junpc/?trackingId=ihXDMu5PSZeRadUywuD7Kw%3D%3D">https://www.linkedin.com/pulse/ai-agents-prompt-engineering-thoughts-l-ravichandran-junpc/?trackingId=ihXDMu5PSZeRadUywuD7Kw%3D%3D</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0a9d657821b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic LLM application development approaches]]></title>
            <link>https://mukund-kannan.medium.com/basic-llm-application-development-approaches-6aebc38555c2?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aebc38555c2</guid>
            <category><![CDATA[ai-ml-development]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[gen-ai-for-business]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 11:07:19 GMT</pubDate>
            <atom:updated>2024-08-05T11:42:12.488Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BTyRfPIJ3Ea19aRj" /><figcaption>Photo by <a href="https://unsplash.com/@neom?utm_source=medium&amp;utm_medium=referral">NEOM</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>LLMs are a powerful way to get the long promised AI upside in understanding and processing information. Since November of 2022 when ChatGPT got launched, the hype and noise level has been palpable. But converting the ‘genius’ of GPT to a business use case has been anything but easy. Initial dreams that the most vexing business problems will be solved through the right prompts proved quickly to be just that — dreams. Different approaches have been developed since then to control and harness the awesome power of this incredible technology that can deliver contextual results in enterprise setup. Here let us walk through some of the specific advances in this space.</p><p>If you are already familiar with LLM application basics, you can happily skip these introductions and directly go to the <a href="https://mukund-kannan.medium.com/building-llm-applications-advanced-techniques-and-tips-b0a9d657821b">next article</a> where we discuss some advanced techniques in LLM application development.</p><p>First, let us have a quick walk through on the most well known approaches to build business use cases — in the order of difficulty of implementation.</p><h4>Retrieval Augmented Generation (RAG)</h4><p>Given that the LLMs are built on larger, global data, the first challenge was to create a LLM solution that learns the use case specific information rather than being global in its understanding. Enter RAG (Retrieval Augmented Generation) approach — it is the simplest approach to get local information to be made available to the LLM that can narrow down the responses with the use case specific information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ElYZk21miUR7O9feEtoItw.jpeg" /><figcaption>Figure: Retrieval Augmented Generation (RAG)</figcaption></figure><p>RAG has three distinct parts: (i) retrieve &amp; chunk, (ii) query &amp; match and (iii) response generation.</p><p>Retrieve &amp; chunk is the Indexing part on the above Figure depicting the RAG flow. In this part, the documents are read from document stores, broken down to small chunks, vectorized (converted to document embeddings) and stored. These embeddings are long, numerical, matrix vector representations that can be used for mathematical operations. These embeddings are created based on syntactical similarity of the content — syntactically similar content tend to be closer to each other in embedding values. The chunking strategy is extremely important — if we are able to create distinct chunks with the right amount of information, search results in the next step would be better. If the chunks are too small with little information (or information broken across multiple chunks), then we will end up missing out the relevant information or we will flood the query with too many similar documents.</p><p>Query &amp; match: Here, the user issues the query, the RAG system searches and retrieves relevant chunks. Typically, the RAG system adds additional prompts to aid the LLM to get better context — this will be from the context of the use case, from earlier interactions and other information the system can gather at the time of the query. Again this query+prompt will get vectorized (using the same embedding technique) producing embeddings. Now these embeddings are used by the next part of the system to find the document chunks that are closest (like nearest neighbour) to the query. Being the ‘closest’, these chunks are most likely to contain answers to the query.</p><p>Finally, this combination of query+prompt and relevant document chunks are presented to the LLM, which generates a coherent response.</p><h4>Domain specific fine-tuning</h4><p>Another way to leverage the power of LLM for specific requirements is domain specific fine tuning (DSF). Compared to RAG, it is a slightly more straightforward approach to explain, but much, much harder to implement. DSF would involve taking a base foundation model like GPT, Google’s T5 etc. and fine tuning with our domain specific documents. APIs and approaches might vary slightly depending on the foundational model chosen, but basic high level steps are the same: load the model, prepare the training data (with your own domain specific dataset), setup &amp; configure the model (hyperparameters, optimizer choice etc.), train and validate the results. In the case of GPT3, the model is accessible through API calls only whereas T5 and GPT2 we can work with locally. But remember, while training locally, the training cycle would require quite a lot of GPU compute &amp; memory and that can be pretty prohibitive for cost sensitive use cases. Even with optimized training techniques like LoRA, we would have to factor in for high compute costs and lengthy training cycles.</p><p>Marrying a fine tuned model with the RAG approach can be more beneficial in some of the use cases where the generic LLM is not that well trained on a specific domain.</p><h4>Pre-training</h4><p>When fine-tuning is not sufficient, next level to go to is pre-training. This approach calls for training a base model from scratch with a large amount of domain specific curated data using supervised learning. This would increase the depth of the domain of the resultant model, but it would mostly come at the cost of breadth of general capability of the original base model. Most importantly, this approach would need a large amount of data and large amount of compute for the training cycle — ‘large’ in both cases is in the orders of magnitude higher than what it would take for fine-tuning. This approach is for extremely specific tasks only, and there are studies that argue that this approach does not provide the necessary value for the investment.</p><p>Please go to the <a href="https://mukund-kannan.medium.com/building-llm-applications-advanced-techniques-and-tips-b0a9d657821b">next article</a> for some of the advanced approaches.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aebc38555c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Product Manager & Machine Learning]]></title>
            <link>https://mukund-kannan.medium.com/product-manager-machine-learning-53505aebadcf?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/53505aebadcf</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[product-manager]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-ml-solution]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Wed, 05 Jun 2024 08:58:09 GMT</pubDate>
            <atom:updated>2024-06-05T09:10:30.822Z</atom:updated>
            <content:encoded><![CDATA[<p><em>All successful products are alike; every unsuccessful product is unsuccessful in its own way.</em></p><p>With pulls and pushes from various stakeholders and juggling day-to-day priorities without losing sight of the larger product strategy, a product manager’s job is tough. Tougher it gets when it involves latest technologies that seem to be stuck eternally in the narrow band between ‘mass media hype begins’ &amp; ‘supplier proliferation’ in the Gartner Hype Cycle.</p><p>Well, now that I have managed to win some brownie points from you, Mr. Product Manager, let me provide some points for a new PM starting off on a ML based product journey. Primarily the difference between traditional software based approach to ML based approach is this: In ML, specific requirements and constraints are all contained within the data that needs to be prised out whereas in traditional software these are all upfront provided by a business subject matter expert clearly. Working in this opaque world is the single biggest challenge for an uninitiated PM.</p><p>Before anything else, probably the most important advice I can give to a PM is to get over the mental barrier of learning AI/ML. All the fancy terms, hyperbolic claims making it all feel like magic, heavy math, probability &amp; statistics — it can surely be daunting. My experience has been to internalize the concepts through intuition based understanding. There is so much material available on the net where these are all explained in extremely simple terms. An aspiring learner should back her/himself up and get started.</p><p>Let us break the PMs responsibilities into three broad segments and discuss important aspects a PM needs to pay attention to.</p><h3>Identifying &amp; defining viable products &amp; features</h3><p>Here, the PM’s focus is to identify the products and/or features that will pretty much define the outcome of the entire journey. This involves maintaining product portfolios &amp; feature backlogs and prioritizing them to maximize the value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*BWx8PR_VoTFX0r1EfiGFqg.jpeg" /><figcaption>Please pardon the funny face here — blame it on GenAI (OpenArt.ai)</figcaption></figure><p>Typically, prioritization would involve a relative comparison on business value, risk of failure, cost of development and skill-set availability. Depending on the company’s business context &amp; current focus, some of these get dialed up or down. In this list, for assessing the risk of failure and cost of development the PM has to have some bit of ML background.</p><p>Failure risk analysis: Data dependency, constant flux of underlying technologies, different development tools &amp; approaches, risk analysis make ML projects different. Most of the ML product builds start off with some hypotheses that would require a POC as a safeguard against certain types of risks. This poses the challenge to the PM on how to plan for this — time/value boxing, how fast is fast in the ‘fail fast’ decisions, identifying interim milestones on slightly larger POCs, validation &amp; evaluation frameworks to be put in place etc. A level of understanding of ML would go a long way in making these decisions in an informed way.</p><p>Cost of development is an important element in the assessment. The initial POC might give some idea of the effort required for some of the moving parts in the project. It will also bring out elements in the ML journey that need additional experiments.</p><p>ML is extremely experiment driven — not just in the model building phase; it is experimental through the lifecycle. Even data identification &amp; gathering might be iterative processes. This is because, in use cases with higher number of features (or in unstructured data projects), it is very difficult to be able to confidently predict data sufficiency beforehand. Only during the hyper iterative model building cycle, these things tend to surface. So, with an experienced data scientist’s inputs a PM should make allowance for these in the planning stages.</p><p>A PM should focus on the following during the initial discussions with the data science and engineering teams.</p><p><strong>Technology choices</strong></p><ul><li>Larger and more complicated models tend to be more accurate, but larger models tend to require more compute. Some of the larger NLP models (Google BERT for example) might work out very well for classification use cases, but each kubernetes pod might require high time (2–3 minutes) to spin up, which possibly is not acceptable in some time sensitive cases. Most of the LLM based models as of now require GPUs during inference making it completely a non-option for highly cost sensitive business scenarios.</li><li>Accuracy is typically reported in statistical terms. A PM has to be comfortable with these accuracy metrics. Most of them are very simple to understand, if we approach them through intuition learning rather than in pure mathematical terms.</li><li>While the data scientists report the accuracy only from the models’ point of view, the PM has to think in terms of end to end process flow. For example, a model with 95% accuracy might sound nice. But this metric is reported based on historical data. At runtime, unless there is a way to clearly identify if the prediction for the runtime data is a failure or success, the output cannot be trusted — bringing the effective accuracy down to 0! So, the PM needs to ensure that the design provides for high confidence predictions separated from those that would have to be routed through a fall out management workflow. Then the metric reporting has to be done for the success scenarios (as models never can predict with 100% accuracy) and the likely effort required to handle the fallout cases — like a human-in-the-loop workflow.</li></ul><p><strong>Maintainability</strong></p><ul><li>Traditional installed executable tend to perform consistently over time. But model performance tends to vary over time due to concept drift (where the model-build-time concept level assumptions change) and data drift (sub-population changes through time). What is the strategy in place to measure and handle the drifts?</li><li>In cases where there are multiple prediction pipelines (or hierarchical models) used for different scenarios, it can get very confusing during average accuracy calculations. PM needs to be sure that the evaluation is in line with the complexity of the model serving layer.</li></ul><p><strong>Overall cost of ownership</strong></p><ul><li>One of the biggest follies while using cloud is not factoring in the cost of development. One needs to plan for what is expected for development &amp; testing (where typically the measurement is pretty relaxed).</li><li>Similarly at serving time, sufficient monitoring &amp; comparison of the live volumes and load profiles against the original assumptions. Any large deviations in these would increase the burn rate.</li><li>Unless designed for the right load profiles and monitoring in place, serverless approach could cause unforeseen overruns.</li><li>Again, better observability systems will play a huge part in estimating and auditing the cost.</li></ul><p><strong>Observability</strong></p><ul><li>As mentioned above, in scenarios where inference pipeline orchestration is in place, a diagnostic audit might prove to be a challenge. In order to handle the above issues, a proper observability system should be in place.</li><li>In the MLOps implementations, observability integration would increase the feedback loop’s reliability significantly.</li></ul><h3>Defining success criteria</h3><p>The PM has to define the requirements and lay down the success criteria for the product. A clear definition of acceptance criteria through the innovation value chain is a must for the overall successful outcome of the product. The last statement should not be read as a documentation diktat; it is a call for the PM to be part of the team through the lifecycle and help iterate quickly and clearly towards the successful completion. Please note that acceptance criteria at every level will also help with the fail fast strategies which are a must in the fast moving product development cycles.</p><p>Data scientists tend to be too focused on data and statistical interpretation of the model performance. A PM should be able to act as the bridge to translate these into business outcome terms.</p><blockquote>A large laminate manufacturer in the US came to us with a problem that they were hoping would make a difference in their customer retention strategy. Using a mobile app, their customer would take a picture of a pattern that they like, the app would send it to a model, which has to identify and provide similar patterns available in the manufacturer’s inventory. The team came up with a Siamese network based approach. It was well received in the initial demos with the sales teams, but subsequently their manufacturer’s styling team did not approve as it did not meet their definition of ‘similarity’. Ideally the team should have consulted the styling team and come up with the process of evaluation &amp; success criteria.</blockquote><p>Remember, the ML systems work on averages and reporting metrics would be gross metrics based on the data scientists understanding of the relative importance of the features. A PM needs to be very careful in this as the cost of failure need not be not well understood by the data science team.</p><blockquote>We had a project where the requirement was to take in a hospital discharge summary as input, extract relevant medical entities from the document and provide standardized medical coding as output. The team developed a multi-modal ML model based system that gave very impressive starting metrics. But when the averages were weighted on the total business value of the different classes, it was realized that the tail where the model had more failures had higher business value and that sent the team back to the drawing board.</blockquote><h3>Product build &amp; execution</h3><p>The PM needs to be very closely engaged in the development and execution of the product. Her/his contribution in decision making will guide the teams to navigate through the uncertainties that crop up during the execution stages.</p><ul><li>ML teams would have to make choices on thresholds and additional validations to be performed to arrive at a proper prediction confidence strategy. Thresholding decisions will be based on factors like cost of failure, cost of manual fall out management, importance of the sub-population from business context etc. These are typically business decisions, not purely data oriented and the PM has a larger role in guiding the data science teams.</li><li>Given that training data tends to cover a small fraction of possible real-world scenarios, introduction of the model into production is typically done in a hyper vigilant manner. A PM needs to be part of the deployment decisions — AB, canary, blue-green deployments, control/treatment group proportion, scaling strategies etc. While these tend to be similar to any of the deployments of web modern applications, decisions are to be taken with a clear understanding of the data the model is trained on. Without this, the models might under perform at scale.</li><li>Monitoring a live ML model is very different from traditional software executable based deliveries. Model behavior might end up changing (drift — as explained earlier) over time. Data scientists will have to create a ‘baseline behavior’ and measure the drift at regular intervals. A PM needs to add in the business context to this very important step.</li><li>To ensure that the models stay within acceptable behavior boundaries, they need to be regularly refreshed by running retraining cycles. While this is a highly data science oriented effort, PM should be part of the discussions on the process to be followed.</li></ul><p>Social and psychological acceptance barriers for an Artificial Intelligence based system are typically much higher, thereby making the change management planning for the ML systems that much higher. One of the ways to gain confidence of the business stakeholder is to let them interact with the model early in the cycle and let them gain some insights on the decision boundaries. This makes the models feel less of a threat. A PM needs to include this into the overall planning.</p><p>In the current world, a product that is of some value is going to have have a ML model embedded in it. The PM driving the product needs to be the one in charge of the critical decisions that maximizes the value for the product’s consumer. May the ML knowledge set you free.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53505aebadcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High Quality Machine Learning — Part 3]]></title>
            <link>https://medium.com/codex/high-quality-machine-learning-part-3-c660b885233c?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c660b885233c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[data-security]]></category>
            <category><![CDATA[robustness]]></category>
            <category><![CDATA[adversarial-attack]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 08:55:38 GMT</pubDate>
            <atom:updated>2021-01-11T11:24:55.150Z</atom:updated>
            <content:encoded><![CDATA[<h3>High-Quality ML — Part 3 — Secure Lifecycle Practices</h3><p><em>Please check out </em><a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-1-d45259ee7613"><em>Part 1</em></a><em> and </em><a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-2-2643c144a2a7"><em>Part 2</em></a><em> of this series</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9D926vW3yUf3uj2I" /><figcaption>Photo by <a href="https://unsplash.com/@erfanprh?utm_source=medium&amp;utm_medium=referral">Erfan Parhizi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Secure DSLC</h3><p>Security and threat assessment in DSLC is still a maturing domain. Over the last couple of years, the DevSecOps movement has brought in a better focus to the need for security thinking through the development lifecycle. Earlier (rather current — still in the majority of projects) approach of ‘let us take the code at the end of the critical test cycles and put it through some code scanners to identify security issues’ has been proven to be insufficient.</p><p>Broader coverage of possible threats to ML models in an enterprise (including non-ML system threats that are applicable in DSLC) could be found in Adversarial ML Threat Matrix (<a href="https://github.com/mitre/advmlthreatmatrix">https://github.com/mitre/advmlthreatmatrix</a>). Let us take a thirty-thousand-foot view of security-related challenges in ML projects.</p><h4>Data management phase</h4><p>Procuring external data is part of an effective data science project strategy. But as mentioned above during the Fairness discussion, ideally external data brokers need to provide a level of assurance on the integrity of data. An act (Data Broker List Act of 2019) that was introduced in the US Congress has taken the initial steps to bring in some regulation under FTC. While this act focuses on privacy, it has the potential to address some concerns about data integrity.</p><p>Data ingestion and preparation can be a good breeding ground for anyone looking to poison from the root. Preventing this would require better data access mechanisms covered by the larger Data Governance strategy. While this is one of the most discussed subjects in the Data Science universe, implementation is proving more and more difficult over time. Approaches vary from old style table level roll-based-access controls to advanced approaches using the real-time discovery of data parts &amp; self-service access driven by dynamic policies.</p><h4>Model build phase</h4><p>For now, let us leave aside the in-your-face threats like taking over the complete training time processing to develop a malicious ML model. Transfer learning is an easier vehicle for an adversary to compromise the final ML model. A crafty operator could offer malignant pre-trained ML models through GitHub repositories, model zoos, and via pickle files. This is an obvious risk in the uncontrolled world that we live in where there is heavy reuse of highly complex starter ML models. While in the open-source world trust was based on the community review of the code, the same is not possible in a shared ML model. Careful consideration should be given to the provenance of the pre-trained ML model to reduce such threats.</p><h4>Deployment management (ILS) phase</h4><p>Adversarial attacks are rightfully gaining attention as the top potential threat for live ML models. A well-placed attacker can use the ML model through legal access, build an understanding of the ML model behavior and use this understanding to add just enough (imperceptible for the humans) perturbations to the input to fool the ML model. The ML model could be fooled to an extent of flipping the predictions to the dangerous opposite. For example, getting the ML model to predict a 55 miles speed limit sign when presented with a STOP sign.</p><p>Defense for such attacks includes noise injection during model build cycle to self-supervised approach to GAN based approaches. IBM’s ART (Adversarial Robustness Toolkit) is a Python library to measure the robustness and harden the ML model. ART covers most of the well-known threats and defensive approaches. Google’s Robustness Metrics is a library released very recently. It has measures for robustness (ability to handle perturbations), out-of-distribution generalizations (how well the ML model can handle cases that were not fully represented by the train data), and uncertainly (a measure of uncertainty of the ML model predictions).</p><h4>Key takeaways</h4><ul><li>Strategically well-defined Data Governance is a fundamental requirement to secure DSLC</li><li>Reuse of models and transfer learning are potential compromise points. Utmost care must be taken in the selection of external reusable artifacts</li><li>Adversarial robustness must be measured and ML model hardened using available libraries like ART</li></ul><h3>Conclusion</h3><p>A ‘quality’ model that is planned to be taken live as part of an enterprise IT system, cannot be measured simply on accuracy goals. It has to be functionally accurate and behave as a good citizen in the environment that is designed to play. There is so much progress made in the last couple of years and more are expected in this area in the coming year.</p><h3>Acknowledgment</h3><p>Most of what I have referred to either specifically while writing this 3 part article or gained knowledge for my day-to-day work, I am listing below. Apart from these, there have been so many podcasts, online videos, and articles that helped shape my thoughts. Unfortunately, the list would be too long to be useful. I would recommend anyone interested to go through the following links to gain more knowledge than what I could present in this small article.</p><p>1. TFDV documentation — <a href="https://www.tensorflow.org/tfx/tutorials/data_validation/tfdv_basic">https://www.tensorflow.org/tfx/tutorials/data_validation/tfdv_basic</a></p><p>2. Great Expectations — <a href="https://greatexpectations.io/">https://greatexpectations.io/</a></p><p>3. Effective testing for ML systems — <a href="https://www.jeremyjordan.me/testing-ml/">https://www.jeremyjordan.me/testing-ml/</a></p><p>4. Behavior testing for NLP — Marco Tulio Ribeiro, Tongshuang Wu, Carlos Guestrin, Sameer Singh — <a href="https://homes.cs.washington.edu/~marcotcr/acl20_checklist.pdf">https://homes.cs.washington.edu/~marcotcr/acl20_checklist.pdf</a></p><p>5. Google What If tool — <a href="https://cloud.google.com/ai-platform/prediction/docs/using-what-if-tool">https://cloud.google.com/ai-platform/prediction/docs/using-what-if-tool</a></p><p>6. Cognitive Scale Cortext Certified — <a href="https://www.cognitivescale.com/certifai/">https://www.cognitivescale.com/certifai/</a></p><p>7. ML Model Fairness in practice — <a href="https://medium.com/swlh/machine-learning-model-fairness-in-practice-bdebeaa76ee8">https://medium.com/swlh/machine-learning-model-fairness-in-practice-bdebeaa76ee8</a></p><p>8. Center for Data Ethics and Innovation — <a href="https://cdeiuk.github.io/bias-mitigation/interventions/">https://cdeiuk.github.io/bias-mitigation/interventions/</a></p><p>9. The most famous AI Fairness 360 framework — <a href="https://github.com/Trusted-AI/AIF360">https://github.com/Trusted-AI/AIF360</a></p><p>10. A Tutorial on fairness in Machine Learning -Ziyuan Zhong — <a href="https://towardsdatascience.com/a-tutorial-on-fairness-in-machine-learning-3ff8ba1040cb">https://towardsdatascience.com/a-tutorial-on-fairness-in-machine-learning-3ff8ba1040cb</a></p><p>11. NIPS fairness in ML slides (Solon Barocas and Moritz Hardt) — <a href="https://mrtz.org/nips17/#/">https://mrtz.org/nips17/#/</a></p><p>12. Pretty useful blog on AI — <a href="https://www.borealisai.com/en/blog/tutorial1-bias-and-fairness-ai/">https://www.borealisai.com/en/blog/tutorial1-bias-and-fairness-ai/</a></p><p>13. AN ARCHITECTURAL RISK ANALYSIS OF MACHINE LEARNING SYSTEMS: Toward More Secure Machine Learning (Gary McGraw, Ph.D. Harold Figueroa, Ph.D. Victor Shepardson Richie Bonett) — <a href="https://berryvilleiml.com/docs/ara.pdf">https://berryvilleiml.com/docs/ara.pdf</a></p><p>14. Google’s Robustness Metrics — <a href="https://github.com/google-research/robustness_metrics">https://github.com/google-research/robustness_metrics</a></p><p>15. Adversarial Readiness Toolbox — <a href="https://github.com/Trusted-AI/adversarial-robustness-toolbox">https://github.com/Trusted-AI/adversarial-robustness-toolbox</a></p><p>16. Data Broker List Act of 2019 — <a href="https://www.congress.gov/bill/116th-congress/senate-bill/2342/text?r=5&amp;s=1">https://www.congress.gov/bill/116th-congress/senate-bill/2342/text?r=5&amp;s=1</a></p><p>17. Adversarial ML Threat Matrix — <a href="https://github.com/mitre/advmlthreatmatrix">https://github.com/mitre/advmlthreatmatrix</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c660b885233c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/high-quality-machine-learning-part-3-c660b885233c">High Quality Machine Learning — Part 3</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High Quality Machine Learning — Part 2]]></title>
            <link>https://medium.com/codex/high-quality-machine-learning-part-2-2643c144a2a7?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2643c144a2a7</guid>
            <category><![CDATA[machine-learning-ai]]></category>
            <category><![CDATA[fairness-and-bias]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[generative-adversarial]]></category>
            <category><![CDATA[ml-lifecycle]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 08:42:02 GMT</pubDate>
            <atom:updated>2021-01-10T03:47:34.495Z</atom:updated>
            <content:encoded><![CDATA[<h3>High-Quality ML — Part 2 — Fairness</h3><h4><em>Please check out </em><a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-1-d45259ee7613"><em>Part 1</em></a><em> if not done already</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qRqGLiNB47TrNmxf" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>ML Fairness</h3><p>Even though ML fairness has been an area of interest for a while, it is gaining more attention only of late. This change in interest from a smaller, niche group to broader enterprises could actually be looked at as a measure of how fast ML models are gaining industrial traction.</p><p>Following our theme of this series, let us take a Data Science Lifecycle perspective of fairness, what one can do at each phase (as described in <a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-1-d45259ee7613">Part 1</a>) to identify &amp; increase the fairness of the ML model.</p><p>Fairness definitions are categorized as individual and group. Demographic parity, equalized odds and predictive rate parity belong to the group fairness category while unawareness, individual parity, and counterfactual fairness belong to individuals. What we choose to measure and balance is to be made in consultation with the business expert.</p><p>For quantifying bias in an ML model there are quite a few metrics to choose from. But given that the judgment on the fairness of the ML model is finally done by humans, the choice should be made with the verification authority’s comfort level — business or statistical terms. If the intended audience is from business, simpler reports that show the ML model’s performance on the advantaged and disadvantaged groups (groups that are suspected of biased towards and against) should be presented intuitively.</p><p>As bias reduction imposes additional constraints on the ML model, the prevailing wisdom is that fairness and accuracy have an inverse relationship. The potential fairness-accuracy tradeoff has to be considered carefully during the architecture phase.</p><h3>Data management phase</h3><p>The data broker market is quite large — some estimate puts it as a $200B industry. Large commercial data providers like Acxiom, Equifax, Bureau, etc. have been collecting and providing data to enterprises for quite some time. I am not aware of any standard fairness metrics along with the procured data. But the team that consumes the data should identify and address any issue.</p><p>Looking for bias in data this early phase might seem like a big ask. Simpler preprocessing techniques like Reweighting, Disparate Impact Remover, Learning Fair Representation, etc. can help identify and weed out some of it in data well before the model build phase. A quick look at these techniques to give the reader a flavor of what can be done at this phase of DSLC.</p><ul><li>Disparate Impact Remover is kind of similar to feature scaling in a way where we are trying to ‘normalize’ the protected attributes of the advantaged and disadvantaged group before training. This reduces the direct correlation of the biased feature to the ground-truth label while retaining the distribution profile for both the groups. Obviously, this works mainly for continuous features.</li><li>Reweighting is an approach to calculate a set of weights based on the probability of protected attributes favoring the disadvantaged group followed by training a classifier with these weights.</li><li>Fair Representation is representing candidate data without (or reduce) the bias with regards to gender, race, etc. In language models, these biases are found in the word vector representations due to the (human-introduced) bias from the original corpora. Learning Fair Representation focuses on reducing the bias by reducing the semantic latent distance between biased words in the direction of the bias-axis.</li></ul><p>While these techniques work well for simple &amp; direct bias, they do not do well in dealing with a bias that is spread across highly correlated features. But in the real-world, human-introduced unconscious bias is the most simpler bias that does not involve too many attributes. What we can eliminate at this stage is still of high value and reduces the unnecessary stress on the downstream processing.</p><h3>Model build phase</h3><p>At the model build phase, bias removal is usually handled as part of the build process itself. One of the most straightforward approaches would be to have a fairness penalty integrated into the loss function. Another is to use a Generative Adversarial Network (GAN) approach to reduce the bias. This would require a discriminator network to be trained in tandem with the predictor network to reduce the impact the protected attribute has on the prediction. While the discriminator tries to identify the protected variable, the predictor tries to adjust the weights to obfuscate the protected feature. It is claimed that this approach also minimizes the fairness-accuracy trade-off better.</p><h3>Deployment management (AIS) phase</h3><p>Testing for bias in the ML model is a functional aspect, not non-functional. While some of the standard practices described in the Acceptance Testing section on <a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-1-d45259ee7613">Part 1</a> will come in handy for fairness testing, it is advisable not to think of this as a separate stage in DSLC and keeping it fully integrated with the functional test strategy. Choice of the right data sampling strategy based on potential bias in the ML model and proper fairness metrics should be done at this phase to have the most effective outcome.</p><h3>Deployment management (ILS) phase</h3><p>A live ML model has to be continued to be monitored for optimum behavior during its lifetime. This is very much part of the standard operating process of live-model maintenance. Quality of live-model performance is a combination of prediction accuracy metrics and fairness metrics. For ML models performing in a highly regulated environment, just monitoring aggregate metrics is not sufficient. Cohort-level sampling for individual predictions should be done, assessed for ML model fairness and the case would have to be sent for manual intervention on what looks like unfair/extreme cases. Manual actions will have to be fed back into the ML model in subsequent training cycles. Governance for this mini-cycle needs to be of the highest level as the ML model behavior can be modified with the introduction of new bias over a period of time.</p><h3>Key takeaways</h3><ul><li>As fairness judgment is finally done by humans, it is highly recommended that these metrics are chosen in line with the expectations of the reviewing stakeholder</li><li>Bias removal techniques to be applied judiciously across all phases. Fairness-performance trade-off has to be kept in mind</li><li>Choice of the right data sampling strategy and proper fairness metrics are very important to measure ML model fairness</li><li>ML Ops should include checking for bias continuously and action to be taken in case of suspected unfair predictions.</li><li>Effective governance should be in place to avoid feedback-retraining cycles pushing the ML model behavior in the negative direction</li></ul><p><em>We will be covering the Security aspects of DSLC in </em><a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-3-c660b885233c"><em>part 3</em></a><em>. Acknowledgment and reference at the end of part 3.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2643c144a2a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/high-quality-machine-learning-part-2-2643c144a2a7">High Quality Machine Learning — Part 2</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High-Quality Machine Learning — Part 1]]></title>
            <link>https://medium.com/codex/high-quality-machine-learning-part-1-d45259ee7613?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d45259ee7613</guid>
            <category><![CDATA[explainable-ai]]></category>
            <category><![CDATA[ml-lifecycle]]></category>
            <category><![CDATA[ai-strategy]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 08:00:46 GMT</pubDate>
            <atom:updated>2021-01-11T11:19:58.004Z</atom:updated>
            <content:encoded><![CDATA[<h3>High-Quality ML — Part 1 — Functional Validation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ttN4JlKjz_lfVWbG" /><figcaption>Photo by <a href="https://unsplash.com/@altumcode?utm_source=medium&amp;utm_medium=referral">AltumCode</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the last year, there is a greater focus from the industry to move Machine Learning (ML) models out of the labs to real-life deployments. In their love of building cooler and cooler ML models, ML teams have not paid sufficient attention to some of the critical Software Engineering aspects that we have learned the hard way in the last decades. An ML model that can be taken as part of business software should be of high quality (functionally), robust, compliant, and explainable. This article is a quick tour of these aspects that define quality in the data science lifecycle (DSLC).</p><p>In practice, DSLC has been looked at as three mini lifecycles — data management, model build, and deployment management. In this article, I am breaking the deployment management phase further into two sub-parts — Acceptance into service (AIS) and In-life service (ILS). AIS includes the necessary independent validation &amp; verification functions like integration testing, business acceptance testing, etc. whereas ILS is more of an operations function maintaining &amp; monitoring the ML model in the production system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l3QM5F2EOD5Tm-kBbLo84g.png" /><figcaption>DSLC Phases</figcaption></figure><p>In an enterprise setup, typically no valuable project is one-off. An application delivered would have to be maintainable and continuously developed over a long period of time. No single component on its own can deliver the business value. DSLC should be designed with well thought out configuration management plan for long shelf life for all the project artifacts. Even though we will not be explicitly discussing them, these fundamental aspects must be kept in mind for the rest of this discussion.</p><p>Following broad aspects should be part of the DSLC for taking an ML model live.</p><ul><li>Functional validation — Ensure the functional performance of the ML model through adequate testing including unit, integration, business acceptance testing. Code-level validations are also an essential part of the end to end validation strategy.</li><li>ML Fairness: ML model is fair and favors or disfavors no single group or collection of groups</li><li>Secure DSLC: Data Science lifecycle follows secure data and model building practices</li></ul><p>The above three requirements in addition to Data Privacy (which we are not covering in this article) fundamentally form the quality foundation of an ML model. Let us look at them individually.</p><h3>Functional Validation</h3><p>Early identification and handling of issues are essential to keep the cost of quality at optimal levels. A data engineer’s view on quality will revolve around standard data quality measures. Ask any ML model engineer about testing — the answer will mostly involve test and validation data sets. But DSLC has to provide holistic quality assurance to the delivered ML model.</p><h3>Data management phase</h3><p>As part of the data pipeline activities, data engineers have been including the necessary checks to ensure basic data quality goals like duplicate checking, missing values, etc. Apache Nifi and Airflow for example have validator mechanisms in place. Testing requirements of this phase are more mature compared to other phases due to ongoing BigData/BI/Analytics projects. The current focus is to move away from batch-mode thinking and bring the Data Management phase as close to CI/CD requirements as possible. In the last couple of years, specialized frameworks like Great Expectations and Tensorflow Data Validation (TFDV) have been built with a focus on early testing of data. These frameworks are built with specialized testing features while bringing the necessary separation of validation requirements from the ‘programming’ part of the data pipeline.</p><h3>Model build phase</h3><p>An essential step that would reduce nightmare diagnostic runs during model build time would be to check the data before starting with ML model training. While a level of assurance on data quality should have been done during ingestion, data would have passed through many levels of transformation in the data pipeline to get to this point. Defensive programming at this stage is highly recommended with checks like data shape validations, schema checks, data anomaly, etc. These can be achieved with a mix of inline programming using python code and data library function calls — eg. TFDV functions like <em>display_anomolies/validate_statistics</em>.</p><p>Build time validations with the test dataset ensure that the ML model works within the constraints of the original data distribution. An ML model’s readiness to be promoted from development to production does not depend only on the aggregate performance metrics like F1 score, AUC, ROC, etc. Theoretically, a valid scenario could be over-represented in the failures even in a high performing ML model. Only when the data scientist studies the result and the associated test data (sample by sample) could she/he find this skew. This very important aspect of manually validating ML model performance is more times skipped by the ML engineers.</p><h3>Deployment Management — AIS phase</h3><p>Integration testing: In projects where an ML-based application replaces an existing non-ML application, the rule of thumb approach for integration testing should be that success criteria do not have to be changed on account of the ML introduction. Any change at the test case level to accommodate ML introduction will have to be clearly analyzed and signed off by the test manager.</p><p>Acceptance testing: The real value of acceptance testing comes when the end-user develops a level of trust with the application before its launch. Developing trust with an ML-model-at-core application might be more difficult. Due to its non-deterministic nature, an ML model-based system might look too temperamental as compared to a traditional, programmed one. The most preferred approach is to give the user a way to play around with the ML model through simple-to-use interfaces that give her/him an intuition on the ML model behavior. Behavior can be inferred by letting the user change the feature values within understood limits (create controlled perturbations) to see the impact on the predictions. If the user creates a perturbation expecting the inference to change from the original prediction, the behavior <em>might be</em> a cause for concern. Italicization is intentional to mean that unexpected ML model behavior need not be an issue in all cases. Coupling this kind of experiment with ML model explainability will get the user to develop a deeper appreciation of the working of the ML model and develop confidence in the new system. IBM’s AIX360 is a fantastic framework for this. In addition to these, setting up a way to run counterfactuals is another way to peer into the mysterious workings of complex ML models. Google’s What-if tool and Cortex CertifAi are two tools that provide a nice framework for achieving this objective.</p><h3>Deployment Management — ILS phase</h3><p>Inference time data input has to be continuously assessed as well. Checking for training-serving data distribution skew is something that can help identify the problem before it hits the deployed ML model. For making this assessment, we need to have a continuous comparison of inference data against the baselined training data linked with the live ML model. A trend on the skew might provide a measure of drift over a period of time and help take necessary action before the system falls over. TFDV provides handy <em>generate_statistics</em>/<em>validate_statistics</em> functions to create the training baseline and validate the inference data. For unstructured data, newer approaches using histogram &amp; centroid based baselines are starting to find use in this area.</p><p>Usage of initial live testing like A/B, Multi-Arm Bandit, Canary testing, etc. before full-fledged roll-out is now getting to be more prevalent and maturing fast. As the real test of ML model performance is with live data, it is highly advisable to set up these kinds of live randomized controlled experiments wherever feasible. The success of these tests clearly depends on the selection of KPIs, cohort selection, and length of testing. As the data is live and real-time, it might be tempting to react to the metrics quickly. But due to the statistical idiosyncrasies which is the main reason why we take up doing these types of testing in the first place, it is better to let the tests run their course, study the results and take action.</p><h3>Key takeaways</h3><ul><li>Usage of specialized testing frameworks like Great Expectations &amp; TFDV during the data pipeline phase highly recommended</li><li>Build time validation is a combination of ML model performance metrics and manual checks of failure mode scenarios to ensure proper ML behavior</li><li>During the acceptance, testing phase business users should be given the right tools to play around and develop trust with ML models</li><li>A proper ML ops strategy includes monitoring for data drift using baselined training data and live inference data to prevent live ML model failure</li><li>Use randomized control experiments to ensure the ML model performs well under live traffic conditions</li></ul><p><em>We shall be covering ML Fairness and Secure DSLC in parts </em><a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-2-2643c144a2a7"><em>2</em></a><em> &amp; </em><a href="https://mukund-kannan.medium.com/high-quality-machine-learning-part-3-c660b885233c"><em>3</em></a><em>. Acknowledgment and reference at the end of part 3.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d45259ee7613" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/high-quality-machine-learning-part-1-d45259ee7613">High-Quality Machine Learning — Part 1</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI that Glitters is Not…]]></title>
            <link>https://mukund-kannan.medium.com/ai-that-glitters-is-not-af7ffb39fdf1?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/af7ffb39fdf1</guid>
            <category><![CDATA[natural-language]]></category>
            <category><![CDATA[risks-of-ai]]></category>
            <category><![CDATA[ai-implementation]]></category>
            <category><![CDATA[ai-impact]]></category>
            <category><![CDATA[financial-scam]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 09:16:34 GMT</pubDate>
            <atom:updated>2020-07-06T12:30:36.488Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xuQXDsBqGNk_reHsC0AkPw.jpeg" /></figure><p>While I was looking around for news about the Kingold Jewelry scam that is raging in China, I came across this article from Marketing Sentinel by an author called Ulysses Erickson.</p><p>For those that might have missed this news item, a quick synopsis: Wuhan based Kingold Jewelry is one of the largest producers of 24 Carat pure gold jewelry in China. Few creditors who had lent money to Kingold, on the back of 83 tonnes of pledged gold came to be reminded of the old aphorism when they saw the glittering bars were nothing but gilded copper alloy!</p><p>When I stumbled upon the article curiously titled “<a href="https://marketingsentinel.com/2020/07/02/kingold-jewelry-inc-kgji-has-great-growth-outlook-for-2020/">Kingold Jewelry, Inc. (KGJI) has great growth outlook for 2020</a>”, I decided to be a victim of (what I thought as) click-bait title. But what I found was an article which seemed predicated on some basic heuristics and devoid of common-sense financial knowledge. Even a finance novice like me knows that a company that is in the midst of a integrity-eroding, mega scam whose value is more than its total asset value cannot have a great outlook — that too in the same year of the scam! A bit more browsing around the Market Sentinel website and particularly Ulysses Erickson articles leaves me to believe that this is an output of a NLG powered automaton.</p><p>In the enterprise context, Natural Language Generation (NLG) which is described by Gartner as an AI domain that synthesizes “textual content by combining analytic output with contextualized narratives” leverages the clever use of templatized, situational text combined with AI to produce some very smart articles. Now it is no secret that some of the most reputed content creators in the business are dependent on NLG. But the usage of NLG based systems would have to be supported by validation of the inputs to the system and the unsexy human editorial processes for the output. I am very sure that most NLG based systems have a form of the former. In this case those validations have proven to be inadequate — scams are not black swan events. While technology is leveraged to produce a human-like product, having humans in the loop is a must as a safety net.</p><p>Good reminder for all of us on why proper guardrails are a must for AI based systems, even though the technology is growing leaps and bounds.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af7ffb39fdf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Work From Home — some practical tips]]></title>
            <link>https://mukund-kannan.medium.com/work-from-home-some-practical-tips-4ad900ea4780?source=rss-e519163e4c8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ad900ea4780</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[future-of-work]]></category>
            <category><![CDATA[work-from-home]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[covid19]]></category>
            <dc:creator><![CDATA[mukund kannan]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 12:27:03 GMT</pubDate>
            <atom:updated>2020-03-29T12:27:03.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>Work From Home — some practical tips</h3><p>Post-Covid world is sure to look different for most of us. As of now, we can only pray and hope that the scars it leaves are not going to be too deep.</p><p>One of the things that I am sure will change is our work patterns. Most of us have been confined to working from home these days. What we feel as forced change will quite possibly become the normal in the future — at least for a good chunk of the IT folks. To be successful in the new normal world, there will have to be some change in our work behaviors.</p><p>1. Electronic communication — Communication over email will become even more than before. ‘Express-watch for reaction-apply correction’ feedback cycle is obviously the longest in the email based communication. ‘Assume positive intent’ mantra is a must for a team to stay together. Do not hesitate to call for clarification. But be mindful of wasting people’s time talking vs. getting message across. MS Teams, slack are wonderful tools — as long as we know how to leverage them properly</p><p>2. Face time — While emails, chat, voice calls will rule majority of the communication space, closest we get to the other person is through meetings face to face. Use the video call facilities where possible. Don’t forget that we are still viewing people at their home environments — so please confirm first that other party/parties are ready to appear in the video.</p><p>3. Going to work — Some people advise dressing up for work rather than continuing in the same home attire through the day. This is a must with regular video meetings. But main thing is to do whatever brings in a sense of separation.</p><p>4. Work space — Create a separate work space, even if it is just a desk and a chair. Going to this place is going to work during these days. This is a good way to bring in work/home balance somewhat.</p><p>5. If you work as a team, pay more attention to the joint-artifacts you create. Think of it as hand-off which has to be of the highest order. check out this blog (https://www.allaboutlean.com/japan-relay-2016/) on Japanese relay race team winning silver medal just focusing on baton exchange. Document well — think from the receiver’s perspective and focus on key points reducing the fluff.</p><p>6. Avoid long meetings. This is probably the most difficult as the whole team has to learn this as a technique. But very important as attention span happens to be much less on remote conferencing. It is certainly possible with better upfront preparation. People have to enter with clear objective and leave with sense of purpose &amp; accomplishment.</p><p>7. If you have to attend a long meeting: During those unavoidable times when we have to be in long calls, learn to focus. Close all the other windows in your computer, put a do-not-disturb in your chat applications and make notes (if possible on paper).</p><p>One of the positive things that seems to be circulating among all the gloomy Covid stuff is how Newton’s best work happened while working from home. With right practices, we can certainly be lot more productive.</p><p>Note (for post-Covid times): I am in no way recommending to do away with physically co-located working. High performing teams have a shared purpose and great bonding. We are genetically predisposed to build bonding in physical proximity. How much ever the tools try to get us closer in the cyber work place, face to face meetings cannot be avoided. Teams should plan to work together from company facilities on a scheduled basis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ad900ea4780" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>