<?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[Prudential AICOE - Medium]]></title>
        <description><![CDATA[Pru AICOE is the global AI center of Excellence team committed to transform Prudential organization - Medium]]></description>
        <link>https://medium.com/prudential-aicoe?source=rss----706e30b48549---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Prudential AICOE - Medium</title>
            <link>https://medium.com/prudential-aicoe?source=rss----706e30b48549---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 13:36:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/prudential-aicoe" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How we deployed our very first Reinforcement learning algorithm]]></title>
            <link>https://medium.com/prudential-aicoe/how-we-deployed-our-very-first-reinforcement-learning-algorithm-dab2dd62ab54?source=rss----706e30b48549---4</link>
            <guid isPermaLink="false">https://medium.com/p/dab2dd62ab54</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[azure-kubernetes-service]]></category>
            <dc:creator><![CDATA[Piyushkumar S. Jain]]></dc:creator>
            <pubDate>Wed, 08 Jul 2020 03:47:48 GMT</pubDate>
            <atom:updated>2020-07-08T03:47:48.360Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Recommending content to unknown/anonymous users at scale</blockquote><p>Our team is working to improve the health and wealth of millions of current customers and acquire more customers in the future. <br>The mobile application has a carousel portion in the bottom half section of the home page where dynamic banners can be rendered. Each banner is utilized as a form of information, communication medium or an application feature. This is the first page that is seen by all users who successfully register and a portion of them clicking on the banner displayed registering their interest. To increase engagement within the app, we had to understand the source of users who were clicking the banners, why are they willing to go into exploring app via banners after registering while others would go on to explore the app via other routes.</p><h4>Problem statement</h4><p>The goal was to increase user engagement within the app by understanding user’s interest in a variety of banners and then leverage the results across the app.</p><p>Considering that we didn’t have existing data about user interaction with the app we were essentially looking at a cold start problem to improve engagement. The other important aspect was there’s a huge inflow of new users expected in near future due to the planned marketing campaigns and we would know little about these users, so time to market was a very important factor. We were expected to go live within a few days to a maximum of two weeks duration with a solution to make the best out of data available at hand.</p><h4>Solution</h4><p>Bayesian bandits with Thomson sampling ticked all boxes as follows:<br>1. It requires no data or less to start with <br>2. It will learn incoming users/data and start recommending appropriate banners which improve the engagement metrics<br>3. Can work with new banners added as arms</p><p>The next phase of the project was also discussed where we agreed to work on building contextual bandits. In this post, I will be talking more about how we used various tools and technology making deployment possible. I will not be talking about how the recommendation algorithm works and the technology stack used to achieve it.</p><h4>Deployment</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*7qDjmYC2jf_WuZpQ1VHtwQ.png" /></figure><p>The build and deployment part of the project was broken down into two technical stages/phases:<br>1. Testing model and documenting results in the pre-prod environment with production data, define the input and the output schema for the model which will be used by the data engineer team to create a streaming pipeline.<br>2. Setup model to consume a live stream of event data, and respond via a REST endpoint with the recommended list of banners for the users<br>The front end of the mobile app is configured for a response time of one second w.r.t to back-end. It meant that the app will try to generate dynamic banners on the user screen based on our recommendations or fall back to static banners if we failed to deliver a response within a second, which added another layer of complexity to the second stage. Our APIs were expected to support a wide range of user load starting from a few hundred requests to millions across the region.</p><p>We could list the deployment infra into three major components:<br>1. A robust build and deployment pipeline<br>2. Automated performance testing<br>3. Production monitoring and alerting</p><p>Tools used for the complete setup:<br>1. Jenkins<br>2. Artifactory<br>3. Docker<br>4. Aquasec image scanning<br>5. Fortify static code scan<br>6.. Sonar Nexus open source code scanning<br>7. Kubernetes<br>8. Predator<br>9. Prometheus<br>10. Grafana<br>11. Bitbucket</p><p>Our application solution is a bunch of docker images which consumes/produces content in Kafka topics.</p><h4>Step 1 — Fetching code and checking for changes</h4><p>Our pipeline starts at fetching the code from Bitbucket repository. We store code in the folder structure for the 4 different docker images that are to be built. We check whether a file has been changed before initiating build for the files in that folder. The code in the Jenkins pipeline is as below for one of the folders titled ‘generator’.</p><pre># Code to check if any changes made in latest commit in a particular folder<br>script{<br>GIT_RESULT = sh(script: &#39;&#39;&#39;git diff --quiet HEAD &quot;$(git rev-parse @~1)&quot; -- generator&#39;&#39;&#39;,<br>                returnStatus: true<br>                )<br>                echo &quot;GIT RESULT -- ${GIT_RESULT} -- ${params.branchname}&quot;<br>              }</pre><h4>Step 2</h4><p>Next step is to run complete code static security scanning by Fortify</p><pre>sh &#39;&#39;&#39;<br>      echo &quot;==================================================&quot;<br>      echo &quot;========--- SAST - Fortify Scan: Start ---========&quot;<br>      echo &quot;==================================================&quot;<br>      hostname<br>      whoami<br>      ls -ahl<br>      echo &#39;WORKSPACE: &#39; $WORKSPACE<br>      cd $WORKSPACE<br>      pwd<br>      sourceanalyzer -v<br>      sourceanalyzer -b ${fortify_app_name} -clean<br>      sourceanalyzer -b ${fortify_app_name} -python-version ${python_version} -python-path ${python_path} ${fortify_scan_files}<br>      sourceanalyzer -b ${fortify_app_name} -scan -f ${fortify_app_name}.fpr<br>      fortifyclient -url <a href="https://sast.intranet.asia/ssc">https://sast.intranet.asia/ssc</a> -authtoken &quot;${fortify_upload_token}&quot; uploadFPR -file ${fortify_app_name}.fpr -project ${fortify_app_name} -version ${fortify_app_version}<br>     &#39;&#39;&#39;</pre><h4>Step 3</h4><p>The next step is to build the docker image. We first login to Artifactory before initiating the build as our pip libraries are also pulled from mirrored pip in the Artifactory. I have provided a sample of code on how we achieve this.</p><pre>sh &quot;&quot;&quot;<br>                echo ${ARTIFACTORY_PASSWORD} | docker login -u ${ARTIFACTORY_USERNAME} --password-stdin docker-registry:8443<br>                cd generator<br>                docker build --file Docker-dev \<br>                 --build-arg HTTPS_PROXY=<a href="http://ip-address/">http://ip-address</a> \<br>                 --build-arg ARTIFACTORY_USERNAME=${ARTIFACTORY_USERNAME} \<br>                 --build-arg ARTIFACTORY_PASSWORD=${ARTIFACTORY_PASSWORD} \<br>                 -t ${env.generator_image_latest} .<br>                docker tag ${env.generator_image_latest} ${env.generator_image_name}<br>                docker push ${env.generator_image_latest}<br>                docker push ${env.generator_image_name}<br>                docker logout docker-pcaaicoe.pruregistry.intranet.asia:8443<br>                cd ..<br>        &quot;&quot;&quot;</pre><h4>Step 4</h4><p>After pushing an image into Artifactory, the next important and mandatory step to be performed is docker image security scanning.</p><pre>sh &quot;&quot;&quot;<br>         echo &quot;==================================================&quot;<br>         echo &quot;=============--- OSS - Nexus Scan ---=============&quot;<br>         echo &quot;==================================================&quot;<br>                docker save -o generator-dev.tar ${env.generator_image_latest}<br>                &quot;&quot;&quot;<br>                String result = nexusscan(&quot;pcaaicoeaipulsenudgesgeneratordev&quot;, &quot;$WORKSPACE&quot;, &quot;build&quot;);<br>                echo result;<br>                sh &quot;&quot;&quot;<br>                rm -f generator-dev.tar<br>                &quot;&quot;&quot;<br>                sh &quot;&quot;&quot;<br>                echo &quot;==================================================&quot;<br>    echo &quot;=============--- CSEC - Aquasec Scan ---==========&quot;<br>                echo &quot;==================================================&quot;<br>                &quot;&quot;&quot;<br>                aquasecscan(&quot;${env.generator_image_latest}&quot;)</pre><p>The code and image security scanning stages are major milestones to be cleared during the deployment phase. It is important as well as difficult to explain and agree between application security teams about what risks are we willing to take while allowing open source libraries with bugs to go live in our environment.</p><h4>Step 5 — Deploy into AKS</h4><p>Now we move on to the stage where we will be able to actually deploy and run our images. In order to deploy our solution, we need a Redis DB and Kafka cluster up and running. We deploy our docker images using the below code:</p><pre>sh &#39;&#39;&#39;<br>            set +x<br>            echo &quot;---- preparing options ----&quot;<br>            export HTTPS_PROXY=ip-address:8080<br>            export KUBE_NAMESPACE=&quot;internal-namespace&quot;<br>            export KC_OPTS=${KC_OPTS}&quot; --kubeconfig=${KUBE_CONFIG}&quot;<br>            export KC_OPTS=${KC_OPTS}&quot; --insecure-skip-tls-verify=true&quot;<br>            export KC_OPTS=${KC_OPTS}&quot; --namespace=${KUBE_NAMESPACE}&quot;<br>            <br>            echo &quot;---- prepared options ----&quot;<br>            echo &quot;---- preparing alias ----&quot;<br>            alias kc=&quot;kubectl ${KC_OPTS} $*&quot;<br>            echo &quot;---- alias prepared ----&quot;<br>            <br>            echo &quot;---- applying manifest ----&quot;<br>   <br>   <br>   kc apply -f configmap.yaml<br>   <br>   if [ $which_app = &quot;generator&quot; ];then<br>     if [ $image_version = &quot;latest&quot; ];then<br>       kc delete deploy ai-pulse-nudges-events-reader||echo<br>     fi<br>     sed -i &quot;s!GENERATOR_VERSION!$image_version!g&quot; &quot;generator.yaml&quot;<br>     kc apply -f generator.yaml<br>   fi  <br>   <br>   if [ $which_app = &quot;aggregator&quot; ];then<br>     if [ $image_version = &quot;latest&quot; ];then<br>       kc delete deploy ai-pulse-nudges-click-counter||echo<br>     fi<br>     sed -i &quot;s!AGGREGATOR_VERSION!$image_version!g&quot; &quot;aggregator.yaml&quot;<br>     kc apply -f aggregator.yaml<br>   fi<br>   <br>   if [ $which_app = &quot;detector&quot; ];then<br>     if [ $image_version = &quot;latest&quot; ];then<br>       kc delete deploy ai-pulse-nudges-engine||echo<br>     fi<br>     sed -i &quot;s!DETECTOR_VERSION!$image_version!g&quot; &quot;detector.yaml&quot; <br>     kc apply -f detector.yaml<br>   fi<br>   <br>   if [ $which_app = &quot;restapi&quot; ];then<br>     if [ $image_version = &quot;latest&quot; ];then<br>       kc delete deploy ai-pulse-nudges-restapi||echo<br>        fi<br>     sed -i &quot;s!REST_VERSION!$image_version!g&quot; &quot;restapi.yaml&quot;<br>     kc apply -f restapi.yaml<br>            fi<br>if [ $which_app = &quot;all&quot; ];then<br>     if [ $image_version = &quot;latest&quot; ];then<br>     kc delete deploy ai-pulse-nudges-events-reader||echo<br>     kc delete deploy ai-pulse-nudges-click-counter||echo<br>     kc delete deploy ai-pulse-nudges-engine||echo<br>     kc delete deploy ai-pulse-nudges-restapi||echo<br>     fi<br>     <br>     sed -i &quot;s!GENERATOR_VERSION!$image_version!g&quot; &quot;generator.yaml&quot;<br>     sed -i &quot;s!AGGREGATOR_VERSION!$image_version!g&quot; &quot;aggregator.yaml&quot;<br>     sed -i &quot;s!DETECTOR_VERSION!$image_version!g&quot; &quot;detector.yaml&quot; <br>     sed -i &quot;s!REST_VERSION!$image_version!g&quot; &quot;restapi.yaml&quot;<br>     <br>     kc apply -f generator.yaml<br>     kc apply -f aggregator.yaml<br>     kc apply -f detector.yaml<br>     kc apply -f restapi.yaml<br>            fi<br>   <br>   <br>   <br>            echo &quot;---- manifest applied ----&quot;<br>echo &quot;---- checking result ----&quot;<br>            <br>            echo &quot; &gt;&gt; Deployments &quot;<br>            kc get deployments<br>            <br>            echo &quot; &gt;&gt; Services&quot;<br>            kc get svc<br>            <br>            echo &quot; &gt;&gt; Ingress&quot;<br>            kc get ingress<br>            <br>            echo &quot; &gt;&gt; Pods&quot;<br>            kc get pods<br>            <br>            echo &quot;---- Done ----&quot;<br>          &#39;&#39;&#39;</pre><h4>Step 6 — Performance test</h4><p>We also need to deploy Predator — the tool which we use for performance test.</p><pre>sh &#39;&#39;&#39;<br>            set +x<br>            echo &quot;---- preparing options ----&quot;<br>            export HTTPS_PROXY=ip-address:8080<br>            export KUBE_NAMESPACE=&quot;internal-namespace&quot;<br>            export KC_OPTS=${KC_OPTS}&quot; --kubeconfig=${KUBE_CONFIG}&quot;<br>            export KC_OPTS=${KC_OPTS}&quot; --insecure-skip-tls-verify=true&quot;<br>            export KC_OPTS=${KC_OPTS}&quot; --namespace=${KUBE_NAMESPACE}&quot;<br>            <br>            echo &quot;---- prepared options ----&quot;<br>            echo &quot;---- preparing alias ----&quot;<br>            alias kc=&quot;kubectl ${KC_OPTS} $*&quot;<br>            echo &quot;---- alias prepared ----&quot;<br>            <br>            echo &quot;---- applying manifest ----&quot;<br>   <br>   kc get deploy|grep predator|awk &#39;{print $1 }&#39; || echo<br>   kc get deploy|grep predator|awk &#39;{print $1 }&#39;|xargs kc delete deploy || echo<br>   <br>   for i in `seq $replica_count`<br>   do<br>     echo $i<br>     cp -rf predator/predator.yaml tmp.yaml<br>     sed -i &quot;s!REPLICA_NO!$i&quot;&quot;!g&quot; &quot;tmp.yaml&quot;<br>     kc apply -f tmp.yaml<br>   done  <br>   <br>   <br>            # kc apply -f predator/predator.yaml<br>            <br>            echo &quot;---- manifest applied ----&quot;<br>echo &quot;---- checking result ----&quot;<br>            <br>            echo &quot; &gt;&gt; Deployments &quot;<br>            kc get deployments<br>            <br>            echo &quot; &gt;&gt; Services&quot;<br>            kc get svc<br>            <br>            echo &quot; &gt;&gt; Ingress&quot;<br>            kc get ingress<br>            <br>            echo &quot; &gt;&gt; Pods&quot;<br>            kc get pods<br>            <br>            echo &quot;---- Done ----&quot;<br>          &#39;&#39;&#39;</pre><p>Predator is an amazing tool that enables us to leverage existing Kubernetes infra for an unlimited number of users for testing. Read more about the tool here: <a href="https://medium.com/zooz-engineering/by-niv-lipetz-software-engineer-zooz-b5928da0b7a8">https://medium.com/zooz-engineering/by-niv-lipetz-software-engineer-zooz-b5928da0b7a8</a><br>We leverage the existing enterprise Prometheus and Grafana set up to monitor the application pods.</p><p>Lessons learned for next time: <br>1. We started writing the pipeline code from scratch, whereas it would have helped save time if an advanced hello world type of empty pipeline existed, which could be used as a template structure. It would have enabled us to know what credentials and access were required at what stage. <br>2. There were many credentials and access that were required to get the pipeline up and running. It would be a time and effort savior if we have one master service id created and assigned to a pipeline which can then be used across all tools in the organization.<br>3. It is very difficult to build a machine learning model, and real-time streaming data was an additional complexity, but productionizing that model with streaming data is many folds difficult.</p><p><em>Contributors: Glenn Bayne, Tien Nguyet Long, John Yue, Zeldon Tay （郑育忠), Steven Chau , Denys Pang , Philipp Gschoepf , Syam Bandi , Uma Maheshwari, Michael Natusch</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dab2dd62ab54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/prudential-aicoe/how-we-deployed-our-very-first-reinforcement-learning-algorithm-dab2dd62ab54">How we deployed our very first Reinforcement learning algorithm</a> was originally published in <a href="https://medium.com/prudential-aicoe">Prudential AICOE</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>