<?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 Nicholas Beaudoin on Medium]]></title>
        <description><![CDATA[Stories by Nicholas Beaudoin on Medium]]></description>
        <link>https://medium.com/@nick.s.beaudoin?source=rss-2acbae65f9b3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RUpOXi3XhYQLjIxsI2QMGA.jpeg</url>
            <title>Stories by Nicholas Beaudoin on Medium</title>
            <link>https://medium.com/@nick.s.beaudoin?source=rss-2acbae65f9b3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:40:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nick.s.beaudoin/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[Gen AI Series: Alternatives]]></title>
            <link>https://medium.com/eviden-data-science-community/gen-ai-series-alternatives-c71778bf029?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c71778bf029</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 18:44:24 GMT</pubDate>
            <atom:updated>2023-06-27T18:48:26.153Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is a continuation of the Gen AI series with particular attention to Large Language Models (LLM). This article discusses alternatives to Gen AI and the questions organizations should be asking before implementing a Gen AI capability. The first question organizations should ask themselves when evaluating ML solutions is “Are there simpler solutions available to me?” Like most organizations, you are probably getting bombarded with decks that have an image of a robot looking at a computer as “slide 1.” (Because nothing signals AI knowledge better than a pic of a Terminator-style robot. Please see the image below). These decks look savvy, dazzling, and full of incredible action-word jargon. But does your organization really need powerful LLM tools? Do you really need that proverbial Ferrari to run errands around town when a Honda Civic can get you to the grocery store in the same amount of time and with much less overhead?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*36T9Ak8WCTzmnZ05" /><figcaption>99% guarantee that a Gen AI slide deck will have a similar robot on “slide 1”. Notice the AI action words! <a href="https://www.analyticsvidhya.com/blog/2023/03/an-introduction-to-large-language-models-llms/">Source</a></figcaption></figure><p><strong>Why not “Gen AI All things?”</strong></p><p>LLMs such as Google’s <a href="https://ai.googleblog.com/2022/04/pathways-language-model-palm-scaling-to.html">PaLM</a>, Azure’s <a href="https://openai.com/blog/chatgpt">ChatGPT</a>, and AWS JumpStart’s use of <a href="https://cohere.com/">Cohere</a>, <a href="https://huggingface.co/">HuggingFace</a>, and <a href="https://www.ai21.com/studio?utm_source=google-search&amp;utm_medium=cpc&amp;utm_campaign=Studio_Search_US_EN_Singup_Branded&amp;ad_set_name=AI21_Studio&amp;utm_term=ai21%20labs&amp;gad=1&amp;gclid=CjwKCAjwkeqkBhAnEiwA5U-uM_yZ6ZEmmvOkeNQLIqw9gWTXgR_1o5aojvUKOHg-hAy1QvZ8DrEZgxoCEFAQAvD_BwE">AI21</a>’s models make using Gen AI appear straightforward and simple. Especially when using a managed service that allocates computed resources, ties in storage, seamlessly links IAM and security credentials, and lays template code to put pipelines in place. Managed services are fantastic! But managed services are expensive. If you are a smaller business and your use case can be deployed on a traditional ML solution, then it may be time to evaluate your options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/0*roMInYYvbaVwa6eS" /></figure><p>There are terrific resources for text extraction, classification with text inputs, and other solutions leveraging LLMs. For example, AWS offers a <a href="https://aws.amazon.com/bedrock/">Bedrock</a>, which is using an LLM under the hood to classify text. Time will tell if these models outperform more traditional document intelligence solutions like Optical Character Recognition (OCR) coupled with a classification layer using <a href="https://medium.com/@nick.s.beaudoin/searching-for-lost-nuclear-bombs-bayes-theorem-in-action-bf4671ea035">Naive Bayes</a> or a tree-based solution like <a href="https://xgboost.readthedocs.io/en/stable/">XGBoost</a>. Or if AWS’s <a href="https://aws.amazon.com/comprehend/">Comprehend</a> platform for document intelligence is a better solution to using AWS Bedrock. As companies adopt one or the other, more specific use cases will evolve to which platform, traditional ML or managed LLM services, are better suited.</p><p>These are the questions that organizations should be thinking about when deciding whether to leverage an LLM over traditional machine learning models:</p><ol><li>How risk-averse is your organization?</li><li>What is the model’s latency?</li><li>What is the marginal cost per inference call?</li><li>Understand the difference between inference for traditional ML vs LLMs</li><li>Is explainability important to you?</li><li>What is the scope of the AI application?</li><li>What is the time to value?</li></ol><p><strong>Can I solve this problem with a traditional ML approach?</strong></p><p>It is important to define why your organization is using machine learning to solve a business use case. In the world of machine learning, the risk is often associated with the degree one’s model gets answers wrong. This article is not geared to a deep dive into the trade-offs between recall and precision, but for those interested in these topics where false negatives and false positives drive decision-making, I highly recommend the blog series from Dr. Jason Brownlee on “<a href="https://machinelearningmastery.com/">Machine Learning Mastery</a>.”</p><p>If a model’s accuracy is paramount to your organization and are leading a risk-averse solution, such as making healthcare decisions that impact people’s lives, then your decision-making will be different than an organization that is more comfortable with risk. Companies that work in fraud detection for credit cards tend to be comfortable with a model that throws false positives, allowing the company to reach out to alert users where there is little downside other than an annoying text. Whereas companies that deal with HIPAA-related information, such as health insurance, will be more prone to avoid false positives that can have life-impacting results if a client is notified.</p><p><strong>What is the model’s latency?</strong></p><p>When evaluating ML solutions, how quickly do you need to get responses from the user? I recall from a client engagement in the entertainment industry, a VP saying that 5 seconds is an eternity for a user to wait for a dashboard to load. Websites that leverage HTML, CSS, and JavaScript can return an API call in nanoseconds, ensuring that the ML model’s inference time (the time it takes to send the user-generated input to the model weights, via API), calculates a prediction, and send it back to the frontend for the user. This takes time. Time makes the model look ineffective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*XrFwGCHSXmcGGcox" /><figcaption>Did someone say “latency”? <a href="https://variety.com/2016/film/reviews/zootopia-film-review-1201703504/">Source</a></figcaption></figure><p>More complex models require longer time at inference, thus longer wait times for clients. If the model is producing predictions in timed intervals (batch processing, aka offline inference) then this doesn’t matter. You can schedule the batch predictions to run during low-traffic periods such as automating actions during graveyard shifts. But if your predictions need to happen in real-time (online inference), then model latency matters. To further add to this dilemma, the longer the text output is in an LLM, the longer the wait for results. Again, more complex models take more time. Your organization needs to determine how time is factored into the user experience.</p><p>Currently, there is little information from companies developing LLMs as to how Service-Level Agreement (SLA) will be produced to give explicit promises to latency. At the time of this writing, <a href="https://huyenchip.com/2023/04/11/llm-engineering.html">OpenAI</a> has not provided an SLA for their GPT-powered models.</p><p><strong>What is the marginal cost per inference call?</strong></p><p>Each time the user calls a model’s API, it costs money. If you are hitting an API that is a simple ML algorithm, such as a tree-based model like random forest or XGBoost, then the cost is minimal. You simply have to take the model weights and perform a simple calculation to get the prediction. If you are using a clustering algorithm that needs to use the entire dataset at the point of inference (called a “greedy” algorithm), then your costs will be higher since you are scanning the dataset at each inference point.</p><p>If you are calling an LLM, then you could be paying as high as $0.25 for each inference call. Adding to that, with prompt chaining, many inference calls are a collection of lower-level API calls, acting in an additive manner to create one larger call to the model. Include prompt management for in-context learning, such as <a href="https://python.langchain.com/docs/get_started/introduction.html">LangChain</a>, throw in vector database storage using open-source solutions such as <a href="https://zilliz.com/what-is-milvus?utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=WP_Milvus_Search&amp;utm_content=WP_Milvus_TKAG&amp;utm_term=milvus&amp;utm_campaign=WP_Milvus_Search&amp;utm_source=adwords&amp;utm_medium=ppc&amp;hsa_acc=3636806625&amp;hsa_cam=20033301076&amp;hsa_grp=151285141111&amp;hsa_ad=656191017493&amp;hsa_src=g&amp;hsa_tgt=kwd-2942447257&amp;hsa_kw=milvus&amp;hsa_mt=e&amp;hsa_net=adwords&amp;hsa_ver=3&amp;gad=1&amp;gclid=CjwKCAjwkeqkBhAnEiwA5U-uM5EfuqmUfG2iaiQxzzAFQLMk0JCR1i_YEdx4qyYqUraGwiZMK5E0nhoCDPkQAvD_BwE">Zilliz</a> (Milvus), and <a href="https://www.trychroma.com/">ChromaDB</a>, paid solutions such as <a href="https://www.pinecone.io/">PineCone</a> and <a href="https://www.deeplake.ai/">DeepLake</a>, or managed solutions like GCP <a href="https://cloud.google.com/vertex-ai/docs/matching-engine/overview">Matching Engine</a> and AWS’s <a href="https://aws.amazon.com/kendra/">Kendra</a>, then these all add up.</p><p><strong>Understand the difference between inference for traditional ML vs LLMs</strong></p><p>As previously stated, when a traditional classification ML model is pushed to production, the model weights are saved in a serialized file, such as a <a href="https://docs.python.org/3/library/pickle.html">pickle file</a>. These files are stored in a place that is easily accessible for the model to access and run in a reproducible manner, such as a <a href="https://www.docker.com/">Docker</a> container. When the model is called for prediction, the inputs go through a data transformation that allows the data to “talk” to the model weights. The model (algorithm) then multiplies those weights by the transformed user inputs. Once those calculations are complete, then the model sends those results back to the user interface, normally through a <a href="https://www.ibm.com/topics/rest-apis#:~:text=the%20next%20step-,What%20is%20a%20REST%20API%3F,representational%20state%20transfer%20architectural%20style.">RestAPI</a>. The cost for the inference call is straightforward: data transforms, weight calculations, and data ingress/egress fees.</p><p>Traditional supervised ML models have different behavior at the point of inference that can have different costs. When users call the API via a frontend interface, the data still needs to go through a transformation so the data inputs to the model can interact with the algo’s calculations. The divergence between classifications is there are no model weights sitting in a file for the model to hit. Furthermore, unsupervised ML models are known to be greedy, meaning they need to take all the training data, calculate the clusters/groupings, and then spit out a prediction. By scanning the data and recalibrating groupings, the new prediction takes more time, and thus, more cost. The predictions are sent back to the user interface through the API and presented to the user. These affect the cost of the prediction returned.</p><p>Large Language Models (LLMs) typically are trained for days, weeks, and months depending on the size of the training dataset. (For more information on training datasets used in LLM architecture, please refer to the following <a href="https://medium.com/@nick.s.beaudoin/large-language-models-101-a64847e17a3f">Medium</a> post). When the user inputs a prompt for prediction, the LLM has a few moving parts that diverge from traditional methods. The user prompt text is sent to an embedding model. This model takes the word strings and converts them to character tokens. These tokens are in the form of float numbers nested between 0 and 1. The embeddings are then compared to the vector database embeddings where the trained model artifacts are located. Often referred to as semantic space, the vector database holds embeddings in the form of vectors which can be queried to look for similarities by leveraging a clustering algorithm most notably <a href="https://ignite.apache.org/docs/latest/machine-learning/binary-classification/ann#:~:text=An%20approximate%20nearest%20neighbor%20search,good%20as%20the%20exact%20one.">Approximate Nearest Neighbors </a>(ANN). <em>Approximate</em> is used instead of explicit because scanning the entire vector database for exact matches would not be time and cost-efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QcozcJEofqz2MtRP" /><figcaption>Semantic space (vector DB) looks like it came from <em>Tron. </em><a href="https://twitter.com/Adarsh____gupta/status/1652543746364567554">Source</a></figcaption></figure><p>Once a match is found in this semantic space, a result is produced to the model. The model then decides which response to select based on a predicted probability score. If the user is chaining prompts together, such as through LangChain, the model will store these prompts as “context” to call in local memory, similar to how the vector database returns results. Once the model has returned predictions, they are returned to the user in the form of text. Since the LLM’s inference architecture is more complex and the training process more costly, the marginal cost of inference is much higher.</p><p><strong>Is explainability important to you?</strong></p><p>Some businesses are required to explain how models work, specifically those in the insurance and financial sectors. With new laws developing around both traditional and generative ML, model explainability is an area that many companies are keenly interested in. However, there are businesses that may not need explainability, particularly when it comes to decisions that don’t directly affect people’s lives. Model explainability becomes more difficult as model complexity increases, often convoluting the cost of model development through new explainability tools. This should be an area that the business should be aware of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*Q5jPKUMycT7qwsfI" /><figcaption>Model explainability on some LLMs. <a href="https://pharmafactz.com/list-of-black-box-warnings/">Source</a></figcaption></figure><p><strong>What is the scope of the AI application?</strong></p><p>Bringing an LLM to production takes time, similar to a traditional machine learning solution. When done, it is just a minor part of a well-oiled process within an MLOps pipeline (machine learning operations). Building both traditional and Gen AI solutions within an MLOps infrastructure allows for ease of scaling, repeatability of results, fast iterations for data scientists to experiment, and the lowering of technical debt. However, MLOps take time. Organizations should understand the type of solution they want to build first. The following are product scopes that need to be determined before building the traditional ML or Gen AI solution. Needless to say, one should always have a well-defined process for adding features to the scope of the AI application to avoid scope creep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*5Xfv0VVVouXCS9JE" /><figcaption>Maintain clear definitions of what the product will look like before the build phase to avoid scope creep. <a href="https://brainleaf.com/blog/management/what-is-scope-creep/">Source</a></figcaption></figure><ul><li><em>Proof of Concept:</em> The POC is a toy example of a working AI solution. Normally this runs in a local environment, such as on a data scientist’s local browser window, and lives in either a Jupyter Notebook or an undeployed snippet of code. The POC shows general functionality but will lack many of the features that are desired for organizational deployment.</li><li><em>Minimal Viable Product: </em>The MVP is a deployable version of the POC. The MVP should be used for gathering buy-in in an organization to sponsor the development of a fully-built solution that can be taken to production. Key elements in an MVP are the ability for users to interact with it in the organization’s cloud environment, local network, or VPC.</li><li><em>Soft Launch Product:</em> Soft launches are when a development team pre-selects a group of users to test the application in an organization’s environment. Sometimes referred to as the Quality Assurance (QA) portion of the development, the QA process is a great time to collect user feedback and improve on the application. The time this takes can range from days to months.</li><li><em>Deployed:</em> If following proper MLOps guidelines, the AI application should be deployable via a simple RestAPI. However, security and infrastructure teams need to be actively aiding in the deployment of the application since they will be the gatekeepers to future use.</li></ul><p>Needless to say, each of these steps takes time. There are areas that further complicate timelines by how involved the data science portion, infrastructure development, data engineering tasks, and organizational governance constraints are. These can include, but are not limited to, the following:</p><ul><li>Data engineering (ETL, processing, querying, prompt engineering, prompt templates, feature engineering)</li><li>Feature store curation</li><li>Modeling (traditional ML algorithms, fine-tuning LLMs, hyperparameter tuning)</li><li>Repository management</li><li>Container registration and orchestration</li><li>Model housing (model registration and tracking)</li><li>Model performance tracking</li><li>Governance templates</li><li>Infrastructure as Code (IaC) components</li><li>Pipeline orchestration</li><li>Security: API endpoint and VPC network (subnets per IPs)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*DCs7bWanH7VUCz-X" /><figcaption>Where does MLOps fit? <a href="https://neptune.ai/blog/mlops-tools-platforms-landscape">Source</a></figcaption></figure><p><strong>What is the time to value?</strong></p><p>Taking into consideration the previous scale of your organization’s AI application, how long does it need to run to yield results? Going further, how long will it take before those results yield value for the organization? Normally, time-to-value encompasses two areas:</p><ol><li>Time to train</li><li>Time to results</li></ol><p>Time to train refers to how long the model takes to complete its training and tuning operations and be ready for use. Time to results refers to how long the model needs to sit in production to gather user data and feedback, in the form of API calls, to provide business value. For example, when using cloud provider AI platforms, such as Google’s <a href="https://cloud.google.com/solutions/retail-product-discovery">Discovery Retail API</a> (a real-time recommendation engine), the AI app needs to be collecting user data for at least <a href="https://cloud.google.com/retail/docs/user-events">one month</a> to yield accurate predictions. Furthermore, the model needs to train for <a href="https://cloud.google.com/retail/docs/manage-models#:~:text=The%20Retail%20API%20uses%20the,continues%20to%20work%20as%20usual.">2 to 4 days</a> before being deployed. Many of these larger cloud-based models will require specific time frames to collect enough user data to make predictions. On the other hand, smaller ML models can be trained in minutes, but with far less accuracy and for smaller use cases. Depending on whether your organization is deploying a robust, managed cloud AI solution through AWS, Google, or Microsoft, or creating the infrastructure for deployment in-house, time-to-value calculations should be taken into account well before work begins.</p><p><strong>Last Word</strong></p><p>Deciding when and where to use Gen AI, particularly LLMs, is a large task for most organizations. Companies need to think about a variety of different factors when considering the gains from LLMs. While not all use cases are appropriate for LLMs, there are certain areas that shine when leveraging Gen AI. Most notably, those that involve language and text inputs. These areas are developing at a rapid pace and the benefits, often at scale, that are occurring in the textual space are at a logarithmic scale.</p><p>Special thanks to <a href="https://www.linkedin.com/in/anurag-bhatia/">Anurag Bhatia</a>, <a href="https://www.linkedin.com/in/steven-pais-4045483/">Steven Pais</a>, and <a href="https://www.linkedin.com/in/rishi-sheth10/">Rishi Sheth</a> for the technical feedback during the writing process.</p><p><em>Author’s note: This article was not written by Gen AI.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c71778bf029" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eviden-data-science-community/gen-ai-series-alternatives-c71778bf029">Gen AI Series: Alternatives</a> was originally published in <a href="https://medium.com/eviden-data-science-community">Eviden Data Science and Engineering Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning Post-GDPR: My conversation with a Spotify chatbot]]></title>
            <link>https://medium.com/@nick.s.beaudoin/machine-learning-post-gdpr-my-conversation-with-a-spotify-chatbot-334301646bc7?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/334301646bc7</guid>
            <category><![CDATA[gdpr]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[ai-regulation]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Mon, 19 Jun 2023 19:18:30 GMT</pubDate>
            <atom:updated>2023-06-19T19:19:32.832Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Author’s Note: This was a post done in 2018. I am re-posting onto Medium since AI regulation will build upon the groundwork that GDPR laid out.</em></p><p>I have a dilemma. I love Spotify and find their recommendation engine and machine learning algorithms spot on (no pun intended). I think their suggestions are fairly accurate to my listening preferences. As well as it should be. I let them take my data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*0CZS0mwV66-2Qa_XWLJwvg.png" /></figure><p>Spotify has been harvesting my personal likes and dislikes for the past 6 years. They have been collecting metadata on what music I listen to, how long I listen to it, what songs I skip and what songs I add to my playlists. I feel like I have a good relationship with Spotify. Then came the emails. Service Term Agreements, Privacy Changes, Consent Forms. Something about GDPR.</p><p>Which brings me to the topic of discussion, what is GDPR and how will services that rely on our metadata to power algorithms and machine learning predictions function in a post-GDPR world? First, let’s back-track a bit for a second. Over the past week, most people’s inboxes have looked like this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*brGHodnOcyA5YdcmJG1CIQ.png" /></figure><p>Or you feel you have won an all expense paid “phishing” trip for your gmail account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*mf1rhPz9F3zfu0DqGBzufQ.png" /></figure><p>Nope, your email hasn’t been hacked, but something monumental has occurred in the data world that has been years in the making. Two years ago, the European Union Parliament passed a law to have strict user-friendly protections added to an already stringent set of EU data regulations. The GDPR stands for the General Data Protection Regulation and went into force today in the member countries of the European Union. There are a number of things that GDPR seeks to accomplish, but the overarching mood of the regulation seeks to streamline how a user of a good or service gives consent to an entity that uses their private data.</p><p>Now I hear you saying, “I thought that GDPR was just an EU regulation, how does it affect me as an American? I don’t like this European way of things and this personal rights stuff.”</p><p>Well, you are correct, it goes into effect May 25, 2018 (today or in the past, if you are reading this now), but any organization that has European customers will need to abide by it. Since most organizations have European customers, everyone is jumping in and updating their privacy policies, begging for your consent in your inbox.</p><p>“Who cares? Aren’t companies going to use my data anyways without me knowing?” Well, not anymore. Not only does GDPR allow individuals and groups to bring suit against companies that are in breach of GDPR, but these companies can be fined 4 percent of their annual global revenue. Yes revenue, not profit, and global revenue at that. Already today Facebook has been hit with 3.9 billion Euros and Google with 3.7 billion Euros in fines. <a href="https://www.theverge.com/2018/5/25/17393766/facebook-google-gdpr-lawsuit-max-schrems-europe">Source</a></p><p>In a book published by Bruce Schneider, <a href="https://www.amazon.com/Data-Goliath-Battles-Collect-Control/dp/039335217X"><em>Data and Goliath: The Hidden Battles to Collect and Control Your World</em></a> speaks to the deluge of data that has congested society’s machines. This data exhaust, as Schneider refers to it, has a plethora of extractable data, known as metadata. Metadata, while not linked to specific conversations you have on your phone or the text contents of your emails, is collected by organizations we use in our daily life. Facebook, Amazon, Google, Yahoo (yes, some of us still use Yahoo email), Apple all rely on gigantic server farms to maintain petabytes of saved metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*Lg4S1v4WuxzEg0RVkTB_vA.png" /></figure><p>Schneider refers to the information age being built on data exhaust and he is correct. Modern algorithms that power recommendation engines for Amazon, the phone towers that collect cell phone signals to show your location, the GPS inside your iPhone, and your Netflix account, all rely on metadata and the effective storage of, well, a boatload of data for lack of a better term.</p><p>Over the course of the past couple of decades, we have been consenting to privacy agreements that allow these companies, and companies like them, to use our data for purposes that we are not aware of. That is the reason for GDPR. This is where consent comes to play.</p><p>According to the New York Times, GDPR rests on two main principles. “The first is that companies need your consent to collect data. The second is that you should be required to share only data that is necessary to make their services work.” <a href="https://www.nytimes.com/2018/05/23/technology/personaltech/what-you-should-look-for-europe-data-law.html">Source</a></p><p>Broken down, here is Translating Nerd’s list of important highlights of GDPR:</p><ol><li><strong>You must give your consent for a company to use your data</strong><br><strong>2. Companies must explain how their data will be used</strong><br><strong>3. You can request your data be deleted</strong><br><strong>4. If there is a data breach at a company, they have 72 hours to notify a public data regulatory agency</strong><br><strong>5. You can request access to the personal data that is kept</strong><br><strong>6. You can object to any processing of your personal data in any situation that arises</strong><br><strong>7. Simply put, consent must be easy to give and easy to take away</strong></li></ol><p>So after receiving Spotify’s updated privacy policy terms in my inbox, I decided to contact a representative of my favorite music streaming company (her name is Joyce). Namely, I was curious if I failed to give my consent for Spotify to use my data, would their recommendation engine not have data from my personal account to provide those terrific suggestions that all seem to begin with Nine Inch Nails and regress slowly to somewhere near Adele. Regression to the mean perhaps? A conversation for another post perhaps or a comment on society’s love of Adele.</p><p>The conversation I had went like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gD_vJAPyAl_8WHN6ckqG1w.png" /></figure><p>As for most chatbots, sorry, Joyce, I was referred to a standard account term source. So I needed to do some more digging. I found that as stated in GDPR terms, I could deactivate certain features such as what data from Facebook is kept on me or using third-party sites to help target ads to me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNI8SEIY58ABaMDnsN7t6w.png" /></figure><p>But this isn’t enough, what I am curious about is can a machine learning algorithm like Spotify’s recommendation engine work without access to my data? And then I saw it, all the way at the bottom of their user terms in this <a href="https://support.spotify.com/us/article/data-rights-and-privacy-settings/?_ga=2.32978302.1752844458.1527303077-1493418971.1527303077">link</a>. A clear and definitive answer that no, to delete my personal data I would need to close my account, which means no Spotify or recommendations for Adele.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vvt5idWFifbilUknHYnwrg.png" /></figure><p>Simply put, Algorithms run on data. No data, no prediction. No prediction, no recommendation engine to suggest Adele. My intuitions proved correct, that data powers the machine learning algorithms we build. This should be obvious. Just as you need fuel to power a car, you need data from a user to run an algorithm. What GDPR ensures is that the data you are giving is used SOLELY for the service you requested. But it remains unclear how this is differentiated in the user agreement.</p><p>And this is exactly where GDPR places us as a society. How much data are we willing to give to receive a service? What if the service is enhanced with more personal data? We rely on the algorithms from recommendation engines to tell us what to buy from Amazon, to inform us what Netflix shows we would like, to help match us on social dating websites like OKCupid and Match.com, but that will require the full consent of the user to receive the full power of the predictive algorithm that drives these products and our cravings for smarter services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=334301646bc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gen AI Series: Bias]]></title>
            <link>https://medium.com/eviden-data-science-community/gen-ai-series-bias-2964a2b4daa3?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2964a2b4daa3</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[bias-in-ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 16:30:31 GMT</pubDate>
            <atom:updated>2023-06-13T16:56:10.170Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the past few months, there have been many explanations of the pros and cons of generative AI (Gen AI). From grandiose visions of AI overlords harnessing the powers of SkyNet, to the less doomsday-like approaches of embracing the free market and letting innovation lead the way. The call for a 6-month moratorium on Gen AI has been at the forefront of our 24-hour news cycle. Comparisons to the Ford Model T affecting replacing the job of the poor horseshoe blacksmith come to mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mh7MB4hDDMef06P-vWYR_w.png" /><figcaption>The call for a recent 6-month pause has gained <a href="https://www.google.com/search?q=ai+6+month+pause+news&amp;rlz=1C5CHFA_enUS972US972&amp;hl=en&amp;tbm=isch&amp;sxsrf=APwXEdcr2Et5cnKvkJM55e_lIwKZTywe8Q:1686674151181&amp;source=lnms&amp;sa=X&amp;ved=2ahUKEwjT3Ift1sD_AhUFO0QIHeIdA6YQ0pQJegQIBhAI&amp;biw=1440&amp;bih=718&amp;dpr=2#imgrc=da6fphHGE_3pMM">momentum</a></figcaption></figure><p>However, the foray into a complete AI narrative is not monolithic, it does not pervade our global narrative as a fight between good and evil. Depending on one’s technical, economic, and political leanings, there seems to be a narrative that fits each flavor of thought. Regulate, demote, stop, pause, inspect. These are all partial solutions to a much more complex problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhK1-MZhfohB_xV1TFgiJQ.png" /><figcaption>Gen AI is not a go or no-go question, there is nuance and dialogue needed in the <a href="https://www.youtube.com/watch?v=BY9KV8uCtj4">AI community</a></figcaption></figure><p>Gen AI is exciting and companies that are implementing it will no doubt provide a better and more timely service to their customers. This article is not about the benefits that any individual company seeks to gain, but rather, a community-level dialogue to the areas where Gen AI is apt to bring debate. The following areas dive into eight sections that I label <strong>BADASSES</strong>. These include:</p><ul><li><strong>B</strong>ias</li><li><strong>A</strong>lternatives</li><li><strong>D</strong>isinformation</li><li><strong>A</strong>ttribution</li><li><strong>S</strong>ecurity</li><li><strong>S</strong>iloing</li><li><strong>E</strong>xplainability</li><li><strong>S</strong>ensationalism</li></ul><p>As we learn more about the new technologies that present themselves each day, the new models, architecture, and infrastructure landscapes, understanding these 8 areas will become increasingly important for companies that are looking to leverage Gen AI gains. Various domains will touch upon different areas of these threads. Those Gen AI solutions directly affect people’s lives, regardless of the domain they fall into. The government domain (politics and national security) will worry more about disinformation, while academia will need to be more aware of attribution and sensationalism. My hope is that by touching these 8 threads, a more coherent understanding of Gen AI Ms in modern society will become more clear.</p><p><strong>Let’s Dig In!</strong></p><h3><strong>Bias</strong></h3><p>Bias is present in all elements of society. Our personal preferences and past experiences culminate into predisposed notions of what is correct. These preferences make their way into the types of news we follow, the clothing we wear, the information we absorb through social media, and the thoughts we have on how society should look and sound. These collective preferences have created the modern internet, embodied in the text and images that are stored on websites. Data is collected at a mass scale for the training of Gen AI solutions (see the ChatGPT model summary later). It is these preferences that are embodied in the Gen AI models and are returned as bias.</p><p>Large-scale data collection is nothing new. We have heard for years of the National Security Agency’s (NSA) ability to collect and store data. 10 years ago, it was reported that the NSA “touches” over <a href="https://medium.com/r?url=https%3A%2F%2Farstechnica.com%2Finformation-technology%2F2013%2F08%2Fthe-1-6-percent-of-the-internet-that-nsa-touches-is-bigger-than-it-seems%2F%23%3A%7E%3Atext%3DWhile%2520the%2520NSA%2520may%2520%2522touch%2Ctap%2520points%2520to%2520do%2520so.">29 petabytes of data daily</a>. In fact, their Utah data center is <a href="https://nsa.gov1.info/utah-data-center/">reported</a> to be able to store a yottabyte (one billion trillion megabytes). One can only assume that has increased at a logarithmic pace. In the private sector, most companies that have high processing capabilities collect data at an astonishing higher rate than before. The world’s largest retailer (WalMart), with over 20,000 stores worldwide, generates <a href="https://www.forbes.com/sites/bernardmarr/2017/01/23/really-big-data-at-walmart-real-time-insights-from-their-40-petabyte-data-cloud/?sh=161e0f366c10">2.5 petabytes of data</a> each hour! Data-centric companies are using data at a rate never before seen in historical records. So how does large-scale data collection affect the development of Gen AI?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BbbNRWwQUlm6YbmS" /><figcaption>National Security Administration <a href="https://medium.com/r?url=https%3A%2F%2Fnsa.gov1.info%2Futah-data-center%2F">Utah Data Center</a></figcaption></figure><p>As a technical background, ChatGPT-3 leverages Common Crawl, a 321 terabyte (TB) collection of raw text from the internet. However, this data tends to be skewed towards <a href="https://stanford-cs324.github.io/winter2022/lectures/data/">younger users</a> from developed countries. GPT-2 relied heavily on <a href="https://stanford-cs324.github.io/winter2022/lectures/data/">Reddit data</a>, which according to a <a href="https://dl.acm.org/doi/pdf/10.1145/3442188.3445922">2016 Pew Internet Research</a> survey is 67 percent men of which 64 percent of those men are between the ages of 18 and 29. The GPT framework utilizes Wikipedia, where only 15 percent of contributors are female. Finally, WebText, another key input to the GPT models, is trained on news sources, Wikipedia, and sources of fiction. A recent study by <a href="https://arxiv.org/pdf/2009.11462.pdf">Gilmen et al. 2020</a> found that a sampling of this text had a toxicity score of equal to or more than <a href="https://arxiv.org/pdf/2009.11462.pdf">50 percent</a>. All this is important because it lays the foundation for how we view bias and the data it lives.</p><p>The issue of bias in ML is not anything new. Take for example Tay, a fun-loving Bot that Microsoft released in 2016. Tay was trained on public Twitter posts. Tay was supposed to emulate the nature of society and how we interact with Twitter. It took less than 24 hours for Tay to be a fun, upbeat friend who sends you cool tweets to a racist, Fascist-loving Bot from hell. (see below for how it began and how it <a href="https://www.theverge.com/2016/3/24/11297050/tay-microsoft-chatbot-racist">ended</a>). Tay taught the ML community that training data matters, and simply throwing the eternity of the public internet at an algorithm is bound to find the worst corners of it to represent if left tweaked by engineers.</p><p>We have seen this story play out, from Microsoft’s unwittingly <a href="https://towardsdatascience.com/racist-data-human-bias-is-infecting-ai-development-8110c1ec50c">fumble</a> with Tay. <a href="https://artsandculture.google.com/story/joy-buolamwini-examining-racial-and-gender-bias-in-facial-analysis-software-barbican-centre/BQWBaNKAVWQPJg?hl=en">Dr. Joy Buolamwini</a> of MIT has done tremendous research and education in this field, promoting a more inclusive use of AI technologies. Frequently bringing to light the inherent racial bias that ML systems contain. What does it mean when AI systems from leading companies fail to correctly classify the faces of Oprah Winfrey, Michelle Obama, and Serena Williams but can classify white celebrities with <a href="https://time.com/5520558/artificial-intelligence-racial-gender-bias/">shocking precision</a>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oF4YgwdfksgL-qWuhfIGIA.png" /><figcaption><a href="https://www.theverge.com/2016/3/24/11297050/tay-microsoft-chatbot-racist">Tay</a></figcaption></figure><p>Bloomberg recently released a <a href="https://www.bloomberg.com/graphics/2023-generative-ai-bias/?leadSource=uverify%20wall">report</a> that took a deep-dive approach to StabilityAI’sgenerative AI text-to-image creation, <a href="https://stability.ai/stablediffusion">Stable Diffusion</a>. The one-sentence summary of the inherent biases is telling:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0auN_Uh_MnxpFL4E" /></figure><blockquote><em>“The world according to Stable Diffusion is run by White male CEOs. Women are rarely doctors, lawyers or judges. Men with dark skin commit crimes, while women with dark skin flip burgers.”</em></blockquote><p>The Bloomberg <a href="https://www.bloomberg.com/graphics/2023-generative-ai-bias/?leadSource=uverify%20wall">report</a> analyzed 5,000 AI-generated faces that represent 16 different types of jobs, from janitor to CEO. They compared these images using a skin-tone index that allows for six different ratings (Fitzpatrick Skin Scale), from light to dark. These ratings were compared across industries to the statistics reported by the US Bureau of Labor Statistics. When compared to the actual distribution of assumed skin tones from US government statistics, the results are shocking to the level of bias in Stable Diffusion’s generated images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ato2vHhdPNfDwcAb" /></figure><blockquote><em>“When prompted to generate images of a “terrorist,” the model consistently rendered men with dark facial hair, often wearing head coverings — clearly leaning on stereotypes of Muslim men. According to a </em><a href="https://www.gao.gov/assets/gao-17-300.pdf"><em>2017 report</em></a><em> from the Government Accountability Office, radical Islamic extremists committed 23 deadly terrorist attacks on US soil since Sept. 11, 2001 — but far-right extremists, including White supremacists, committed nearly three times as many during the same time frame.”</em></blockquote><p>The bias doesn’t only affect ethnicity. As seen below, using the Bureau of Labor Statistics data, Stable Diffusion tends to skew its results to generate more women for lower social status jobs (dishwasher, cashier, housekeeper) and lean more towards men for positions that have higher education and social ladder requirements.</p><p>But there are solutions to this problem, as Dr. Buolamwini describes in her “Safe Face Pledge” whereby companies promise to evaluate the data they train models on for racial biases. For Gen AI to build on the work that pioneers in racial equality and justice movements have moved through society, they must address the data they train on. Take for example areas in large language models, a type of Gen AI. As evidenced by a recent <a href="https://arxiv.org/abs/2203.15556">Chinchilla paper</a>, tuning an LLM algorithm can only get you so far, the real improvement comes from more training data. For companies training LLMs to rely solely on the gigabytes they throw at LLMs won’t be enough. It will take a concerted effort to give these models the right data to improve their performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0oMZQW-UHz_IEr8WeqT2w.png" /><figcaption>Wrong type of <a href="https://animals.sandiegozoo.org/animals/chinchilla">Chinchilla</a></figcaption></figure><p>What is the solution to overcoming this deluge of training data bias in the LLMs that are deployed today?</p><ol><li>Commit to ethical training data curation</li><li>Join open communities</li><li>Document dataset curation</li><li>Release training dataset samples to the public</li><li>Hold data in escrow accounts</li></ol><p><strong>Commit to ethical training data curation</strong></p><p>Ethical training data curation borrows from academic sampling methodologies frequently found in public opinion research and survey analytics. By leveraging bedrock sampling methodologies from leaders in the political science academic arena, notably Leslie Kish, Ph.D., a more robust sampling framework can be put in place to better represent underrepresented groups. The world of political opinion survey research has leveraged these methodologies for half a century to create accurate samples of the American electorate. By looking into the pioneering work of people like Stan Greenberg who was Bill Clinton’s pollster Stan Greenberg (or his organization Greenberg Quinlan Rosner) or Jan van Lohuizen and Fred Steeper, George W Bush’s <a href="https://www.brookings.edu/articles/words-vs-deeds-president-george-w-bush-and-polling/">pollsters</a>, we can borrow from methodologies that have proven successful in understanding the American electorate. These methodologies, as it comes to choosing data sampling allocations and distributions can help create a more equitable and accurate data representation. When combined with model parameters and data size recommendations from the Chinchilla paper, gains to LLM accuracy, capabilities, and costs can go hand-in-hand with a more diverse and ethically appropriate data collection.</p><p><strong>Join open communities</strong></p><p>Joining open communities where data collection ideas are shared is critical. Open collaboration in the 1980s for nuclear deterrence proved fruitful in helping overcome some of the largest stockpiling drawdowns in human history of fissile materials. A similar approach to open collaboration, even when competing in the traditional Prisoner’s Dilemma constraint where the optimal choice is to cheat, will help in curating better datasets. Open participation, open sharing of code (ie, Reagan’s “Trust but verify” approach) can lead to more robust training data sets.</p><p><strong>Document dataset curation</strong></p><p>Any software engineer or machine learning engineer knows that proper documentation of code is worth its “weight” in gold. The same holds for how data is curated. Just as DevOps and MLOps filled the gaps in software development and ML model infrastructure, respectively, so too does a new era of data documentation. This documentation should answer four key questions: where, when, how, and why. Where was the data collected, the duration of collection, the methods, such as filtering and permissions used, and why it was collected?</p><p><strong>Release training dataset samples to the public</strong></p><p>AI companies should share a random sample of training data for a proper audit of their processes. The algorithm for this sampling methodology should be an openly agreed upon consent that allows for the input of multiple leading, and independent, companies that can offer clarity and statistical best practices to sampling methodologies used. Furthermore, allowing these datasets to be evaluated by the open community such as Kaggle has helped engage machine learning practitioners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*8Z_2p9qJlT2yMQzH" /></figure><p><strong>Hold data in “escrow” accounts</strong></p><p>AWS JumpStart recently launched LLM management and productionalization that allows data and model weights to the law in “escrow.” Similar to a buyer and seller putting their money in an escrow account to ensure the proper functioning of a home sale. Since users are concerned about companies training their future models on their input prompts, and companies not wanting their model weights <a href="https://www.theverge.com/2023/3/8/23629362/meta-ai-language-model-llama-leak-online-misuse">leaked to the public</a> (LLaMA from Facebook), this concept has gained traction. AWS allows the user to place their data on AWS-managed infrastructure while the model weights, for example, AI21 and Cohere model weights, are stored on a similar stored capacity on AWS. At the point of inference, the model weights are called in the escrow account and compared against the user input data. This allows the flexibility to use the model vehicle keeping the user data private and the model weights the IP of the company.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5GiYwVdUeInxh4lQ" /></figure><p><a href="https://www.realtor.com/advice/buy/understand-the-basics-of-escrow/">Source</a></p><p><strong>Where do we go from here?</strong></p><p>Bias in data collection impacts LLMs at an astonishing rate. While there are specific actions that can be taken immediately, there is a regulation that is pending that will attempt to draft the future of Gen AI. Most notably in the EU and US Congress. Time will tell where Gen AI is headed, but if GDPR and CCPA are any indicators, more regulation is around the corner. In the meantime, there remain areas of additional exploration. The idea of human-in-the-loop actions that allow for more human involvement in the data curation process, stress-testing the datasets for undisclosed bias, and other creative means of data discovery in the model-building process will help organizations uncover new areas for growth.</p><p><strong>Author’s note</strong>: Special thanks goes out to Steven Pais, Rishi Sheth, and Claire Salling for their technical review and sound boarding as this draft moved from PROD to DEV :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2964a2b4daa3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eviden-data-science-community/gen-ai-series-bias-2964a2b4daa3">Gen AI Series: Bias</a> was originally published in <a href="https://medium.com/eviden-data-science-community">Eviden Data Science and Engineering Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book Summary: Weapons of Mathematical Destruction]]></title>
            <link>https://medium.com/@nick.s.beaudoin/book-summary-weapons-of-mathematical-destruction-eaf1d7cc44d0?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaf1d7cc44d0</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bias-in-ai]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Sat, 10 Jun 2023 18:40:06 GMT</pubDate>
            <atom:updated>2023-06-10T18:40:44.691Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Author’s note: This piece was originally written by the author and posted in </em><a href="https://translatingnerd.wordpress.com/"><em>Translating Nerd</em></a><em> in 2018. The recent advancement of generative AI (Gen AI), and the data collection methods that create systemic bias in current models, was a prescient discussion point in O’Neill’s book. As the AI industry grapples with data collection bias affecting Gen AI models, these points are even more important.</em></p><p>Cathy O’Neil’s <a href="https://www.amazon.com/Weapons-Math-Destruction-Increases-Inequality/dp/0553418831/ref=sr_1_sc_1?ie=UTF8&amp;qid=1515339019&amp;sr=8-1-spell&amp;keywords=weapns+of+math+destru"><em>Weapons of Math Destruction</em></a>, or <em>WMD</em> for short, offers a moralistic argument that with big data, so too comes big responsibility. Uncovering what she refers to an inherent prejudice, racism and economic unfairness in predictive algorithms and machine learning models, no analytical model is safe from her fierce criticism. With an opening salvo that our very democracy hangs on the moralism of our mathematical models, O’Neill unveils the destructive power of the models that impact our daily lives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/0*1RjMMjX67jdZKMxl" /></figure><p>O’Neill defines a WMD with the following characteristics:</p><p>It is<strong> opaque,</strong> as if a hidden veil sits between the subject and the controller</p><ol><li>It causes a <strong>negative feedback loop</strong> where the output of the model adversely affects the future decisions for the subject, only to impute further damaging data</li><li>It <strong>disadvantages a specific group</strong>, most notably minorities</li><li>It <strong>presumes guilt</strong>, treating innocence as a mere constraint in the model</li><li>It <strong>favors efficiency</strong> resulting in further model variance</li><li>It <strong>doesn’t calculate fairness</strong> by relying solely on numbers and data</li><li>It <strong>lacks a feedback structure</strong>, resulting in creating noise without signals to readjust</li></ol><p>A prime example of a WMD is as follows,</p><p><em>“Do you see the paradox? An algorithm processes a slew of statistics and comes up with a probability that a certain person might be a bad hire, a risky borrower, a terrorist, or a miserable teacher. That probability is distilled into a score, which can turn someone’s life upside down. And yet when the person fights back, ‘suggestive’ countervailing evidence simply won’t cut it. The case must be ironclad. The human victims of WMD’s, we’ll see time and again, are held to a far higher standard of evidence than the algorithms themselves.”</em></p><p>Some intriguing examples O’Neill sites are common in the analytic community. These include the star high school student who applies to a state-level university, only to be turned away because the state school’s predictive model for acceptance states that all-star students have a high probability of turning down so-called “safety schools” for more prestigious institutions. Knowing that the models for what makes a good university ranking relies on having a low acceptance rate, the state school rejects the all-star student. This cycle is perpetuated in a negative feedback loop.</p><p>Another example is the predictive models that city police departments rely on. Using various inputs to machine learning algorithms such as the number of ATMs, geographical inputs, classifications of high-risk zones, the models attempt to optimize police resources by placing cop cars in areas with a higher probability of a crime occurring. Unfortunately, these areas tend to be lower class and with a large minority population. The sheer act of having an increased police presence results in minor crimes such as drug use, being seen, acted upon and enforced. More police reports and arrests feedback into the machine learning model resulting in a further bias towards placing more police units in the area. This is another prime example of a negative feedback loop presuming guilt without model readjustment.</p><p>As seen from these examples, O’Neill argues that more data is not the panacea that will fix our predictive problems. If the algorithm favors a certain piece of the population or refuses to readjust based on algorithm tuning (accuracy, precision, recall, a combination of the two in the F1 or F-beta scores), then no matter the n-size of the data, the model will still fail. However, there is hope! O’Neill offers the following suggestions to improve our models and restore dependency on a more fair and robust set of algorithms.</p><ol><li>Ensure there is an opportunity for <strong>outside introspection</strong>. Let the general public understand the models that judge them, be it credit e-scores or teacher evaluation criteria</li><li>Allow <strong>user sign-off</strong> to use their online actions as data that can be resold. Europe follows a similar model that could be copied</li><li><strong>Make public the assumptions</strong> that the model is built upon</li><li><strong>Audit algorithms</strong> as if they were financial institutions</li></ol><p>While O’Neil’s work strongly falls into the category of personal rights and privacy in a data-filled world, much of her anecdotal evidence is convincing. The moralism that surrounds what we inexplicably provide the data world in our online actions, voting behavior, consumer choices, and personal health well-being should not be the product for others, but of ourselves. This is a question that will plague future technologists as we come to terms with what is and isn’t the public domain.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaf1d7cc44d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Book Summary: Turning Text into Gold]]></title>
            <link>https://medium.com/@nick.s.beaudoin/book-summary-turning-text-into-gold-c9cff43dd88?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9cff43dd88</guid>
            <category><![CDATA[databases-big-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[data-collection]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Sat, 10 Jun 2023 18:32:03 GMT</pubDate>
            <atom:updated>2023-06-10T18:41:35.644Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Author’s Note: This was a review written by the author and posted on the </em><a href="https://translatingnerd.wordpress.com/"><em>Translating Nerd</em></a><em> blog from 2017. The recent emergence of generative AI, specifically large language models (LLM) makes basic NLP knowledge more important to understand. For businesses, organizations and governments alike seek to leverage the advancements in LLM, having a sounds grasp to the taxonomies and processes of NLP and text analytics is paramount.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*H9FpF9XaugVLwnXSHr334Q.png" /></figure><h3>Key Takeaways</h3><p><a href="https://www.amazon.com/Turning-Text-into-Gold-Taxonomies/dp/1634621662"><em>Turning Text into Gold: Taxonomies and Textual Analytics</em></a>, by Bill Inmon, covers a plethora of text analytics and Natural Language Processing (NLP) foundations. Inmon makes it abundantly clear in the first chapter of his book that organizations are underutilizing their data. He states that <strong>98 percent of corporate decisions are based on only 20 percent of available data</strong>. This data, labeled structured data due to its ability to fit in matrices, spreadsheets, relational databases and are easily ingested into machine learning models, are well understood. However, unstructured data, the text, and words that our world generates on a daily basis are seldom used. Similar to the alchemists of the middle ages who searched for a method to turn ordinary metals into gold, Inmon describes a process to turn unstructured data into decisions; turning text into gold.</p><h3>What the heck is a taxonomy?</h3><p>Taxonomies are the dictionaries that we use to refer tie the words in a document, book, corpus of materials, into a business-related understanding. For example, if I were a car manufacturer, I would have a taxonomy of various car-related concepts so I could identify those concepts in the text. We then start to see repetition and patterns in the text. We might begin to see new words that relate to car manufacturing in the text. We can then add these terms to our taxonomy. While the original taxonomy might garner 70 percent of car-related words in the document, 90 percent is usually a business appropriate level to move from taxonomy/ontology to database migration.</p><h3>Now what?</h3><p>Once we have the necessary inputs from our long list of taxonomies. Through textual disambiguation, the raw text from our document is compared to the taxonomy we have created. If there is a fit, then this text is moved from the document and stored in a processing stage. This stage involves looking for more distinct patterns in the newly moved text. Using regular expressions, or a type of investigative method in coding, we can discern more distinct patterns from the text. We can then move this raw text into a matrix, or what many people are familiar with in a spreadsheet. Transferring the text into a matrix involves the manipulation of text to numbers, which can be rather large when fitting into a matrix. While there are specific steps that can be taken (ie, sparse matrix vs. dense matrix), the process is the same: make text machine-readable. Words become zeros and ones and analytical models can now be applied to the document. Machine learning algorithms, such as offshoots of Bayes Theorem and other classification techniques can be used to categorize and cluster text.</p><h3>A simple example</h3><p>Imagine you go to the ER one day and a report is generated when you are out-processed. This record holds many important elements to your medical history. However, having someone extract the name, address, your medications, your condition, your treating doctor’s information, your health vitals, etc would take a lot of time. More time than a swamped hospital staff on a limited budget can handle. Text analytics is used to link the all this information into a spreadsheet that can then be fitted into the hospital’s database. Add up enough of these records and you can start looking for patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdiujQOTEJy7uHzxcQ2SKg.png" /></figure><ol><li>Your visit to the ER is documented as text</li><li>The hospital takes a pre-defined “dictionary”, or taxonomy, of medical-related terms</li><li>The taxonomy is compared against your medical evaluation and processed into a spreadsheet/matrix.</li><li>The spreadsheet is uploaded into a relational database the hospital maintains</li><li>An analyst queries the database data to make a machine learning model that can create value-added predictions.</li><li>Based on your model, a value is produced that results in a decision being made.</li></ol><p>Image sources:</p><p><a href="http://www.medicalexpo.com/">www.medicalexpo.com</a><a href="http://openres.ersjournals.com/content/2/1/00077-2015">http://openres.ersjournals.com/content/2/1/00077-2015</a><a href="https://www.sharesight.com/blog/ode-to-the-spreadsheet/">https://www.sharesight.com/blog/ode-to-the-spreadsheet/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9cff43dd88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLP for Prediction: Getting back to basics]]></title>
            <link>https://medium.com/@nick.s.beaudoin/nlp-for-prediction-getting-back-to-basics-1e75611dcf90?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e75611dcf90</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[nlp-training]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Sat, 10 Jun 2023 13:00:36 GMT</pubDate>
            <atom:updated>2023-06-10T13:00:36.887Z</atom:updated>
            <content:encoded><![CDATA[<p>With the surge of information being posted on LinkedIn and public social media sites about large language models (LLMs) in the generative AI space (Gen AI), I wanted to pull up an old piece I originally wrote for <a href="https://translatingnerd.wordpress.com/">Translating Nerd</a> back in 2018. Hopefully, this helps with some of the natural language processing (NLP) pieces that are being recast in the LLM space.</p><p>My mom really likes to write. She writes emails that would make folks in college English departments give valedictorian status. Now I know this makes me seem like a bad son, but there are times when I would like an indicator on the emails that tell me the urgency of responding. When there is great news, then I can respond over the weekend by giving her a phone call, but if there is something that is upsetting, I need a red flag to pop up and let me know that I need to respond via phone call or else my father is going to start texting me saying, “Dude, call your mom.” (Preface to say, see image below, I think everyone should be calling their mom when asking this question. But this does not make a convincing data science blog).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*ZjOqu1u5V7swC-6ZbWUINg.png" /></figure><p>Well, natural language processing (NLP) offers a solution. In fact, NLP is at the forefront of data science industry specialists for its use on unstructured (text) data. Once arduous tasks of combing through piles of PDFs and reading long emails have been replaced by techniques that allow the automation of these time-consuming tasks. We have spam detectors that filter out suspicious emails based on text cues predicting with astonishing accuracy which emails are spam and which are notes from grandma. But what lacks in the data science community is the “Mom Alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*Ao7DDf6i0vTkYzJgRlXtKw.png" /></figure><p>To understand the complexities that NLP has to offer, let’s break down the “Mom Alert.” First, we need a corpus (collection) of past emails that my mom has sent me. These need to be labeled by hand as “upset” mom and “happy” mom. Once I have created labels for my mom’s historical emails, I can take those emails and break them down into a format that the computer algorithm can understand.</p><p>But first, I need to separate these emails into two sets of data, one with known labels of upset and happy and the other with no labels that I want to predict. The set with labels will be called the training emails and the one without labels will be called the testing emails. This is important in the NLP process because it is going to help me build a model that can help generalize, or better predict the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*mc8wK3xSIUud8OYbOJcMXA.png" /></figure><p>It is important to note that I will want to pre-process my data. That is, I want to make sure that all the words are lowercase because I don’t want my model to treat words that are capitalized and not as different words. I will then remove all words that offer little value and occur frequently in the English language. These are called “stop words” and usually offer little semantic value. “And”, “but”, “the”, “a”, “an” give little meaning to the purpose of a sentence and can all go. I will also remove punctuation because that is not going to give me information for my model. Finally, I will take any word that is plural and bring it down to its singular form, thus shoes to shoe and cars to car. The point of all this pre-processing is to reduce the number of words that I need to have in my model.</p><p>Now that I have separated emails into training and testing sets, pre-processed the words, I need to put those emails into a format that my computer algorithm can understand: numbers. This is called the “vectorization” process where we create a document-term matrix. The matrix is simply a count of the words in a document (mom’s email) and the times that a word occurred. This matrix is then used to compare documents across themselves. The reason we pre-processed these words was that the vectorization process would result in a massive, extremely clumsy matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2WjQXbLkaNDkwQvpHvTYjA.png" /></figure><p>As you can see by the image above, each email is displayed as their own row in the matrix (document-term matrix). This document-term matrix then takes each unique word in ALL the emails from the training emails and places them in the columns. These are called features. Features of a document-term matrix can make this matrix incredibly long. Think of every unique word in thousands of emails. That is one long matrix! Which is the reason we did pre-processing in the first place! We want to reduce the number of columns, or features, which is a process known as dimensionality reduction. In other words, we are reducing the numbers that our algorithm needs to digest.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzccMllcSQvwa8UABdaVpQ.png" /></figure><p>Now that I have my emails represented as a matrix, I can create an algorithm to take those numerical representations and convert them to a prediction. Recall from a previous post that we introduced Bayes Theorem. (see <a href="http://translatingnerd.com/2018/02/08/searching-for-lost-nuclear-bombs-bayes-rule-in-action/">Translating Nerd’s post on Bayes</a>). Well, we could use Bayes Theorem to create a predicted probability that my mom is upset. We will call upset = 1 and happy = 0.</p><p>Side Note: I know this seems pessimistic, but my outcome variable is going to be the probability that she is upset, and that is why we need to constrain our algorithm between zero and one. Full disclosure, my mom is wonderful and I prefer her happy. Again, see images under the text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*RkiTmyixIenppAGnMREtIA.png" /></figure><p>Now, there are other algorithms that can be used, such as logistic regression, support vector machines and even neural networks, but let’s keep this simple. Actually, the first email spam detectors used Naïve Bayes because it works so darn well with large numbers of features (words in our case). But “naïve”, what does that mean you may ask? The model makes the naïve assumption that these words are not related to each other. We know this cannot be true because that is how we create sentences, that is, words have meaning when coupled with each other. Of course, each algorithm has drawbacks but Naïve Bayes proves to be quite accurate with large amounts of features (ie, words).</p><p>Once we have implemented our Naïve Bayes model on the document-term matrix, we can make a prediction on each email in the test set. This test set acts as a validation on the training set which will allow us to make changes to our model and get as close as possible to a generalized model for determining an upset email from mom. A keynote of machine learning is to create a model that doesn’t just fit our training data, because we need it to be vague enough to generalize to new data. This is called overfitting a model and should be avoided at all costs. Of course, there is a trade-off between under-fitting a model that needs to be balanced but again, I digress (see image below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXkMkZ68YE7ZOdi4QaLWQw.png" /></figure><p>Once we have tuned our Naïve Bayes algorithm to both fit the training emails and generalize well enough to future emails in the test set, we are ready to test it out on a new email from mom. When mom sends us a new email, our algorithm will output a predicted probability. Let’s say that any email that has a predicted probability of 50 percent or more (0.5) will be called upset (1) and any predicted probability that is under 50 percent will be called happy (0).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpcctsKiXiSaUx7I6I9ApQ.png" /></figure><p>If we wanted a simplistic model we could look at the above new emails that have been run (without labels) through our Naive Bayes algorithm. It looks like the predicted probabilities have cleared our 0.5 threshold and made a classification of happy, upset, upset, and happy. It looks like I will have some calls to make this evening!</p><p>Images sources:</p><p><a href="https://datascienceomar.wordpress.com/2016/07/04/classification-with-scikit-learn/">https://datascienceomar.wordpress.com/2016/07/04/classification-with-scikit-learn/</a><a href="http://www.cs.nthu.edu.tw/~shwu/courses/ml/labs/08_CV_Ensembling/08_CV_Ensembling.html">http://www.cs.nthu.edu.tw/~shwu/courses/ml/labs/08_CV_Ensembling/08_CV_Ensembling.html</a><a href="https://www.includehelp.com/ml-ai/data-splitting.aspx">https://www.includehelp.com/ml-ai/data-splitting.aspx</a><a href="https://lespetitesgourmettes.com/recipes/friday-funnies-8/attachment/call-your-mom/">https://lespetitesgourmettes.com/recipes/friday-funnies-8/attachment/call-your-mom/</a><a href="https://logobaker.ru/logo/3407-reazon.html">https://logobaker.ru/logo/3407-reazon.html</a><a href="https://kultura.zpravy.idnes.cz/filmove-novinky-zari-2017-0sa-/filmvideo.aspx?c=A170912_120514_filmvideo_ts">https://kultura.zpravy.idnes.cz/filmove-novinky-zari-2017-0sa-/filmvideo.aspx?c=A170912_120514_filmvideo_ts</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e75611dcf90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Large Language Models 101]]></title>
            <link>https://medium.com/eviden-data-science-community/large-language-models-101-a64847e17a3f?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a64847e17a3f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Thu, 01 Jun 2023 16:26:08 GMT</pubDate>
            <atom:updated>2023-06-01T16:26:08.483Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide does not propose new insights into LLM architecture, nor does it provide a deep dive into the tuning adjustments made on LM hyperparameters. It doesn’t assume you know the current Chinchilla paper ratios of parameters to data input, nor does it assume you subscribe to the latest episode of AI Daily. (However, if you would like daily updates to the latest and greatest happenings in the world of LLMs, be sure to check out <a href="https://thesequence.substack.com/">The Sequence</a> for a daily email on what is happening in the world of LLMs). You want straight facts, and you want them in the most distilled medium (pun intended) possible.</p><p>At a high level, Large Language Models give users the ability to generate human-readable text from input entered by a user. While there are myriad details for LLMs, we will stick to the important points:</p><ul><li>Model architecture</li><li>Training Data</li><li>Storing inputs</li><li>Inference</li><li>Use cases</li></ul><p><strong>Model Architecture</strong></p><p>At a high level, LLM models attempt to predict a word or sequence of words, given the previous words it has seen. This is referred to as “token prediction,” where each word is represented as a token. To scale this idea out further, tokens can also be representations of many words, known as n-grams. A 1-gram token could be one word like “new,” whereas a two-gram token could be a word like “New York,” and a three-gram token could be “New York City.” Over the past decades, various methodologies have been revealed in mathematical and computational thinking that allow for various ways to analyze and predict new words using input tokens. Phrases like “transformers,” “attention,” and “masking” are all just fancy methods that researchers have spent countless hours on to improve the next token prediction method.</p><p>Parameters in a model represent the connections that the model makes when learning new material. On a high level, this can be seen as similar to how the human brain functions, albeit a loose analogy. These parameters are given a random weight at the beginning of training. Each time the model iterates over new training data, it forms stronger connections, known as adjusting the weights of the parameters. More parameters equate to a more advanced model, requiring more time for each connection to reach an optimal balance with the other parameters. Once the model is trained, these parameters are “frozen” and stored in memory, entering the pipeline for predictions to be made based on input data, otherwise known as “inference.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vXhJP4IKNTQs1EdhtPnpQ.png" /><figcaption>Image made with <a href="https://www.midjourney.com/app/">MidJourney</a></figcaption></figure><p>There has been exciting advancement over the past several years in the natural language processing (NLP) domain. In 2019, an LLM called <a href="https://arxiv.org/pdf/1810.04805.pdf">BERT</a> (Bidirectional Encoder Representations from Transformers) was released to great fanfare. This was the first truly “<a href="https://towardsdatascience.com/bert-explained-state-of-the-art-language-model-for-nlp-f8b21a9b6270">approachable</a>” LLM that was fine-tunable and quick to provide results (inference), based on a 2017 paper titled “<a href="https://arxiv.org/pdf/1706.03762.pdf">Attention Is All You Need.</a>” Most notable was that BERT was trained on 64 TPUs over 4 days and has resulted in 23 smaller versions of BERT that reach 95% of performance and run 60% faster. Rightly so, HuggingFace (a popular open-source LLM framework) calls BERT the “<a href="https://huggingface.co/blog/bert-101#1-what-is-bert-used-for">Swiss army knife solution</a>” to most common NLP tasks.</p><p>In 2020, T5 (Text-to-Text Transform Transformer) was released. This model was trained with 11 billion parameters and built upon the architecture of BERT, albeit with some small improvements that we won’t dive into here (but if you want, check out encoder-decoder architectures). While more updated versions of T5 have been released, the original architecture is very much still in use today.</p><p>In 2019, OpenAI released GPT-1 and GPT-2. This was a transformative moment due to the size of the data and the 1.5 billion parameters used. Then in 2020, GPT-3 was unveiled. This monolith was 100 times larger than its predecessor (GPT-2) at 175 billion parameters and exhibited unprecedented few-shot and zero-shot learning. In all, GPT-3 was trained on 300 billion tokens ( more on this in a moment). GPT-4 was released in 2023 and has surpassed the capacity that was set by GPT-3.</p><p>Models you may have heard of:</p><ul><li>LLaMA by Meta AI (open source)</li><li>PaLM by Google (closed)</li><li>GPT-4 by OpenAI (closed)</li><li>Alpaca by Stanford (open source)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIHbQiUD8xHD_eNBPyV2Bg.png" /><figcaption><a href="https://s10251.pcdn.co/wp-content/uploads/2023/03/2023-Alan-D-Thompson-AI-Bubbles-Rev-7b.png">source</a></figcaption></figure><p><strong>Training Data</strong></p><p>And what about the data these models are trained on? Large language models (LLMs) like GPT-3 are typically trained on large amounts of text data collected from the internet. The exact details of the training data used for specific models may vary, but here are some common sources:</p><ul><li>Web Pages</li><li>Books and Literature</li><li>Wikipedia</li><li>News Articles</li><li>Other Text Sources (think places like Reddit)</li><li>Code repositories (think GitHub)</li></ul><p>A recent article by <a href="https://www.washingtonpost.com/technology/interactive/2023/ai-chatbot-learning/"><em>The Washington Post</em></a> has a phenomenal breakdown of the 15 million websites that have been used to train LLMs, which include Google’s T5 and Facebook’s LLaMA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBlW4GKSb21L_PwJYO849Q.png" /><figcaption><a href="https://www.washingtonpost.com/technology/interactive/2023/ai-chatbot-learning/">Source</a></figcaption></figure><p>The article does a superb job of visually highlighting where the data for some of the most popular LLMs come from and the percentage of each area that certain popular public information sources represent in that dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpGKQ3sLEOorx5teM9fjpg.png" /><figcaption><a href="https://www.washingtonpost.com/technology/interactive/2023/ai-chatbot-learning/">Source</a></figcaption></figure><p>Now there is an important caveat here. LLMs are typically unfiltered, and the models learn from the patterns and information present in the data. Not unfiltered like #unfiltered on Instagram, but unfiltered where the raw data going into the model is not curated to remove specific data points that are not representative of the world. This means that the model results could reflect any biases that are in the data. For example, part of the data used to train ChatGPT came from Reddit, where <a href="https://dl.acm.org/doi/pdf/10.1145/3442188.3445922">67 percent</a> of users are men, and <a href="https://stanford-cs324.github.io/winter2022/lectures/data/">64 percent</a> of those are between the ages of 18 and 29. Furthermore, ChatGPT is also trained using Wikipedia, which only has <a href="https://stanford-cs324.github.io/winter2022/lectures/data/">15 percent</a> of its authorship identifying as female.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*GSZOlhnZo5dYAuec8kQ8Bg.png" /><figcaption><a href="https://stanford-cs324.github.io/winter2022/lectures/data/">source</a></figcaption></figure><p><strong>Storing inputs</strong></p><p>Now that we have a model, how do we process data through it? This is where embeddings come into play. When you input data for the model to train on, the model can only read numbers to make sense of the world. In light of this, embeddings are a mathematical algorithm that allows for individual and strings of text to be represented as numbers between 0 and 1. These numbers are put into a semantic space in the form of vectors. Words or strings of text that have similarities are close to each other in this space. See the image below where each dot represents a token/string in semantic n-dimensional space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*8yTpJOzbyhAwC6VoWMrPxw.png" /></figure><p>Words or phrases that are not related farther away. See <a href="https://www.pinecone.io/learn/vector-database-old/">image</a> below on the far right for a visual comparison of text embeddings as clusters</p><p>To store this data, we use a vector database. The vector DB is a means to store these vector embeddings that can be queried later. To query the semantic space, another algorithm is used for the search capability. Most notable is the Approximate Nearest Neighbors (ANN) algorithm. This algorithm is a traditional machine learning (ML) clustering algorithm that allows for an approximation of the embedded vectors&#39; location to save time. If the algo needed to query all possible matches EXACTLY, then time would be a major issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*OnGW8PpxY6uJzYbXelRizw.png" /></figure><p>For more information on vector databases, please refer to this <a href="https://www.pinecone.io/learn/vector-database-old/">article</a> by Pinecone.</p><p>Tools you may have heard of:</p><ul><li>ChromaDB (open source)</li><li>Weaviate (open source / paid, runs in containers — Docker/Kubernetes)</li><li>AWS Zilliz Cloud (third-party tool within AWS Marketplace)</li><li>GCP Matching Engine (managed service)</li><li>Pinecone (paid)</li><li>Milvus (paid)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*1W4s_6msI7Uhcdph54FApA.png" /><figcaption>Image made with <a href="https://www.midjourney.com/app/">MidJourney</a></figcaption></figure><p><strong>Inference</strong></p><p>One will frequently hear the term “shots” when performing and evaluating LLM performance. Shots refer to the number of times that a user needs to guide the LLM to reach a level of acceptance in its response. The more times the user needs to intervene, the more shots that the model is said to perform. If there is no prompting by the user, then the model can generate responses without any tuning. Few shot learning would indicate that the model needed to go back and forth with the user to get the desired results. Let’s keep in mind that every time we do a “shot,” the model needs to store that information in the vector DB for future retrieval.</p><p>Moving on, there are phrases like “prompt engineering” and “fine-tuning.” Prompt engineering simply means that you are changing the prompt to be more specific to what you want to see. By tailoring one’s wording to a more specific representation of what the user wants to get out of the response, or even using multiple “shots” at getting a response and querying based on that response, the user can create a more customized LLM experience. On the other hand, hyperparameter tuning allows more engineer-focused users to change the proverbial dials on the LLM. This can be used to change how the LLM retrieves vectors from the vector DB or returns text based on how exact the match needs to be.</p><p>What is happening under the hood with our friend the vector DB? Like any traditional ML process, when the data inputs go to the model for inference, a data transformation needs to take place. Similar to how the training data was transformed for model training, the text inputs also need to be embedded to compare to the vector DB for similarity matches. This is where the ANN, or similar model, enters the picture. That ANN model looks for the most similar comparison (comp) to what its user input embeddings represent. Once found, it retrieves those embeddings and begins the prediction process with the model weights. These weights are numbers that represent the various parameters that the model has and are often obfuscated by the model vendor if not open-source. Once the model has determined a predicted probability for the next token in the sequence, it generates a response. This is why you will find prompts to appear like they are being written on a typewriter in front of you. The model is literally deciding what text to put next based on a predicted probability and a set of model rules!</p><p><strong>Use Cases</strong></p><p>LLMs have a wide variety of uses. From text summarization to text generation to enhanced chatbots, LLMs are capable of both traditional NLP tasks, and more modern areas. The more modern areas we see LLMs in use are in the area of content generation. For this article, ChatGPT was used to ideate, but not to directly pull text. It is very possible that I could have used the ChatGPT LLM to cut and paste content. For example, if I asked ChatGPT to tell me how a vector database worked, but prompt engineered it to give me high-level bullets, this is what I would get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*alruvccvRqggTwvimZWrQA.png" /></figure><p>With more prompt engineering, I could very well create output from ChatGPT (or another LLM of choice) that would mirror the language that I was using to have a more natural flow. In fact, I could even go as far as to use a model, such as AWS’s Flan-T5 , GCP’s PaLM 2.0, or an open-source option like PrivateGPT. This is an area referred to as “Foundation Models” where the LLM is trained on a large corpus of data, then transferred to be trained on a specific domain, like my personal style of writing in this article. The LLM would store the foundation model weights and train a layer, stored in the vector database, that could more coherently replicate my tone and style!</p><p><strong>Limitations</strong></p><p>There are limitations to use cases that should also be kept in mind. Primarily, a term called “hallucination.” This refers to the LLM&#39;s ability to make up answers that don’t exist. One of the main drawbacks to LLMs is out-of-the-box responses that can be made up if those input data points have not been in the training data and in the vector representations that are stored in the vector DB. Without LLM engineers tuning the model to the use case, the model results could have dire consequences.</p><p>Another key limitation is the size of the input prompts. ChatGPT-3 can have 4,096 tokens (words), but anything more is <a href="https://the-decoder.com/chatgpt-guide-prompt-strategies/#:~:text=ChatGPT%20processes%20up%20to%204%2C096,is%20ignored%20without%20a%20message.">ignored</a> by the model. This becomes an issue when using multiple shots in the prompt engineering process. Since the model itself has difficulty storing values, we rely on chained prompting that allows the user to break up complex prompts into multiple <a href="https://the-decoder.com/chatgpt-guide-prompt-strategies/#:~:text=ChatGPT%20processes%20up%20to%204%2C096,is%20ignored%20without%20a%20message.">intermediate steps</a>. Most notably with the use of <a href="https://python.langchain.com/en/latest/index.html">LangChain</a>, these steps can be chained together to form a living memory for the LLM. IN turn, this allows for more efficient memory as the LLM can leverage previous user inputs for more refined responses.</p><p><strong>Future Discussions</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eX_3b3wyXGHfp_JrXzdCJg.png" /><figcaption>Image made with <a href="https://www.midjourney.com/app/">MidJourney</a></figcaption></figure><p>The ethical and legal dilemmas that LLMs face in the Gen AI community are for another post. While there are tremendous areas for business growth irrespective of industry, there are undefined solutions for how to deal with this newer implementation of NLP tech. Namely, these areas include issues of data bias, attribution of work, disinformation uses, authentication of ownership, siloing of tech, security, model explainability, and sensationalism of product breakthroughs.</p><p><strong>New Horizons</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfZjvek7ce9moW3wcl__Qg.png" /><figcaption>Image made with <a href="https://www.midjourney.com/app/">MidJourney</a></figcaption></figure><p>LLMs have a storied history as they build upon the foundations laid before them. From probabilistic and statistical models of the 1990s to neural networks in the 2000s to more robust neural networks leveraging stronger GPUs and advanced architectures in the 2010s, generative AI has brought a new era, if not a paradigm shift, to the advancements in NLP. We continue to see advancements in training data, new benchmarks in the graphical processing unit (GPU) capacity, refined models, and innovative infrastructure to support novel business use cases.</p><p>Author’s note: A very special appreciation to the numerous team members at Eviden who helped review and comment on this post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a64847e17a3f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eviden-data-science-community/large-language-models-101-a64847e17a3f">Large Language Models 101</a> was originally published in <a href="https://medium.com/eviden-data-science-community">Eviden Data Science and Engineering Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future-proofing your data science toolkit]]></title>
            <link>https://medium.com/@nick.s.beaudoin/future-proofing-your-data-science-toolkit-b14c009fc071?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b14c009fc071</guid>
            <category><![CDATA[distributed-computing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Tue, 15 Nov 2022 02:53:43 GMT</pubDate>
            <atom:updated>2022-11-15T02:53:43.446Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*cJZ9aQYRSmt0OwVUgV6hfg.png" /></figure><p>We are constantly inundated with the latest and greatest tools. We see over and over again friends, LinkedIn acquaintances, and former classmates posting about new certifications and technologies that are being used on the data science front. We feel that we are in a never-ending GIF that never quite allows us to reach completion in our data science career.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25662420&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Ftruck-crash-slowed-gif-25662420&amp;image=https%3A%2F%2Fc.tenor.com%2F8pCpc_FdfWAAAAAd%2Ftruck-crash-slowed.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c7717e3375605f8d63ff6ddec165541/href">https://medium.com/media/9c7717e3375605f8d63ff6ddec165541/href</a></iframe><p>So how do you cut through this massive tidal wave of tech stacks to focus on what is important? How does one seek clarity through the haze of skills that are important and those tools that are simply worthless certifications that will never be used on the job?</p><p>Over the past few years, there has been a handful of tools that have transcended industries and shown a clear signal of being key to a high-performing data science team in the near future. Mainly, these technologies revolve around the concept of big data. Now, you may be asking yourself, what does “big data” really mean? Is it gigabytes, terabytes, or petabytes of data? Is it streaming, large batch jobs, or a hybrid? Or is it anything that doesn’t fit on an Excel spreadsheet?</p><h3>What is big data?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*zYyk21N-mIfB_3zy2V4D1A.png" /><figcaption>Image to make it look like this article is important</figcaption></figure><p>We are used to hearing the three Vs of big data: velocity, volume, and veracity. But these are opaque and hard to grasp. They don’t meet the qualifications of a mom-and-pop analytics start-up to a fully-fledged Fortune 500 firm leveraging analytics solutions. A better example of big data is from <a href="https://www.amazon.com/Data-Teams-Management-Successful-Data-Focused-ebook/dp/B08JLFTPBV/ref=sr_1_1?dchild=1&amp;keywords=jesse+anderson&amp;qid=1606103175&amp;sr=8-1">Jesse Anderson’s recent book <strong>Data Teams</strong></a>. In it, he states that big data is simply when your analytics team says they cannot do something due to data processing constraints. I like to think of this analogy.</p><p>My own take: Imagine that you grew up in Enterprise, Oregon, a Northwest Oregon farming town of approximately 2,000 people. Now, if you were to venture across the border over to Washington state, you would think that Seattle is the biggest city on earth. Rightly so, if you grew up in New York City, you would think that Seattle is small in comparison to your home city.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*Cccl0gtWyTaCf0ZNqxtADA.png" /><figcaption><em>Small town, small data</em></figcaption></figure><p>This analogy applies to the size of an organization’s data; when you work with small data, everything seems big, and when you work with large data, it takes a larger magnitude of data ingestion to become overwhelmed. But each organization has a breaking point. That point where the data team throws up their hands and says, “we can’t go any further.” This is where the future of data science lies. To leverage the massive amounts of data (or taken as the three Vs of big data in velocity, volume, and veracity), we need tools that allow us to compute at scale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*_j77yPbDdOnnm1-PAnn9-w.png" /><figcaption><em>Big city, big data</em></figcaption></figure><h3>Soaring through the clouds</h3><p>There is no wonder that scaling up data science workloads involves using someone else’s machine. Your (and my) dinky MacBook Air or HP glorified netbook can only store up to 8 GB of information in location memory (RAM), 16 if you are lucky enough to stuff another memory card in the thing. This creates myriad problems when trying to conduct anything beyond basic querying with larger datasets (over 1 GB). Once we enter this space, a simple Pandas GroupBy command or R data.frame equivalent will render your machine worthless until a reboot.</p><p>To use compute capacity, you need to rent another machine. When renting a machine, this is referred to as spinning up a compute instance. These compute instances go by different names and there are wide varieties of hardware and software that are leveraged when increasing our data science workload capacity. However, when it comes to who to rent from, there are really only 3 major players on the market: Amazon Web Services (AWS), Microsoft Azure and Google Cloud Platform (GCP). Of course, Oracle and IBM have their own dedicated cloud, but they don’t crack the surface when competing with the big girls and boys.</p><h3>Data Lakes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*q3yWTSyVQV3y_4gNnseGBg.png" /></figure><p>When venturing into the cloud, it is best to begin with the two primary means a data scientist will interact: storage and compute. When developing data science products on the cloud, you will need to store your data somewhere. In fact, what you really want, a data lake somewhere you can store your data with as few rules as possible. This is where the concept of the data lake comes into play. Data lakes give you the opportunity to dump data, regardless of file type, into a central location where you can they grab and place that data into an experiment. The respective players here are the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*DnTFqdiXZlVk48tkz-kZlw.png" /></figure><ul><li>AWS Simple Storage Service (S3)</li><li>Microsoft Azure Data Blob</li><li>GCP Cloud Storage</li></ul><p>Now, don’t get me wrong, being able to store data in its proper home, be it a relational database based on SQL or an unstructured storage area using NoSQL, will always be preferential to dumping your data in a data lake. Moreover, for those data sources that you want to have on-hand at a moment’s notice, creating a data warehouse will be preferable, especially when it comes to <a href="https://en.wikipedia.org/wiki/Online_analytical_processing">OLAP</a> operations. But to get up and started with data science experimentation and skill building on the cloud, data lakes are fantastic.</p><h3>Compute Power</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*7XEETitK4XH0P9UTzVF0PQ.png" /><figcaption>Just wait for that AWS bill after the ride</figcaption></figure><p>Once you have your data in a safe location, you can start looking at renting compute power. Again, our three main players will look like this:</p><ul><li>AWS Elastic Compute (EC2)</li><li>Microsoft Azure Compute</li><li>GCP Virtual Machines (VM)</li></ul><p>When getting started, you want to learn a few things:</p><ol><li><em>How do I make sure that I don’t get charged too much money if I accidentally (you will) leave this thing on?</em> There are free-tier compute instances that you can select to avoid unnecessary shocks when looking at your cloud bill.</li><li><em>How do I ensure the correct ports are turned on?</em> You will need to ensure that you have the correct web portals open when creating a compute instance. Failure to do so will not allow data science tools like Jupyter Notebook to run successfully. Leave ports open that you aren’t supposed to, then the world can see your instance.</li><li><em>How do I make things talk to each other?</em> Ensure that you have the correct permissions set up. AWS, Azure, and GCP all have access management portals that need to have the minimum permissions and rules set for your storage and compute instance.</li><li>If I had 2 more hours to spend on this, what would be the next steps? Knowing the next level of complexity is oftentimes as important as knowing how to do it. Being able to see how your application naturally builds upon itself and ties into other services will allow you to see the world as a true solutions architect.</li></ol><h3>Abstracting the noise</h3><p>Oftentimes, you will find yourself on a team that does not want to worry about how to manage a cluster or HDFS (Hadoop Distributed File System). Naturally, when jumping into the world of big data and scaling out data science workflows, the question of how involved you want to be in the day-to-day management of the big data ecosystem needs to be answered. This is why there has been a recent rise in products that allow the user to abstract the more nuanced data engineering and system administrator roles of the cloud to a platform that is more user-friendly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/1*mPVH4SWFC9a8oQIzf6PE-Q.png" /></figure><p>Databricks is one mover and shaker on the market that has been receiving significant fanfare and accolades for its ease of use. But don’t let its new-kid-on-the-block persona dissuade you from using it. Started by the original researchers from UC Berkeley who created Apache Spark, the Databricks team has created a product that can leverage cloud computing and the data science Jupyter Notebook environment with ease. For a nominal fee, depending on how much power you seek, you can set the cluster size with the click of a button, create instant autoscaling groups and serve as your own cluster admin team with little upkeep. To sweeten the pot, there is a Community Edition that can be used and a legit Coursera course that was dropped a few years ago by Databricks staff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*Fli2_4YZZGOT-Ao45bszDg.png" /></figure><p>Zeppelin notebooks is another data science tool that operates on top of distributed systems. Normally a little more difficult to implement, due to the manual creation of HDFS clusters and permissions granting between cloud applications, Zeppelin notebooks allow you to leverage a Spark environment through PySpark and SparkR. Due to constraints around requirements a company may have, such as a contract with a cloud support service, Zeppelin notebooks can allow you to operate within your already existing cluster setup.</p><p>While there are more tools that allow your company to leverage big data compute, distributed file systems, and all the buzzwords that lie between, the prime movers are going to be built on the big three cloud computing resources (AWS, Azure, GCP). Learning one easily translates to learning the other. Oftentimes, within the data science space, you will find yourself moving from one service to the other. Simply knowing the mapping of related terms is often enough to ensure consistency in thought and action when creating new applications across cloud platforms within big data. Personally, I have found having a <a href="https://cloud.google.com/free/docs/aws-azure-gcp-service-comparison">chart</a> of the naming conventions used for AWS and Azure to be quite helpful and ensure continued success in both learning and developing new data science products.</p><p>Examples:</p><ul><li>AWS S3 - Azure Blob Storage</li><li>GCP VM - AWS EC2</li><li>AWS SageMaker -GCP Vertex AI</li></ul><p><em>Pic sources:</em></p><ul><li><a href="https://unsplash.com/@drew_beamer">https://unsplash.com/@drew_beamer</a></li><li><a href="https://unsplash.com/@sortino">https://unsplash.com/@sortino</a></li><li><a href="https://unsplash.com/@monicabourgeau">https://unsplash.com/@monicabourgeau</a></li><li><a href="https://unsplash.com/@jamesting">https://unsplash.com/@jamesting</a></li><li><a href="https://unsplash.com/@its_tgain">https://unsplash.com/@its_tgain</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b14c009fc071" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Data Science Tool that Never Goes Out of Style]]></title>
            <link>https://medium.com/@nick.s.beaudoin/the-data-science-tool-that-never-goes-out-of-style-a62816b9bbd1?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a62816b9bbd1</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machinelearningalgorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Sun, 30 Oct 2022 14:37:04 GMT</pubDate>
            <atom:updated>2022-10-30T14:37:04.623Z</atom:updated>
            <content:encoded><![CDATA[<p>Admit, we have all been there. You are on your 5th Udemy course on what you think is the next must-have algorithm/tech skill, from Generative Adversarial Networks, to <a href="https://arxiv.org/abs/1506.02640">YOLO</a> and <a href="https://arxiv.org/pdf/1610.02455.pdf">ANNOY</a> algorithms, when you ask yourself, why am I doing this? Yes, it looks super cool to post about how only real data scientists do back-propagation by hand or grow their own neural nets with organic soil under their desks, but does this actually translate into on-the-job success? Does this further drive the passion for data science and the creative spirit to constantly follow the most recent trend? Or as previously stated a few years ago on this blog, to be lost in the utter darkness of the “<a href="https://medium.com/@nick.s.beaudoin/the-mooc-trap-679539f3bee6">MOOC Trap</a>?” So hit that CAPS LOCK key and let’s get down to business!</p><p>I am not saying that there is no place for advanced algorithmic learning and the implementation of cutting-edge machine learning techniques on the job market. What truly matters are the core skills that we tend to forget. This is why I am hitting that #ThrowbackThursday button on your social media feed and recommending to pour a glass of wine, light a candle, and take your relationship with SQL to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*K7okRlysPRFAVdd1_CanQw.png" /></figure><p>No one loves SQL. Seriously, it is not what we think about when we hear “Sexiest job of the 21st century.” Running queries does not win <a href="https://www.kaggle.com/">Kaggle</a> competitions nor does it get on the front page of <a href="https://www.analyticsvidhya.com/blog/">Analytics Vidhya</a>, make you want to hit that subscribe button and pay for a monthly membership to <a href="https://towardsdatascience.com/">TowardsDataScience.com</a> or make you yearn for some sweet, sweet credits to run queries on AWS RDS. But it is important, oh so very important. Most of the jobs on the market in both data analytics and data science not only require SQL, but act as the first cone you must pass to actually speak with a human being beyond a phone screen for most jobs. So where to start?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*CFuB2DRC7UGfNiTDcdaHGA.png" /><figcaption>“SQL Rocks!” or something like that. You get the idea.</figcaption></figure><p><strong><em>Write one query a day</em></strong></p><p>Habits grow out of consistency, but our better natures tend to pull us away, telling us that one day won’t make a difference and that we can wait to start tomorrow. But the simple act of one query a day can be quite transformative. This can be as simple as SELECT * FROM table. That basic act will create a routine within your subconscious. That one query will then become two the next, to five the following day. Next thing you know, you will most from basic queries to more complex WHERE clauses, conditional statements and playing interior designer with those WINDOW functions that you will be dropping in no time.</p><p><strong><em>But how do I start?</em></strong></p><p>It is no secret that data science is more and more influenced by game theory and behavioral economics and one thing we learn is that incentives matter. In fact, research has shown that losing something hurts more than gaining something. (<a href="https://www.jstor.org/stable/1914185?seq=1">Kahneman &amp; Tversky, 1979</a>) This is why starting creating a penalty rather than reward can get you to SQL habit forming faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*PGMewHX1VniXrrtk_hvkHQ.png" /></figure><p><strong><em>Action Item</em></strong></p><p>Create a daily penalty, which has to be outside your own benefit. Believe me, I have tried creating penalties that involve paying off $10 of student loans for each day I miss. That just ended up with me patting myself on the back saying, “I can skip, because it is going to be something I need to accomplish regardless.” The penalty should be to a charity, 50 burpees you have to do that day or the loss of a TV privilege for your favorite show. This may seem tough, but to create a habit, sometimes we need a fire under our butt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*A9gEaeV7hjbU9e0hJcW3jg.png" /></figure><p><strong><em>I don’t like penalties, just give me something fun!</em></strong></p><p>Ok, ok, I may have come off a little harsh with the whole penalty thing. If you are someone who is big on motivational phrases, like to watch motivational videos before going on a jog, or big on the social media scene, create a challenge. We see a lot of the <a href="https://www.100daysofcode.com/">#100DaysofCoding</a> challenges out there. This is where you can jump right in. Challenge a friend to a bet. Whoever can accumulate the most days of writing a SQL query in a row will receive something (cash, a 6-pack of beer, or back rub, you figure it out). Create a leaderboard, invite colleagues, those friends that are on the job hunt, and get after it!</p><p><strong><em>What are some good resources?</em></strong></p><p>Some fine resources out there are the following:</p><ol><li><a href="https://www.udemy.com/course/the-complete-sql-bootcamp/">SQL by Jose Portillo</a>. The guy is a legit phenom of an instructor.</li><li><a href="https://www.datacamp.com/">DataCamp</a></li><li><a href="https://leetcode.com/">LeetCode</a></li><li><a href="https://www.w3schools.com/sql/">w3schools</a> SQL course</li><li><a href="https://learnsql.com/">learnsql</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWCEop7idca13ew6pjWSHA.png" /><figcaption>ETL team is the new best friend (<a href="https://unsplash.com/photos/QckxruozjRg">source</a>)</figcaption></figure><p><strong><em>Advanced: Make friends with the ETL team</em></strong></p><p>If you are already on the job market and on a data science team, slide one seat over on the proverbial team chairs and make friends with a member of the ETL team. These are the folks that create the pipelines that move data in and out of the applications and machine learning algorithms we design. ETL team members are expert-level SQL junkies. Almost every member of an ETL team or solutions architecture team has SQL skills. By talking about the data challenges they face, seeing how they approach complex table joins and create data warehouses for your analytic dashboarding pleasure, or simply unclogging your data faucets, you can learn a lot. In my experience, these individuals are also excited to learn about data science, and friendly lunch-and-shares can not only create internal team synergies but lead to you acquiring new SQL skills in the process.</p><p>Images:</p><p><a href="https://9gag.com/gag/aqnW0QY"><em>https://9gag.com/gag/aqnW0QY</em></a></p><p><a href="https://www.pinterest.com/pin/499055202427808374/"><em>https://www.pinterest.com/pin/499055202427808374/</em></a></p><p><a href="https://cheezburger.com/8323023360"><em>https://cheezburger.com/8323023360</em></a></p><p><a href="https://medium.com/datadriveninvestor/"><em>https://medium.com/datadriveninvestor/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a62816b9bbd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing an end-to-end machine learning project — Part II]]></title>
            <link>https://medium.com/@nick.s.beaudoin/implementing-an-end-to-end-machine-learning-project-part-ii-c7ed700b529e?source=rss-2acbae65f9b3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7ed700b529e</guid>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Nicholas Beaudoin]]></dc:creator>
            <pubDate>Sun, 16 Oct 2022 21:20:36 GMT</pubDate>
            <atom:updated>2022-10-16T21:20:36.943Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://translatingnerd.com/2020/11/15/walking-the-talk-implementing-an-end-to-end-machine-learning-project/">Implementing an end-to-end machine learning project</a> — Part II</h3><p><em>Authors Note: This piece was originally published by the author in November 2020 on translatingnerd.com</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*v4dhD_ElYlWHB3feVU836w.png" /><figcaption>3–1–2, Lift Off!</figcaption></figure><p>In the previous post, “<a href="https://medium.com/@nick.s.beaudoin/how-to-create-your-first-end-to-end-machine-learning-project-3bf6ba2c6dbb">How to create your first end-to-end machine learning project — Part I</a>”, a four-stage process was offered to get you out of the endless MOOC Trap and jump that fence to greener pastures. These included:</p><ol><li><strong>Find a tutorial</strong></li><li><strong>Follow said tutorial</strong></li><li><strong>Re-follow tutorial with your own data</strong></li><li><strong>Customize your pipeline with your own bling</strong></li></ol><p>To illustrate these concepts, I am going to walk you through how to do this on a newer tech stack. Let’s say, for example, that the Udemy commercials on your YouTube feed have been blaring at you that “Python is where it is at.” So naturally, you want to be like the rest of the cool kids and learn some new tech. You also have a vague idea that cloud-based environments are terrific for Python-based deep learning. Not having a lot of experience in deep learning, you Google, “Deep Learning Projects” and come across some really sweet algorithms that can help you generate text. You now have two things in front of you that you have little experience with: deep learning and renting GPUs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*lsoXS35C2wRV6kKgh1Bgdw.png" /><figcaption>“You know, deep learning is where it is at”</figcaption></figure><p>A few years ago, I found myself in a similar situation. I had a solid understanding and had completed a 300-hour MOOC on deep learning through <a href="https://www.udacity.com/course/deep-learning-nanodegree--nd101">Udacity</a>, but I had yet to complete a project outside of MOOC land. I had learned the math, the tech stack when following a tutorial, and how to leverage GPUs from a sandbox environment. But what I truly needed in my development was the chance to take this new proverbial toolbelt and test it out. Enter the four-step process of moving out of the MOOC Trap!</p><h3>1. Find a Tutorial</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*HNnBhcF_Dwb8UUjbodAjXQ.png" /><figcaption>Tutorial searching.</figcaption></figure><p>The first thing that I needed to do was a solid review of how to use deep learning for text generation. Using recurrent Neural Networks (RNN) and Long-Sort Term Memory (LSTM) neural nets is not at the same level of explaining linear regression. This is where reading blogs and watching YouTube videos of folks talking about their use cases and deep dives into the algorithms is important. Naturally, <a href="https://medium.com/">Medium</a> and <a href="https://towardsdatascience.com/">TowardsDataScience</a> are going to be starting resources.</p><p>After many failed attempts to find a tutorial online that fit my particular use case, I ran across one of my favorite online contributors, Jason Brownlee Ph.D., and attempted to follow his tutorial “<a href="https://machinelearningmastery.com/text-generation-lstm-recurrent-neural-networks-python-keras/">Text Generation with LSTM Recurrent Neural Networks in Python with Keras</a>”. There were many concepts that needed refreshing, so in order to begin Dr. Brownlee’s tutorial, I needed to see some other examples by review. In fact, many of these links were first attempted and a portion of the ideas set forth here was used over the course of my pipeline. But as any student of data science knows, the first GitHub repo or tutorial you look at rarely has the gold you are looking to uncover:</p><ul><li><a href="https://www.youtube.com/watch?v=QtQt1CUEE3w">Keras tutorial on LSTMs</a> and supporting <a href="https://github.com/TannerGilbert/Tutorials/blob/master/Keras-Tutorials/4.%20LSTM%20Text%20Generation/Keras%20LSTM%20Text%20Generation.ipynb">notebook</a></li><li>Jeff Heaton’s deep learning <a href="https://github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_10_3_text_generation.ipynb">notebook</a> tutorial</li><li>Jeff Heaton’s <a href="https://www.youtube.com/watch?v=6ORnRAz3gnA">video series</a></li><li>Dive into how<a href="http://www.datastuff.tech/machine-learning/lstm-how-to-train-neural-networks-to-write-like-lovecraft/"> LSTMs work</a></li></ul><h3>2. Follow tutorial</h3><p>The tutorial leverages LSTMs by taking Lewis Carroll’s Adventures in Wonderland by Lewis Carroll and trying to generate unseen text. Text generation is powerful because it can be used for bots that support and reduce human power to automate tasks such as customer support. This was certainly an area that I wanted to experiment in and Dr. Brownlee’s posts and one of the most well-articulated and presented set of tutorials on the open market.</p><p>Once I read through the tutorial, I opened up my local Jupyter Notebook and got cracking! Leveraging resources outside the technical tutorial was important to understand the math and reasons why LSTMs were a superior form of RNNs (see above links). Namely, which activation functions, drop-out rates, and learning rates needed to be applied out of the gate (no pun for LSTM fans intended).</p><h3>3. Refollow tutorial with your own data</h3><p>After following Dr. Brownlee’s tutorial, I found that my computer’s compute was severely limited. Wanting to make things easy on myself, I transferred my Jupyter Notebook to Google Colab where I could leverage a GPU to speed up the process. While the end goal was to run this on AWS, Google Colab was a safer bet so I wouldn’t accidentally be charged a month’s rent to run a fun side project on EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*6q0cG8QLxLnX3sE6fooY8A.png" /><figcaption>Those EC2 charges</figcaption></figure><p>I have always had this idea of creating a project that could actually solve something in my life. Since I was a little kid, I remember my mother waking up in the dark each Sunday to finish her sermon. Since she was a minister for 30+ years, this practice would occur weekly. The idea came to me that if I could create a bot for her to complete her work, then much time could be freed up. The main issue with training LSTMs is the absence of large amounts of data. Lucky for me, my mother saved every sermon she ever gave on Microsoft Word. Over the past year, she had been sending me emails of 5 sermons that I stored in a folder, thinking that I would get around to this project, but never actually pulling the trigger. After a year of emails, I had 30 years&#39; worth of documents! (20 years x 52 weeks = 1,042 documents). To play it safe, I chose her most recent 300 documents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*pfsGrQGfXta1fhkWZKi5ng.png" /><figcaption>Soooo, do you have a document I can store my documents in?</figcaption></figure><p>Immediately, it became obvious that this would not be like changing the batteries out of a remote. There was much work to customize the various string editors, make sure that certain words were treated differently, and ensure that capitalization mattered where needed. NLP and text analytics are not all about algorithms and knowing what hyperparameters to set, it is more and more about domain knowledge. So like any experienced data science consultant, I called up mom to find out more about her sermons. Having had a front-row seat to most of her career, either in diapers waddling under pews, or to sitting in my 20s/30s listening to her ideas flow of social justice and how the historical prophets would preach about helping those disenfranchised, I felt I had a good sense to her writings. But just as gathering requirements for clients on a work site, I felt that a phone call to mom to gather her biblical requirements to her interpretations was key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*34nv_QFLooaIlqyhrXsm7A.png" /><figcaption>Ramping up that GPU!</figcaption></figure><p>Once all my customizations were in place, I was able to return basic text generations. Since my LSTM was learning on one document, it didn’t have a lot to go off of. I needed more power. I needed a lot more power to run over 300 documents. I went to Google Colab, selected the $10 a month GPU subscription so this bad boy could run uninterrupted overnight and transferred Dr. Brownlee’s followed tutorial from Jupyter Notebook on my weak little MacBook Air to Colab. This is where things got interesting!</p><h3>4. Customize your pipeline with your own bling</h3><p>First off, Dr. Brownlee offers his neural wisdom to recommend algorithm improvements. I quote:</p><p>1) Predict fewer than 1,000 characters as output for a given seed.</p><p>2) Remove all punctuation from the source text, and therefore from the models’ vocabulary.</p><p>3) Try a one-hot encoding for the input sequences.</p><p>4) Train the model on padded sentences rather than random sequences of characters.</p><p>5) Increase the number of training epochs to 100 or many hundreds.</p><p>6) Add dropout to the visible input layer and consider tuning the dropout percentage.</p><p>7) Tune the batch size, try a batch size of 1 as a (very slow) baseline and larger sizes from there.</p><p>8) Add more memory units to the layers and/or more layers.</p><p>9) Experiment with scale factors (<a href="https://en.wikipedia.org/wiki/Softmax_function#Reinforcement_learning">temperature</a>) when interpreting the prediction probabilities.</p><p>10) Change the LSTM layers to be “stateful” to maintain state across batches.</p><p>And he is also nice enough to offer LSTM recurrent neural net “office hour” materials in the following:</p><ul><li><a href="http://www.cs.utoronto.ca/~ilya/pubs/2011/LANG-RNN.pdf">Generating Text with Recurrent Neural Networks</a> [pdf], 2011</li><li><a href="https://github.com/fchollet/keras/blob/master/examples/lstm_text_generation.py">Keras code example of LSTM for text generation</a>.</li><li><a href="https://github.com/Lasagne/Recipes/blob/master/examples/lstm_text_generation.py">Lasagne code example of LSTM for text generation</a>.</li><li><a href="http://mxnetjl.readthedocs.io/en/latest/tutorial/char-lstm.html">MXNet tutorial for using an LSTM for text generation</a>.</li><li><a href="https://larseidnes.com/2015/10/13/auto-generating-clickbait-with-recurrent-neural-networks/">Auto-Generating Clickbait With Recurrent Neural Networks</a>.</li></ul><p>The main issue I had was creating a mechanism that could take each document and extract only the body text, no header, no footers, no fluff, and place it neatly in a .txt document. It took a few iterations, but the following script was able to extract all text and append neatly into one file. As you can see from hte text below, we have dates, locations, names and biblical passages that all need cleaning before being converted into vector space for the LSTM model.</p><p>The below sample sermon shows these areas:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*xGhqsHvZP9ayiD2Y8sb11Q.png" /></figure><p>As you can see, there are many areas that need to be cleaned in this document. There are various titles, headers and specialized characters that need to be taken into account. The following script allows me to read a Microsoft word document or .txt file and append it to a master .txt file that can be fed into the LSTM model clean job. Sources for the initial scripting that this is based on are linked at the beginning of the article. But overall, you can see that the documents are being aggregated from the folder I have on my desktop, the same folder that I dropped my mom’s emails in each week, and loaded to a master document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*KQ8FZrN8hnHhJ4nlLHhBLg.png" /></figure><p>Once I had 300 sermons read into my pipeline on Google Colab, I was able to begin fiddling with the hyperparameters of the LSTM model. Setting multiple layers, optimization methods, activation functions, and back-propagation learning rates, I felt that I could let the neural net train overnight. As you can see, there are 100,352 unique words in my network. These can be seen as nodes that are going to abstract themselves with magic (linear algebra) to create a layer of 8,643 words to predict what word will come next based on the previous words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*xdS2N9YqbVt_3lznLNLDgg.png" /><figcaption>Simple LSTM net, but effective.</figcaption></figure><p>Waking up the next morning was like being a kid on Christmas morning. The excitement I felt opening up Google Colab to see the results pulsated through my veins. I opened up the first paragraph to see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*0azwuY9jLLLr7bpcdOn12g.png" /><figcaption>A puppy, representative of Christmas morning, because, well… puppies.</figcaption></figure><p><em>“I found myself wondering about the wire this church, the people and the post of the seen of the complical seeming the church. The and in the and the lives that the see the worship in the pertans the life the hell the story that the people and the people that the people the work. The work that the light and viel the final see the make of us the for the world the healing of the conter and the people and this people at the story and the say.”</em></p><p>Ok, not exactly the <a href="https://en.wikipedia.org/wiki/Sermon_on_the_Mount">Sermon on the Mount</a>, but hot dang, I got something running and we seem to be cooking with gas now! Of course, getting closer to actual human speak would take more effort, and the idea behind this end-to-end machine learning project was to get something on the board and move from there. Currently, the next step is to place this onto AWS, store the documents on S3 inside a bucket, and pull them into SageMaker where I can control the level of compute power needed for a more in-depth tuning of the product.</p><p>As you can tell, there are now many avenues to take this project. We can look at creating a front-end user interface with Flask, deployed on EC2 with a Docker container and customized Route53 Elastic IP address. We can deploy on Azure’s machine learning studio if we have a specific bend to Microsoft.</p><p>Getting started and out of the MOOC Trap is the main battle for nascent data scientists and experts alike. We pride ourselves on the knowledge that we have accumulated but may feel shy to go out into the world and look at a blank page. I hope that explaining this process will be helpful to those data scientists out there just getting their feet wet.</p><p>The following are links to my code, the resources I used, including the proper accreditations for the code that was borrowed and influential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*1N3G9VUg6kYtYhMqlxiDlQ.png" /><figcaption>AWS integration, here we come!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/0*i0nKFNkvHCV2zUmd" /><figcaption>Link to <a href="https://github.com/nbeaudoin/Sermon-Generator/blob/master/text_aggregator.ipynb">GitHub</a> with code</figcaption></figure><h4>Props and credits to the following images:</h4><ul><li><a href="https://unsplash.com/@spacex">https://unsplash.com/@spacex</a></li><li><a href="https://unsplash.com/@wflwong">https://unsplash.com/@wflwong</a></li><li><a href="https://unsplash.com/@anniespratt">https://unsplash.com/@anniespratt</a></li><li><a href="https://unsplash.com/@jakobowens1">https://unsplash.com/@jakobowens1</a></li><li><a href="https://unsplash.com/@thkelley">https://unsplash.com/@thkelley</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7ed700b529e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>