<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>AI on keithrozario.com</title><link>https://keithrozario.com/categories/ai/</link><description>Recent content in AI on keithrozario.com</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 22 Apr 2019 00:29:34 +0000</lastBuildDate><atom:link href="https://keithrozario.com/categories/ai/index.xml" rel="self" type="application/rss+xml"/><item><title>Spacy in a Lambda</title><link>https://keithrozario.com/2019/04/spacy-in-a-lambda-layer/</link><pubDate>Mon, 22 Apr 2019 00:29:34 +0000</pubDate><guid>https://keithrozario.com/2019/04/spacy-in-a-lambda-layer/</guid><description>&lt;!-- wp:image {"id":6728} -->
&lt;p>&lt;img
 src="https://keithrozario.com/uploads/social_default-1d3b50b1eba4c2b06244425ff0c49570_hu_6c3c2b58cfe8e316.jpg"
 srcset="
 /uploads/social_default-1d3b50b1eba4c2b06244425ff0c49570_hu_d7cc2799bce7347c.jpg 480w,
 /uploads/social_default-1d3b50b1eba4c2b06244425ff0c49570_hu_6c3c2b58cfe8e316.jpg 768w,
 /uploads/social_default-1d3b50b1eba4c2b06244425ff0c49570_hu_e1a54db6d9c6d336.jpg 1024w,
 /uploads/social_default-1d3b50b1eba4c2b06244425ff0c49570.jpg 1200w"
 sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, (max-width: 1024px) 1024px, 100vw"
 alt=""
 
 loading="lazy"
 />&lt;/p>
&lt;!-- /wp:image -->
&lt;!-- wp:paragraph -->
&lt;p>I've been really digging into &lt;a href="https://www.keithrozario.com/2019/02/keith-at-aws-meetup.html">Lambda Layers&lt;/a> lately, and once you begin using layers you'll wonder how you got by without them.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>Layers allow you to package just about anything into lambda, but in a modular way. So elements of your code that don't change much, can be packaged into layers, while keeping your actual lambda deployment for just the code that's changing.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p> It's akin to docker cache, where you keep the un-changing elements higher up in your docker file, separate from the code that always changes. The difference though, is that docker cache speeds up builds, while layers speeds up lambda deployments.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>But layers aren't magic, and they're still limited by the AWS size limit, hence your entire function (including all it's layers) need to be no larger than 250MB (unzipped). &lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>Which is tough for something like &lt;a href="https://spacy.io/">spaCy &lt;/a>-- because its default installation size on a AWS Linux is ~400MB (or 492MB based on my quick installation on &lt;a href="https://github.com/lambci/lambci">lambci&lt;/a> for python3.7). So, in order to get spaCy working on a lambda, certain tweaks are going to be necessary.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>Some have tried working around this problem by installing spaCy onto the lambda container on &lt;a href="https://stackoverflow.com/questions/47879258/spacy-model-wont-load-in-aws-lambda">cold-start&lt;/a> -- i.e. pull the data into lambda only when you have access to the 512MB in &lt;code>/tmp&lt;/code>. Cool solution, but it almost completely fills out &lt;code>/tmp&lt;/code>, and makes a cold-start even slower.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>A more optimal solution would be to reduce the size of the spaCy installation and have it fit into a layer! Fortunately I found a &lt;a href="https://github.com/explosion/spaCy/issues/2851">GitHub issue&lt;/a> after some googling that enables us to do exactly this.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>It involves removing unnecessary language files, which spaCy lazy load in, If you're only interested in one language, you can simply remove the unnnecessary language files in the &lt;code>site-packages/spacy/lang&lt;/code> directory. &lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>After manually removing all non-English (en) language files, I managed to reduce the size of the spaCy package to 110MB, which fits very nicely into a lambda layer, in the end my lang directory only had the following files:&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:image {"id":6733} -->
&lt;p>&lt;img
 src="https://keithrozario.com/uploads/Screenshot-2019-04-22-at-9.54.23-PM.png"
 alt=""
 
 loading="lazy"
 />&lt;/p>
&lt;!-- /wp:image -->
&lt;!-- wp:paragraph -->
&lt;p>As a bonus, I also included the English &lt;a href="https://github.com/explosion/spacy-models/releases/tag/en_core_web_sm-2.1.0">en_core_web_sm-2.1.0&lt;/a> model, to make the lambda layer fully usable on its own . &lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:paragraph -->
&lt;p>Finally I published it as a publicly available layer, for anyone to consume. One of the amazing things about layers, is that once a layer is made, it can be shared across AWS for anyone to consume.&lt;/p>
&lt;!-- /wp:paragraph -->
&lt;!-- wp:more --></description></item><item><title>Internet of shitty things!</title><link>https://keithrozario.com/2016/10/internet-of-shitty-things/</link><pubDate>Mon, 24 Oct 2016 23:05:27 +0000</pubDate><guid>https://keithrozario.com/2016/10/internet-of-shitty-things/</guid><description>&lt;p>&lt;img
 src="https://keithrozario.com/uploads/b66b95478f-300x188.jpg"
 alt="b66b95478f"
 
 loading="lazy"
 />&lt;/p>
&lt;p>Brian Krebs is the most reputable name in CyberSecurity reporting, his &lt;a href="http://www.krebsonsecurity.com">krebsonsecurity&lt;/a> website is the best source of &amp;lsquo;real&amp;rsquo; journalism on the subject.&lt;/p>
&lt;p>But reputation works both ways, the same thing that makes him popular in some circles, makes him unpopular in other. He&amp;rsquo;s had criminal hackers send him &lt;a href="http://www.vice.com/read/i-interviewed-the-fraudster-who-frames-people-for-heroin-possession">heroin in the mail&lt;/a> and even have &lt;a href="http://krebsonsecurity.com/2013/03/the-world-has-no-room-for-cowards/">SWAT teams descend on his home with guns all blazing&lt;/a> (in a phenomenon called &lt;a href="https://en.wikipedia.org/wiki/Swatting">swatting!&lt;/a>). Reporting and exposing underground cyber-criminals comes at a price, you don&amp;rsquo;t piss of darknet crime lords without taking a few hits along the way.&lt;/p>
&lt;p>The problem though is when those &amp;lsquo;few&amp;rsquo; hits, turn into a hurricane of web traffic aimed at your server, because that&amp;rsquo;s exactly what descended on Krebs&amp;rsquo; server late last week, when krebsonsecurity was hit by an epic DDOS attack&lt;/p>
&lt;p>DDOS is an acronym for Distributed-Denial-of-Service, which basically means forcing so much web traffic to a single website that it eventually collapses&amp;ndash;making it unable to provide services to the &amp;lsquo;real&amp;rsquo; visitors of the site. All websites run on servers with finite capacity, DDOS attacks are about sending enough traffic to those servers that they eventually exceed that capacity.&lt;/p>
&lt;p>But this DDOS was different, and krebsonsecurity will go down in history as the Hiroshima of this type of DDOS. But nuclear weapons only had Hiroshima and Nagasaki, krebsonsecurity will be the first in a Looooong line of DDOS attacks of this scale.&lt;/p>
&lt;p>So what makes this attack so different as to merit it&amp;rsquo;s own class? Well 3 things.&lt;/p></description></item><item><title>Technology saves lives, but it isn't perfect</title><link>https://keithrozario.com/2016/07/technology-saves-lives-but-it-kills-too/</link><pubDate>Sat, 02 Jul 2016 18:07:38 +0000</pubDate><guid>https://keithrozario.com/2016/07/technology-saves-lives-but-it-kills-too/</guid><description>&lt;p>What do you do when the technology turns on you?&lt;/p>
&lt;p>Or when the feature that&amp;rsquo;s built to save you, is the one that might just kill you?&lt;/p>
&lt;p>There&amp;rsquo;s a stark similarity between the Takata airbag fiasco, that&amp;rsquo;s already taken 2 Malaysian lives, and the lady who died in self-driving Tesla.&lt;/p>
&lt;p>Both involve the auto-industry and both are technology related, but together they represent a much deeper issue at hand&amp;ndash;despite our noblest expectations, technology isn&amp;rsquo;t perfect&amp;ndash;but it&amp;rsquo;s better than we had before.&lt;/p>
&lt;p>We&amp;rsquo;ve all been trained by Hollywood to expect perfect technology, working all the time and in every scenario, but in reality technology sometimes fails, and newer technology fails more often.&lt;/p>
&lt;p>Technology endures through failures, only by our good graces, but unless we grant that grace to it, we will not progress.&lt;/p>
&lt;p>What should our response to a technical failure be?&lt;/p>
&lt;p>Do we insist on removing ALL traces of the offending technology, or do we accept it as a price of progress, that the occasional failure is a tax we pay to get better technology.&lt;/p>
&lt;p>But are some taxes just too high?&lt;/p>
&lt;p>Society might accept &lt;a href="http://www.cultofmac.com/224579/antennagate-is-finally-over-good-riddance/">failing antennas on an iPhone&lt;/a>, or even &lt;a href="http://searchengineland.com/george-bush-knowledge-graph-miserable-failure-163009">bad Google searches&lt;/a>, but an air-bag, that might blow a hole in your chest or a car that might crash you into a truck, might be too high of a price.&lt;/p>
&lt;p>So is the tax for air-bags and self-driving cars just not worth the potential safety we get in return?&lt;/p></description></item></channel></rss>