<?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 Vinayak Sengupta on Medium]]></title>
        <description><![CDATA[Stories by Vinayak Sengupta on Medium]]></description>
        <link>https://medium.com/@vinayak.sengupta?source=rss-315151b8e67d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Gn7EcT-snVAY1JEdON3uCw.png</url>
            <title>Stories by Vinayak Sengupta on Medium</title>
            <link>https://medium.com/@vinayak.sengupta?source=rss-315151b8e67d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 08 Apr 2026 01:35:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vinayak.sengupta/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[The Essential Guide to Effectively Summarizing Massive Documents, Part 1]]></title>
            <link>https://medium.com/data-science/demystifying-document-digestion-a-deep-dive-into-summarizing-massive-documents-part-1-53f2ed9a669d?source=rss-315151b8e67d------2</link>
            <guid isPermaLink="false">https://medium.com/p/53f2ed9a669d</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[document-summarization]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <dc:creator><![CDATA[Vinayak Sengupta]]></dc:creator>
            <pubDate>Sat, 14 Sep 2024 00:10:35 GMT</pubDate>
            <atom:updated>2025-01-06T07:13:03.608Z</atom:updated>
            <content:encoded><![CDATA[<h4>Document summarization is important for GenAI use cases, but what if the documents are too BIG!? Read on to find out how I have solved it.</h4><figure><img alt="Document summarization — Image generated by the author with GPT-4o" src="https://cdn-images-1.medium.com/max/1024/1*XpFUc37Ol5aeqXiFB92f5A.png" /><figcaption>“Summarizing a lot of text”— Image generated with GPT-4o</figcaption></figure><p>Document summarization today has become one of the most (if not the most) common problem statements to solve using modern Generative AI (GenAI) technology. Retrieval Augmented Generation (RAG) is a common yet effective solution architecture used to solve it (If you want a deeper dive into what RAG is, check out this <a href="https://medium.com/@vinayak.sengupta/exploring-the-core-of-augmented-intelligence-advancing-the-power-of-retrievers-in-rag-frameworks-3ef9fe273764"><strong>blog</strong></a>!). But what if the document itself is so large that it cannot be sent as a whole in a single API request? Or what if it produces too many chunks to cause the infamous ‘Lost in the Middle’ context problem? In this article, I will discuss the challenges we face with such a problem statement and go through a step-by-step solution that I applied using the guidance offered by Greg Kamradt in his <a href="https://github.com/gkamradt/langchain-tutorials/blob/main/data_generation/5%20Levels%20Of%20Summarization%20-%20Novice%20To%20Expert.ipynb"><strong>GitHub repository</strong></a>.</p><h3>Some “c<em>ontext”</em></h3><p>RAG is a well-discussed and widely implemented solution for addressing document summarizing optimization using GenAI technologies. However, like any new technology or solution, it is prone to edge-case challenges, especially in today’s enterprise environment. Two main concerns are contextual length coupled with per-prompt cost and the previously mentioned ‘Lost in the Middle’ context problem. Let’s dive a bit deeper to understand these challenges.</p><blockquote><strong>Note</strong><em>:</em> <em>I will perform the exercises in Python, using the LangChain, Scikit-Learn, Numpy, and Matplotlib libraries for quick iterations.</em></blockquote><h3>Context window and Cost constraints</h3><p>Today, with automated workflows enabled by GenAI, analyzing big documents has become an industry expectation/requirement. People want to quickly find relevant information from medical reports or financial audits by prompting the LLM. But there is a caveat: enterprise documents are not like documents or datasets we deal with in academics; the sizes are considerably bigger, and the pertinent information can be present anywhere in the documents. Hence, methods like data cleaning/filtering are often not a viable option since domain knowledge regarding these documents is not always given.</p><p>In addition to this, even the latest Large Language Models (LLMs) like GPT-4o by OpenAI with context windows of 128K tokens cannot just consume these documents in one shot, or even if they did, the quality of response will not meet standards, especially for the cost it will incur. To showcase this, let’s take a real-world example of trying to summarize the Employee Handbook of GitLab, which can downloaded <a href="https://kocielnik.gitlab.io/gitlab_handbook_takeaway/about-the-handbook.html"><strong>here</strong></a>. This document is available free of charge under the MIT license available on their GitHub <a href="https://gitlab.com/kocielnik/gitlab_handbook_takeaway/-/blob/master/LICENSE">repository</a>.</p><p>1 We start by loading the document and also initializing our LLM, to keep this exercise relevant, I will make use of GPT-4o.</p><p><strong><em>Note</em></strong>: We have removed the first 30 pages of the document as they are change logs and will not contribute to insightful information and only consume memory.</p><pre>from langchain_community.document_loaders import PyPDFLoader<br><br># Load PDFs<br>pdf_paths = [&quot;/content/gitlab_handbook.pdf&quot;]<br>documents = []<br><br>for path in pdf_paths:<br>    loader = PyPDFLoader(path)<br>    documents.extend(loader.load())<br><br>from langchain_openai import ChatOpenAI<br>llm = ChatOpenAI(model=&quot;gpt-4o&quot;)</pre><p>2 Then, we can divide the document into smaller chunks (this is for <em>embedding</em>; I will explain why in the later steps).</p><pre>from langchain.text_splitter import RecursiveCharacterTextSplitter<br><br># Initialize the text splitter<br>text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=0)<br><br># Split documents into chunks<br>splits = text_splitter.split_documents(documents)</pre><p>3 Now, let’s calculate how many tokens make up this document, for this, we will iterate through each document chunk and calculate the total tokens that make up the document.</p><pre>total_tokens = 0<br><br>for chunk in splits:<br>    text = chunk.page_content  # Assuming `page_content` is where the text is stored<br>    num_tokens = llm.get_num_tokens(text)  # Get the token count for each chunk<br>    total_tokens += num_tokens<br><br>print(f&quot;Total number of tokens in the book: {total_tokens}&quot;)<br><br># Total number of tokens in the book: 254006</pre><p>As we can see, the number of tokens is 236,592, while the context window limit for GPT-4o is 128,000. This document cannot be sent in one go through the LLM’s API. In addition to this, considering this model&#39;s pricing is $0.00500 / 1K input tokens, a single request sent to OpenAI for this document would cost $1.18! This does not sound horrible until you present this in an enterprise paradigm with multiple users and daily interactions across many such large documents, especially in a startup scenario where many GenAI solutions are being born.</p><h3>Lost in the Middle</h3><p>Another challenge faced by LLMs is the <em>Lost in the Middle </em>Context problem, as discussed in detail in this <a href="https://arxiv.org/abs/2307.03172"><strong>paper</strong></a>. Research and my experiences with RAG systems handling multiple documents describe that LLMs are not very robust when it comes to extrapolating information from long context inputs. Model performance degrades considerably when relevant information is somewhere in the middle of the context. However, the performance improves when the required information is either at the beginning or the end of the provided context. Document Re-ranking is a solution that has become a subject of progressively heavy discussion and research to tackle this specific issue. I will be exploring a few of these methods in another post. For now, let us get back to the solution we are exploring, which utilizes K-Means Clustering.</p><h3>What is K-Means Clustering?!</h3><p>Okay, I admit I sneaked in a technical concept in the last section. Allow me to explain it (for those who may not be aware of the method, I got you).</p><h4>First the basics</h4><p>To understand K-means clustering, we should first know what clustering is. Consider this: we have a messy desk with pens, pencils, and notes all scattered together. To clean up, one would group items, like all pens in one group, pencils in another, and notes in another, creating essentially three separate groups (not promoting segregation). Clustering is the same process where among a collection of data (in our case, the different chunks of document text), similar data or information are grouped, creating a clear separation of concerns for the model, making it easier for our RAG system to pick and choose information effectively and efficiently instead of having to go through it all like a greedy method.</p><h4>K, Means?</h4><p>K-means is a specific method to perform clustering (there are other methods, but let’s not information dump). Let me explain how it works in 5 simple steps:</p><ol><li><strong>Picking the number of groups (K)</strong>: How many groups we want the data to be divided into</li><li><strong>Selecting group centers</strong>: Initially, a center value for each of the K-groups is randomly selected</li><li><strong>Group assignment</strong>: Each data point is then assigned to each group based on how close it is to the previously chosen centers. Example: items closest to center 1 are assigned to group 1, items closest to center 2 will be assigned to group 2…and so on till Kth group.</li><li><strong>Adjusting the centers</strong>: After all the data points have been pigeonholed, we calculate the average of the positions of the items in each group, and these averages become the new centers to improve accuracy (because we had initially selected them at random).</li><li><strong>Rinse and repeat: </strong>With the new centers, the data point assignments are again updated for the K-groups. This is done till the difference (mathematically the <strong><em>Euclidean</em> <em>distance</em></strong>) is minimal for items within a group and the maximal from other data points of other groups, ergo optimal segregation.</li></ol><p>While this may be quite a simplified explanation, a more detailed and technical explanation (for my fellow nerds) of this algorithm can be found <a href="https://www.analyticsvidhya.com/blog/2019/08/comprehensive-guide-k-means-clustering/">here</a>.</p><h3>Enough theory, let’s code.</h3><p>Now that we have discussed K-means clustering, which is the main protagonist in our journey to optimization, let us see how this robust algorithm can be used in practice to summarize our Handbook.</p><p>4 Now that we have our chunks of document text, we will be embedding them into vectors.</p><pre>from langchain_openai import OpenAIEmbeddings<br><br>embeddings = OpenAIEmbeddings()<br><br># Embed the chunks<br>chunk_texts = [chunk.page_content for chunk in splits]  # Extract the text from each chunk<br>chunk_embeddings = embeddings.embed_documents(chunk_texts)</pre><h4>Maybe a little theory</h4><p>Alright, alright, so maybe there’s more to learn here — what’s embedding? Vectors?! and why?</p><h4>Embedding &amp; Vectors</h4><p>Think of how a computer does things — it sees everything as binary, ergo, the best language to teach/instruct it is in numbers. Hence, an optimal way to have complex ML systems understand our data is to see all that text as numbers, and that very method by which we do this conversion is called <strong>Embedding</strong>. The number list describing the text or word is known as <strong>Vectors</strong>.</p><p>Embeddings can differ depending on how we want to describe our data and the heuristics we choose. Let’s say we wanted to describe an apple; we need to consider its color (Red), its shape (Roundness), and its size. Each of these could be encoded as numbers, like the ‘redness’ could be an 8 on a scale of 1–10. The roundness could be 9, and the size could be 3 (inches in width). Hence, our vector for representing the apple would be [8,9,3]. This very concept is applied in more complexity when describing different qualities of documents where we want each number to map the topic, the semantic relationships, etc. This would result in vectors having hundreds or more numbers long.</p><h4>But, Why?!</h4><p>Now, what improvements does this method provide? Firstly, as I mentioned before, it makes data interpretation for the LLMs easier, which provides better accuracy in inference from the models. Secondly, it also helps massively in memory optimization (space complexity in technical terms) by reducing the amount of memory consumption by converting the data into vectors. The paradigm of vectors is known as vector space, for example, A document with 1000 words can be reduced to a 768-dimensional vector representation, hence resulting in a 768 number representation instead of 1000 words.</p><p>A little deeper math (for my dear nerds again), “1234” in word (or strings in computer language) form would consume 54 bytes of memory, while the 1234 in numeral (integers in computer language) form would consume only 8 bytes! So, if you were to consider documents consuming Megabytes, we are reducing memory management costs as well (yay, budget!).</p><h4>And we are back!</h4><p>5 Using the Scikit-Learn Python library for easy implementation, we first select the number of clusters we want, in our case 15. We then run the algorithm to fit our embedded documents into 15 clusters. The parameter ‘random_state = 42’ means that we are shuffling the dataset to prevent pattern bias in our model.</p><p>It is also important to note that we are converting our list of embeddings into a Numpy array (a mathematical representation of vectors for advanced operation in the Numpy library). This is because Scikit-learn requires Numpy arrays for K-means operation.</p><pre>from sklearn.cluster import KMeans<br>import numpy as np<br><br>num_clusters = 15<br># Convert the list of embeddings to a NumPy array<br>chunk_embeddings_array = np.array(chunk_embeddings)<br><br># Perform K-means clustering<br>kmeans = KMeans(n_clusters=num_clusters, random_state=42).fit(chunk_embeddings)</pre><h3>Class dismissed…for now.</h3><p>I think this is a good place for a pit stop! We have covered much, both in code and theory. But no worries, I will be posting a second part covering how we make use of these clusters in generating rich summaries for large documents. There are going to be more interesting techniques to showcase, and of course, I will be explaining through all the theory and understanding as best as I can!</p><p>So stay tuned! Also, I would love your feedback and any comments you may have regarding this article, as it helps me improve my content, as always, Thank you so much for trading, and I hope it was worth the read!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JSurhfpP5kxYiVib" /><figcaption>Photo by <a href="https://unsplash.com/@priscilladupreez?utm_source=medium&amp;utm_medium=referral">Priscilla Du Preez 🇨🇦</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53f2ed9a669d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/demystifying-document-digestion-a-deep-dive-into-summarizing-massive-documents-part-1-53f2ed9a669d">The Essential Guide to Effectively Summarizing Massive Documents, Part 1</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advancing the Power of Retrievers in RAG Frameworks]]></title>
            <link>https://medium.com/swlh/exploring-the-core-of-augmented-intelligence-advancing-the-power-of-retrievers-in-rag-frameworks-3ef9fe273764?source=rss-315151b8e67d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ef9fe273764</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[retrieval-augmented]]></category>
            <category><![CDATA[retrieval-generation]]></category>
            <category><![CDATA[information-retrieval]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Vinayak Sengupta]]></dc:creator>
            <pubDate>Sat, 13 Jan 2024 14:43:36 GMT</pubDate>
            <atom:updated>2024-09-05T19:54:11.118Z</atom:updated>
            <content:encoded><![CDATA[<h4>In this article, I try to give credit where it’s due, spotlighting the unsung heroes that determine the effectiveness in the many document question-answering toolkits: the retrievers themselves.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nwJz-CvG6epJoZd9" /><figcaption>Photo by <a href="https://unsplash.com/@vonshnauzer?utm_source=medium&amp;utm_medium=referral">Egor Myznik</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>A small but needed Introduction</h3><p>Retrieval-Augmented Generation (RAG) like many Generative AI (GenAI) topics is being exhaustively discussed. Information retrieval techniques learnt in undergraduate studies are now being combined with Large Language Models (LLMs). Yet, amidst this broader discussions, I feel the ‘R’ in RAG — isn&#39;t as deeply discussed. As the crucial component that navigates through vast corpora of knowledge to retrieve relevant information and context for our foundation models, retrievers form the backbone of this modern and dare I say, sophisticated architecture.</p><p>Hence, through a rather detailed experimenting with various modern retrieval methodologies I have employed, I have tried to document as to <strong>What</strong> these methods are, <strong>Why</strong> would we use them, and <strong>When</strong> are they most fruitful in their retrievals.</p><h3>Primary Schooling</h3><p>Before getting down and dirty with the different methods of retrieval, lets familiarize ourselves with a few introductory concepts (for some of you this maybe a refresher)</p><ul><li><strong>Language Models (LLMs)</strong> :- Large Language Models, example — OpenAI’s GPT-4 and Google’s Gemini Pro, are trained on humongous corpus’ of text data and can generate human-like responses towards, answering queries, and performing other language-related tasks like translations and even summarizing large amounts text. They have become a game-changer in natural language processing applications.</li><li><strong>Information Retrieval</strong> :- It is the process of obtaining relevant information from a large quantity of data. In our architecture (which I will show shortly), it involves finding the right parts of the documents that are most relevant to a user’s question.</li><li><strong>Retrieval-Augmented Generation (RAG)</strong> :- RAG is an architecture that is a Venn diagram between Information Retrieval (IR) and LLMs, to generate contextually relevant and insight rich responses. The retriever first fetches relevant parts of the document pertaining to user query, and then the LLM uses this information to generate a response.</li><li><strong>Vector Database (VectorDB)<em> </em></strong>:- A unique breed of databases, vector databases store data in a high-dimensional space, allowing for unique searching methods towards similarity and semantic searching (explained just below).</li><li><strong>Semantic Search</strong> :- Semantic searching goes beyond the now generic keyword-matching methodology in understanding the contextual meaning of a user prompt. It uses <a href="https://www.techtarget.com/searchenterpriseai/definition/natural-language-understanding-NLU"><strong>Natural Language Understanding</strong></a> (NLU) techniques to retrieve information that is conceptually relevant to the prompt, even if the exact words are not present in the documents.</li><li><strong>Contextual Information</strong> :- Context is imperative in NLU. In the architecture, context is added to the user query to provide additional information, which can help the LLM generate more accurate and relevant responses.</li><li><strong>Metadata<em> </em></strong>:- Metadata refers to any additional information regarding the primary data that can be used to guide the retrieval and generation process. In our architecture, metadata includes details like the user query itself, context (this can include any addition prompt engineering or data), and parameters (I will explain in a bit) that might positively influence the retrieval and response generation process.</li></ul><h3>The RAG Architecture</h3><figure><img alt="The architecture is a flowchart representing the different retrievers and how they are initialized and what parameters they need to be configured" src="https://cdn-images-1.medium.com/max/1024/1*7NMXWfHnRy79m2CQgdx3YA.png" /><figcaption>RAG function flowchart</figcaption></figure><p>The above flowchart is a representation of a function architecture I developed using classes from the <a href="https://python.langchain.com/docs/modules/data_connection/retrievers/"><strong>Langchain</strong></a><em> </em>package in Python. Lets go step-by-step in understanding what the architecture is performing and then I will explain each concept in more theoretical detail to highlight their differences.</p><p>1 — The function extracts parameters such as `<em>retrieval_k</em>`, `<em>mmr_lambda_mult</em>`, `<em>retriever_search_type</em>`, and `<em>ensemble_weights</em>` from the user input. These parameters will be the configurations for the retrievers themselves.</p><p>2 — The value of `<em>retriever_search_type</em>` is recorded, to decide which retriever methodology to configure and apply. There are several conditions based on the value:</p><ul><li>The function initializes a `<em>BM25Retriever</em>` using the provided `<em>documents</em>` and `<em>metadatas</em>`. This retriever will be used either on its own or as part of an ensemble.</li><li>If <em>retriever_search_type </em>is <strong><em>mmr</em></strong>, the function creates a MMR-based retriever from the `<em>vectordb</em>`, then creates a `<em>MultiQueryRetriever</em>` using the `<em>llm</em>`, and finally returns an `<em>EnsembleRetriever</em>` combining the `<em>bm25_retriever</em>` and the `<em>multi_query_retriever</em>`.</li><li>If <em>retriever_search_type</em> is <strong><em>no_mmr</em></strong>, the function initializes MMR-based retriever from the `<em>vectordb</em>`, then creates a `<em>MultiQueryRetriever</em>` using the `<em>llm</em>`, and returns an `<em>EnsembleRetriever</em>` as before.</li><li>If <em>retriever_search_type</em> is <strong><em>mmr_without_multi</em></strong>, an MMR-based retriever but without the multi-query functionality is initialized and returns an `EnsembleRetriever` with just the `bm25_retriever` and the MMR retriever.</li><li>If <em>retriever_search_type</em> is <strong><em>no_mmr_without_multi</em></strong>, the function creates a retriever without MMR and without multi-query functionality, and returns an `<em>EnsembleRetriever</em>` as before.</li><li>If <em>retriever_search_type</em> is <strong><em>retriever_mmr</em></strong>, the function returns the MMR-based retriever from the `<em>vectordb</em>` directly.</li></ul><p>3 — If none of the specific `<em>retriever_search_type</em>` conditions are met, the function defaults to returning the `<em>vectordb</em>` as a retriever without MMR.</p><h3>Secondary Schooling (The What)</h3><p>Now, I know I threw around a number of statistical and technical jargon throughout the explanations and (while some of you may know what they mean) allow me explain them in detail in this section.</p><h3>BM25Retriever</h3><h4>What is it?</h4><p>BM25 is an IR methodology applying the <strong>B</strong><a href="https://machinelearningmastery.com/gentle-introduction-bag-words-model/"><strong>ag-Of-Words</strong></a> (BOW) model, that ranks a set of documents based on the exact presence of user prompt’s words appearing in each document, regardless of the inter-relationship between the words themselves within a document like their proximity to each other or the order in which they appear. It’s an extension of the <a href="https://monkeylearn.com/blog/what-is-tf-idf/"><strong>Term Frequency-Inverse Document Frequency</strong></a> (TF-IDF) algorithm.</p><h4>What variables (parameters) make it work?</h4><ul><li>`<strong><em>documents</em></strong>`: The list of documents to be indexed and searched through.</li><li>`<strong><em>metadatas</em></strong>`: Additional information about the documents or the question itself, that may can be used for filtering during retrieval.</li></ul><h4>How does it work?</h4><p>In the function, `<em>BM25Retriever</em>` is created from the provided `<em>documents</em>` and `<em>metadatas</em>`. It’s used either on its own or as part of an ensemble retriever.</p><h3>VectorStore (vectordb) as a retriever</h3><h4>What is it?</h4><p>‘<em>VectorStore</em>’ essentially represents the Vector Database that we had discussed earlier. In our architecture the `<em>VectorStore</em>` is used to create a retriever to perform semantic searches.</p><h4>What variables (parameters) make it work?</h4><ul><li>`<strong><em>search_type</em></strong>`: This parameter defines the type of search algorithm for the retriever. For example, “mmr” indicates that the search should use Maximal Marginal Relevance (MMR) to balance relevance to the question with diversity of different information chunks from the document. <em>There are a number of different algorithms that can be chosen from and I strongly urge you to explore them all!</em></li><li>`<strong><em>search_kwargs</em></strong>`: These are keyword arguments that specify main configurations for the retrievers and their search algorithms. A common argument includes — `<strong><em>k</em></strong>`: The number of top document chunks to retrieve.</li></ul><h4>How does it work?</h4><p>In our architecture, a retriever is created using the `<em>VectorStore</em>` to perform semantic searches. Depending on the `<em>retriever_search_type</em>`, the `<em>VectorStore</em>` may be configured to use MMR or not as its underlying search algorithm.</p><p>When the `<em>VectorStore</em>` is used as a retriever with MMR (which I will be explaining below), it will rank the retrieved search results to provide a set of document chunks that are not only contextually relevant to the user prompt but also diverse in its content. This is particularly useful when you want to avoid redundancy in the retrieval results and generate a response based on a broader range of information.</p><p>If MMR is not used, the `<em>VectorStore</em>` retriever will apply similarity search by first converting the user prompt into its respective vector representation and then focusing on matching the most relevant document chunks based on the similarity of their vector representations to the prompt vectors. This approach is simpler and prioritizes relevance over diversity.</p><h3>Maximal Marginal Relevance (MMR)</h3><h4>What is it?</h4><p>MMR is a rank-order technique to re-rank the retrieval results to balance relevance and diversity. It helps in reducing information redundancy by considering both the similarity of each document to the query and the dissimilarity of the documents to each other.</p><h4>What variables (parameters) make it work?</h4><ul><li>`<strong><em>k</em></strong>`: The number of top documents to retrieve.</li><li>`<strong><em>lambda_mult</em></strong>`: A parameter that measures the magnitude of trade-off between relevance and diversity. A higher value favors relevance, while a lower value favors diversity.</li></ul><h4>How does it work?</h4><p>In the function, MMR is used as a `<em>search_type</em>` for the `<em>vectordb</em>` retriever. It’s also used to determine whether to include MMR in the ensemble retriever architecture.</p><h3>MultiQueryRetriever</h3><h4>What is it?</h4><p>The `MultiQueryRetriever` is a class from the LangChain library that enhances the retrieval process by generating multiple versions of the given user prompt, this is done using an LLM as the underlying foundation model. The approach aims at addressing the limitations of traditional distance-based vector database retrieval methods (like direct similarity search), which can be sensitive to subtle changes in prompt wording and may not always capture the semantics of the data correctly.</p><p>Distance-based vector database retrieval works by converting the prompt and documents into a high-dimensional vectors using an <a href="https://www.cloudflare.com/learning/ai/what-are-embeddings/"><strong>Embedding Model</strong></a>, and then finding document vectors that are “close” to the prompt vectors in terms of some distance metric (e.g., cosine similarity).</p><p><em>Again there are many other metrics to measure semantic distances and I urge you play around with them!</em>.</p><p>However, this method can sometimes fail to retrieve relevant document chunks if the embeddings do not align well with the semantics of the user query or the documents, hence, using the right embedding model is crucial as different models produce vectors of different dimensionality as well.</p><p>The `<em>MultiQueryRetriever</em>` overcomes this by using an LLM to generate multiple variations of the original query. These variations are intended to capture different interpretations of the query, thus augmenting the context of the user question itself, which can lead to a more comprehensive set of retrieved documents.</p><h4>What variables (parameters) make it work?</h4><ul><li>`<strong><em>llm</em></strong>`: The language model used for generating multiple queries. This model can be configured with parameters like `<em>temperature</em>` to control the diversity of the generated queries.</li><li>`<strong><em>retriever</em></strong>`: The underlying retriever that is used to perform the actual document retrieval for each generated query. This is typically a vector store-based retriever to uphold sparsity.</li><li>`<strong><em>query</em></strong>`: The original user input prompt that is to be expanded into multiple queries.</li></ul><h4>How does it work?</h4><ul><li><strong>Query Generation</strong>: The `MultiQueryRetriever` takes the original user query and uses the LLM to generate multiple versions of same question.</li><li><strong>Retrieval</strong>: For each generated version, the retriever performs a search using the underlying vector database to retrieve a comprehensive set of relevant documents.</li><li><strong>Aggregation</strong>: The retriever then takes the mathematical union of all the unique documents retrieved from the different queries to form the comprehensive set of relevant document chunks.</li></ul><p>‘<em>MultiQueryRetriever</em>` is created using a retriever (with or without MMR) and a language model. It is also used in the ensemble architecture when multi-query functionality is desired.</p><h3>EnsembleRetriever</h3><h4>What is it?</h4><p>The `<em>EnsembleRetriever</em>` is a retrieval architecture that combines the retrieved information from multiple retrievers to provide a more comprehensive and potentially more accurate set of search results.</p><p>An ensemble method in the context of IR involves using multiple retrieval algorithms to obtain a set of candidate document chunks and then merging these results into a single ranked list. The `<em>EnsembleRetriever</em>` specifically uses the <a href="https://safjan.com/implementing-rank-fusion-in-python/"><strong>Reciprocal Rank Fusion</strong></a><strong> </strong>(RRF) algorithm to re-rank the combined results.</p><p>Ok I just dropped another big algorithm name, but what is it exactly?</p><p>RRF is a ranking followed by aggregation algorithm that essentially combines the documents chunks that have been retrieved and ranked according to relevancy from different retrieval systems. The key idea is to assign a score to each document based on its rank in each individual retrieval system’s results. The inverse of the rank (1/rank) is used, so that higher-ranked documents receive higher scores. The scores from all retrieval systems are then summed for each document, and the documents are then re-ranked based on these combined scores to produce the final ranking.</p><h4>What variables (parameters) make it work?</h4><ul><li>`<strong><em>retrievers</em></strong>`: list of retriever that are to be combined. Each retriever has its own method for obtaining relevant documents, such as BM25 for keyword-based retrieval or a vector-based method for semantic retrieval.</li><li>`<strong><em>weights</em></strong>`: The weights assigned to each retriever’s results when combining them. Essentially setting the ratio between which retriever to give more importance to.</li></ul><h4>How does it work?</h4><p>To use the `EnsembleRetriever`, you provide a list of retrievers that you want to combine. The `EnsembleRetriever` will then call the `<em>get_relevant_documents()</em>` method for each retriever (this is a built-in function by LangChain for these retriever classes) for a given user prompt, combine the results using RRF, and return the re-ranked list of document chunks.</p><h3>Going into the Why and When</h3><p>Now I hope that I have been able to give you atleast a beginners understanding of the different retrievers possible and their use-cases, but you would ask — why would I necessarily choose one over the other? lets dive into some of their key differences and when one would be preferred over the other.</p><h3>BM25Retriever</h3><h4>Advantages</h4><ul><li><strong>Keyword matching</strong>: BM25 is hard to beat when it comes to finding regions in the documents that contain specific keywords, making it suitable for searches where users know exactly what terms they are looking for.</li><li><strong>Scalability</strong>: BM25 is computationally efficient and can handle large collections of documents within relatively low resource environments.</li><li><strong>Simplicity</strong>: It is straightforward to implement and understand as the underlying search algorithm is not very complicated, with well-established tuning parameters.</li></ul><h4>Disadvantages</h4><ul><li><strong>Lack of semantic understanding</strong>: BM25 does not capture the meaning behind of words in the context or user prompt, so it can tend to miss out on relevant documents that do not contain the exact prompt terms being referenced.</li><li><strong>Sensitivity to term frequency</strong>: BM25 can be biased towards longer documents or those that repeat certain terms, which may not always align with relevance.</li></ul><h4>Preferred Use Cases</h4><p>BM25 is preferred when the search queries are expected to contain precise keywords that match the document content, and when computational efficiency is a higher priority.</p><h3>VectorStore Retriever</h3><h4>Advantages</h4><ul><li><strong>Semantic search</strong>: Vector-based retrieval is able capture the meaning of (semantic relationship between words) the text, enabling it to find relevant document chunks based on conceptual and contextual similarity rather than exact keyword matches.</li><li><strong>Model capabilities</strong>: The embeddings used in vector-based retrieval benefit from the advancements in language models, which can understand nuanced language and context. The embeddings being essentially mathematical representations of data can be be more accurately processed and evaluated.</li></ul><h4>Disadvantages</h4><ul><li><strong>Computational cost</strong>: Generating and storing the embeddings of the documents can be resource-intensive, especially for large document collections.</li><li><strong>Sensitivity to embedding quality</strong>: The effectiveness of the retrieval depends on the quality of the embeddings, which can vary based on the language model itself.</li></ul><h4>Preferred Use Cases</h4><p>Vector-based retrieval is preferred when the search requires a need to find relevant information without only relying on exact keyword matches.</p><h3>MultiQueryRetriever</h3><h4>Advantages</h4><ul><li><strong>Query expansion</strong>: By generating multiple versions of the user’s prompt, the MultiQueryRetriever can capture a wider range of relevant documents that may have been missed by a single query.</li><li><strong>Robustness in query creation</strong>: It is less sensitive to the specific wording of the query, as it explores different ways of expressing the same intent. This is done by the underlying LLM.</li></ul><h4>Disadvantages</h4><ul><li><strong>Computational overhead</strong>: Generating multiple queries and retrieving documents for each can be computationally expensive.</li><li><strong>Potential for introducing noise</strong>: While a broader set of documents are retrieved, some of them could be less relevant, increasing non-relevant or inaccurate content in the results.</li></ul><h4>Preferred Use Cases</h4><p>MultiQueryRetriever is preferred when there is uncertainty in how users may want to phrase their queries, and when it’s important to retrieve a diverse set of potentially relevant documents.</p><h3>EnsembleRetriever</h3><h4>Advantages</h4><ul><li><strong>Combining strengths</strong>: By bringing the best of both <a href="https://ar5iv.labs.arxiv.org/html/2109.10739"><strong>sparse and dense retrievers</strong></a>, the EnsembleRetriever can provide a more comprehensive set of results that benefits from keyword matching and semantic understanding.</li><li><strong>Improved performance</strong>: It often achieves better performance than any single retriever by working on and mitigating their individual weaknesses.</li></ul><h4>Disadvantages</h4><ul><li><strong>Complexity</strong>: Managing and tuning multiple retrievers is more complex than using a single method.</li><li><strong>Resource intensity</strong>: The need to run multiple retrievers and then to combine their results leads to higher computational and memory consumption.</li></ul><h4>Preferred Use Cases</h4><p>The EnsembleRetriever is preferred when the goal is to maximize retrieval performance and when there is a need to balance keyword precision against semantic recall. It’s particularly useful when dealing with very heterogeneous data or when highly variability in user questioning is expected in terms of specificity or phrasing.</p><h3>Encapsulating our long discussion</h3><p>In summary, I think I can confidently say that retrievers — are the linchpin that enables these modern LLMs to sift through like a dispensing machine that understands what you might to want to drink and outputs the drink that you actually wanted. From the more traditional <strong>BM25Retriever</strong>, to the <strong>VectorStore’s</strong> nuanced grasp of semantics, each retriever plays a distinct role in the performance of an effective RAG system. The <strong>MultiQueryRetriever</strong> broadens the search horizon by multi-faceting the user prompts, while the <strong>EnsembleRetriever</strong> efficiently balances different strategies to retrieve search results that single retriever could fail to do on their own.</p><p>Through comprehensive understanding, it’s evidently visible that building an optimal retrieval system is not just a technical skill but requires strategic understanding of information retrival intentions. The carefully calculated parameters like ‘<em>retriever_search_type</em>’ and ‘<em>mmr_lambda_mult</em>’ are not merely switches that turn on a process, but are tools to influence the precision as well as the recall of the very architecture.</p><h3>Wrapping up this conversation</h3><p>As GenAI progresses, we are already seeing innovative methods and optimizations in these kind of architectures. Understanding the interplay of and between retrievers not only enhances current performance but also the chances of more sophisticated and intelligent information retrieval.</p><p>If you did find this article informative or helpful, let me know! and if you found areas of improvement, please let me know as well, because even I am an ever learning developer in the generative AI landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ef9fe273764" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/exploring-the-core-of-augmented-intelligence-advancing-the-power-of-retrievers-in-rag-frameworks-3ef9fe273764">Advancing the Power of Retrievers in RAG Frameworks</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customer Segmentation, Identifying the Profit Among the Loose Ends.]]></title>
            <link>https://medium.com/swlh/customer-segmentation-identifying-the-profit-among-the-loose-ends-6fe4d6279873?source=rss-315151b8e67d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fe4d6279873</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[customer-segmentation]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[udacity]]></category>
            <dc:creator><![CDATA[Vinayak Sengupta]]></dc:creator>
            <pubDate>Wed, 15 Jul 2020 04:50:20 GMT</pubDate>
            <atom:updated>2020-09-02T14:50:22.837Z</atom:updated>
            <content:encoded><![CDATA[<p>A short descriptive narrative about a recent real-world, data science project I just completed for an online certification course on Udacity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*LqG9ESNbBC0NU6LltHd8rg.jpeg" /></figure><h3>What is this about?</h3><p>The blog post basically is a discussion about the insights, that I learnt from working on the data provided by <strong>Bertelsmann Arvato Analytics</strong>. This project is based on real-world data science problem of customer segmentation.</p><p>The main aim of this project is to predict those individuals who are likely to become customers of the company based on many of their attributes, from the general population.</p><h3>How was this done?</h3><p>2 main approaches were taken in the identification of potential clients:</p><ul><li>An Unsupervised Learning approach, where we perform segmentation and form <strong>Clusters </strong>on the company’s current customer base as well the general population.</li><li>A Supervised Learning approach, in which we use a <strong>machine-learning algorithm</strong> to predict whether or not each individual will respond to the campaign (target customers).</li></ul><p>For the evaluation of our model’s accuracy, we have utilised AUC/ROC.</p><h3>Engineering the Data</h3><p>For the project, we were provided with 4 files containing the demographic data of both customers and the general population of Germany. The dataset contains a notorious amount of missing values, and so we must clean the dataset to be able to work with it.</p><blockquote><strong><em>The Dataset files</em></strong></blockquote><ul><li><strong>CUSTOMERS: </strong>Demographics data for customers of a mail-order company. 191,652 (rows) x 369 (columns)</li><li><strong>AZDIAS: </strong>Demographic data for the general population of Germany. 891,211 (rows) x 366 (columns)</li><li><strong>MAILOUT_TRAIN: </strong>Demographic data for individuals who were targets of a marketing campaign. 42,982 (rows) x 367 (columns)</li><li><strong>MAILOUT_TEST</strong>: Demographic data for individuals who were targets of a marketing campaign. 42,833 persons (rows) x 366 (columns).</li></ul><p>Our main focus would be on the customer and azdias datasets.</p><blockquote><strong><em>Exploring the Datasets</em></strong></blockquote><p>To make the data ready as an input to the machine learning algorithm we have to fill the NaN (missing) values. To understand how all the missing values can be filled, let&#39;s take a closer look at the columns with the most number of missing values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*NtXN6EmRaulfferBkpEEng.png" /><figcaption>Top 10 columns containing missing values (in %)</figcaption></figure><p>From the graph above, it can be clearly seen that there are a significant amount of missing data in many columns, with 4 columns having more than 90% of the data, missing.</p><p>The graph below showcases the proportion of missing data in the columns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*7Nv5xEleyVkn_SeIm3SKQw.png" /><figcaption>The percentage of missing data</figcaption></figure><p>To make the dataset workable for our analysis, we will have to heavily clean it and modify it, so as to not lose too many important information but also get rid of sources of inaccuracies.</p><p>Hence, we start by dropping all the rows with more than 16 missing data present in them. This will reduce the row count for our dataset from 891,211 to 733,227.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*RxYGkFYQBI5ennGYQi0iOQ.png" /><figcaption>Percentage of data kept</figcaption></figure><p>The following flow of steps have been taken, to get rid of unnecessary columns and missing data:</p><ul><li>We have removed all the columns that contain more than 65% missing data.</li><li>Dropped additional 3 columns that are present in the customer dataset but not in general population data.</li><li>Dropped columns with too many different items.</li><li>Columns that are highly correlated.</li><li>Filled missing values in certain columns with ‘-1’ based on our analysis.</li><li>Filled the remaining missing data with mode.</li></ul><p>We then went ahead and finally removed the outliers as well as normalised the data to a range of standardized values for better analytical calculations.</p><h3>Reduction of Dimensionality</h3><p>Having cleaned the data using the above-mentioned steps, the final shape we get of our <strong>general population </strong>data is 415405 rows and 283 columns and of the <strong>customer data </strong>is 100341 rows and 303 columns. Even after dropping multiple columns we still have a high dimensional data. To reduce the dimensionality of our data further we can use <strong>Principal Component Analysis (PCA)</strong> to retain the important information whilst reducing the dimensions. To choose the number of components to keep we can take help of the following graph,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PuZvbb0XAEMaXk27THfBZQ.png" /><figcaption>Principal Component Analysis Graph</figcaption></figure><p>Our aim is to choose the value for the component for which our PCA will have high variance on the data. We can see from the graph above that the line seems to be flattened at around 220 components.</p><p>So we reduce the number of feature to 220 in both of the datasets, and we see that we get a variance ratio of 0.92699 for <strong>azdias</strong> and 0.99735 on <strong>customer</strong> dataset.</p><h3>Clustering</h3><p>To decide on the number of clusters, we utilise the <strong>Elbow Method</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*6pGnnlbNq6C5QXkDtEW5fA.png" /><figcaption>Elbow Graph for Clusters</figcaption></figure><p>Referring to the chart above we can see that at about 16 clusters, the average distance between the clusters more or less flattens. Hence, we will be using 16 clusters for the segmentation.</p><p>By analyzing the clustering data closely, we also found out that cluster ‘5’ particularly has over-representation of customers.</p><h3>Supervised Learning</h3><p>In the final part of our project, we train our Machine-Learning(ML) model on the <strong>MAILOUT_TRAIN </strong>dataset and then to predict on <strong>MAILOUT_TEST</strong>,<strong> </strong>whether an individual is a potential customer to the company or not.</p><p>To train our model we first cleaned our file using the above methods and then split the data into training and validation(testing) sets.</p><p>We have utilised the <strong>LGBM Regressor </strong>to train our model and have used the <strong>Grid Search</strong> to get the best parameters for our model for which our <strong>ROC</strong> score is highest. Then predictions on the test data using the above-trained model were made.</p><h3>Conclusion</h3><p>Over the course of the project, I have learned a lot more than I expected to since it was tackling a real-world problem using real industry data. The most challenging part of this project was the data cleaning part. Understanding the data to remove the missing values and potential outliers are necessary but it must not be at the cost of otherwise important information. For this, various steps and methods must be researched and kept in mind and exemplified above.</p><p>Like every implementation of a concept, even this project can be improved upon. A different model and various other fine-tuning could get a better score overall. Other approaches towards data engineering can be used to handle the missing and misleading data. These changes might improve the performance of our model.</p><p>Lastly, I would like to express my utmost gratitude to Arvato Analytics and Udacity for providing me with this opportunity to work on such a challenging problem which has helped me sharpen my data science skills.</p><p>The code of all the above methods implemented can be found on my <a href="https://github.com/vinzlercodes/Customer-Segmentation">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fe4d6279873" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/customer-segmentation-identifying-the-profit-among-the-loose-ends-6fe4d6279873">Customer Segmentation, Identifying the Profit Among the Loose Ends.</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Last 40 Years of Gaming Industry, Unlocked.]]></title>
            <link>https://medium.com/swlh/the-last-40-years-of-gaming-industry-unlocked-baf4699ad8ba?source=rss-315151b8e67d------2</link>
            <guid isPermaLink="false">https://medium.com/p/baf4699ad8ba</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[video-games-industry]]></category>
            <category><![CDATA[kaggle]]></category>
            <dc:creator><![CDATA[Vinayak Sengupta]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 08:08:03 GMT</pubDate>
            <atom:updated>2020-09-02T14:49:53.154Z</atom:updated>
            <content:encoded><![CDATA[<h4>The gaming industry has become enormously popular and lucrative.<br>This article delves into the elements that are making this form of<br>entertainment industry tick.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a9VWuYoDOKDAADPJ" /></figure><p>The US Gaming Industry has made $120 Billion (yes with a B!) worth of revenue in 2018 alone. The gaming industry is a playground for pioneering technology innovation. It has introduced ideas like real-life motion replication in the games (Nintendo’s Wii) and life-like graphics-enabled entertainment consoles (Sony’s PlayStation series). The innovations in the gaming industry have lent themselves to aid high-end research in the Technology industry — ex: NVIDIA GPUs commonly used for high-end PC gaming have become paramount for performance enhancement for Machine Learning Models’ research and training.</p><p>Such an industry that has driven many of today’s tech innovations deserves a deeper understanding. What makes it go round and analyse some attributes that affect the rise and fall of the industry.</p><h3>The Questions</h3><p>The following are the questions that I have answered regarding the analysis:</p><ul><li>Which <strong>Genre</strong> of gaming has been the most popular?</li><li>Which<strong> Platform</strong> has been the most popular to play games on?</li><li>How the <strong>Sales Trend </strong>for games has been for the past 40 years?</li><li><strong>Publishers</strong> with most <strong>Global Sales</strong> along with which<strong> Regions</strong> offer the maximum of these sales?</li></ul><h3>The Data and its Preparation</h3><p>I started by searching for an informative dataset and decided upon <a href="https://www.kaggle.com/rush4ratio/video-game-sales-with-ratings">this</a> dataset from Kaggle. The attributes used to perform the analysis are:</p><ul><li><strong>Name </strong>: The games’ name</li><li><strong>Platform </strong>: The Platform of the game&#39;s release (PC, PS4, etc.)</li><li><strong>Year_of_Release </strong>: Year of the game’s release</li><li><strong>Genre </strong>: The Genre of the game</li><li><strong>Publisher </strong>: Publisher of the game</li><li><strong>NA_Sales </strong>: Sales in North America (in Millions)</li><li><strong>EU_Sales </strong>: Sales in Europe (in Millions)</li><li><strong>JP_Sales </strong>: Sales in Japan (in Millions)</li><li><strong>Other_Sales </strong>: Sales in the Other Regions like India, S.E Asia, etc. (in Millions)</li><li><strong>Global_Sales </strong>: Total worldwide sales (in Millions)</li></ul><p>Along with these attributes, the data set also consisted of certain attributes that would have proven helpful, but unfortunately due to these columns missing up to 45–50% of their values I had to drop them to avoid inaccuracies.</p><p>I continued to make the dataset more workable by checking for missing values in columns. The Publisher column had 54 missing values which I searched and populated in the dataset. Also, there were some rows which had missing values across multiple columns which I had to drop as well. These few steps led to a much cleaner data set with no missing values, ready for analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*KCn-P3fqQ7NBoyLhpS9xbA.png" /><figcaption>The Cleaned Dataset</figcaption></figure><h3><strong>The Answers</strong></h3><ol><li><em>Which </em><strong><em>Genre</em></strong><em> of gaming has been the most popular?</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*9yduSKZrdNh8C5Ew_BSbZQ.png" /><figcaption>Top 5 globally selling gaming genres</figcaption></figure><p>The above graph clearly shows which 5 genres of gaming have acquired most popularity over the past 40 years with “<strong>Action</strong>” reigning supreme with more than 3000 million games sold. Followed by “<strong>Sports</strong>”, “<strong>Miscellaneous</strong>” (which basically means a single game having multiple forms of games ex: Wii Play, having laser hockey, shooting, fishing etc. Basically “<strong>Party Games</strong>”), “<strong>Role-Playing</strong>” and finally “<strong>Shooter</strong>”. The above analysis was performed using each genre’s <strong>Global Sales</strong>.</p><p>2. <em>Which</em><strong><em> Platform</em></strong><em> has been the most popular to play games on?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*KTnfeAC5krHeXxU_duOxaw.png" /><figcaption>Top 5 globally selling gaming platforms</figcaption></figure><p>Analysing the last dataset further revealed that from the year 1984–2020, “<strong>Sony’s PlayStation 2 (PS2)”</strong> has proven to be the world’s most selling gaming console. Released in 2000, it continues to beat all that came after it, including giants like “<strong>Nintendo DS”</strong>, its own successor <strong>Sony’s PlayStation 3 (PS3)</strong>, “<strong>Nintendo Wii</strong>” and finally “<strong>Microsoft’s Xbox 360</strong>”.</p><p>3. <em>How the </em><strong><em>Sales Trend </em></strong><em>for games has been for the past 40 years?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*UlwSkiWr78EK3IVJU7DS_w.png" /><figcaption>The Global Sales Trend through the past 40 years</figcaption></figure><p>Studying the <strong>Sales Trends</strong> of an industry is important to the successful analysis of any industry. The above <strong>Time-Series Analysis</strong> showcases the <strong>Global Sales</strong> Revenue Trend for the past 40 years. Till <strong>1995</strong> the video game sales were up and down probably due to the fact that the industry was just starting out and spreading out across nations and building a base. After 1995 there was a steady rise in sales with fewer variations in the trend. From <strong>2000</strong> the volumes jumped sharply and the graph almost grew vertically till <strong>2007–2008</strong>. Thereafter, there was a sharp and steady fall in sales and consequent revenues until <strong>2015</strong>, owing to the World Financial Crisis, lasting from 2012 to 2016. <strong>Post-2016</strong>, the trend has been growing although slowly. <strong>2020</strong> was supposed to be a game-changing (no pun intended) year for the industry with massive titles and new consoles announced. Unfortunately, the COVID-19 Pandemic continuing to this day has greatly hampered sales and releases continuing to affect the industry.</p><p>4. <strong><em>Publishers</em></strong><em> with most </em><strong><em>Global Sales</em></strong><em> along with which</em><strong><em> Regions</em></strong><em> offer the maximum of these sales?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*urPgTiRCWDVR1VKFUWjwKA.png" /><figcaption>Top 5 Publishers with most Global Sales</figcaption></figure><p>The above bar graph showcases the top 5 companies with the most global sales when it comes to their video game titles and respective gaming consoles. With America leading the way with “<strong>Electronic Arts(EA)</strong>” with over 1345 million copies sold. EA has been responsible for some of the biggest titles like “<strong>FIFA Series</strong>”<strong> </strong>and<strong> </strong>“<strong>Need for Speed Series</strong>”, which currently holds the title for the most selling game of all time. The second place to “<strong>Activision</strong>” having made the sensational “<strong>Call of Duty Series</strong>”. Then a close third “<strong>Namco Bandai Games</strong>” producing the world-famous “<strong>PAC-MAN</strong>”. The ranking is followed by “<strong>Ubisoft</strong>” holding the fan favourite “<strong>Assasin’s Creed Series</strong>”. Finally the Japanese publisher “<strong>Konami Digital Entertainment</strong>” having made the retro sensation “<strong>Contra</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*8vHgslbC-dk3-pw5ucaLyg.png" /><figcaption>Regional Sales Division for the top 5 companies</figcaption></figure><p>Looking at these companies more closely, I decided to see which regions out of the ones in the dataset (North America, Europe, Japan, Other Regions) have been responsible for the majority of their sales, globally. Starting with “<strong>Activision</strong>”, the graph clearly shows that majority of its video-game sales are in the “<strong>North America</strong>” region. “<strong>Electronic Arts</strong>” seems to be getting its most profits thanks to “<strong>North America</strong>” as well. As expected “<strong>Konami Digital Entertainment</strong>” started by Hideo Kojima gains its maximum sale volume from <strong>“Japan</strong>” with “<strong>North America</strong>” coming a close second. “<strong>Namco Bandai Games</strong>” as well receives a majority of its sales from <strong>“Japan</strong>”, by a big margin as well. And lastly “<strong>Ubisoft</strong>” as well owes the majority of its sales to “<strong>North America</strong>”.</p><h3>Conclusion</h3><p>In conclusion, it can definitely be said that like any other large tech giant, the gaming industry is also not just consumer-driven, but also bases its various releases to cater to a large heterogeneous audience. After the analysis, I can also firmly state that the future of video-games will only grow and branch out, giving birth to more genres, and as well as a fusion of genres to build more dynamic gaming experiences. There is also a gradual rise in the spread of video-games culture that is not anymore restricted to the USA or the west, eastern countries like Japan, India are also jumping on the Kart. A big example is how colossal E-sports tournaments have become with humongous money pool prizes of millions of dollars all over the world, with games like “<strong>Counter-Strike Global Offensive</strong>” and “<strong>PUBG</strong>”.</p><h3>What&#39;s the next step?</h3><p>There are many ways one can conduct further analytics on the gaming industry. Comparing different Sales Regions or even Experimenting to find various different attributes affecting the sales of the games. In fact, additional work can be done on the dataset itself regarding the missing values in the customer and critic scores for each game for more in-depth analysis.</p><p>Food for thought:<em> What elements do you think determines the success of a gaming company?</em></p><p>Please do share your thoughts and suggestions. A link to my Github Repository can be found <a href="https://github.com/vinzlercodes/Gaming-Industry-Analysis">here</a>, containing the code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baf4699ad8ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/the-last-40-years-of-gaming-industry-unlocked-baf4699ad8ba">The Last 40 Years of Gaming Industry, Unlocked.</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>