<?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 Qiang Chen on Medium]]></title>
        <description><![CDATA[Stories by Qiang Chen on Medium]]></description>
        <link>https://medium.com/@qiangc?source=rss-62280ab78709------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FI7dPfaMtgc2Xpt6VyUolA.jpeg</url>
            <title>Stories by Qiang Chen on Medium</title>
            <link>https://medium.com/@qiangc?source=rss-62280ab78709------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:35:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@qiangc/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[Let’s reproduce GPT-2 (124M): Great Content, Messy Code?]]></title>
            <link>https://qiangc.medium.com/lets-reproduce-gpt-2-124m-great-content-messy-code-02781c827e26?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/02781c827e26</guid>
            <category><![CDATA[gpt]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Wed, 20 May 2026 16:31:57 GMT</pubDate>
            <atom:updated>2026-05-20T16:31:57.173Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bThmbepzY00WeP6KUtQ8gw.png" /><figcaption>Credit to ChatGPT</figcaption></figure><p>I really appreciate Andrej Karpathy’s amazing 4 hours educational video, “Let’s reproduce GPT-2 (124M)”. Since it was published in 2024, it has already reached over a million views. I’ve watched it multiple times, spent days reproducing the code step by step, and learned an enormous amount from it. I’d absolutely recommend it to anyone getting into LLMs.</p><p>But, coming from both machine learning engineering and software engineering, I think the coding part can be better if you want to put it into production, and make it more readable. I was struggling to navigate back and forth to see which variable is defined where, and when it is used. If you already have a strong mental model of everything, it might be okay, but for learners, especially newer engineers, it can become difficult to navigate.</p><p>Here are a few examples where I got confused and ended up rewriting parts during my own GPT-2 reproduction.</p><p>For example, in get_lr, the original implementation refers to global variables. I prefer passing dependencies explicitly into the function. It makes the function self-contained, easier to test, and easier to reason about. Unit tests can also catch issues earlier — for example, forgetting to import the math library might otherwise only fail after warmup begins.</p><pre># learning rate decay scheduler (cosine with warmup)<br># original style from the video<br><br>def get_lr(it):<br>    if it &lt; warmup_iters:<br>        return learning_rate * (it + 1) / (warmup_iters + 1)<br><br>    if it &gt; lr_decay_iters:<br>        return min_lr<br><br>    decay_ratio = (it - warmup_iters) / (lr_decay_iters - warmup_iters)<br>    assert 0 &lt;= decay_ratio &lt;= 1<br><br>    coeff = 0.5 * (1.0 + math.cos(math.pi * decay_ratio))<br>    return min_lr + coeff * (learning_rate - min_lr)<br># production-oriented version<br><br>def get_lr(step, warmup_steps, max_steps, max_lr, min_lr):<br>    if step &lt; warmup_steps:<br>        return max_lr * (step + 1) / warmup_steps<br><br>    if step &gt; max_steps:<br>        return min_lr<br><br>    decay_ratio = (step - warmup_steps) / (max_steps - warmup_steps)<br><br>    coeff = 0.5 * (1.0 + math.cos(math.pi * decay_ratio))<br>    return min_lr + coeff * (max_lr - min_lr)</pre><pre># another example<br># poor man&#39;s data loader<br>data_dir = os.path.join(&#39;data&#39;, dataset)<br>def get_batch(split):<br>    # We recreate np.memmap every batch to avoid a memory leak, as per<br>    # https://stackoverflow.com/questions/45132940/numpy-memmap-memory-usage-want-to-iterate-once/61472122#61472122<br>    if split == &#39;train&#39;:<br>        data = np.memmap(os.path.join(data_dir, &#39;train.bin&#39;), dtype=np.uint16, mode=&#39;r&#39;)<br>    else:<br>        data = np.memmap(os.path.join(data_dir, &#39;val.bin&#39;), dtype=np.uint16, mode=&#39;r&#39;)<br>    ix = torch.randint(len(data) - block_size, (batch_size,))<br>    x = torch.stack([torch.from_numpy((data[i:i+block_size]).astype(np.int64)) for i in ix])<br>    y = torch.stack([torch.from_numpy((data[i+1:i+1+block_size]).astype(np.int64)) for i in ix])<br>    if device_type == &#39;cuda&#39;:<br>        # pin arrays x,y, which allows us to move them to GPU asynchronously (non_blocking=True)<br>        x, y = x.pin_memory().to(device, non_blocking=True), y.pin_memory().to(device, non_blocking=True)<br>    else:<br>        x, y = x.to(device), y.to(device)<br>    return x, y</pre><p>Same thing to get_batch, function, I would rather separate the IO part and the data processing part. And rewrite it in this way. The read will know we will need the data, and also block_size, batch_size to get the batch data we need.</p><pre>def get_random_batch(data, block_size, batch_size):<br>    ix = torch.randint(len(data) - block_size, (batch_size, ))<br>    x = torch.stack([data[i:i+block_size] for i in ix])<br>    y = torch.stack([data[i+1:i+block_size+1] for i in ix])<br>    return x, y</pre><p>None of these ideas are new — they’re common principles from functional programming and clean software design. And of course, educational code and production code optimize for different things.</p><p>Still, I think good coding practices matter, even in demos. Clear structure helps humans collaborate, helps learners build better mental models, and probably helps LLMs generate cleaner code too.</p><p>And to be clear: none of this takes away from how valuable Andrej’s content is. I genuinely hope to see more videos from him in the future. These are just thoughts from someone learning deeply by reproducing the work line by line.</p><p>Have a great day reading, writing coding, or vibe code, agentic coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02781c827e26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Matrix Factorization in Recommendation Systems]]></title>
            <link>https://qiangc.medium.com/matrix-factorization-in-recommendation-systems-331c605648bb?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/331c605648bb</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 23:44:26 GMT</pubDate>
            <atom:updated>2024-10-13T23:44:26.278Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KpybmXgfMxNOhJU39bwu9A.jpeg" /></figure><p>In recommendation systems, previously mentioned statistical methods that rely solely on co-occurrence relationships are often unable to effectively solve certain problems, such as whether A and C are similar when A and B frequently occur together, and B and C also frequently occur together. Matrix factorization, as a classic recommendation algorithm, can effectively solve this type of problem. Although many modern recommendation systems have switched to tree-based models or deep learning models, the embedding idea in matrix factorization is still ubiquitous and plays an important role in understanding the construction of recommendation systems.</p><p>So, what is matrix factorization? Why is it considered a classic algorithm? Why is it so effective? What are its drawbacks, and how can it maximize user selection benefits? Let us answer these questions one by one.</p><h3><strong>What is Matrix Factorization</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lq4Bb2D9DIKWucbg-NiSJA.png" /><figcaption>Google Developers — Matrix Factorization.</figcaption></figure><p>The basic idea of matrix factorization is to use data to collect user interactions with content, such as click-through rate (CTR). Here, CTR can be defined as the ratio of the number of clicks to the number of impressions. To simplify, we usually represent CTR as either 0 or 1. In common recommendation algorithms, the goal of matrix factorization is to represent the relationship between users and content as the inner product of two low-dimensional vectors, which represent the features of users and content respectively. By taking the inner product of the user and content vectors, matrix factorization can explain why a particular user is interested in a particular content, effectively capturing the relationship between user preferences and content. For more details, see Google Developers — Matrix Factorization.</p><p>From another perspective, this is similar to a simple one-layer neural network, where each content and user is mapped to a low-dimensional vector, and the network output is the probability of the content being clicked. Similar to word embeddings in natural language processing, the embedding in matrix factorization is also learned from the data, abstracting the interaction information between users and content to better understand potential associations.</p><p>The idea behind this method is to learn from large-scale interaction data and use the learned embeddings to capture implicit similarities between users and users, users and content, and content and content. Even if two pieces of content have never occurred together, matrix factorization can find a potential association between them and further achieve personalized recommendations.</p><h3><strong>Why is Matrix Factorization Effective?</strong></h3><p>Matrix factorization is very effective because of its ability to capture latent features of the data. Each user or content is embedded into a relatively low-dimensional latent space, which can reveal relationships that are difficult to observe directly, such as common interest topics or hidden preference patterns. These features allow the recommendation system not only to recommend content that users already know they are interested in but also to recommend content that they have not yet encountered but are likely to be interested in.</p><p>This method is particularly suitable for collaborative filtering scenarios, i.e., recommending based on user-content interaction behaviors. In this scenario, matrix factorization uses historical data between users and content to predict future interactions. Therefore, matrix factorization is called a classic algorithm in recommendation systems because it is simple and easy to use.</p><h3><strong>Limitations of Matrix Factorization</strong></h3><p>Although matrix factorization is widely used in recommendation systems, it also has some limitations:</p><ul><li><strong>Model Complexity</strong>: Matrix factorization is essentially a linear model and can only capture linear interactions between users and content. For more complex relationships, matrix factorization falls short. Today’s deep learning methods are better at handling nonlinear features, thereby improving recommendation accuracy.</li><li><strong>Inability to Utilize Other Features of Content and Users</strong>: The recommendation process of matrix factorization is solely based on user-content interaction behavior and cannot directly utilize other content features (such as descriptions, overall popularity) or user-specific information (such as gender, age, interest tags). This makes it insufficient in scenarios with rich content and user information.</li><li><strong>Not Friendly to New Content</strong>: Matrix factorization requires sufficient interaction between users and content. When new content is added, due to the lack of interaction, it is difficult to effectively recommend new content, which is known as the cold-start problem.</li><li><strong>Embedding Reliability</strong>: The embeddings generated by less frequently interacted content may be less reliable, leading to over-recommendation of such content. Unlike bucket sorting, it is not easy to control the quality of recommendations and effectively balance popularity and click-through rate.</li></ul><h3><strong>Conclusion</strong></h3><p>As a classic recommendation algorithm, matrix factorization, despite its shortcomings, has its embedding concept widely applied in modern recommendation systems, especially in the implicit modeling of user-content relationships. To overcome its limitations, matrix factorization can be combined with other models, such as tree-based models and deep learning models, to improve the recommendation effectiveness.</p><p>The construction and optimization of recommendation systems is a task of balancing multiple factors, especially the trade-off between maximizing user selection benefits and enhancing user experience. Although methods are constantly evolving, matrix factorization, as a foundational algorithm, still plays an irreplaceable role in many scenarios. Future discussions will explore more ways to address the limitations of the matrix factorization recommendation algorithm.</p><h3><strong>References</strong></h3><p><a href="https://developers.google.com/machine-learning/recommendation/collaborative/matrix">Google Developers — Matrix Factorization</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=331c605648bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing the Power of Personalized Recommendation Systems: Improving the Classic “Beer and…]]></title>
            <link>https://qiangc.medium.com/unleashing-the-power-of-personalized-recommendation-systems-improving-the-classic-beer-and-888a746dcda8?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/888a746dcda8</guid>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 00:52:57 GMT</pubDate>
            <atom:updated>2024-10-13T00:52:57.673Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unleashing the Power of Personalized Recommendation Systems: Improving the Classic “Beer and Diapers” Example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVIP2ixlUce9FKl7uuJzYQ.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>In a recommendation system, it’s not only crucial to suggest content to new users but also to personalize recommendations for users with interaction history. This is where personalized recommendation comes into play. Providing personalized recommendations is a significant challenge that continues to evolve. Previously, we discussed the pros and cons of popular item ranking and introduced a more sophisticated approach called “<a href="https://qiangc.medium.com/the-pros-and-cons-of-popularity-ranking-cfdf044ec4b3">bucket sorting</a>,” which aims to maximize the overall effectiveness of recommendations. This method is particularly helpful for new users since it offers near-optimal ranking without knowing anything about them.</p><p>But how do we achieve personalization in a recommendation system? Association rule learning is often employed as a technique for personalized recommendations. However, it comes with certain pitfalls, which, if not managed properly, could harm the recommendation system in the long run.</p><h3><strong>The Basics of Association Rule Learning</strong></h3><p>Association rule learning is a statistical method used to find relationships between items. The basic idea is straightforward: if two pieces of content — say A and B — frequently appear together in user interaction data, we can assume that users who like A might also be interested in B. The classic example here is the “beer and diapers” story: analysis of supermarket purchasing history showed that beer and diapers were often bought together. This was because fathers of newborns would often grab beer for themselves when buying diapers for their babies. The surprising connection between seemingly unrelated items was discovered through user behavior data. The power of this method lies in its simplicity; it can use co-occurrence data to find potential associations that can be used to generate personalized recommendations.</p><h3><strong>The Limitations of Association Rule Learning</strong></h3><p>While association rule learning may seem like a suitable approach for personalized content, it has some major flaws — primarily, the issue of correlation versus causation.</p><p>The “beer and diapers” story illustrates only a statistical correlation, but not causation. The frequent co-occurrence of beer and diapers doesn’t imply that buying diapers <em>causes</em> someone to buy beer. Association rule learning merely indicates that two items co-occur with a high frequency, but it does not establish a causal relationship. While this anecdote may happen to align with causation, such cases are more the exception than the rule.</p><h3><strong>Improving Association Rule Learning</strong></h3><p>To overcome the limitations of association rule learning, it’s important to revisit the core objective of recommendation systems — maximizing the likelihood of a user interacting positively with the recommended content. This can be achieved by leveraging click-through rates (CTR) rather than solely relying on the number of co-occurrences between items. For example, instead of just recommending beer to users who buy diapers based on purchase frequency, it’s more effective to consider how often users who were shown beer also clicked on it when they were purchasing diapers.</p><p>However, click-through rates can be unstable, especially when dealing with items that haven’t been shown enough times to accumulate statistically significant data. Simply sorting by CTR might result in some items with very high but unstable CTR being ranked too high. To address this, we can use a bucket sorting approach, which balances click counts and click-through rates, ensuring that items with both high CTR and high click count are given priority.</p><p><strong>Formalizing the Two Approaches</strong></p><p>Let’s formally describe the two different approaches to illustrate the difference:</p><ul><li><strong>Association Rule Learning</strong>: The probability of recommending item B to a user who likes item A is calculated as:<br> (Count of A and B appearing together in user interaction history) / (Count of A appearing in user interaction history)</li><li><strong>Ideal Approach</strong>: The probability of recommending item B to a user who likes item A should be calculated as:<br> (Number of clicks on B by users who liked A) / (Number of times B was shown to users who liked A)</li></ul><p>Since CTR can be unreliable due to insufficient data, we can’t rely solely on CTR-based ranking. Instead, by combining click count and CTR using bucket sorting, we can prioritize items that are both popular and have high user engagement.</p><h3><strong>Conclusion</strong></h3><p>So far, we’ve explored two key strategies for recommendation — one for new users with no prior information, and one for users with some interaction history. These approaches provide a solid foundation for a recommendation system that can adapt to different stages of user engagement. The bucket sorting approach allows less popular content with high potential to gain visibility, gradually earning clicks and moving up the ranks as it proves itself.</p><p>A major limitation of association rule learning is that two pieces of content must co-occur in user interaction data for them to be linked. If item A appears with B, and B appears with C, does it mean we should recommend C to a user who likes A? We’ll dive into this challenge in our next discussion.</p><p>Stay tuned as we continue to unravel more sophisticated ways to improve recommendation systems and tackle real-world challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=888a746dcda8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Pros and Cons of Popularity Ranking]]></title>
            <link>https://qiangc.medium.com/the-pros-and-cons-of-popularity-ranking-cfdf044ec4b3?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfdf044ec4b3</guid>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 23:23:20 GMT</pubDate>
            <atom:updated>2024-10-13T00:51:34.465Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Pros and Cons of Popularity Ranking, Introducing Bucket Sorting</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyEpujgAfodAluS2b0dhdQ.jpeg" /></figure><h3><strong>Popularity Ranking</strong></h3><p>When it comes to recommendation systems, the goal is simple: maximize the benefit of user choices. While this might sound straightforward, applying it in practice can be quite challenging. Let’s dive into a common, seemingly effective approach that doesn’t always yield the optimal outcome — sorting by popularity.</p><p>Imagine a music streaming platform. Users come to the platform to listen to songs. But when you don’t know anything about a particular user, how do you decide what music to recommend? A common approach is to rank the songs by popularity. Popular songs have a higher chance of being enjoyed compared to less popular ones, making this method effective and widely used. People tend to follow the crowd — whether it’s buying a car model with the highest sales or choosing the busiest restaurant, popularity often implies safety and quality.</p><h3><strong>Popularity vs. Click-Through Rate</strong></h3><p>Let’s take this problem and formalize it a bit, which can help reveal its flaws. For instance, consider that the platform’s goal is to maximize user engagement, such as clicks on a song recommendation. Would recommending songs with the highest click-through rates (CTR) maximize clicks? Popular content usually refers to the songs with the most total clicks. This method often performs better than random ranking, but why would it outperform sorting by CTR?</p><p>Theoretically, if you’re buying a car, it makes more sense to rank by satisfaction rates, not just sales. The same applies when choosing a restaurant — it’s better to pick the one with the highest ratings. But ranking by CTR has its issues as well. Imagine a new song is released, and on its very first display, a user clicks it. Its CTR is 100%, which would mean it could shoot straight to the top of the list. But a 100% CTR on its first few displays is likely to be temporary — and such an approach introduces a lot of noise into the recommendations.</p><h3><strong>A Balanced Approach: Bucket Sorting</strong></h3><p>If sorting by popularity is practical but flawed, and sorting purely by CTR is ideal but unrealistic, is there a middle ground? Fortunately, there is. In the Tubi blog “Reducing Bias in Recommender Systems,” an approach was discussed that strikes a better balance — let’s call it <strong>bucket sorting</strong>.</p><p>Here’s how it works. Imagine each recommended song as a ball. The number of clicks represents the ball’s weight, while the CTR represents its density. First, the balls are sorted by weight and distributed across a set number of buckets such that each bucket contains balls of roughly the same total weight. The first bucket will have the heaviest “balls”, while the last will have the lightest. The next step is to sort the balls within each bucket by density (CTR), giving us a final ranking that accounts for both total clicks and CTR.</p><p>Popular content will still be prioritized, but content that is both popular and engaging will rise to the very top. If you set the number of buckets to just one, this approach simplifies to a CTR-based ranking. On the other hand, if you increase the bucket count significantly, it essentially becomes a popularity-based ranking. By adjusting the number of buckets, you can balance between reducing risk (by emphasizing popularity) and maximizing potential engagement (by emphasizing CTR). Experiments can be conducted to determine the optimal number of buckets based on user experience.</p><h3><strong>The Broader Impact of Bucket Sorting</strong></h3><p>The concept of bucket sorting can be applied far beyond music recommendations. If your aim is to maximize returns, focusing solely on the most popular items might not always be the best strategy. As a recommender system specialist, consider reevaluating situations where popularity is still the main ranking criterion — it might be a golden opportunity to enhance engagement and performance.</p><p>Ultimately, by balancing popularity with user satisfaction through methods like bucket sorting, we can design recommendation systems that maximize the benefit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfdf044ec4b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the Essence of a Recommendation System]]></title>
            <link>https://qiangc.medium.com/what-is-the-essence-of-a-recommendation-system-3005f794c4d8?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/3005f794c4d8</guid>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Sat, 05 Oct 2024 22:38:40 GMT</pubDate>
            <atom:updated>2024-10-06T23:13:26.858Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>What is the Essence of a Recommendation System A1</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vx5cVAMyF7UYns_HMIgMw.jpeg" /><figcaption>What is the Essence of a Recommendation System</figcaption></figure><h3><strong>Why Understand the Essence of Recommendation Systems?</strong></h3><p>If you work in the field of recommendation systems, you might be curious about their true nature and how to improve them. Even if you’re not familiar with the term, chances are you interact with recommendation systems every day — whether it’s the news, videos, novels you consume, or many of the choices you make on various apps. Understanding their essence can help you use these tools more effectively.</p><p>There are many books discussing recommendation systems, most of which focus on the technical aspects. Some touch on their essence, and while their conclusions are not necessarily wrong, I find them somewhat narrow or not deep enough. After reading the following content, I hope you will gain a broader understanding of recommendation systems. If you’re a practitioner, you’ll feel more confident about your work; if you’re a user, you’ll be able to leverage recommendation systems more efficiently to enhance your daily life.</p><h3><strong>Common Misconceptions About Recommendation Systems: Right and Wrong</strong></h3><p>It is often said that the goal of a recommendation system is to understand users’ interests and recommend content they may like. This statement is not incorrect, and many users do experience this. Engineers working on recommendation systems strive for this approach, and indeed, it can improve user experience. However, this perspective is incomplete. The concept of “interest” is somewhat narrow. Recommendation systems do not only help users find content they are interested in; their essence lies in maximizing the user’s overall benefit. Recommending interesting content is just one effective way to achieve this.</p><p>A recommendation system’s definition is also not limited to suggesting content within an app; it’s everywhere. In fact, every person is a kind of recommendation system. For example, people can answer a friend’s recommendation queries. Recommendation systems have always existed in various forms: asking elders for advice on choosing a university major, asking friends for movie recommendations, or asking a teacher for book suggestions. These are all forms of recommendation. The purpose of any recommendation is to help people make choices that maximize their benefit. The existence of recommendation systems makes it easier for people to make decisions that maximize their benefits. People have the right to choose and naturally want to maximize the benefit of those choices, which gives recommendation systems a reason to exist.</p><p>In a recommendation system, recommending content based on a user’s interests is an excellent way to maximize their benefit. Put another way, a more comprehensive explanation would be: based on the current understanding of the user, recommend the choices that maximize their benefit. Much research in recommendation systems is aimed at achieving this goal, which is a good direction and worthy of further development. As a user of recommendation systems, if you want them to recommend better content, you should help the system understand you better. For example, by clicking on videos or products you like, a good recommendation system will use this information to suggest content you enjoy. If you don’t help the system understand you, it’s not surprising if you feel the recommendations aren’t great.</p><h3><strong>A Commonly Overlooked Issue in Recommendation Systems</strong></h3><p>One common approach in recommendation systems is recommending choices that maximize the user’s benefit based on current information — this is referred to as “exploitation” in the industry. This is important, but it’s not the only issue in recommendation systems. If you go through life always making decisions based on the best choice from the information you currently have, you might miss out on new opportunities. For instance, if you love Sichuan cuisine, and based on your current preferences, eating Sichuan food makes you the happiest, you might continue eating it all the time. However, if you tried Cantonese food, you might discover that you enjoy it as well. Similarly, in recommendation systems, there’s another issue called “exploration.” Because the information you know is limited, and you don’t fully understand yourself, exploration allows you to try new things, gain a better understanding of yourself and the environment, and acquire more information to make choices that further maximize your benefit. Ignoring this issue can lead a recommendation system to get stuck in a locally optimal solution, just as you could get trapped in what you think is the best world.</p><h3><strong>More content is coming</strong></h3><p>Recommendation systems are about maximizing the benefits of choices, which is a complex process with many nuances worth exploring. The aforementioned concepts of exploitation and exploration are key aspects that I hope will inspire both your work and personal life. I plan to write more on recommendation systems in the future, and if you find this content useful, please like or share it, as that will give me more motivation to continue.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3005f794c4d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Monitor a Recommender System?]]></title>
            <link>https://code.tubitv.com/how-to-monitor-a-recommender-system-6d720c922c90?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d720c922c90</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[monitoring-system]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Wed, 24 Jan 2024 14:12:17 GMT</pubDate>
            <atom:updated>2024-01-24T14:19:17.203Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Gt6PiwVVWnXND77YnNQDA.jpeg" /></figure><h3><strong>How to Monitor a Recommender System</strong></h3><p><strong><em>Authors: Qiang Chen and Bin Chen.</em></strong></p><p>Tubi is an advertiser-based video-on-demand (AVOD) streaming company that lets viewers watch content for free. Tubi’s extensive content library is made up of movies, TV series, live news, and sports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/0*zIZr0sIwQpCjcdFJ" /><figcaption><strong>Tubi is available across the web, mobile, and OTT</strong></figcaption></figure><p>The recommender system is a crucial part of Tubi because it helps users discover the next, best content to watch. It is important to monitor the recommender system to make sure it works as expected.</p><p>We know that monitoring a recommender system as a traditional service is not enough. There are significant differences between a recommender system and traditional software. For instance, a web page can be down or it can be up. On the other hand, a recommender system can be up, but it can also be seriously downgraded at the same time.</p><p>It is a challenge to detect the change in recommendation quality. Keep reading and see how Tubi solves this problem.</p><h3>Where are the Recommender System quality issues?</h3><p>In order to detect the change in recommendation quality, we have to identify the places where errors could occur that impact the recommendation quality. Once we identify these places, we propose solutions for monitoring them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fUi1jFWhDN9lrg7x" /><figcaption><strong>The diagram demonstrates the recommendation process. The solid arrows show the data flow and dotted lines show the model offline update process.</strong></figcaption></figure><p>To identify the recommender system quality issues, let’s go through what will happen when a user requests the recommender system.</p><p><strong>(1). </strong>The client sends the user information to the backend for recommendation.</p><p><strong>(2).</strong> The backend forwards the user information to the recommender server.</p><p><strong>(3). </strong>The recommender feeds the user information into models and returns results.</p><p><strong>(4).</strong> The backend post processes the recommendations.</p><p><strong>(5).</strong> The post-process rules apply to results. For example, removing unavailable content.</p><p><strong>(6).</strong> The backend returns the recommendations to the client.</p><p><strong>(7).</strong> Models are trained on data asynchronously with the user requests.</p><p><strong>(8).</strong> Trained models are synced to recommender servers asynchronously.</p><h3>Potential issues</h3><p><strong>(1)(2): User information could be abnormal</strong> — Based on the garbage in, garbage out principle, the model is likely to make inaccurate predictions when user information is wrong. For example, when a user’s location is lost, the prediction is based on other user information. This causes the quality of the recommendation to downgrade.</p><p><strong>(5)(6): Process outside of the recommender system could be wrong </strong>— For instance, the logic that determines that a title is expired may be wrong. This is why it is necessary to monitor the recommendations returned to the client.</p><p>(<strong>7)(8): The dotted lines on the diagram represent the recommendation system model update process</strong> — The process involves data cleaning, generating training data, training a new model, and delivering the trained model to the server. The quality of the model depends on the quality of the training data.</p><p>Abnormal training data can appear in the following areas:</p><ul><li><strong>Content feature — </strong>The content metadata may be missing.</li><li><strong>Context feature </strong>— Information passed to the model can lead to inference problems and training data problems.</li><li><strong>Labels</strong> — Improper data processing could significantly reduce positive samples.</li><li><strong>Upstreaming data </strong>— This data is key to training data but is outside Machine Learning Team’s scope. For example, third-party content metadata, and homepage impressions. Monitoring and catching unexpected data issues due to upstream changes is crucial to keeping your machine learning system on track.</li></ul><h3>Proposal for monitoring potential issues</h3><p>With a comprehensive understanding of potential issues, we propose to monitor three key types of data to monitor the recommender system:</p><ul><li>The data passed to the model which is used for inference prediction.</li><li>The final recommendation results that appear on the user’s screen.</li><li>The model training data that determines the quality of models</li></ul><h3>Data passed to the model</h3><p>Data passed to the model is the earliest step in the recommender system workflow. Once an error occurs, the recommendation deteriorates because of the incorrect information.</p><p>This kind of issue is hard to identify because it is sent by the client, received by the backend and then passed to the recommender system. In addition, the client and backend teams may not be sensitive to the abnormal changes on recommendation.</p><p>It is important to log and monitor the data passed from the client. For example, the percentage of users with language passed into the models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jn9Pk7fNrKrZ7FdN" /><figcaption><strong>User device language percentage over time in 2023 January. Each line represents the percentage of a certain language.</strong></figcaption></figure><h3>Final recommendation results</h3><p>The final recommendation results for users are determined by the recommender models and the post-process step. Our team needs to figure out important properties based on the final recommendation results and monitor them. For example, each content type recommendation percentage. Building monitors based on recommendation results requires a deep understanding of the business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QKHWS_ax81JJtolR" /><figcaption><strong>The percentage of recommendation which size is &lt; X, overtime in January 2023. A high percentage of this metric indicates a problem in the whole recommendation pipeline.</strong></figcaption></figure><h3>Model training data</h3><p>The quality of the training data determines the quality of the model and the quality of the recommendation. We found that key properties do not change much for training data over time, but that large changes in those properties indicate potential issues. For example,</p><ul><li>Changes in the row number of training data.</li><li>Changes in positive label ratio in the training data.</li><li>Missing value ratio of feature fields in the training data.</li></ul><p>Monitoring the final training data ensures that its properties meet expectations. The same monitoring concept can also be applied to basic data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qB6WigcfT7jusNsy" /><figcaption><strong>The positive label ratio over time in January 2023. It should be stable. If it changes too much, some issues might occur.</strong></figcaption></figure><h3>Implementation design and considerations</h3><p>Monitoring models primarily involve monitoring changes in data distribution (while following the garbage in, garbage out principle).</p><p>The initial version was a result of our learning from failures in a post-mortem culture. This has allowed us to accumulate valuable use cases that have contributed to the construction of the entire platform.</p><p>Given the focus on data monitoring, there are several aspects to consider based on the characteristics of the data:</p><p>•<strong> Timeliness</strong> — As a monitoring system, timeliness is crucial. We aim to detect anomalies as soon as possible. In a recommendation system, we observed two types of data (user requests and responses) form a real-time data flow. It is essential to conduct real-time monitoring of this data to promptly identify any anomalies in the deployed models or services to enable timely intervention.</p><p>•<strong> Data characteristics</strong> — In real-time monitoring, the support of a time series database is indispensable. This type of data possesses a specific trait where processing time closely aligns with event time. Consequently, we can overlook the disparity between processing time and event time during the processing of data instances like (1), (2), (5), and (6). Conversely, when dealing with another type of data commonly known as batch processing, profiling data at this scale is relatively modest. Batch processing is characterized by updates at the hourly or daily level. Notably, the distinguishing feature lies in the substantial and erratic difference between event time and processing time. When handling this category of data, it is imperative to prioritize event time during processing. Consequently, the two data types necessitate distinct treatment, with a majority of cases falling under this category, including (7) and (8).</p><p>•<strong> Scalability</strong> — Given the evolving nature of business requirements, it’s crucial that monitoring metrics remain independent of each other. This ensures ease of deployment or decommissioning for any metric without impacting the monitoring of others, especially those in real-time scenarios.</p><p>Horizontal scaling to accommodate the expansion of business requirements is also essential. For instance, when introducing a new model, a default set of monitoring metrics should concurrently be deployed to guarantee the basic stability of the system that is detectable through the monitoring system.</p><ul><li><strong>Scalability of Data Volume </strong>— The system should seamlessly handle an increasing volume of data without compromising performance.</li><li><strong>Scalability of Supported Types </strong>— The system should be flexible enough to support the addition of different types, adapting to new business requirements, or the introduction of diverse models.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FcJPeRuz4fi3kgbA" /><figcaption><strong>Data Monitoring Metrics Data Flow</strong></figcaption></figure><p>To achieve these objectives, we implemented the following:</p><ul><li><strong>Defined flexible and explicit proto — </strong>We established a proto with a relatively loose and clear structure that employs a three-tiered framework of source, scope, and name to correspond to a metric. This allows users to define generic metrics. Different instances can also be distinguished through shared source and scope attributes, along with unique names to facilitate easy expansion.</li><li><strong>User-defined metrics with multiple approaches — </strong>Users have the flexibility to define metrics through Scala, Python APIs, or by utilizing our provided DSL language to configure metric extraction logic. Within the DSL, we employ a simple and effective JSON path representation for defining extraction logic. For example, we can check if there is enough content using<strong><em> .containers[*]{.slug == \\”featured\\” &amp;&amp; .contents &lt; 8}.contents</em></strong></li><li><strong>Configuration file updates instead of job deployment — </strong>For real-time data monitoring, dedicated monitoring jobs need to run as stable services for extended periods. Considering resource efficiency, we configure a service for each real-time data source. However, we allow dynamic adjustments to metric extraction rules for a service through configuration file changes that ensure timely and efficient updates without the need for job redeployment. This configuration rule aligns with the DSL mentioned in the second point.</li></ul><h3>Key takeaways</h3><p>The key takeaways are as follows:</p><ul><li>Monitoring the quality of the recommender system is a long-term project. Existing monitors may need to be adjusted and new monitors are needed to capture new types of issues.</li><li>A key to make the monitor scalable is to delegate it to domain owners. The domain owner is responsible for managing alerts, setting alert thresholds, and identifying potential issues.</li><li>It is important to focus on alert precision over recall as precision means the percentage of alerts are true issues and recall means the percentage of issues get alerted. This is because when the alert precision is low, there is a tendency for people to ignore them.</li><li>A monthly summary of the monitoring would be helpful to the team to know what’s going on with the recommender system.</li></ul><h3>Summary</h3><p>Monitoring a recommender system is challenging because of how difficult it can be to detect changes in recommendation quality. Based on the many real post-mortem issues and a full understanding of the recommender system, Tubi’s Machine Learning Team and Data Team have designed an efficient and scalable data-based monitoring solution that shows how these changes can be detected and monitored.</p><h3>We’re hiring!</h3><p>If you’re interested in large-scale, high-impact projects like how we monitor a recommender system, why not join us? Tubi Engineering is hiring across a range of positions in Machine Learning, Machine Learning Infrastructure, Data, and more. You can check out Tubi careers<a href="https://corporate.tubitv.com/careers/"> here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d720c922c90" width="1" height="1" alt=""><hr><p><a href="https://code.tubitv.com/how-to-monitor-a-recommender-system-6d720c922c90">How to Monitor a Recommender System?</a> was originally published in <a href="https://code.tubitv.com/">Tubi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reducing Bias in Recommender System]]></title>
            <link>https://code.tubitv.com/reducing-bias-in-recommender-system-7a03d9bd75c?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a03d9bd75c</guid>
            <category><![CDATA[recommender-systems]]></category>
            <category><![CDATA[bias]]></category>
            <category><![CDATA[contextual-bandit]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 15:48:13 GMT</pubDate>
            <atom:updated>2022-04-26T15:48:13.503Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reducing Bias in Recommender Systems</h3><p>Authors: Qiang Chen, Jiayuan Dong, Tal Levy, and Jaya Kawale</p><p>Tubi is an advertiser-based video on demand (AVOD) streaming company that allows viewers to watch any content available on the service for free. We have an extensive content library with various content, including movies, TV series, live news, and sports. Naturally, recommender systems form a crucial component of the service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/0*3SInMR2ya_lVc225" /><figcaption><strong>Tubi Homepage — Machine learning powers the different recommendations that generate the homepage.</strong></figcaption></figure><h3>Presentation Bias in Recommender Systems</h3><p>Recommender systems help surface content from our vast library of thousands of movies and TV shows. They learn via feedback collected from user behavior. Typically, the recommendation algorithm provides a ranked list of recommendations. The user will take action, for example, play a title. This feedback is collected and is used further for training new models. Thus the current recommendations will impact future recommendations. This scenario leads to the dreaded <em>presentation bias</em>. Over time, the recommendations for a user converge into a small set, which is called an information island in the recommender system. What’s more, some videos are never exposed to the users, so we never know if users would have enjoyed watching them or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*m6rJCW8aRwHuwtpz" /><figcaption><strong>The recommendation algorithm provides a ranked list of recommendations. The user will take action, for example, play a title. This feedback is collected and is used further for training new models. Thus the current recommendations will impact future recommendations.</strong></figcaption></figure><p>We utilize user behavior to generate personalized recommendations, such as clicking and viewing data. If we don’t carefully account for presentation bias, it will create feedback loop issues. For example, a user is only presented with horror content on Halloween. The user watches a horror film. Then the recommender system recommends more horror content, and the users thus watch more horror content, perpetuating the problem. On the other hand, the user might also be interested in other genre titles. Therefore we need some way to allow for an escape hatch.</p><p>In this blog, we present some solutions we have adapted for the problem of presentation bias. Let’s examine them in the following sections.</p><h3>Feature Engineering</h3><p>Let’s first examine simple approaches utilizing feature engineering to help reduce the presentation bias in the system. The feature typically used by many machine learning models to recommend items is the popularity of content. Popularity, by definition, is biased toward presentation. Popular content has a lot of presentation opportunities. The presentation bias keeps the popularity high even if only a tiny percentage of users like the content.</p><p>How do we reduce the popularity bias? A quick fix is to not look at the popularity metric directly but to use some normalization based on presentation. For example, use a popularity per presentation metric. One caveat with this feature is that the metric is unstable for titles with a little presentation. Firstly, to encounter the caveat, We order the content by popularity and group them into X buckets, where X is a hyperparameter. The group step makes each bucket has 1/Xth of the overall popularity. Secondly, we rank content in each bucket by its popularity per presentation. We assume content in each bucket has the same confidence level of popularity per presentation. The online experiments showed that adding this new feature to content ranking gives more presentation opportunities to titles in the long tail that we would otherwise miss. The below figure shows the improvement in rank for the long-tail content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*efgBXbf03-Sw4uzxlj6-SA.png" /><figcaption><strong>In the figures, each point is content. The x-axis is popularity rank, and a lower popularity rank means higher popular content. The y-axis represents the improved rank. The improved rank is calculated by ranking content in each bucket by popularity per presentation. The left one is for the top 300 popular content. The right one is for the top 3000 popular content. As you can see, the improved ranks are very different in the top and tail buckets.</strong></figcaption></figure><h3>Leveraging Additional Sources of Engagement</h3><p>This section examines additional sources of engagement that are different from the homepage recommendations.</p><p>We can incorporate many additional sources like thumbs up/down on content, user’s search query, and watch behavior from search. Let’s take the example of watch behavior from search. We found that some users’ watch history from search is different from the homepage. So there is an opportunity to leverage the search history to improve the homepage recommendation.</p><p>Let’s illustrate that using a real example. The figure below shows a user’s watch history from the homepage indicating that they enjoyed watching thrillers and horror movies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*VDe-AEmAMS4LRRe-" /><figcaption><strong>User A’s watch history from the homepage</strong></figcaption></figure><p>However, this user also searched and watched many documentaries. The figure below shows the user’s watch history based on their past searches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*v5d_wTehRjDm0wZD" /><figcaption><strong>User A’s watch history based upon the searches</strong></figcaption></figure><p>This example indicates that our recommender system can benefit from the user’s search history. We can recommend some documentaries to this user apart from Horror. Furthermore, whenever the user searches for something, it could mean a missed opportunity from the point of view of the recommender system. We use collaborative filtering-based approaches to leverage the user’s search history while learning to rank contents. The online experiment results indicated this additional feature improved streaming and retention metrics.</p><p>Since the additional sources of engagement bring in a different dimension, they help reduce the homepage presentation bias.</p><h3>Exploration</h3><p>One key idea to help reduce the bias is via exploration. The key idea behind exploration is to expose users to parts of the catalog. Exploration is helpful to account for uncertainty when the user feedback is sparse. We usually use it to find audiences for new content and discover new tastes for users. We can naturally use it to alleviate presentation bias as it helps gather feedback on items that the recommender system would not have sought. In general, there is a cost of exploration in the near term, and the cost can vary from poor user experience to unsubscription depending upon the nature of exploration. We focus on exploration as a tool to reduce presentation bias and present some simple solutions for that. The following paragraphs describe some of the methods for exploration.</p><p>We tried a straightforward idea: add jitter to our ranking model scores. The ranking scores typically come from an offline model. We use the Boltzman exploration, which is widely used in the literature, to add exploration to our ranking scores online. One problem we saw in our online tests with this exploration was that it harmed the overall user experience.</p><p>Another successful idea is having a constant exploration running to collect unbiased feedback from the users. We need to consider the cost vs. benefit of exploring the content. New titles benefit from exploration. For existing titles, it is essential to break the feedback loop and collect feedback on users with different tastes. We continuously run various exploration algorithms on one such container on our homepage called “Something Completely Different.” The feedback from this container has been very helpful in improving the rest of the recommendations pipelines, and we have seen successful follow-up experiments leveraging this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X8yBKpUFOZKMWYtT" /><figcaption><strong>“Something Completely Different” Row</strong></figcaption></figure><h3>Bandits</h3><p>Finally, the tradeoff between exploration and exploitation is crucial to make sure we do not hurt the user experience and gather feedback in regions where it is sparse. This tradeoff is central to the design of reinforcement learning or bandit algorithms. The framework either exploits the best results the model can present or explores less ideal alternatives. We can learn that a user who only watches horror films is also interested in other genres like comedies during the exploration phase. The Bandits exploration strategy is also a great way to cold start a title. Cold starting refers to recommending content that was just added and has no training data for the model to learn.</p><p>The tricky part is to find the sweet spot for the exploration/exploitation tradeoff. You don’t want to exploit too much that you don’t get enough chances to learn from exploration. On the other hand, exploring too much will hurt your user experience. There is no magic bullet, and with every experiment, you get closer to the right balance for each Bandits use case.</p><p>One area where we have seen bandits helping is the new user recommendations.</p><p>The new users have no historical viewing data and very few available features. It is too easy to end up in an endless feedback loop of recommending the same popular titles and only learning from this small subset of titles. Our new user bandits model gets us out of that loop by allowing a more diverse set of recommendations while generating a great user experience thanks to the bandit’s explore/exploit strategy.</p><h3>Summary</h3><p>We introduced some practical ideas to reduce bias in the recommender system. They can quickly adapt to new systems and new problem settings. Want to learn and develop more ways to reduce bias? Follow our blog and join us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a03d9bd75c" width="1" height="1" alt=""><hr><p><a href="https://code.tubitv.com/reducing-bias-in-recommender-system-7a03d9bd75c">Reducing Bias in Recommender System</a> was originally published in <a href="https://code.tubitv.com/">Tubi Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recommender System and Sales]]></title>
            <link>https://qiangc.medium.com/recommender-system-and-sales-4ca0f09e83d8?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ca0f09e83d8</guid>
            <category><![CDATA[recommender-systems]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Mon, 29 Mar 2021 12:17:40 GMT</pubDate>
            <atom:updated>2021-03-29T12:17:40.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v1yZRfO6YnEVbwBWcH-WuQ.png" /><figcaption>Recommender system and sales</figcaption></figure><p>Software engineering is resembled by civil engineering, both have a lot of the same terminology: blueprint, framework, scaffolding, build, etc. To create a recommender system, the machine learning engineer needs to write code like a general software engineer, however, the creating recommendations system is very different from creating software which methodology is described in software engineering clearly.</p><p>The machine learning engineer analyzes the user’s behavior then creates algorithms to find interesting content for the user then increases the company revenue by improving user experiences. However, software engineers create product features to meet user’s needs. From the perspective of economic, the recommender system is like the sales, she recommends items to users continually. What’s the relationship between the recommender system and sales? What can the machine learning engineer learn from this idea?</p><p><strong>Recommendation System in Salesman Eye</strong></p><p>In the sales world, We have items, customers, cost, revenue, etc. There is the same thing in the recommender system.</p><ul><li>Item: movie, series, music, books, news, etc, most of them can be consumed repeatedly</li><li>Customer: potential users, new users, returning users</li><li>Cost: usually opportunity cost, if recommender present one item, it won’t be able to present another item in the same time at the same position</li><li>Revenue: Ads, subscription fee, one-time payment, etc</li></ul><p><strong>Different Kind of Recommendation System in Sales Eye</strong></p><ul><li>Non-personalized recommender system: this kind of salesman doesn’t care who is the customer, she recommends items based on the item attribution only, for example, she always recommends the hottest items, the recently added items</li><li>Group recommender system: she can group her customer, and recommend items based on the customer’s group, for example, she will recommend items based on customer’s gender, location, etc because she knows different groups have different preferences.</li><li>Personalized recommender system: she knows as much as possible a lot about each customer, and provides different recommendations considering each customer’s background even they come from the same group.</li></ul><p><strong>Different Problems in Recommendations System in Sales Eye</strong></p><ul><li>Cold starting for new item: it means new products available in the market, and no one knows how does the customer like it, with no feedback from the market, How the sales find the product potential customer based on understanding user’s preference and the attribution of the new product, and gradually gain feedbacks and increase the new product’s customer and make a profit.</li><li>Cold starting for the new user: sales should have a different strategy for returning customer and new customer, for new customer, the sales know nothing, how does the sale acquire new customer’s background: location, job occupation, consumption level, etc which is good for a better recommendation, or in some case with no background of the customer, how to provide a recommendation based on the understanding of product feature, performance, and the context</li><li>The context in recommender system: How to utilize something just happen to improve recommendation? For example, in Related Title, when customer show preference on a product, how to recommend related products the user might love</li><li>User growth: How to attract more potential users, How to establish new channel acquiring user who likes your product possibly</li><li>Recommender system with explanation: How to give a nice explanation about your product recommendation, what does the customer care, the customer accepts the recommendation more if there is a reason even it is a simple reason like this is an awesome product</li><li>Feature engineering: Which aspect the sales should care about the customer to give a better recommendation? Which group of people like which type of product, we collect a lot of information about the customer, the clothes, income, age, which is useful to predict the customer’s preferences</li><li>Exploration and exploitation: the sales can not always recommend known preferences about the customer, because the customer may get tired of his existing interest, it would be great if you can mine something new to the customer and the customer like it. How to properly explore user’s interest at appropriate timing and context is a question</li><li>Diversity in recommender system: To increase the possibility of making a deal, the sales will recommend different types of product to include something the customer like. Then How to define diversity, what kind of diversity is perfect?</li></ul><p><strong>Summary</strong></p><p>Recommender system is similar to sales in a lot of ways, for machine learning engineer, why don’t you take a look how does the sale handle the similar problem, they will probably give you insight on solving the recommender system problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ca0f09e83d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RecSys2020 Highlight Sharing]]></title>
            <link>https://qiangc.medium.com/recsys2020-highlight-sharing-c5f74b1b771c?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5f74b1b771c</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[conference]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Sun, 01 Nov 2020 09:56:57 GMT</pubDate>
            <atom:updated>2020-11-01T09:56:57.358Z</atom:updated>
            <content:encoded><![CDATA[<p>RecSys 2020 was planned to be held in Brazil, South America, but it had to be changed to an online event due to the COVIOD19. Although holding a conference online wouldn’t allow people to communicate effectively but it also provides convenience for me located in Beijing who is far away from Brazil. Thanks to the efforts of all parties and the application of the software, the overall effect of this participation is higher than my expectations. Here are some highlights from the engineer’s point of view, I hope you learn something from it.</p><h3>Conference Organization Highlight</h3><p>Let me briefly introduce the organization of this meeting. I have to say that the organizer worked very hard to make the online conference as good as possible, In order to ensure the normal progress of the meeting, some people keep alive for 24 hours.</p><ul><li>In order to enable participants in all time zones around the world to engage the presentation in a good time slot, speakers are asked to give presentation in two different time periods</li><li>In order for the online meeting process to proceed smoothly, the conference uses Whova software to help the entire process. Whoa includes the meeting schedule, live broadcast platform, collecting questions, forums, making friends, and event organization.</li><li>In order for the participants to gather and discuss freely, the conference uses Gather.town to organize Poster Session and other activities, and everyone can communicate in a virtual space by themselves. In the picture below, I am standing in front of the RECSYS panel in the aisle of this virtual space.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Eayly4YhlOu09oILHKt6w.png" /><figcaption>Gather.town Virtual 2D Space</figcaption></figure><h3><strong>RecSys2020 Highlight</strong></h3><p>This is my third time attending RecSys. The research progress of recommender systems is not fast, and some strange research directions and repeated research results can often be seen at conferences, but there are always some highlights.</p><p><strong>Highlight from Industry Direction</strong></p><ul><li>PURS: Personalized Unexpected Recommender System for Improving User Satisfaction, <strong>Pan Li</strong></li><li>Behavior-based Popularity Ranking on Amazon Video<strong>, Lakshmi Ramachandran</strong></li><li>Query as Context for Item-to-Item Recommendation<strong>,</strong> <strong>Moumita Bhattacharya</strong></li></ul><p>These methods are either verified by the AB test in the industry, or they are simple to implement and can solve some problems.</p><p><strong>Highlight from Research Direction</strong></p><ul><li>Counterfactual Learning for Recommender System,<strong> Zhenhua Dong</strong></li><li>Debiasing Item-to-Item Recommendations with Small Annotated Datasets, <strong>Tobias Schnabel</strong></li><li>A Large-scale Open Dataset for Bandit Algorithms, <strong>Yuta Saito</strong></li></ul><p>These methods are either novel, broad prospects for the future, or contain open source code or data.</p><h4>PURS: Personalized Unexpected Recommender System for Improving User Satisfaction</h4><p>The author Pan Li is a doctoral student at NYU Stern School of Business. This work is the result of cooperation with Alibaba. In order to solve the problem of Filter Bubble in the recommendation system, they proposed PURS. The advantages of this work include</p><ul><li>AB testing on Video Streaming Alibaba-Youku App increased their TVT 4.6%</li><li>It Solved Filter Bubble by Unexpectedness</li><li>It Modeled Unexpectedness by Embedding Similarity</li><li>It implemented Personalization of Exploration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t4rhn4s0BtZKEE5rbf-_gg.png" /><figcaption>Implementation of PURS recommendation ideas on Embedding</figcaption></figure><h4>Behavior-based Popularity Ranking on Amazon Video</h4><p>The author Lakshmi Ramachandran, Applied Scientists of Amazon Video, introduced a work of their Popularity Ranking.</p><p>I used to think that Popularity Ranking can use the current statistics of Popularity to complete the ranking. I did not expect that Popularity Ranking can also use machine learning to solve the cold start problem in Popularity Ranking: some new content cannot be ranked in a good position by ordinary Popularity Ranking. , Expose to users.</p><p>The author uses data such as some text information of the content itself, previous popularity, and user interaction information to predict the current Popularity, and finally sort by the predicted Popularity. An interesting phenomenon is the length of time the content exists on the platform, which will give new content a high score. The screenshot below mentions the impact of Age Feature (the duration of existence on the platform)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAbbvxaeGdwyioVcU8_zcw.png" /><figcaption>The influence of Age Feature (the duration of existence on the platform), the X-axis is Age, and the Y-axis is the predicted Popularity</figcaption></figure><h4>Query as Context for Item-to-Item Recommendation</h4><p>The author Moumita Bhattacharya is a Senior Applied Scientist at ESTY.COM, an e-commerce website. She introduced ESTY’s technical options for creating related product recommendations. They have 65 million products, which makes their technology choices very different from Amazon Video. The number of videos on Amazon Video may be on the order of tens of thousands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkK9OYEKJ6S2-LM21pRTDg.png" /><figcaption><a href="http://esty.com/">ESTY.COM</a> ’s related production recommendation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gsgw2t_HpqY1wa2s-9CDLA.png" /><figcaption><a href="http://esty.com/">ESTY.COM</a> Two-stage recommendation system</figcaption></figure><p>Related item recommendation is broken into two stages. In the Candidate Set Generation part of the first stage, they use Word2Vector technology to use the content that users search and click as training data, generate Embedding for each content, and then use Faiss: A library for efficient Similarity search, returns a list of items most similar to the current item as Candidate Set.</p><p>The second stage uses lightGBM to sort the Candidate Set.</p><p>One of the highlights of the work they mentioned was that they used Context to personalize related items. The following figure mentions that the current program can be used as the Context. For example, during Halloween, for a red recommendation related item, is it possible to recommend some items suitable for Halloween and related items instead of only Only the red hat is recommended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n3GhsRVp9ZIWR5xpzZd3Iw.png" /><figcaption>During Halloween, you can use the current holiday as the context to recommend items that match the current holiday</figcaption></figure><h4>Counterfactual Learning for Recommender System</h4><p>The author Zhenhua Dong is the Principal Researcher of Huawei’s Noah’s Ark Laboratory. This speech summarized a series of achievements of Huawei in the Counterfactual direction. In order to solve the counterfactual problem, the author proposes Uniform Unbiased Data, which randomly selects content from 1% of traffic and presents it to users, so that every content has the opportunity to collect user feedback. Using Uniform Unbiased Data, the author launched a systematic research and experiment, and achieved a series of results. One of them was the use of Unbiased Data generated by this 1% of traffic, which created a 3% increase in indicators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oYgtIwpmD_9vA-QzZ2ALwg.png" /><figcaption>The speaker was introducing Counterfactual machine learning</figcaption></figure><h4>Debiasing Item-to-Item Recommendations with Small Annotated Datasets</h4><p>The author Tobias Schnabel is a researcher from Microsoft Research, who proposes to use small-scale annotation data to improve Item-to-Item recommendations (the same as the related recommendation of an item mentioned earlier). Insufficient intelligence, people come together. Experiments show that this method is indeed effective, which shows that there are a lot of interference in our training data, and it does not fully represent the user’s preferences for all items. The industry may be able to use the previously mentioned Unbiased Data to achieve the effect of the Small Annotated Dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*wRwQHEcTuszeqO44px9MDg.png" /><figcaption>The method in the article is better than other methods</figcaption></figure><h4>A Large-scale Open Dataset for Bandit Algorithms</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H6xIC66N-Ayw4hv6JKRmLA.png" /><figcaption>Yann Lecun said that RL is the cherry on top of the whole machine learning cake</figcaption></figure><p>The author Yuta Saito is an undergraduate, and in this Workshop showed his work in the direction of RL&amp;Bandits.</p><p>One of the core problems of reinforcement learning is how to evaluate the trained reinforcement learning model before going online or conducting experiments, that is, Offline Policy Evaluation. Academia has proposed a lot of methods, many of which are data generated by simulators, but there are few actual data support.</p><p>This work provides two sets of clothing shopping behavior data generated through Uniform Rank and Bernoliour Rank, which can be used to evaluate the effects of different Offline Policy Evaluations, and can also be used to develop new policies and use Offline Policy Evaluation to evaluate them. <a href="https://github.com/st-tech/zr-obp">https://github.com/st-tech/zr-obp</a> Open Bandits Pipeline The open source code is of high quality and there are many code comments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*Gy_UlFe0_Q4M6r9dEl5Nrg.png" /><figcaption>User shopping behavior collected in 3 placements</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ga5J2-wtFokTOLr3uaEx_A.png" /><figcaption>The author proposed OPEN BANDIT PIPELINE</figcaption></figure><p>The recommendation system is not like image recognition. Theoretically, recommendation system is a typical application scenario of reinforcement learning. However, it is limited to various engineering constraints and the theory is immature. Reinforcement learning has not been well applied to recommendation systems. Successful application. This area deserves attention.</p><h3>Summary</h3><p>This online RecSys experience is unique, and the disadvantage is not as much as I was worried about before. Many participants are also very serious about preparing for speeches. I hope that next year, we can see more highlights from RecSys.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5f74b1b771c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Three-Level Ladder to Improve Machine Learning System — — The Book of Why Learning Part 2]]></title>
            <link>https://medium.com/machine-learning-and-math/the-three-level-ladder-to-improve-machine-learning-system-the-book-of-why-learning-part-2-8f799c193157?source=rss-62280ab78709------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f799c193157</guid>
            <category><![CDATA[why]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[causality]]></category>
            <dc:creator><![CDATA[Qiang Chen]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 10:08:17 GMT</pubDate>
            <atom:updated>2020-06-14T10:08:17.888Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Three-Level Ladder to Improve Machine Learning System — — The Book of Why<em> </em>Learning Part 2</strong></h3><h3><strong>Foreword</strong></h3><p>Regarding <em>The Book of Why</em>¹, you have seen my learning of part 1, <a href="https://medium.com/@fishlovebanana/drawing-different-conclusions-from-the-same-data-the-book-of-why-learning-part-1-1f465467f2b5">Drawing Different Conclusions from the Same Data — — The Book of Why Learning Part 1</a>, in addition, it is also worth mentioning that the three-level ladder in the opening chapter of the book: Seeing (observing the past), Doing (executing the present) and Imaging (imagining the future), human use those capability to change the natural environment to make them suitable for living. If you consider that how we improve machine learning system (recommended system, search system, ad click rate estimation system, etc.) is like how we change the nature, you will conclude that engineers can’t optimize the machine learning system without the there-level ladder. With the idea of the author of <em>The Book of Why</em>, I like to summarize my thought on the machine learning system. While sorting my own thoughts in this article, I also hope to help everyone to understand the evolution of machine learning system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sayxzkf2WMH5nXfZRlnGig.png" /><figcaption>The three-level ladder to change the natural environment：Seeing (observing the past), Doing (executing the present) and Imaging (imagining the future)</figcaption></figure><p>In order to optimize the nature for living, All the three human cognitive ability levels: Seeing, Doing, Imaging are indispensable.</p><p>Seeing is the most basic ability, both machines and animals have this ability to perceive the surrounding environment. Doing is different from conditioned reflex actions. A small number of animals, such as chimpanzees who can use tools, Homo sapiens who try to roast food with fire, have the doing ability.</p><p>Imaging’s ability is the biggest feature that distinguishes humans from animals. Humans may imagine many non-existent things, such as airplane with the bird’s association, with the understanding of the aerodynamics of the bird’s flight process, human create airplane which can fly on the sky like birds. Engineers who improve machine learning systems need the ability of the three-level ladder as humans change nature.</p><h3><strong>Seeing（Observing the Past）</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vm5Da8jbL59TRpPakb-yNA.png" /><figcaption>Seeing is the first level in the cognitive ladder and also the basic level</figcaption></figure><p>Seeing is the first level in the cognitive ladder and also the basic level. Humans, animals and machines all have seeing ability from different perspective. Books, broadcast media, search engines, etc. have greatly improved the ability of humans to see more things, which is one of the reasons why humans can develop rapidly. For engineers, the more accurate and detailed the user behavior recorded by the machine learning system, the stronger the engineer’s ability to observe the system.</p><p>Interestingly, the author of <em>The Book of Why</em> said that we always use machine learning algorithms to mine the correlation between things, This process is considered to be the most basic cognitive ability, the Seeing level activity. For example, the mined correlation cannot directly infer causality. The correlation can not be used to guide us and predict the future. However, it is still easy for the human brain to treat the correlation and causality the same. We need to be careful on that.</p><p>What we can do with the Seeing ability are very limited. It can only see the correlation between something, and however it cannot directly guide us any future actions. The chatbot is known as equipment with latest artificial intelligence technology, but it only has the seeing cognitive ability. Although the substantial help brought by Seeing’s ability is very limited, Seeing’s cognitive ability is an indispensable basic ability for us to change nature. It is difficult to imagine how to change nature without seeing it.</p><h3><strong>Doing（Executing the Present）</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Rh5cKXX-pH39NCBTWLJRA.png" /><figcaption>The second level of cognitive ability is Doing. Doing is the ability to execute an idea, the ability to execute plans, and the ability to intervene in the environment</figcaption></figure><p>The second level of cognitive ability is Doing. Doing is the ability to execute an idea, the ability to execute plans, and the ability to intervene in the environment. For example, Shennong tasted hundreds of wild plants to find effective Chinese medicine, and Edison tested different materials to find durable filaments. The cognitive ability of this ladder does not require us to understand the principles behind it, only the ability to verify ideas. For example, there is no need to understand why this plants cure the ill, Why does the filament of this material last so long. But we can conduct experiments verify the assumptions.</p><p>We often praise people for their strong execution ability, which essentially means Doing’s strong ability, they can quickly turn an idea into reality and be verified. Doing is different from Seeing. Seeing cannot verify ideas. The ideas can only be verified by Doing’s ability which make ideas into reality and get the feedback from the environment to verify the ideas.</p><p>For verifying ideas for improving machine learning systems, the doing ability specifically is the ability to conduct randomized controlled trials (AB tests). Randomized controlled trials are also a compass for human, it tell us where to go. It is also the golden rule for testing drugs, and a large number of scientific experiments are based on it. A lot of technology companies also use this to measure whether a software feature improves the user experience. For the iteration of machine learning systems, randomized controlled trials are like compasses for big ships in the vast sea, it guide the ship to reach the destination.</p><p>Doing’s ability is essential for humans to change nature and validate useful ideas. This is also true for machine learning. If the we do not have the ability to ab test any ideas for machine learning system, it is a pity that this system cannot be optimized. The engineer just like the Animals in the nature which can only observe the environment, but can not change it.</p><p>For more about randomized controlled trials, you can refer to the previous articles ⁴ ⁵</p><h3><strong>Imaging (Imagining the future)</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ej1k-u9LwUXL-z7Eupu3zA.png" /><figcaption>The highest level of the cognitive ability ladder is Imaging, which is the ability to propose ideas, to image what happens if doing something.</figcaption></figure><p>The highest level of the cognitive ability ladder is Imaging, which is the ability to propose ideas, to image what happens if doing something. Animals have the ability of seeing, and some animals have the ability of doing, but their imaging’s ability is far less than humans. It is because of human imagination that humans continue to invent new things: airplanes, skyscrapers, computers, and so on.</p><p>In order to come up with reliable ideas, you need to have a deep understanding and analysis of things. The improvement of Seeing and Doing’s ability will help Imaging’s ability.</p><p>For machine learning engineers, it is necessary to continue to think deeply, understand the experimental results, and use Imaging’s ability to propose the next experimental plan that may work. You can’t just use Doing to make random attempts and hope one of them will work.</p><h3><strong>Summary</strong></h3><p>Taking the recommendation system as an example, the core job of the machine learning engineer is to provide better recommendation results for the users. It is necessary to constantly propose new ideas to optimize the existing system. In order to achieve this goal: Seeing, Doing and Imaging capabilities need to be improved.</p><ul><li>Seeing: It requires the engineer to add the ability to record user activity in the system, it is always good to record those information in detail and accurately, the information includes the behavior of the system and the behavior of the user. Those logs power the seeing ability of the engineer. Only when he has the ability to see the existing system, the engineer can optimize the existing system</li><li>Doing: It requires engineers the ability to implement ideas efficiently, and requires the system to support random controlled trials to test different ideas.</li><li>Imaging：It requires engineers to have a deep understanding of user behavior from failed and successful experiments and propose new ideas that might work next time.</li></ul><p>In changing nature, Imaging is one of the core competitiveness of the human. Imaging capabilities are also very important to optimize machine learning systems. While developing the capabilities of Seeing and Doing, machine learning engineers also need to strengthen the Imaging’s capabilities.</p><h3><strong>References</strong></h3><ol><li><a href="https://book.douban.com/subject/30139217/">https://book.douban.com/subject/30139217/</a></li><li><a href="https://medium.com/@fishlovebanana/drawing-different-conclusions-from-the-same-data-the-book-of-why-learning-part-1-1f465467f2b5">Drawing Different Conclusions from the Same Data — — The Book of Why Learning Part 1</a></li><li><a href="https://medium.com/@fishlovebanana/a-b-test-and-hypothesis-test-9ebb3af59e6b">A/B testing and hypothesis testing I</a></li><li><a href="https://medium.com/@fishlovebanana/a-b-testing-and-hypothesis-testing-ii-the-significance-level-55e4ab8366ce">A/B testing and hypothesis testing II — the significance level</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f799c193157" width="1" height="1" alt=""><hr><p><a href="https://medium.com/machine-learning-and-math/the-three-level-ladder-to-improve-machine-learning-system-the-book-of-why-learning-part-2-8f799c193157">The Three-Level Ladder to Improve Machine Learning System — — The Book of Why Learning Part 2</a> was originally published in <a href="https://medium.com/machine-learning-and-math">Machine Learning and Math</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>