<?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 Chaitanya Basava on Medium]]></title>
        <description><![CDATA[Stories by Chaitanya Basava on Medium]]></description>
        <link>https://medium.com/@chaitanya-basava?source=rss-c816f94b49ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*I-_WGmCZurpJOR2oCOWbZg.jpeg</url>
            <title>Stories by Chaitanya Basava on Medium</title>
            <link>https://medium.com/@chaitanya-basava?source=rss-c816f94b49ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:38:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chaitanya-basava/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[So You Pushed Your .env to Git… What’s Next?]]></title>
            <link>https://chaitanya-basava.medium.com/so-you-pushed-your-env-to-git-whats-next-014fd92c4bfd?source=rss-c816f94b49ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/014fd92c4bfd</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[api-key]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Chaitanya Basava]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 00:55:57 GMT</pubDate>
            <atom:updated>2025-03-30T05:03:47.361Z</atom:updated>
            <content:encoded><![CDATA[<h3>So You Pushed Your .env to Git… What’s Next?</h3><p>The rise of Large Language Models (LLMs) has revolutionized the tech landscape, spawning numerous cloud-based solutions and enabling developers to integrate advanced AI capabilities into their applications. For many developers, especially those unable to host their own models, services like <a href="https://platform.openai.com/docs/overview">OpenAI</a>, <a href="https://www.anthropic.com/api">Anthropic</a>, <a href="https://dashboard.cohere.com/">Cohere</a>, <a href="https://huggingface.co/docs/hub/en/index">Hugging Face Hub</a>, and <a href="https://console.groq.com/docs/quickstart">Groq Cloud</a> have become go-to resources for accessing the LLM power.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-SbFtg6qlQWeuy9cdwsEow.jpeg" /></figure><p>These services typically provide access through API keys, which serve a dual purpose: granting access to the models and tracking usage for billing. While this system streamlines integration and monetization, it also introduces a significant risk. API keys, by their nature, are highly sensitive credentials. Their exposure can lead to catastrophic financial consequences for unwary developers.</p><p>Imagine a scenario where a hobby project accidentally exposes an API key. What started as an exciting exploration of AI capabilities could swiftly transform into a financial nightmare, with unexpected charges potentially reaching thousands of dollars.</p><p>One of the most common ways developers inadvertently expose their API keys is by pushing .env files to SCM platforms like GitHub. This simple oversight can turn an API key into a liability in seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*GQXoO9aF-NL0BJVi0wa8Bg.jpeg" /><figcaption>no, it’s not, unless you are extremely wealthy</figcaption></figure><p>This article will guide you through a method to remove the .env file (or any other file, for that matter) from your Git history.</p><p>You can choose to go ahead with this approach if there are just a lot of keys and limited time to wipe them from the public space to minimize exposure for the time being.</p><p>The git-filter-repo command is a handy tool for such scenarios. It doesn’t come bundled with Git and needs to be installed separately using either of the following commands:</p><pre># pip<br>pip install git-filter-repo<br><br># For Debian/Ubuntu<br>sudo apt install git-filter-repo<br><br># For macOS with Homebrew<br>brew install git-filter-repo</pre><p><strong>Take a copy of your current </strong><strong>.env file</strong> and execute the following command to remove it from all the commits across branches.</p><pre>git filter-repo --invert-paths --path-glob &#39;**/.env&#39; --force</pre><p>This might take a while to execute, once finished, force push the changes to the remote repository using the following command.</p><pre>git push origin --force --all</pre><p>These commands can be used to remove any file of your choice from your Git history. While effective, this approach comes with potential issues that one should be aware of, especially in a collaborative environment.</p><h3>The Ripple Effect: Consequences of Rewriting Git History</h3><p>The git-filter-repo command would alter the history of your git repository. The structure of your history graph would remain exactly the same, but the commit hashes would get altered, leading to the following downstream effects:</p><ol><li><strong>Altered Commit Hashes:</strong> The command rewrites Git history by modifying all commits that contained the .env file and the ones after the first occurrence of the file in the history. This process generates new commit hashes for these altered commits.</li><li><strong>Broken References:</strong> As a result of changed commit hashes, any references to the original commits will become invalid.</li><li><strong>Collaboration Challenges:</strong> Team members who have based their work on the original history will face conflicts when pulling the rewritten history, potentially leading to complex merge scenarios.</li><li><strong>Force Push Required:</strong> To update the remote repository, you’ll need to force push the rewritten history, which can overwrite changes if not done carefully.</li><li><strong>Loss of Consistency:</strong> The rewritten history may no longer align with any forks or local copies of the repository.</li></ol><p>Keep in mind that while this method can help clean up your repository, it’s not a substitute for proper key management and security practices. Always treat exposed keys as compromised and replace them as soon as possible.</p><p>To learn more about git-filter-repo you can read the following <a href="https://andrewlock.net/rewriting-git-history-simply-with-git-filter-repo/">blog</a>.</p><p><em>Thanks for reading! If you have any suggestions or questions, please leave them in the comments below.</em></p><p><em>PS: memes taken off the internet. Not that creative unfortunately, will get better though ;)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=014fd92c4bfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smart Push notifications (Multi-Armed Bandits at Swiggy: Part-4)]]></title>
            <link>https://medium.com/swiggy-bytes/smart-push-notifications-multi-armed-bandits-at-swiggy-part-4-f5698f2af0a6?source=rss-c816f94b49ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5698f2af0a6</guid>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[linear-programming]]></category>
            <category><![CDATA[swiggy-data-science]]></category>
            <category><![CDATA[multi-armed-bandit]]></category>
            <dc:creator><![CDATA[Chaitanya Basava]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 12:21:20 GMT</pubDate>
            <atom:updated>2023-03-30T12:21:20.432Z</atom:updated>
            <content:encoded><![CDATA[<p>Co-authored with <a href="https://www.linkedin.com/in/viswanath-gangavaram-4336937/">Viswanath Gangavaram</a></p><p>This is part-4 of our blog post series on Multi-armed Bandits (MAB) at Swiggy. In <a href="https://bytes.swiggy.com/multi-armed-bandits-at-swiggy-5b1a4b1c2724">Part-1</a>, we introduced the fundamental concepts of MABs, and we briefly talked about various products that are currently powered by MABs at Swiggy. In <a href="https://bytes.swiggy.com/multi-armed-bandits-at-swiggy-part-2-ec6c4f7e7e29">Part-2</a>, we studied regret, and convergence properties of some of the popular MAB algorithms namely Epsilon Greedy, Softmax, Upper Confidence Bound, and Thompson Sampling. In <a href="https://bytes.swiggy.com/contextual-bandits-for-ads-recommendations-ec210775fcf">Part-3</a>, we deep-dived into how contextual MABs are powering Ads recommendation on the Swiggy App, and we also talked about practical aspects of productionising MABs.</p><p>In this blog post, we are giving a detailed account of Smart Push Notifications, one such project where we employed MABs, and briefed the complete end-to-end pipeline that powers Smart Push Notifications.</p><h3>Terminology</h3><p><strong>Push Notification (PN):</strong> An alert (typically a pop-up or a message) generated by an application when the application is not open, notifying the user of its offerings.</p><p><strong>CTR (click-through rate):</strong> # of PNs clicked / # of PNs sent</p><p><a href="https://clevertap.com/"><strong>CleverTap</strong></a><strong>:</strong> A platform, with which we send PNs to user devices</p><p><strong>Smart Push Notifications:</strong> An end-to-end system that orchestrates all eligible PNs for a given user and creates an optimised weekly plan by satisfying a given set of constraints.</p><p><strong>Entity:</strong> An entity is a restaurant or a dish or cuisine that appears in a PN.</p><p><strong>Note:</strong> PN theme / PN / Theme: In the article, we used three terms interchangeably.</p><h3>Push Notifications</h3><p>Let’s admit it, push notifications (PNs) are a tricky territory! Sending too few of them translates to leaving money on the table; sending too many — you risk annoying the user. Another dimension to take into consideration is incorporating diversity and novelty aspects. For example, a user may have a higher affinity towards a specific PN but sending it over and over again might lead to fatigue in the long run.</p><figure><img alt="Image-1: Example PNs sent by Smart Push Notifications" src="https://cdn-images-1.medium.com/max/1024/1*ZXeJ8WrKCNliFa2UbaicQQ.png" /><figcaption>Image-1: Example PNs sent by Smart Push Notifications</figcaption></figure><p>As seen in Image-1&amp;2, a push notification is composed of three different types of content 1) PN-text: The English text in the title and the body 2) Entity: Restaurant/Dish/Cuisine name mentions, and 3) Callouts: user name/user’s location/user’s rating/discount.</p><figure><img alt="PN context explaination" src="https://cdn-images-1.medium.com/max/636/0*bzD-AplTKyINOLBb" /><figcaption>Image-2: Components of a Push Notification</figcaption></figure><p>We designed various personalised, and non-personalised recommender systems to suggest restaurants/dishes/cuisines (entities) be shown in the PNs. Personalised recommender systems suggest based on the user’s preferences, whereas non-personalised recommender systems suggest based on the user’s location like top-rated restaurants in the user’s location.</p><p>Creating a PN-text is a creative art with rich dividends if we get it correct. We have seen a 2–3x lift in the CTRs with different PN-text for the same data recommenders, and callouts. We have an in-house content team, who regularly innovate on the PN-text.</p><p>For every PN-text, and data recommender we created multiple variants with different callouts like user name, user’s location, and best available discount for a given user. Regularly, we have seen a 20–40% lift in CTRs with these callouts.</p><h3>The Problem Setup</h3><p>Given the way the PNs are composed, and how the users are expected to react to them, we can see the following properties of the data science problem at hand 1) the Heterogeneous nature of optimization set up at a user level 2) The constraints to optimize for a given time period 3) The dynamic nature of PN campaigns.</p><p><strong>1. Heterogeneous nature of optimization set up at a user level:</strong></p><blockquote>a. Each user is eligible for different types of PNs.<br>b. A user might be eligible for more PNs than we can send in a period (week).<br>c. Variance in the optimal number of PNs per user in a time period.</blockquote><p><strong>2. The constraints to optimize for a given time period:</strong></p><blockquote>a. Do not send a PN more than n1 times in a week.<br>b. Do not send a PN more than n2 times in a day.<br>c. Do not send more than n3 PNs in a week/day.</blockquote><p><strong>3. The dynamic nature of PN campaigns:</strong></p><blockquote>a. The continuous innovation in PN-text leads to an ever-increasing number of PNs<br>b. New data recommendation systems mean new types of PNs<br>c. A PN’s CTR changes with time<br>d. Multivariate nature of PN’s CTRs as a function of user’s attributes<br>e. A given PN is more similar to some PNs than other PNs</blockquote><p>One of the ideal modelling candidates to model the dynamic nature of the PNs is through contextual MABs, given their inherent nature to handle explore/exploit dilemmas. To further reduce the regret of the MAB algorithm in the “cold start” stage, we employed a hierarchical variant of MABs (refer to Image-4), wherein we estimated a set of CTRs for a given PN from a terminal node to the root node and took the weighted sum of CTRs by taking an advantage of similarity among the PNs. To model the changes in CTR trends, we are estimating multiple CTRs with feedback data from different intervals of time and taking the weighted average of the estimated CTRs to compute the final CTR estimate.</p><p>To handle the heterogeneous nature of the optimization setup at a user level, and the constraints to optimize for longer periods, we pose the problem as an integer optimization problem.</p><h3>Unserviceable menu visits</h3><p>While we send location-sensitive PNs, we need to be aware of the user’s location, otherwise, we will end up having a bad user experience with unserviceable restaurant menu visits, whenever a user is far away from the serviceable limits of the restaurant after they clicked on a PN. To tackle the issue, we are using the user’s most frequently visited location from the past, and along with it, we modelled the probability of the user’s current location being the user’s most frequently visited location given the user’s attributes. If this confidence score is more than x, we send these location-sensitive PNs, otherwise, we restrict to sending only location-insensitive PNs, like PNs taking the user to the Swiggy app’s home screen on a click.</p><h3>End-to-End Pipeline: An intelligent orchestration of PNs with constraints</h3><figure><img alt="SmartPN end-to-end pipeline" src="https://cdn-images-1.medium.com/max/1024/0*tKUTTRMMR3dzVHZw" /><figcaption>Image-3: End-to-End Smart Push Notification pipelines for Weekly Scheduler, and daily upload Jobs</figcaption></figure><p>The various blocks in the system flow represented above starting from Eligible PNs to pushing the notifications into CleverTap are described below.</p><h4>a. Universe of PNs</h4><p>This module tracks all the possible PNs that can potentially be sent to a user. This is derived from the outputs of the various recommender systems (such as Restaurants You Love, Items You Love, Because You Ordered, etc), PN-text, and callouts.</p><h4>b. Orchestration Table:</h4><p>The Orchestration table maintains which user received which PN and the corresponding entity (restaurant/dish) recommendations. It is used to avoid repeating the same entity recommendation within a specified time period and in building the eligible PN entities for weekly modelling. It is updated daily to hold the last N days of data uploaded to CleverTap.</p><h4>c. Customer Location:</h4><p>The customer location module is used to predict the customer’s location along with an associated confidence score. We make use of this predicted confidence score, if the confidence score is less than X, then we mark the user to be ineligible for receiving the location-sensitive PNs.</p><h4>d. Serviceability + Availability checks:</h4><p>This module along with the orchestration table is used to filter eligible themes from the universe of available PNs. We check the serviceability of the entities recommended in the PNs by validating if the user is within a K km radius of the recommended restaurant. At the same time, the availability of a restaurant is validated by ensuring that the restaurant is taking orders at the time of sending PNs. By employing an accurate customer location prediction model and restaurant availability and serviceability checks before sending PN, we reduced landings on unserviceable PN sessions significantly compared to when not using them.</p><h4>e. Eligible PN Themes:</h4><p>The universe of potential PNs is trimmed down using the orchestration table, serviceability, and availability checks. Only the PNs that satisfy the aforementioned validations are processed further through the pipeline to generate the final week’s plan for all the users.</p><h4>f. Historic PN feedback:</h4><p>We gather the impressions and clicks data for each user in our user base, which is used to build an aggregated feedback dataset that contains the #impressions and #clicks at a user, PN theme level. This feedback data is used as input to our HCB module, which estimates the click-through rate using contextual bandits.</p><h4>g. User Segments:</h4><p>When we observe the data at a user level, the feedback data would be very sparse as the rate of a PN getting a click from a given user is very low. To avoid using sparse feedback data, we mapped each user present in our user base to a segment.</p><h4>h. Hierarchical Contextual Bandits:</h4><p>SmartPN aims to emit an optimised weekly plan at a user level based on the estimated click-through rate (CTR) for each push notification. HCB is used to estimate CTR for each push notification and these estimated CTRs go as input to the weekly plan scheduler. To reduce the initial complexity, we employed segmented hierarchical bandits as hierarchical contextual bandits (HCBs) that make use of the impressions &amp; click data for PNs at the user-segment level and perform hierarchical Thompson sampling over PN-types tree and emit an estimated CTR for each user, theme pair. An illustration of the PN-types tree is given below.</p><figure><img alt="PN-type tree" src="https://cdn-images-1.medium.com/max/1024/0*yj3PnZF4KJxg4oFN" /><figcaption>Image-4: PN-types tree: Encodes PNs similarity</figcaption></figure><p>Notes on Image-4:</p><ol><li>Here BYL1, BYL2, RYL, Supply1, and Supply2 are actual PNs. Exploit, Explore, Personalised, Non-Personalised, and Root-Node are logical nodes, which capture the similarity among PNs.</li><li>Logical nodes encode human intelligence.</li><li>Nodes separated by smaller distances are regarded as more similar to each other than nodes separated far apart. For example, BYL1 is more similar to BYL2 than Supply1.</li></ol><h4>i. Weekly plan optimiser:</h4><p>This module takes in the optimal number of PNs and the estimated CTRs from HCB as the inputs and outputs of a weekly PN schedule at a user level. We make use of linear programming which aims to optimize for maximising the overall CTR attainable at a user level, under a given set of diversified business constraints. We used the MIP library in python to model the constraints and the optimization problem at hand.</p><h4>j. Weekly PN schedule:</h4><p>The output of the optimiser is a weekly plan at a user level, with details like the PN and the entity to be recommended for each of the next 7 days. This plan is generated every Sunday and is used for the next 7 days to create the PNs to be sent to the eligible users.</p><h4>k. Daily upload list generation:</h4><p>This generated schedule is then used by the daily uploader module to create the day’s final upload list. We rerun all the serviceability and availability checks using similar logic described earlier in section d. In addition, we also check for available discount coupons used for powering the discount campaigns. The PNs which satisfy all the validation checks are made to be part of the final upload list.</p><h4>l. CleverTap upload:</h4><p>We make use of the final upload list generated in the earlier step and gather all the necessary metadata required for showing the PN to the user. We then upload these PN details for each user into CleverTap, which finally disburses the notifications to all the eligible users.</p><h3>Learnings from experimentations</h3><p>Some of the learnings from our experiments with variants of HCBs and the optimization parameters are summarised below:</p><ul><li>We tested “Max number of PNs per PN type = 1” Vs. “Max number of PNs per PN type = 2”, we found that “Max number of PNs per PN type = 1” is working significantly better than the other variant. This proved our hypothesis that if we send more of our champion PNs in a given time period then the champion PNs lose their goodness.</li><li>We evaluated UCB as against Thompson sampling, and what we found is Thompson Sampling significantly works better than UCB in this use case.</li><li>Another interesting insight that we found is that the majority of the incremental benefit from Smart Push Notifications is coming from the high transacting user base, so to reduce the running cost, we restricted Smart Push Notifications only to targeting a high transacting user base. A point to be noted is that the goodness of Smart Push Notifications is a function of the PN copies that it’s given, so currently, we are working on PN copies that are best suited for a lower transacting user base.</li><li>Cost optimisations: 1) to reduce the running cost, instead of estimating CTR for each &lt;user, PN&gt;, we tried to estimate the CTR at a &lt;segment, random cohort, PN&gt;, and assign this CTR to every user within the same segment, and random cohort. We experimentally found that this run-time optimisation has no significant effect on the overall performance as compared to estimating CTR for every user. 2) Given the run-time of the optimiser is directly proportional to the number of constraints that it needs to satisfy, one trick that we found is that if the estimated CTR is less than a particular threshold then we removed that PN from the eligible list of PNs that a user can get, this significantly reduces the number of constraints inputted to the optimiser.</li></ul><h3>Endnotes</h3><p>In conclusion, we are long on MABs, and so far in this series, we have covered how MABs are addressing the fundamental dilemma of <a href="https://bytes.swiggy.com/multi-armed-bandits-at-swiggy-5b1a4b1c2724">explore-exploit trade-off</a>, we studied <a href="https://bytes.swiggy.com/multi-armed-bandits-at-swiggy-part-2-ec6c4f7e7e29">regret properties</a> of various MAB algorithms, and we have seen how contextual MABs are powering our <a href="https://bytes.swiggy.com/contextual-bandits-for-ads-recommendations-ec210775fcf">ads recommendations</a>, personalising <a href="https://bytes.swiggy.com/personalising-the-swiggy-homepage-layout-part-ii-450c55a40058">Swiggy homepage layout</a>, and enabling smart push notifications at Swiggy. Next up is a blog piece that intertwines the fields of MABs, and causal inference.</p><p>Until then, Swiggy karo, phir jo chahe karo 😁</p><p>Acknowledgments: Smart Push Notifications wouldn’t be possible without the persistent efforts of <a href="https://in.linkedin.com/in/shreniksurana">Shrenik Surana</a>, <a href="https://in.linkedin.com/in/shohan-n-10a354122">Shohan N</a>, <a href="https://in.linkedin.com/in/bhavi-chawla-a07723175">Bhavi Chawla</a>, <a href="https://www.linkedin.com/in/dharun-suryaa-09b372176">Dharun Surya</a>, and many others.</p><p>Credits to <a href="https://www.linkedin.com/in/jairajs">Jairaj Sathyanarayana</a> &amp; <a href="https://in.linkedin.com/in/abhinav-ganesan">G Abhinav</a> for reviewing this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5698f2af0a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swiggy-bytes/smart-push-notifications-multi-armed-bandits-at-swiggy-part-4-f5698f2af0a6">Smart Push notifications (Multi-Armed Bandits at Swiggy: Part-4)</a> was originally published in <a href="https://medium.com/swiggy-bytes">Swiggy Bytes — Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>