<?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 Mani Sarkar on Medium]]></title>
        <description><![CDATA[Stories by Mani Sarkar on Medium]]></description>
        <link>https://medium.com/@neomatrix369?source=rss-6e56fdbd9c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8t2uhxPY54Lh97xAGGd7rQ.jpeg</url>
            <title>Stories by Mani Sarkar on Medium</title>
            <link>https://medium.com/@neomatrix369?source=rss-6e56fdbd9c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:19:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@neomatrix369/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[AI Coding Tools (MCP-series)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://neomatrix369.medium.com/ai-coding-tools-mcp-series-cdee7f552e36?source=rss-6e56fdbd9c6------2"><img src="https://cdn-images-1.medium.com/max/1000/0*7rmtX6L2W8neAdVR.png" width="1000"></a></p><p class="medium-feed-snippet">AI-assisted development, code assistants, and intelligent developer tools</p><p class="medium-feed-link"><a href="https://neomatrix369.medium.com/ai-coding-tools-mcp-series-cdee7f552e36?source=rss-6e56fdbd9c6------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://neomatrix369.medium.com/ai-coding-tools-mcp-series-cdee7f552e36?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdee7f552e36</guid>
            <category><![CDATA[ai-tools]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mcps]]></category>
            <category><![CDATA[cursor]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Thu, 09 Oct 2025 13:16:45 GMT</pubDate>
            <atom:updated>2025-10-09T13:16:45.623Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Another Two Years In The Life Of AI, ML, DL And Java]]></title>
            <link>https://neomatrix369.medium.com/another-two-years-in-the-life-of-ai-ml-dl-and-java-14dc8df169c9?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/14dc8df169c9</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Mon, 28 Dec 2020 13:47:03 GMT</pubDate>
            <atom:updated>2020-12-28T13:47:03.219Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*4C688DiD-iybu-iS" /><figcaption><em>selective focus photo of hourglass on stones: </em><a href="https://unsplash.com/photos/BXOXnQ26B7o"><em>https://unsplash.com/photos/BXOXnQ26B7o</em></a></figcaption></figure><h3><strong><em>This is a reblog of the original post at </em></strong><a href="https://www.javaadvent.com/"><strong><em>Java Advent Calendar 2020</em></strong></a><strong><em>, see </em></strong><a href="https://www.javaadvent.com/2020/12/another-two-years-in-the-life-of-ai-ml-dl-and-java.html"><strong><em>original post</em></strong></a><strong><em>.</em></strong></h3><h3>A bit of a background</h3><p>Many of you know of my first post on this topic <a href="https://dev.to/neomatrix369/two-years-in-the-life-of-ai-ml-dl-and-java--nni"><strong><em>Two years in the life of AI, ML, DL and Java</em></strong></a>that was back in 2018/2019 when I had just started with my journey which still continues but I have more to share in this update (and I hope you will like it). At that time we had a good number of resources and the divide between <strong>Java</strong> and non-<strong>Java</strong> related resources were not so to have discussions about — since then things have changed, let’s see what the landscape looks like.</p><p>I’m hoping that I’m able to share richer aspects of my journey, views, opinions, observations and learnings this time around as compared to <a href="https://dev.to/neomatrix369/two-years-in-the-life-of-ai-ml-dl-and-java--nni">my previous summary post</a>.</p><p>I do admit that this is only a summary post and I intend to write more specific and focussed posts like the ones I did in 2019 (see the following section) — I have earmarked a couple of topics and I will flesh them out as soon as I’m happy with my selections.</p><h3>2019: year of blogs</h3><p>Looking at my activities in 2019 towards 2020, I can say I was more focussed on writing blogs and creating a lot of hands-on solution which I shared via my projects on GitHub and blogs on Medium. Here is a list of all of them:</p><ul><li>August 2019: <a href="https://medium.com/oracledevs/how-to-build-graal-enabled-jdk8-on-circleci-3e20ae07a5d3?sk=85ddf84d1c444a224f9ec12bdcb03034"><strong>How to build Graal-enabled JDK8 on CircleCI?</strong></a></li><li>August 2019: <a href="https://towardsdatascience.com/how-to-do-deep-learning-for-java-on-the-valohai-platform-eec8ba9f71d8?sk=6b81209d56de2b5bf45aa2b3367b0a1f"><strong>How to do Deep Learning for Java?</strong></a></li><li>September 2019: <a href="https://medium.com/oracledevs/running-your-jupyter-notebooks-on-the-cloud-ed970326649f?sk=d064432ccc14576f9156096b333d7647"><strong>Running your JuPyTeR notebooks on the cloud</strong></a></li><li>October 2019: <a href="https://medium.com/oracledevs/running-apache-zeppelin-on-oracle-cloud-infrastructure-b0aecc79597a?sk=d531a8cf4ca5b2d345e529805d676975"><strong>Running Apache Zeppelin on the cloud</strong></a></li><li>November 2019: <a href="https://towardsdatascience.com/applying-nlp-in-java-all-from-the-command-line-1225dd591e80?sk=4dabee3fbeaee3633c3065becca8e2a6"><strong>Applying NLP in Java, all from the command-line</strong></a></li><li>November 2019: <a href="https://towardsdatascience.com/exploring-nlp-concepts-using-apache-opennlp-4d59c3cac8?sk=a0495c3b93fa8a67b12747e6ac975db1"><strong>Exploring NLP concepts using Apache OpenNLP</strong></a></li><li>December 2019: <a href="https://towardsdatascience.com/exploring-nlp-concepts-using-apache-opennlp-inside-a-jupyter-notebook-e53489ba2bd8?sk=3f0925d458e73193a5fab445d2c14bdf"><strong>Exploring NLP concepts using Apache OpenNLP inside a Java-enabled Jupyter notebook</strong></a></li></ul><h3>2020: year of presentations</h3><p>Similarly in 2020, from a blogging point-of-view I didn’t write much, this officially my first proper post of the year (with the exception of one in August 2020, which you will find below) — I was quite busy with preparing for talks and presentations and online meetings and discussions. I kicked off the year with my talk at the <a href="https://www.grakncosmos.com/">Grakn Cosmos 2020</a> conference in London, UK. So let me list them here so you can take a look at them in your own time:</p><ul><li>February 2020: <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/data/04-grakn-cosmos-2020">Naturally, getting productive, my journey with Grakn and Graql</a> at <strong>Grakn Cosmos 2020</strong> conference</li><li>July 2020: <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/awesome-ai-ml-dl/01-jonconf-2020">“nn”</a> <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/awesome-ai-ml-dl/01-jonconf-2020">things every Java Developer should know about AI/ML/DL</a> at <strong>JOnConf 2020</strong> conference</li><li>August 2020: <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/awesome-ai-ml-dl/02-abhishektalks-2020">From backend development to machine learning</a> on <strong>Abhishek Talks(YouTube</strong> <strong>channel)</strong> meetup</li><li><em>August 2020:</em> <a href="https://medium.com/@neomatrix369/an-interview-by-neural-magic-machine-learning-engineer-spotlight-e9be4ea61f8?source=friends_link&amp;sk=42b6b4dc15ebef567fe8341ba7c541ba"><strong><em>An Interview by Neural Magic: Machine Learning Engineer Spotlight</em></strong></a><em>(blog</em> <em>post)</em></li><li>October 2020: <a href="https://github.com/neomatrix369/nlp_profiler/tree/master/presentations/01-nlp-zurich-2020">Profiling Text Data</a> at the NLP Zurich meetup</li><li>October 2020: <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/awesome-ai-ml-dl/03-makeitweek-2020">Tribuo: an introduction to a Java ML Library</a> at <strong>MakeITWeek 2020</strong> conference</li><li>October 2020: <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/awesome-ai-ml-dl/04-gba-apac-tour-2020">“nn”</a> <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/presentations/awesome-ai-ml-dl/04-gba-apac-tour-2020">things every Java Developer should know about AI/ML/DL</a> at <strong>Oracle Groundbreakers Tour — APAC 2020</strong> conference</li></ul><p>You can find slides (and videos of some) of the above presentations under the links provided.</p><h3>Other achievements and activities this year</h3><p>As to my journey, I have also been involved a good part of this year learning by online AI/ML competitions, see <a href="https://twitter.com/theNeomatrix369/status/1214601525856747520">this</a> and <a href="https://mobile.twitter.com/theNeomatrix369/status/1265411110473252866">this</a> post shared to learn more. You can also find all of my <a href="https://www.kaggle.com/neomatrix369/datasets">datasets</a> and <a href="https://www.kaggle.com/neomatrix369/notebooks">notebooks</a> for further study. Also the launch of an <strong>Python</strong>-based NLP Library called <a href="https://github.com/neomatrix369/nlp_profiler">NLP Profiler</a> was another important feat for me this year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*u3YxcJ_1-19z0_j6.png" /></figure><h3>What’s happening in this space?</h3><p>There is a lot of hype happening in the space and as <a href="https://twitter.com/suyashcjoshi"><strong>Suyash Joshi</strong></a> rightly said during a conversation sometime back: <em>“It’s</em> <em>easy to get sucked into hype and shiny new stuff I fell a lot for that and then get overwhelmed“.</em> And I think you will agree with me that we can relate to this situation. Also many of the things we are seeing look nice, and shiny but may NOT be fully ready for the real-world yet, I did cover similar arguments in a<a href="https://medium.com/@neomatrix369/an-interview-by-neural-magic-machine-learning-engineer-spotlight-e9be4ea61f8?source=friends_link&amp;sk=42b6b4dc15ebef567fe8341ba7c541ba"> <em>post in August</em></a>.</p><p>There are few entities who are openly claiming various things about the not-so-bright-sides of AI, they are things like:</p><ul><li><em>the statistical methods used are from the last century and may not be suited to modern day data(led</em> <em>by</em> <a href="https://www.amazon.co.uk/s?k=nassim+taleb&amp;dc&amp;ref=a9_sc_1"><em>Nassim Taleb’</em></a><em>s school of thought)</em></li><li><em>many modern-day open-source tools and industry methods to derive at solutions are broken or inadequate</em></li><li><em>we are not able to explain our predictions and findings(blackbox</em> <em>issue: explainability and interpretability)</em></li><li><em>our AI solutions lack causality, intent and reasoning</em> (similar to the previous point)</li></ul><p>These come from individuals, groups and companies who are building their own solutions (mostly closed-source) as they have noticed the above drawbacks and doing things to overcome them but also making the rest of the world aware of it.</p><h3>Where is Java on the map?</h3><p>Java has been contributing to the AI force since sometime now, all the way when there was a lot of talk during the Big Data buzz, which then transformed to the new buzz about AI, Machine Learning and Deep Learning. If we closely look at the categories and sub-categories of resources here:</p><ul><li><a href="https://spark.apache.org/">Apache Spark</a> <a href="https://www.nvidia.com/en-us/deep-learning-ai/solutions/data-science/apache-spark-3/"><em>[1]</em></a> <em>|</em><a href="https://blogs.oracle.com/graalvm/apache-spark%e2%80%94lightning-fast-on-graalvm-enterprise"><em>[2]</em></a></li><li><a href="http://hadoop.apache.org/">Apache Hadoop</a></li><li><a href="https://github.com/eclipse/deeplearning4j">Deeplearning4J</a></li><li>and many other such tools, libraries, frameworks, and products</li></ul><p>and now more recently</p><ul><li><a href="https://github.com/NVIDIA/grcuda">grCuda</a> and <a href="https://github.com/graalvm/graalpython">graalPython</a> (from the folks at <a href="https://labs.oracle.com/pls/apex/f?p=94065:INTRO::::::">Oracle Labs</a> behind all the <a href="http://graalvm.org/"><strong>GraalVM</strong></a> <em>magic</em>)</li><li><a href="https://www.deepnetts.com/">DeepNetts</a></li><li><a href="https://tribuo.org/">Tribuo</a></li></ul><p>and more under these resources</p><ul><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/details/java-jvm.md">Java: AI/ML/DL</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/natural-language-processing/java-jvm.md">NLP Java</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/details/java-jvm.md#tools--libraries-other-resources">Tools and libraries(Java/JVM)</a></li><li>some intriguing <strong>GitHub</strong> resources: <a href="https://github.com/search?q=java+ai&amp;type=repositories">AI</a> or <a href="https://github.com/search?q=java+artificial+intelligence&amp;type=repositories">Artificial Intelligence</a> | <a href="https://github.com/search?q=java+ML&amp;type=repositories">ML</a> or <a href="https://github.com/search?q=java+Machine+Learning&amp;type=repositories">Machine Learning</a> | <a href="https://github.com/search?q=java+DL&amp;type=repositories">DL</a> or <a href="https://github.com/search?q=java+Deep+Learning&amp;type=repositories">Deep Learning</a> | <a href="https://github.com/search?q=java+RL&amp;type=repositories">RL</a> or <a href="https://github.com/search?q=java+reinforcement+learning&amp;type=repositories">Reinforcement Learning</a> | <a href="https://github.com/search?q=java+NLP&amp;type=repositories">NLP</a> or <a href="https://github.com/search?q=java+Natural+Language+Processing&amp;type=repositories">Natural Language Processing</a></li></ul><p><a href="https://www.nvidia.com/en-us/deep-learning-ai/solutions/data-science/apache-spark-3/"><em>[1] Nvidia and Apache Spark</em></a></p><p><a href="https://blogs.oracle.com/graalvm/apache-spark%e2%80%94lightning-fast-on-graalvm-enterprise"><em>[2] Oracle Labs and Apache Spark</em></a></p><p>You can already see various implementations using Java and other JVM languages — they have just not been noticed by us, unless we made an attempt to look for them.</p><p>If you have been following the progress of <a href="https://graalvm.org/">GraalVM and Truffle</a> (see <a href="https://github.com/oracle/graal">GitHub</a>) in this space boosting server-side, desktop and cloud-base systems in terms of performance, ergonomic footprint and language interop — then you will, just like me also see that <strong>Java</strong>’s presence and position is growing from strength-to-strength in this space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*a33HBfF6ZqZM0oec.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*NWCH8vcqsiwoSJQY.png" /></figure><p><em>(</em><strong><em>grCuda</em></strong> <em>and</em> <strong><em>graalPython</em></strong> <em>are two such examples: see AI/ML/DL related resources on</em> <a href="https://github.com/neomatrix369/awesome-graal"><em>Awesome Graal</em></a> <em>and also at the appendix sections of the talk slides for more resources — see section above for talks)</em></p><h3>Some highlights in pictures</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*YPtmwnld85dBhCBT.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/0*PPruGzOXD-i-pHRq.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/0*0ZnBB7m33Ks6B-P2.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*Sg5Q_a4ayqBB3YgE.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*2m__L2dgZk4GvoFX.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*PzzJnyqiwe-ZrmVd.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*vtV1-_FEsDxYQxNH.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*0C5VFAJYn44t3G_F.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*9Uf3jUse0UHTu7vz.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*RVyAoFT-kzbszUhX.png" /></figure><h3>Recommended Resources</h3><p>If I had to go through many of the resources I have shared in this post so far, of all of them I would look at these topics (in no particular order and also not an exhaustive list, it’s still a lot of topics to learn and know about):</p><p><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/details/maths-stats-probability.md#bayesian">Bayesian</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/Python-Performance.md">Performance in Python</a> | <a href="https://madewithml.com/">Made With ML</a> | <a href="https://virgili0.github.io/Virgilio/">Virgilio</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/details/visualisation.md#visualisation"><strong>Visualisation</strong></a> | <a href="https://tvm.apache.org/docs/index.html"><strong>TVM: Compiler stack for CPUs, GPUs, etc…</strong></a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/data/README.md#hyperparameter-tuning">Hyperparameter tuning</a> | <a href="https://www.kaggle.com/neomatrix369/normalising-a-distribution">Normalising (and Standardising) a distribution</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/things-to-know.md">Things to Know</a> | <a href="https://github.com/NVIDIA/grcuda"><strong>grCuda</strong></a> | <a href="https://www.scailable.net/"><strong>Running compiled and optimised AI Models in the Cloud</strong></a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/cloud-devops-infra/about-neural-magic.md">Neural Magic: Model Pruning and Sparsification</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/tribuo#native-image-build-optional"><strong>Train and Infer models via a native-image</strong></a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/details/julia-python-and-r.md#genetic-algorithms">Genetic Algorithms by Eyal</a> | <a href="https://www.deepnetts.com/">DeepNetts: Deep Learning in Java by Zoran</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/natural-language-processing#natural-language-processing-nlp"><strong>NLP</strong></a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/natural-language-processing/java-jvm.md#javajvm">NLP with Java</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/README-details.md#graphs">Graphs</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/ML-on-code-programming-source-code.md">ML on Code/Program/Source Code</a> | <a href="https://tribuo.org/"><strong>Tribuo: A java-base ML library</strong></a>|<a href="https://github.com/neomatrix369/chatbot-conversations">Chatbots talking to each other</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/details/julia-python-and-r.md#testing"><strong>Testing</strong></a></p><p>My apologies as <a href="https://www.lifewire.com/what-is-ymmv-2483722"><strong><em>YMMV</em></strong></a> — I’m working on these topics and slowly gaining knowledge and experience and hence my urge to immediately share them with the rest of the community. I’ll admit few of these may be still <em>Work in Progress</em> — but I hope we can all learn these together. I’ll share more as I make more progress with them during the course of the days, weeks and months into 2021.</p><h3>Conclusions</h3><p>We are in a heterogenous space and AI/ML/DL ideas and innovations from creation to deployment go through various forms and shapes and depending on the comfort-zones and end-use cases of the ideas and innovations get implemented using multitudes of technologies. It won’t be correct or fair to say only one technology is being used.</p><p>We are seeing R&amp;D, rapid prototyping, MVP, PoC and the likes are being done using languages like <strong>Python</strong>, <strong>R</strong>, <strong>Matlab</strong>, <strong>Julia</strong> and the likes while when it comes to robust, reliable, scalable, production-ready solutions more serious contenders are chosen for encapsulating the original work. And <strong>Java</strong> and other <strong>JVM</strong> languages, and the likes that can provide such stability are often being considered both for desktop and cloud implementations.</p><p><strong>Wearing my Oracle Groundbreaker Ambassador hat</strong><em>: I recommend taking advantage of the</em> <a href="https://www.oracle.com/cloud/free/"><strong><em>Free cloud credits from Oracle</em></strong></a><em>(also see</em> <a href="https://dev.to/phocks/how-to-get-2x-oracle-cloud-servers-free-forever-4o22"><strong><em>this post</em></strong></a><em>) — the VMs are super fast and easy to setup(see my posts above).</em></p><h3>What next?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*4lZlUxJjiOSur0u5" /></figure><p><em>The journey continues, the road may be long, but it’s full of learnings — that certainly helps us grow. Many times we learn at the turning points while the milestones keep changing. Let’s continue learning and improving ourselves.</em></p><p>Please do feedback if you are curious to explore deeper aspects of what you read above, as you may understand the topic is wide and deep and one post cannot do full justice to such rich topics (plus many of them are moving targets).</p><p><strong><em>This is a reblog of the original post at </em></strong><a href="https://www.javaadvent.com/"><strong><em>Java Advent Calendar 2020</em></strong></a><strong><em>, see </em></strong><a href="https://www.javaadvent.com/2020/12/another-two-years-in-the-life-of-ai-ml-dl-and-java.html"><strong><em>original post</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14dc8df169c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Interview by Neural Magic: Machine Learning Engineer Spotlight]]></title>
            <link>https://medium.com/swlh/an-interview-by-neural-magic-machine-learning-engineer-spotlight-e9be4ea61f8?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9be4ea61f8</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Sun, 01 Nov 2020 09:19:24 GMT</pubDate>
            <atom:updated>2020-11-01T21:19:01.049Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*UQb0MvjfzPhanyNJ" /><figcaption><a href="https://unsplash.com/photos/lBs7NrB2Cu8">Image source</a> by <a href="https://unsplash.com/@martinpechy">Martin Pechy</a></figcaption></figure><p>— -<br><strong><em>This is a reblog of the original post at </em></strong><a href="https://neuralmagic.com/blog/machine-learning-engineer-spotlight-mani-sarkar/"><strong><em>https://neuralmagic.com/blog/machine-learning-engineer-spotlight-mani-sarkar/</em></strong></a><strong><em> by </em></strong><a href="https://neuralmagic.com/"><strong><em>Neural Magic</em></strong></a><br> — -</p><p>In our new blog series, we’re interviewing data scientists and machine learning engineers about their career paths, areas of interest and thoughts on the future of AI. We kick off this week with a 20-year veteran and jack-of-all-trades when it comes to machine learning and data science: <a href="https://www.linkedin.com/in/mani-sarkar/?originalSubdomain=uk">Mani Sarkar</a>. Mani is a strategic machine learning engineer based in London, UK, who believes in getting beyond the theoretical and applying AI to real-world problems.</p><p>Below is our interview, lightly edited for clarity.</p><h4>Tell us more about how you got into machine learning.</h4><p>I started my career as a software developer, writing desktop, web-based applications and command-line tools. The best thing about being a developer is learning new things. I’ve always been interested in data, numbers and math. In the last few years, I got more serious about it.</p><p>After 20 years of working as a permanent employee, I decided to take charge of my career as a freelancer. I help companies develop proof-of-concept or minimum viable products to secure funding or go to market quickly. I focus on improving performance or the speed of the software development process. My motto is, “Strengthening teams and helping them accelerate!”</p><p>There are really no boundaries to what I’m asked to do, so learning data science became a major priority for me. One client inspired me to delve into this subject more. The company wrote bots that could read and write computer code. The bot provides recommendations on how to improve your code as a developer. As someone who’s interested in software quality, it pushed me to pursue practical machine learning and data science projects.</p><h4>What are you most excited about in the work you are doing these days?</h4><p>I take a top-down approach to machine learning where I focus on the business problem, as opposed to many others who take a bottom-up approach. I can count on my fingers the entities taking a top-down approach. My philosophy of learning and implementing matches greatly with theirs. Creating programs, content, guides and everything else using this principle is very exciting. Machine learning is an ever-changing and hard-to-grasp field, so it is important to help business users contextualize technical projects.</p><p>Autonomy and creativity is a great part of what I do. When I’m free to be creative, I’m able to get the best results for the end-user, the customer or even the community (when I’m working on open source projects).</p><h4>What is the coolest machine learning problem you have worked toward solving?</h4><p>Natural language processing (NLP) is a widespread field with many new innovations and advancements. Despite that, at a very basic level, there are no comprehensive tools to analyze tabular text data. There are a lot of fragmented tools and utilities available, but many of them are not open-sourced or widely shared. So, we all end up building our own little solutions to analyze text datasets. Each one of us might do it differently and get a different response.</p><p>While preparing for a talk last month, I wrote a simple utility called <a href="https://www.kaggle.com/general/166954">NLP Profiler</a> in under three hours, which is now going to be part of the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/better-nlp">Better NLP</a> library. When given a dataset and a column name with text data, <a href="https://www.kaggle.com/general/166954">NLP Profiler</a> will return either high-level insights about the text or low-level/granular statistical information about the same text. Think of it as using the <em>pandas.describe()</em> function or running <strong>Pandas Profiling</strong> on your data frame, but for datasets containing text columns rather than columnar datasets (tabular or spreadsheet-like data where each column may be a different data type like string, numeric, date, etc. This includes most kinds of data commonly stored in a relational database or tab or .csv files)</p><p>I have used it on a few datasets and it has shown some interesting information. High-level information would include things like sentiment analysis, subjectivity/objectivity analysis, grammar or spelling quality check, etc. Low-level details could include the number of words in the sentence, the number of emojis in the text, etc. <a href="https://www.kaggle.com/general/166954">NLP Profiler</a> can do this analysis using a single line of code. Above all, it can be extended and shared openly with others. This opens a new world of machine learning on text data and can help any NLP engineer or practitioner.</p><h4>How do you predict machine learning will evolve over the next decade?</h4><p>Automation will play a big role. Even though there will be big challenges — like privacy, ethics, bias, and more — there will be ways around it using a combination of automation and human intervention. Machine learning will evolve as a human-in-the-loop or AI will assist humans to do everything from collecting data to training models, to analyzing models.</p><p>I predict that there are three different pathways that may occur in parallel:</p><p>- <strong>Fully/partially AI-driven systems: </strong>Many of these error-prone systems have been attempted, and I imagine there will be even more failures to learn from in the future.<br>- <strong>AI assisting humans: </strong>Rather than AI taking people’s jobs, AI will augment mundane tasks. This will create a cascade of new industries, just like the advent of PCs in the 80s and 90s created countless fulfilling careers.<br>- <strong>Humans doing tasks AI cannot do fully or partially: </strong>AI still isn’t good at some tasks humans excel at, which will remain the case for some time.</p><p>Since NLP is an area in which I’m particularly interested, I imagine in the future we may see a smart dialogue system with memory and ability to detect context. We’ve already come a long way from the 1960s MIT NLP program, <a href="https://en.wikipedia.org/wiki/ELIZA">ELIZA</a>. I created a conversational chatbot demo and video based on the logic used to build ELIZA, which people can play with <a href="https://github.com/neomatrix369/chatbot-conversations">on my Github</a><a href="https://github.com/neomatrix369/chatbot-conversations).&amp;nbsp">.</a></p><h4>What is the most interesting application of machine learning you have seen out there?</h4><p>I was recently at an online meetup where a small startup called PolyAI <a href="https://www.facebook.com/nathan.benaich/videos/10100448047785480">gave a demo</a> of an interactive chatbot app that would take a phone call and make a reservation from any caller. It was used to demonstrate how a person could book a restaurant table via the app. It was amazing to see how the chatbot picked up many of the nuances in the caller’s language or style of speaking (even the accent) that only experienced professionals could have responded to. The accuracy at which the information was delivered to the user was impressive. Even though the caller was a bit unfamiliar with the fact that they were talking to a chatbot and not a human, they could get their points across and were pleasantly surprised.</p><p>Another demo I recently experienced was a technical open-source application called <a href="https://pycaret.org/">PyCaret</a>, where the whole process of creating a machine learning model was automated or made available with only a few lines of code in Python. The tool made all kinds of analysis and generated metrics and logs that could be assessed to make further decisions. It even had a way to perform post-model creation analysis using <strong>SHAPLY</strong>.</p><h4>What do you see as the biggest challenges in machine learning and AI right now?</h4><p>Ethics and privacy are big challenges, which we are all aware of. However, we have not developed General AI yet (or if it’s available, we don’t see it in the mainstream) where these concerns would become more severe.</p><p>Specialization in different domains is still a challenge. There’s still a lot of work to be done to master practical applications of AI. Smaller subsets of different domain expertise need to come together to become generally useful to the population.</p><p>On the NLP front, machine understanding of various languages and dialects will continue to remain an issue, even though not for long. The accuracy of general NLP systems’ results still needs work before we can accept them in the mainstream for domestic or industrial use. That said, many industries have achieved success creating solutions for specific needs (under controlled environments).</p><p>The other challenge will be the ability to weave society and these AI creations. With certain inventions and innovations, challenges lie in the lack of knowledge around these systems. Specific areas of concern could include algorithms for crime and law enforcement, or health and safety. Authenticity and the rise of “deep fakes” will continue to be a challenge for some time.</p><p>Finally, energy consumption within data centres that specialize in AI/machine learning tasks are having negative consequences on the environment. That’s a global problem that needs to be solved.</p><h4>If you could change one thing about the public perception of machine learning and AI, what would it be?</h4><p>The biggest perception to change is that AI is not here to take away our jobs or make lives difficult. When augmented with our skills and knowledge, it can assist us in our regular life and work processes. Contrary to what the entertainment industry might have you believe, AI can’t “think” like us independently. We haven’t reached that stage where we can say we have built an electronic or digital consciousness around us. We may think we are going to be able to build one in the distant future, but that’s a discussion for another time.</p><p>— -<br><strong><em>This is a reblog of the original post at </em></strong><a href="https://neuralmagic.com/blog/machine-learning-engineer-spotlight-mani-sarkar/"><strong><em>https://neuralmagic.com/blog/machine-learning-engineer-spotlight-mani-sarkar/</em></strong></a><strong><em> by </em></strong><a href="https://neuralmagic.com/"><strong><em>Neural Magic</em></strong></a></p><p>— -</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9be4ea61f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/an-interview-by-neural-magic-machine-learning-engineer-spotlight-e9be4ea61f8">An Interview by Neural Magic: Machine Learning Engineer Spotlight</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring NLP concepts using Apache OpenNLP inside a Jupyter notebook]]></title>
            <link>https://medium.com/data-science/exploring-nlp-concepts-using-apache-opennlp-inside-a-jupyter-notebook-e53489ba2bd8?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e53489ba2bd8</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Tue, 03 Dec 2019 07:58:05 GMT</pubDate>
            <atom:updated>2020-11-01T22:07:28.213Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring NLP concepts using Apache OpenNLP inside a Java-enabled Jupyter notebook</h3><h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*lgmRK-fbf83PG-7L.jpg" /><figcaption><a href="https://unsplash.com/photos/gEta6dbzFy0">Image source</a> (unsplash) via <a href="https://unsplash.com/@danesduet">Daniel Olah</a></figcaption></figure><p>I have been exploring and playing around with the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> library after a bit of convincing. For those who are not aware of it, it’s an <a href="https://apache.org/">Apache</a> project, supporters of F/OSS Java projects for the last two decades or so (see <a href="https://en.wikipedia.org/wiki/The_Apache_Software_Foundation">Wikipedia</a>). I found their command-line interface pretty simple to use and it is a great learning tool for learning and trying to understand <a href="https://en.wikipedia.org/wiki/Natural_language_processing">Natural Language Processing (NLP)</a>. Independent of this post, you can find <a href="https://blog.valohai.com/nlp_with_dl4j_in_java_all_from_the_command-line">another perspective on exploring NLP concepts</a> using <a href="https://opennlp.apache.org/">Apache OpenNLP</a>, all of this directly from the realms of your command-prompt.</p><p>I can say almost everyone in this space is also aware and familiar with <a href="https://jupyter.org/">Jupyter Notebooks</a> (in case you are not, have a look at this <a href="https://www.youtube.com/watch?v=HW29067qVWk">video</a> or <a href="http://www.geomarvel.com/2019/09/03/getting-started-with-jupyter-notebooks/">[1]</a> or <a href="https://www.dataquest.io/blog/jupyter-notebook-tutorial/">[2]</a>). Here onwards we will be doing the same things you have been doing with your own experiments from within the realms of the notebook.</p><h3>Exploring NLP using Apache OpenNLP</h3><h3>Command-line Interface</h3><p>I’ll refer you to <a href="https://medium.com/@neomatrix369/exploring-nlp-concepts-using-apache-opennlp-4d59c3cac8?source=---------2------------------&amp;gi=2aabe5762998">the post</a> where we cover the command-line experience with <a href="https://opennlp.apache.org/">Apache OpenNLP</a>, and it’s a great way to familiarise yourself with this NLP library.</p><h3>Jupyter Notebook: Getting started</h3><p>Do the following before proceeding any further:</p><pre>$ git clone git@github.com:neomatrix369/nlp-java-jvm-example.git</pre><pre>or</pre><pre>$ git clone https://github.com/neomatrix369/nlp-java-jvm-example.git</pre><pre>$ cd nlp-java-jvm-example</pre><p><em>And then</em> <em>see </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#getting-started"><em>Getting started</em></a><em> section in the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#exploring-nlp-concepts-from-inside-a-java-based-jupyter-notebook"><em>Exploring NLP concepts from inside a Java-based Jupyter notebook</em></a><em> part of the README before proceeding further.</em></p><p>Also, we have chosen the JDK to be <a href="https://graalvm.org/">GraalVM</a> by default, you can see this from these lines in the console messages:</p><pre>&lt;---snipped--&gt;</pre><pre>JDK_TO_USE=GRAALVM</pre><pre>openjdk version &quot;11.0.5&quot; 2019-10-15</pre><pre>OpenJDK Runtime Environment (build 11.0.5+10-jvmci-19.3-b05-LTS)</pre><pre>OpenJDK 64-Bit GraalVM CE 19.3.0 (build 11.0.5+10-jvmci-19.3-b05-LTS, mixed mode, sharing)</pre><pre>&lt;---snipped--&gt;</pre><p><strong><em>Note</em></strong><em>: a </em><a href="https://hub.docker.com/r/neomatrix369/nlp-java"><em>docker image</em></a><em> has been provided to be able to run a docker container that would contain all the tools you need. You can see the shared folder has been created which is linked to the volume mounted into your container, mapping your the folder from the local machine. So anything created or downloaded into the shared folder will be available even after you exit your container!</em></p><p>Have a quick read of the main <a href="https://github.com/neomatrix369/nlp-java-jvm-example#nlp-javajvm-">README</a> file to get an idea of how to go about using the <a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/docker-runner.sh">docker-runner.sh shell script</a>, and take a quick glance at the <a href="https://github.com/neomatrix369/nlp-java-jvm-example#usage">Usage section</a> of the <a href="https://github.com/neomatrix369/nlp-java-jvm-example/tree/master/images/java/opennlp#scripts-provided">scripts</a> as well<strong>.</strong></p><h3>Running the Jupyter notebook container</h3><p><em>See </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#running-the-jupyter-notebook-container"><em>Running the Jupyter notebook container</em></a><em> section in the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#exploring-nlp-concepts-from-inside-a-java-based-jupyter-notebook"><em>Exploring NLP concepts from inside a Java-based Jupyter notebook</em></a><em> part of the README before proceeding further.</em></p><p>All you need to do is run this command after cloning the repo mentioned in the links above:</p><pre>$ ./docker-runner.sh --notebookMode --runContainer</pre><p>Once you have the above running, the action will automatically open load the Jupyter notebook interface for you into a browser window. You will have a couple of Java notebooks to choose from (placed in the shared/notebooks folder on your local machine):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-7ioNONeUiWcWoyT.png" /></figure><h3>Installing Apache OpenNLP in the container</h3><p>When inside the container in the notebook mode, you have two approaches to install <a href="https://opennlp.apache.org/">Apache OpenNLP</a>:</p><ul><li><strong>From the command-line interface (optional)</strong></li><li><em>See </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#from-the-command-line-interface"><em>From the command-line interface</em></a><em> sub-section under the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#installing-apache-opennlp-in-the-container"><em>Installing Apache OpenNLP in the container</em></a><em> section in the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#exploring-nlp-concepts-from-inside-a-java-based-jupyter-notebook"><em>Exploring NLP concepts from inside a Java-based Jupyter notebook</em></a><em> part of the README before proceeding further.</em></li><li><strong>From inside the Jupyter notebook (recommended)</strong></li><li><em>See </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#from-inside-the-jupyter-notebook"><em>From inside the Jupyter notebook</em></a><em> sub-section under the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#installing-apache-opennlp-in-the-container"><em>Installing Apache OpenNLP in the container</em></a><em> section in the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#exploring-nlp-concepts-from-inside-a-java-based-jupyter-notebook"><em>Exploring NLP concepts from inside a Java-based Jupyter notebook</em></a><em> part of the README before proceeding further.</em></li></ul><h3>Viewing and accessing the shared folder</h3><p><em>See </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#viewing-and-accessing-the-shared-folder"><em>Viewing and accessing the shared folder</em></a><em> section in the </em><a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/images/java/opennlp/README-exploring-nlp-java-jupyter-notebook.md#exploring-nlp-concepts-from-inside-a-java-based-jupyter-notebook"><em>Exploring NLP concepts from inside a Java-based Jupyter notebook</em></a><em> part of the README before proceeding further.</em></p><p>This will also be covered in a small way via the Jupyter notebooks in the following section. You can see directory contents via the %system <a href="https://github.com/SpencerPark/IJava/blob/master/docs/magics.md">Java cell magic</a> and then from the command prompt a similar files/folders layout.</p><h3>Performing NLP actions in a Jupyter notebook</h3><p>While you have the notebook server running you will see this launcher window with a list of notebooks and other supporting files show up as soon as the notebook server launches:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pYMZlFJkkCpW8diZ.png" /></figure><p>Each of the notebooks above has a purpose, <a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/shared/notebooks/MyFirstJupyterNLPJavaNotebook.ipynb">MyFirstJupyterNLPJavaNotebook.ipynb</a> shows how to write Java in a IPython notebook and perform NLP actions using Java code snippets that invoke the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> library functionalities (see <a href="https://opennlp.apache.org/docs/1.9.1/apidocs/opennlp-tools/index.html">docs for more details on the classes and methods</a> and also the <a href="https://opennlp.apache.org/docs/1.9.1/apidocs/opennlp-tools/index.html">Java Docs for more details on the Java API usages</a>).</p><p>The other notebook <a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/shared/notebooks/MyNextJupyterNLPJavaNotebook.ipynb">MyNextJupyterNLPJavaNotebook.ipynb</a> runs the same Java code snippets on a remote cloud instance (with the help of the <a href="https://docs.valohai.com/valohai-cli/index.html">Valohai CLI</a> client) and returns the results in the cells, with just single commands. It’s fast and free to <a href="https://app.valohai.com/accounts/signup/">create an account</a> and use within the<a href="https://valohai.com/pricing/"> free-tier plan</a>.</p><p>We are able to examine the below Java API bindings to the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> library from inside both the Java-based notebooks:</p><ul><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.langdetect.classifying.api">Language Detector API</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.sentdetect.detection.api">Sentence Detection API</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.tokenizer.api">Tokenizer API</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.namefind.recognition.api">Name Finder API</a> (including other examples)</li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.postagger.tagging.api">Parts of speech (POS) Tagger API</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.parser.chunking.api">Chunking API</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html#tools.parser.parsing.api">Parsing API</a></li></ul><p><strong>Exploring the above Apache OpenNLP Java APIs via the notebook directly</strong></p><p>We are able to do this from inside a notebook, running the <a href="https://github.com/SpencerPark/IJava">IJava Jupyter interpreter</a> which allows writing Java in a typical notebook. We will be exploring the above named Java APIs using small snippets of Java code and see the results appear in the notebook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*dElv_WFeEz94631_sgZbOg.gif" /></figure><p>So go back to your browser and look for the <a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/shared/notebooks/MyFirstJupyterNLPJavaNotebook.ipynb">MyFirstJupyterNLPJavaNotebook.ipynb</a> notebook and have a play with it, reading and executing each cell and observing the responses.</p><p><strong>Exploring the above Apache OpenNLP Java APIs via the notebook with the help of remote cloud services</strong></p><p>We are able to do this from inside a notebook, running the <a href="https://github.com/SpencerPark/IJava">IJava Jupyter interpreter</a> which allows writing Java in a typical notebook. But in this notebook, we have taken it further and used the %system <a href="https://github.com/SpencerPark/IJava/blob/master/docs/magics.md">Java cell magic</a> and the <a href="https://docs.valohai.com/valohai-cli/index.html">Valohai CLI</a> magic instead of running the Java code snippets in the various cells like the previous notebook.</p><p>So that way the downloading of the models and processing of the text using the model does not happen on your local machine but one a more sophisticated remote server in the cloud. And you are able to control this process from inside the notebook cells. This is more relevant when the models and the datasets to process are large and your local instance(s) do not have the necessary resources to support long-standing NLP processes. I have seen NLP training and evaluations to take long to finish and hence high-spec resources are a must.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*2nfxMdIlDICpGbvsVEJ6xg.gif" /></figure><p>And again go back to your browser and look for the <a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/shared/notebooks/MyNextJupyterNLPJavaNotebook.ipynb">MyNextJupyterNLPJavaNotebook.ipynb</a> notebook and have a play with it, reading and executing each cell. All the necessary details are in there including links to the docs and supporting pages.</p><p>To get a deeper understanding of how these two notebooks were put together and how they work operationally, please have a look at all <a href="https://github.com/neomatrix369/nlp-java-jvm-example/tree/master/shared/notebooks">the source files</a>.</p><h3>Closing the Jupyter notebook</h3><p>Make sure you have saved your notebook before you do this. Switch to the console window from where you ran the docker-runner shell script. Pressing <strong>Ctrl-C</strong> in the console running the Docker container gives you this:</p><pre>&lt;---snipped---&gt;</pre><pre>[I 21:13:16.253 NotebookApp] Saving file at /MyFirstJupyterJavaNotebook.ipynb</pre><pre>^C[I 21:13:22.953 NotebookApp] interrupted</pre><pre>Serving notebooks from local directory: /home/jovyan/work</pre><pre>1 active kernel</pre><pre>The Jupyter Notebook is running at:</pre><pre><a href="http://1e2b8182be38:8888/">http://1e2b8182be38:8888/</a></pre><pre>Shutdown this notebook server (y/[n])? y</pre><pre>[C 21:14:05.035 NotebookApp] Shutdown confirmed</pre><pre>[I 21:14:05.036 NotebookApp] Shutting down 1 kernel</pre><pre>Nov 15, 2019 9:14:05 PM io.github.spencerpark.jupyter.channels.Loop shutdown</pre><pre>INFO: Loop shutdown.</pre><pre>&lt;--snipped--&gt;</pre><pre>[I 21:14:05.441 NotebookApp] Kernel shutdown: 448d46f0-1bde-461b-be60-e248c6342f69</pre><p>This shuts down the container and you are back to your local machine command-prompt. Your notebook stays preserved in the shares/notebooks folder on your local machine, provided you have been saving them as you kept changing them.</p><h3>Other concepts, libraries and tools</h3><p>There are other <a href="https://github.com/neomatrix369/nlp-java-jvm-example#libraries--frameworks-provided">Java/JVM based NLP libraries</a> mentioned in the <strong>Resources</strong> section below, for brevity we won’t cover them. The links provided will lead to further information for your own pursuit.</p><p>Within the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> tool itself, we have only covered the command-line access part of it and not the Java Bindings. In addition, we haven’t gone through all the NLP concepts or features of the tool again for brevity have only covered a handful of them. But the <a href="https://opennlp.apache.org/docs/">documentation</a> and <a href="https://github.com/apache/opennlp#useful-links">resources</a> on the <a href="https://github.com/apache/opennlp">GitHub repo</a> should help in further exploration.</p><p>You can also find out how to build the <a href="https://hub.docker.com/r/neomatrix369/nlp-java">docker image</a> for yourself, by examining the <a href="https://github.com/neomatrix369/nlp-java-jvm-example/blob/master/docker-runner.sh">docker-runner script</a>.</p><h3>Limitations</h3><p>Although the <a href="https://github.com/SpencerPark/IJava/blob/master/docs/magics.md">Java cell magic</a> does make a difference and helps run commands. Even though it’s a non-Python based notebook we could still run shell commands and execute Java code in our cells and do some decent NLP work in the Jupyter notebooks.</p><p>If you had a python-based notebook, then <a href="https://www.valohai.com/">Valohai</a>’s extension called <a href="https://docs.valohai.com/jupyter/index.html">Jupyhai</a> specially made for such purposes would suffice. Have a look at the <strong>Jupyhai</strong> sub-section in the <strong>Resources</strong> section of this post (at the end of the post). In fact, we have been running all our actions in the Jupyhai notebook, although I have been calling it Jupyter Notebook, have a look at the icon on the toolbar in the middle part of the panel in the browser):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4Z6rClsE92z83a_g.png" /></figure><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*N6cRU5K_tAGzu_6V" /><figcaption><a href="https://unsplash.com/photos/CKlHKtCJZKk">Image source</a> (unsplash) via <a href="https://unsplash.com/@aaronburden">Aaron Burden</a></figcaption></figure><p>This has been a very different experience than most of the other ways of exploring and learning, and you can see why the whole industry specifically speaking areas that cover Academia, Research, Data Science and Machine Learning have taken this approach like a storm. We still have limitations but with time even they will be overcome making our experience a smooth one.</p><p>Seeing your results in the same page where your code sits is a lot assuring and gives us a short and quick feedback loop. Especially being able to see the visualisations and change them dynamically and get instant results can cut through the cruft for busy and eager students, scientists, mathematicians, engineers and analysts in every field not just Computing or Data Science or Machine Learning.</p><h3>Resources</h3><h3>IJava (Jupyter interpreter)</h3><ul><li><a href="https://github.com/SpencerPark/IJava">Github</a></li><li><a href="https://github.com/SpencerPark/IJava/tree/master/docs">Docs</a></li><li><a href="https://github.com/SpencerPark/IJava/pull/78">%system Java cell magic implementation</a></li><li><a href="https://hub.docker.com/r/neomatrix369/nlp-java">Docker image with IJava + Jupyhai + other dependencies</a></li></ul><h3>Jupyhai</h3><ul><li><a href="https://get.valohai.com/jupyter-notebook-version-control">Version Control for Jupyter Notebooks</a></li><li><a href="https://blog.valohai.com/topic/jupyter-notebook">Blogs on Jupyter Notebooks</a></li><li><a href="https://blog.valohai.com/valohai-jupyter-notebook-extension">Valohai’s Jupyter Notebook Extension</a></li><li><a href="https://blog.valohai.com/asynchronous-workflows-in-data-science">Asynchronous Workflows in Data Science</a></li><li><a href="https://blog.valohai.com/automatic-version-control-meets-jupyter-notebooks">Automatic Version Control Meets Jupyter Notebooks</a></li><li><a href="https://blog.valohai.com/leveling-up-your-ml-code-from-notebook">Level Up Your Machine Learning Code from Notebook to Production</a></li><li><a href="https://blog.valohai.com/run-jupyter-notebook-any-cloud-provider">Run Jupyter Notebook On Any Cloud Provider</a></li><li><a href="https://blog.valohai.com/jupyter-extension-updates">Updates for Valohai Powered Notebooks</a></li><li><a href="https://www.youtube.com/watch?v=IOv-yps387Q&amp;list=PLMskd1Tlj2wZjKK15qNMjYeJZtapUK01h&amp;index=5">Version control for Jupyter Notebooks (video)</a></li><li><a href="https://docs.valohai.com/jupyter/index.html">Docs</a></li></ul><h3>Apache OpenNLP</h3><ul><li><a href="https://github.com/neomatrix369/nlp-java-jvm-example">nlp-java-jvm-example</a> GitHub project</li><li><a href="https://opennlp.apache.org/">Apache OpenNLP</a> | <a href="https://github.com/apache/opennlp">GitHub</a> | <a href="https://opennlp.apache.org/mailing-lists.html">Mailing list</a> | <a href="https://twitter.com/@apacheopennlp">@apacheopennlp</a></li><li>Docs</li><li><a href="https://opennlp.apache.org/docs/">Documentation resources</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html">Manual</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/apidocs/opennlp-tools/index.html">Apache OpenNLP Tools Javadoc</a></li><li>Download</li><li><a href="https://opennlp.apache.org/download.html">Apache OpenNLP Jar/binary</a></li><li>Model Zoo</li><li><a href="https://opennlp.apache.org/models.html">Models page</a></li><li><a href="http://www.mirrorservice.org/sites/ftp.apache.org/opennlp/models/langdetect/1.8.3/langdetect-183.bin">Language Detect model</a></li><li><a href="http://opennlp.sourceforge.net/models-1.5/">Older models to support the examples in the docs</a></li><li>Legends to support the examples in the docs</li><li><a href="https://www.apache.org/dist/opennlp/models/langdetect/1.8.3/README.txt">List of languages</a></li><li><a href="https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html">Penn Treebank tagset</a></li><li>Find more in the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/nlp-java-jvm/images/java/opennlp/README.md#resources">Resources</a> section in the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/nlp-java-jvm/images/java/opennlp/README.md#apache-opennlp--">README</a></li></ul><h3>Other related posts</h3><ul><li><a href="https://medium.com/@neomatrix369/how-to-do-deep-learning-for-java-on-the-valohai-platform-eec8ba9f71d8?source=---------7------------------">How to do Deep Learning for Java?</a></li><li><a href="https://medium.com/@neomatrix369/applying-nlp-in-java-all-from-the-command-line-1225dd591e80?source=---------4------------------">NLP with DL4J in Java, all from the command-line</a></li><li><a href="https://medium.com/@neomatrix369/exploring-nlp-concepts-using-apache-opennlp-4d59c3cac8">Exploring NLP concepts using Apache OpenNLP</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e53489ba2bd8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/exploring-nlp-concepts-using-apache-opennlp-inside-a-jupyter-notebook-e53489ba2bd8">Exploring NLP concepts using Apache OpenNLP inside a Jupyter notebook</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring NLP concepts using Apache OpenNLP]]></title>
            <link>https://medium.com/data-science/exploring-nlp-concepts-using-apache-opennlp-4d59c3cac8?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d59c3cac8</guid>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Wed, 20 Nov 2019 00:13:52 GMT</pubDate>
            <atom:updated>2020-11-01T21:40:07.964Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*EJqGI5S0B_mJg_Z71wP0uA.jpeg" /><figcaption>Open-source image <a href="https://www.google.co.uk/search?hl=en-GB&amp;tbs=simg:CAQS5gIJws2O9UB3iiMa2gILELCMpwgaYgpgCAMSKPIUyxXeFdEV0hXdFeYV9RTlFYALyiimKrUqoyqpKskopyrNOKQqzjgaMLapFKN038S_1R2IDB3kjS2lXpJND1fI-eDwEVaqFtuZviKuyy3gfcz2S1aM9EVZZmiAEDAsQjq7-CBoKCggIARIEa370BAwLEJ3twQka0gEKJQoRbmF0dXJhbCBsYW5kc2NhcGXapYj2AwwKCi9tLzAzZDI4eTMKFwoFc2hhZGXapYj2AwoKCC9tLzBobmRsCiwKGG5vcnRoZXJuIGhhcmR3b29kIGZvcmVzdNqliPYDDAoKL20vMDNkM3pxbgoyCh92YWxkaXZpYW4gdGVtcGVyYXRlIHJhaW4gZm9yZXN02qWI9gMLCgkvbS8wMmp2azMKLgoabm9ydGhlcm4gd2hpdGUgY2VkYXIgc3dhbXDapYj2AwwKCi9tLzA0XzdodHAM&amp;sxsrf=ALeKk0371dkX4j_Wlyi9eHXEuSFMsDmiHQ:1604266002900&amp;q=nolde+forest&amp;tbm=isch&amp;sa=X&amp;ved=2ahUKEwiRjenJpOLsAhXEsHEKHeIIBKEQwg4oAHoECB8QKw&amp;biw=1440&amp;bih=728#imgrc=P9t6yFAw7n76XM">widely used</a></figcaption></figure><p>After looking at a lot of <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/natural-language-processing/java-jvm.md#javajvm">Java/JVM based NLP libraries</a> listed on <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/">Awesome AI/ML/DL</a> I decided to pick the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> library. One of the reasons comes from the fact another developer (who had a look at it previously) recommended it. Besides, it’s an <a href="https://apache.org/">Apache</a> project, they have been great supporters of F/OSS Java projects for the last two decades or so (see <a href="https://en.wikipedia.org/wiki/The_Apache_Software_Foundation">Wikipedia</a>). It also goes without saying that <a href="https://opennlp.apache.org/">Apache OpenNLP</a> is backed by the <a href="https://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0 license</a>.</p><p>In addition, this tweet from an NLP researcher added some more confidence to the matter:</p><blockquote><em>In my current research project, I experimented with </em><a href="https://twitter.com/ApacheOpennlp?ref_src=twsrc%5Etfw"><em>@ApacheOpennlp</em></a><em> and was delighed to see it’s a valuable NLP toolkit with a user-friendly API. Too early to draw a comparison between </em><a href="https://twitter.com/ApacheOpennlp?ref_src=twsrc%5Etfw"><em>@ApacheOpennlp</em></a><em> and </em><a href="https://twitter.com/stanfordnlp?ref_src=twsrc%5Etfw"><em>@stanfordnlp</em></a><em>. I will see how they perform in named entity recognition first.</em></blockquote><blockquote><em>- Linda (Xia) Liu (@DrLiuBigData) </em><a href="https://twitter.com/DrLiuBigData/status/1101890668283215872?ref_src=twsrc%5Etfw"><em>March 2, 2019</em></a></blockquote><h3>Linda (Xia) Liu on Twitter</h3><p>In my current research project, I experimented with @ApacheOpennlp and was delighed to see it&#39;s a valuable NLP toolkit with a user-friendly API. Too early to draw a comparison between @ApacheOpennlp and @stanfordnlp. I will see how they perform in named entity recognition first.</p><p>I’ll like to say my personal experience has been similar with <a href="https://opennlp.apache.org/">Apache OpenNLP</a> so far and I echo the simplicity and user-friendly API and design. You will see as we explore it further, that being the case.</p><h3>Exploring NLP using Apache OpenNLP</h3><h4>Java bindings</h4><p>We won’t be covering the Java API to <a href="https://opennlp.apache.org/">Apache OpenNLP</a> tool in this post but you can find a number of examples in <a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html">their docs</a>. A bit later you will also need some of the resources enlisted in the <strong>Resources</strong> section at the bottom of this post in order to progress further.</p><h4>Command-line Interface</h4><p>I was drawn to the simplicity of the CLI available and it just worked out-of-the-box, for instances where a model was needed, and when it was provided. It would just work without additional configuration.</p><p>To make it easier to use and also not have to remember all the CLI parameters it supports I have put together some <a href="https://github.com/valohai/nlp-java-jvm-example#scripts-provided">shell scripts</a>. Have a look at the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> to get more insight into what they are and how to use them.</p><h4>Getting started</h4><p>You will need the following from this point forward:</p><ul><li>Git client 2.x or higher (an account on GitHub to fork the repo)</li><li>Java 8 or higher (suggest install <a href="https://www.graalvm.org/">GraalVM CE</a> 19.x or higher)</li><li>Docker CE 19.x or higher and check it is running before going further</li><li>Ability to run <a href="https://github.com/valohai/nlp-java-jvm-example#scripts-provided">shell scripts</a> from the CLI</li><li>Understand reading/writing shell scripts (optional)</li></ul><p>Note: At the time of the writing version 1.9.1 of <a href="https://opennlp.apache.org/">Apache OpenNLP</a> was available.</p><p>We have put <a href="https://github.com/valohai/nlp-java-jvm-example#scripts-provided">together scripts</a> to make these steps easy for everyone:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a90f498129d95854fcf948ed5c2f230/href">https://medium.com/media/4a90f498129d95854fcf948ed5c2f230/href</a></iframe><p>This will lead us to the folder with the following files in it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f2d500d5750cac441f0c1664103da8f/href">https://medium.com/media/4f2d500d5750cac441f0c1664103da8f/href</a></iframe><p><em>Note: a</em> <a href="https://hub.docker.com/r/neomatrix369/nlp-java"><em>docker image</em></a> <em>has been provided to be able to run a docker container that would contain all the tools you need to go further. You can see the</em> *shared* <em>folder has been created, which is a volume mounted into your container but it&#39;s actually</em> <em>a</em> <em>directory created on your local machine and mapped to this volume. So anything created or downloaded there will be available even after you exit out of your container!</em></p><p>Have a quick read of the main <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> file to get an idea of how to go about using the <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/docker-runner.sh">docker-runner.sh shell script</a>, and take a quick glance at the <a href="https://github.com/valohai/nlp-java-jvm-example#usage">Usage section</a> <em>as well.</em> Thereafter also take a look into the <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README.md">Apache OpenNLP README</a> file to see the <a href="https://github.com/valohai/nlp-java-jvm-example/tree/master/images/java/opennlp#exploring-nlp-concepts">usages</a> of the <a href="https://github.com/valohai/nlp-java-jvm-example/tree/master/images/java/opennlp#scripts-provided">scripts</a> provided therein.</p><h4>Run the NLP Java/JVM docker container</h4><p>At your local machine command prompt while at the root of the project, do this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f411fd37ccf97c8f67fa72724ccaca7a/href">https://medium.com/media/f411fd37ccf97c8f67fa72724ccaca7a/href</a></iframe><p>There is a chance you get this first before you get the prompt:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8014fdf11e8cdbe8fea6f8bacde55159/href">https://medium.com/media/8014fdf11e8cdbe8fea6f8bacde55159/href</a></iframe><p>And then you will be presented with prompt inside the container:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e800b2ed14e9adac87ddd504f7329307/href">https://medium.com/media/e800b2ed14e9adac87ddd504f7329307/href</a></iframe><p>The container is packed with all the <a href="https://github.com/valohai/nlp-java-jvm-example/tree/master/images/java/opennlp">Apache OpenNLP scripts/tools</a> you need to get started with exploring various NLP solutions.</p><h4>Installing Apache OpenNLP inside the container</h4><p>Here is how we go further from here when you are inside the container, at the container command-prompt:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b745d8b9c87750b4c031de24935b0d5/href">https://medium.com/media/4b745d8b9c87750b4c031de24935b0d5/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35e5d8afa3c76c53dee9ca9847649a7f/href">https://medium.com/media/35e5d8afa3c76c53dee9ca9847649a7f/href</a></iframe><p>You will see the apache-opennlp-1.9.1-bin.tar.gz artifact being downloaded and expanded into the shared folder:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1579111c3c2a59e1ec76d109299f822/href">https://medium.com/media/f1579111c3c2a59e1ec76d109299f822/href</a></iframe><h4>Viewing and accessing the shared folder</h4><p>Just as you run the container, a shared folder is created, it may be empty in the beginning but as we go along we will find it fill up with different files and folders.</p><p>It’s also where you will find the downloaded models and the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> binary exploded into its own directory (by the name apache-opennlp-1.9.1).</p><p>You can access and see the contents of it from the command-prompt (outside the container) as well:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbcc71a0d43aa6d978a9d42771cea72b/href">https://medium.com/media/bbcc71a0d43aa6d978a9d42771cea72b/href</a></iframe><p>From inside the container, this is what you see:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/44954e7b27018f1a567bd7e0d00d2ce5/href">https://medium.com/media/44954e7b27018f1a567bd7e0d00d2ce5/href</a></iframe><h4>Performing NLP actions inside the container</h4><p>The good thing is without ever leaving your current folder you can perform these NLP actions (check out the <a href="https://github.com/valohai/nlp-java-jvm-example/tree/master/images/java/opennlp#exploring-nlp-concepts">Exploring NLP Concepts</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example/tree/master/images/java/opennlp#apache-opennlp--">README</a>):</p><p>Usage help of any of the scripts: at any point in time you can always query the scripts by calling them this way:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb90e0113b409d7810fb26afa0496340/href">https://medium.com/media/bb90e0113b409d7810fb26afa0496340/href</a></iframe><p>For e.g.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b985fbf8d0df264895ef1fa1811912e/href">https://medium.com/media/6b985fbf8d0df264895ef1fa1811912e/href</a></iframe><p>gives us this usage text as output:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b08aa44b70bf34912929cb4cdb55556/href">https://medium.com/media/6b08aa44b70bf34912929cb4cdb55556/href</a></iframe><ul><li>Detecting language in a single-line text or article (see <a href="https://www.apache.org/dist/opennlp/models/langdetect/1.8.3/README.txt">legend of language abbreviations</a> used)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fb7af5922e948d4cf514b4e38de0c98/href">https://medium.com/media/0fb7af5922e948d4cf514b4e38de0c98/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c0376dfdb214e2696571c65ab6f16b7/href">https://medium.com/media/2c0376dfdb214e2696571c65ab6f16b7/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-detecting-language.md">Detecting languages</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output.</p><ul><li>Detecting sentences in a single line text or article.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88d0541c499fe96e937188211203d6d4/href">https://medium.com/media/88d0541c499fe96e937188211203d6d4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6e33890d019c3a8f3719d37ee1f9ee6/href">https://medium.com/media/d6e33890d019c3a8f3719d37ee1f9ee6/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-detecting-sentences.md">Detecting sentences</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output.</p><ul><li>Finding person name, organisation name, date, time, money, location, percentage information in a single line text or article.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a40881c8e1be9cd29493674f5ec84113/href">https://medium.com/media/a40881c8e1be9cd29493674f5ec84113/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27a3f547cbd82820b6b26742ffb9aa6e/href">https://medium.com/media/27a3f547cbd82820b6b26742ffb9aa6e/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-finding-names.md">Finding names</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output. There are a number of types of name finder examples in this section.</p><ul><li>Tokenize a line of text or an article into its smaller components (i.e. words, punctuation, numbers).</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f44a9b156b70f84661cfce0ce88db0bb/href">https://medium.com/media/f44a9b156b70f84661cfce0ce88db0bb/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1127a37d852fecbf4b8fc08e5f168a4/href">https://medium.com/media/a1127a37d852fecbf4b8fc08e5f168a4/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-tokenise.md">Tokenise</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output.</p><ul><li>Parse a line of text or an article and identify groups of words or phrases that go together (see <a href="https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html">Penn Treebank tag set</a> for the legend of token types), also see <a href="https://nlp.stanford.edu/software/lex-parser.shtml">https://nlp.stanford.edu/software/lex-parser.shtml.</a></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e912438b92dc42a851e87a2e80b7de2/href">https://medium.com/media/1e912438b92dc42a851e87a2e80b7de2/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f5ced08f12980b05d9133333314b7d6/href">https://medium.com/media/5f5ced08f12980b05d9133333314b7d6/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-parser.md">Parser</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output.</p><ul><li>Tag parts of speech of each token in a line of text or an article (see <a href="https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html">Penn Treebank tag set</a> for legend of token types), also see <a href="https://nlp.stanford.edu/software/tagger.shtml">https://nlp.stanford.edu/software/tagger.shtml.</a></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd49b9cd058ab4f002bf06d15523ef48/href">https://medium.com/media/dd49b9cd058ab4f002bf06d15523ef48/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/017de156156499d5b6076da8498dc9c8/href">https://medium.com/media/017de156156499d5b6076da8498dc9c8/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-tag-parts-of-speech.md">Tag Parts of Speech</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output.</p><ul><li>Text chunking by dividing a text or an article into syntactically correlated parts of words, like noun groups, verb groups. You apply this feature on the tagged parts of speech text or article. <em>Apply chunking on a text already tagged by PoS tagger</em> (see <a href="https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html">Penn Treebank tag set</a> for the legend of token types, also see <a href="https://nlpforhackers.io/text-chunking/">https://nlpforhackers.io/text-chunking/</a>)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e89da3429b064a161296d8d2f8a1ed1/href">https://medium.com/media/7e89da3429b064a161296d8d2f8a1ed1/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85e2342815834c88368ceb81618686e4/href">https://medium.com/media/85e2342815834c88368ceb81618686e4/href</a></iframe><p>See <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README-chunking.md">Chunking</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example#nlp-javajvm-">README</a> for more examples and detailed output.</p><h4>Exiting from the NLP Java/JVM docker container</h4><p>It is as simple as this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8295994bcb941466bd6aea97a4cee73e/href">https://medium.com/media/8295994bcb941466bd6aea97a4cee73e/href</a></iframe><p>And you are back to your local machine prompt.</p><h3>Benchmarking</h3><p>One of the salient features of this tool is, it’s recording and reporting metrics of its actions at different execution points — time taken at micro and macro levels, here’s a sample output to illustrate this feature:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e0ed6caed732a9d33ff3c79fc366f5b/href">https://medium.com/media/5e0ed6caed732a9d33ff3c79fc366f5b/href</a></iframe><p>From the above I have come across 5 metrics that are useful for me as a scientist or an analyst or even as an engineer:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aaabf0c3e52418687bc6772d7496818f/href">https://medium.com/media/aaabf0c3e52418687bc6772d7496818f/href</a></iframe><p>Information like this is invaluable when it comes to making performance comparisons like:</p><ul><li>between two or more models (load-time and run-time performance)</li><li>between two or more environments or configurations</li><li>between applications doing the same NLP, action put together using different tech stacks</li><li>also includes different languages</li><li>finding co-relations between different corpora of text data processed (quantitative and qualitative comparisons)</li></ul><h3>Empirical example</h3><p><a href="https://bit.ly/better-nlp-launch"><em>BetterNLP</em></a> <em>library written in python is doing something similar, see</em> <a href="https://kaggle.com/"><em>Kaggle</em></a> <em>kernels:</em> <a href="https://www.kaggle.com/neomatrix369/better-nlp-class-notebook"><em>Better NLP Notebook</em></a> <em>and</em> <a href="https://www.kaggle.com/neomatrix369/better-nlp-summarisers-notebook"><em>Better NLP Summarisers Notebook</em></a> <em>(search for</em> <em>time_in_secs</em> <em>inside both the notebooks to see the metrics reported).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/0*WV7bzTILjHrt_E8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/0*Q2wgvd8rfuk6XgUN.png" /></figure><p>Personally, it’s quite inspiring and also validates that this is a useful feature (or action) to offer to the end-user.</p><h3>Other concepts, libraries and tools</h3><p>There are other <a href="https://github.com/valohai/nlp-java-jvm-example#libraries--frameworks-provided">Java/JVM based NLP libraries</a> mentioned in the <strong>Resources</strong> section below, for brevity we won’t cover them. The links provided will lead to further information for your own pursuit.</p><p>Within the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> tool itself, we have only covered the command-line access part of it and not the Java Bindings. In addition, we haven’t gone through all the NLP concepts or features of the tool again for brevity have only covered a handful of them. But the <a href="https://opennlp.apache.org/docs/">documentation</a> and <a href="https://github.com/apache/opennlp#useful-links">resources</a> on the <a href="https://github.com/apache/opennlp">GitHub repo</a> should help in further exploration.</p><p>You can also find out how to build the <a href="https://hub.docker.com/r/neomatrix369/nlp-java">docker image</a> for yourself, by examining the <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/docker-runner.sh">docker-runner script</a>.</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Zzfxrr40NHoXU1Dy" /><figcaption><a href="https://unsplash.com/photos/RQR94izYg2k">Image source</a> by <a href="https://unsplash.com/@simonbhray">Simon Ray</a></figcaption></figure><p>After going through the above, we can conclude the following about the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> tool by exploring its pros and cons:</p><p><strong>Pros</strong></p><ul><li>It’s an easy to use API and understand</li><li>Shallow learning curve and detailed documentation with lots of examples</li><li>Covers a lot of NLP functionality, there’s more in the <a href="https://opennlp.apache.org/docs/">docs</a> to explore than we did above</li><li>Easy <a href="https://github.com/valohai/nlp-java-jvm-example#scripts-provided">shell scripts</a> and <a href="https://github.com/valohai/nlp-java-jvm-example/tree/master/images/java/opennlp">Apache OpenNLP scripts</a> have been provided to play with the tool</li><li>Lots of resources available below to learn more about NLP (See the <strong>Resources</strong> section below)</li><li>Resources provided to quickly get started and explore the <a href="https://opennlp.apache.org/">Apache OpenNLP</a> tool</li></ul><p><strong>Cons</strong></p><ul><li>Looking at the <a href="https://github.com/apache/opennlp">GitHub</a> repo, it seems the development is slow or has been stagnated (last two commits have a wide gap i.e. May 2019 and Oct 15, 2019)</li><li>A few models are missing when going through the examples in the <a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html">documentation (manual)</a></li><li>The current models provided may need further training as per your use case(s), see this tweet:</li></ul><h3>Linda (Xia) Liu on Twitter</h3><p>@theNeomatrix369 @ApacheOpennlp @stanfordnlp If your project&#39;s success depends heavily on performance of Named Entity Recognition, please start with OpenNLP. Be aware that NER&#39;s results are highly domain specific. If your textual data is very different from the training data OpenNLP or StanfordNLP used, train your own model</p><h3>Resources</h3><h4>Apache OpenNLP</h4><ul><li><a href="https://github.com/valohai/nlp-java-jvm-example">nlp-java-jvm-example</a> GitHub project</li><li><a href="https://opennlp.apache.org/">Apache OpenNLP</a> | <a href="https://github.com/apache/opennlp">GitHub</a> | <a href="https://opennlp.apache.org/mailing-lists.html">Mailing list</a> | <a href="https://twitter.com/@apacheopennlp">@apacheopennlp</a></li><li><strong>Docs</strong></li><li><a href="https://opennlp.apache.org/docs/">Documentation resources</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/manual/opennlp.html">Manual</a></li><li><a href="https://opennlp.apache.org/docs/1.9.1/apidocs/opennlp-tools/index.html">Apache OpenNLP Tools Javadoc</a></li><li><strong>Download</strong></li><li><a href="https://opennlp.apache.org/download.html">Apache OpenNLP Jar/binary</a></li><li><strong>Model Zoo</strong></li><li><a href="https://opennlp.apache.org/models.html">Models page</a></li><li><a href="http://www.mirrorservice.org/sites/ftp.apache.org/opennlp/models/langdetect/1.8.3/langdetect-183.bin">Language Detect model</a></li><li><a href="http://opennlp.sourceforge.net/models-1.5/">Older models to support the examples in the docs</a></li><li><strong>Legends to support the examples in the docs</strong></li><li><a href="https://www.apache.org/dist/opennlp/models/langdetect/1.8.3/README.txt">List of languages</a></li><li><a href="https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html">Penn Treebank tag set</a></li><li>Find more in the <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README.md#resources">Resources</a> section in the <a href="https://github.com/valohai/nlp-java-jvm-example/blob/master/images/java/opennlp/README.md#apache-opennlp--">README</a></li></ul><h4>Other related posts</h4><ul><li><a href="https://blog.valohai.com/nlp_with_dl4j_in_java_all_from_the_command-line?from=3oxenia9mtr6">How to do Deep Learning for Java on the Valohai Platform?</a></li><li><a href="https://blog.valohai.com/nlp_with_dl4j_in_java_all_from_the_command-line?from=3oxenia9mtr6">NLP with DL4J in Java, all from the command-line</a></li></ul><h4>About me</h4><p>Mani Sarkar is a passionate developer mainly in the Java/JVM space, currently strengthening teams and helping them accelerate when working with small teams and startups, as a freelance software engineer/data/ml engineer, <a href="https://neomatrix369.wordpress.com/about">more….</a></p><p><strong>Twitter:</strong> <a href="https://twitter.com/@theNeomatrix369">@theNeomatrix369</a> | <strong>GitHub:</strong> <a href="https://github.com/neomatrix369">@neomatrix369</a></p><p><strong>Originally published at </strong><a href="https://blog.valohai.com/exploring-nlp-concepts-using-apache-opennlp-1?from=3oxenia9mtr6"><strong>https://blog.valohai.com</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d59c3cac8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/exploring-nlp-concepts-using-apache-opennlp-4d59c3cac8">Exploring NLP concepts using Apache OpenNLP</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Applying NLP in Java, all from the command-line]]></title>
            <link>https://medium.com/data-science/applying-nlp-in-java-all-from-the-command-line-1225dd591e80?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1225dd591e80</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[deeplearning4j]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Fri, 01 Nov 2019 15:34:42 GMT</pubDate>
            <atom:updated>2020-11-01T21:45:51.082Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1Aqukz_R_l3BCaapwWWJw.jpeg" /><figcaption><a href="https://unsplash.com/photos/ZzWsHbu2y80">Image source</a> by <a href="https://unsplash.com/@hannahwrightdesigner">Hannah Wright</a></figcaption></figure><h3>Introduction</h3><p>We are all aware of Machine Learning tools and cloud services that work via the browser and give us an interface we can use to perform our day-to-day data analysis, model training, and evaluation, and other tasks to various degrees of efficiencies.</p><p>But what would you do if you want to do these tasks on or from your local machine or infrastructure available in your organisation? And, if these resources available do not meet the pre-requisites to do decent end-to-end Data Science or Machine Learning tasks. That’s when access to a cloud-provider agnostic deep learning management environments like <a href="https://valohai.com/">Valohai</a> can help. And to add to this, we will be using the <a href="https://valohai.com/pricing/"><strong>free-tier</strong></a> that is accessible to one and all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*E3tRjVu5Fi5LBL9e3kbKCQ.png" /><figcaption><a href="https://get.valohai.com/cs/c/?cta_guid=18d3c2db-7630-414e-bbe4-e835f2ec42cb&amp;placement_guid=ce53cbd9-210d-4576-91d8-f05ffce8e0f5&amp;portal_id=2730768&amp;canon=https%3A%2F%2Fblog.valohai.com%2Fnlp_with_dl4j_in_java_all_from_the_command-line&amp;redirect_url=APefjpG1TUcWlv-eZxsAmaxlG9rqk38vQfsLAo3VQl7OzSuw2OUIBALvYxU3A69CoabsAMcniWEMdw5b8IVb6_S31r76TRKyqUaMNuD8Adq4yCgUtW2oaic2axBV2q8uZ80cmjDK-9D6&amp;click=aeaa9976-80f2-4445-99fa-e4524f1f026b&amp;hsutk=c7a00000164d193418f2016e273067b4&amp;signature=AAH58kEvsi27jm-eKViSt0dBogTwMi0_4w&amp;utm_referrer=https%3A%2F%2Fblog.valohai.com%2F&amp;pageId=19375533141"><strong>Create a free account</strong></a></figcaption></figure><p>We will be performing the task of building a Java app, and then training and evaluating an NLP model using it, and we will do all of it from the command-line interface with less interaction with the available web interface — basically it will be an end-to-end process all the way to training, saving and evaluation of the NLP model. And we won’t need to worry much about setting up any environments, configuring or managing it.</p><h3>Purpose or Goals</h3><p>We will learn to do a bunch of things in this post covering various levels of abstractions (in no particular order):</p><ul><li>how to build and run an NLP model on the local machine?</li><li>how to build and run an NLP model on the cloud?</li><li>how to build NLP Java apps that run on the CPU or GPU?</li><li>most examples out there are non-Java based, much less Java-based ones</li><li>most examples are CPU based, much less on GPUs</li><li>how to perform the above depending on absence/presence of resources i.e. GPU?</li><li>how to build a CUDA docker container for Java?</li><li>how to do all the above all from the command-line?</li><li>via individual commands</li><li>via shell scripts</li></ul><h3>What do we need and how?</h3><p>Here’s what we need to be able to get started:</p><ul><li>a Java app that builds and runs on any operating system</li><li>CLI tools that allow connecting to remote cloud services</li><li>shell scripts and code configuration to manage all of the above</li></ul><p>The <em>how</em> part of this task is not hard once we have our goals and requirements clear, we will expand on this in the following sections.</p><h3>NLP for Java, DL4J and Valohai</h3><h3>NLP for Java: DL4J</h3><p>We have all of the code and instructions needed to get started with this post, <a href="https://github.com/valohai/dl4j-nlp-cuda-example">captured for you on GitHub</a>. Below are the steps you go through to get acquainted with the project:</p><h4>Quick startup</h4><p>To quickly get started we need to do just these:</p><ul><li>open an account on <a href="https://valohai.com/">https://valohai.com</a>, see <a href="https://app.valohai.com/accounts/signup/">https://app.valohai.com/accounts/signup/</a></li><li><a href="https://docs.valohai.com/tutorials/quick-start-cli.html">install Valohai CLI</a> on your local machine</li><li>clone the repo <a href="https://github.com/valohai/dl4j-nlp-cuda-example/">https://github.com/valohai/dl4j-nlp-cuda-example/</a></li></ul><pre>$ git clone https://github.com/valohai/dl4j-nlp-cuda-example/<br>$ cd dl4j-nlp-cuda-example</pre><ul><li>create a <a href="https://valohai.com/">Valohai</a> project using the <a href="https://docs.valohai.com/tutorials/quick-start-cli.html?highlight%3Dcli">Valohai CLI </a>tool, and give it a name</li></ul><pre>$ vh project create</pre><ul><li>link your <a href="https://valohai.com/">Valohai</a> project with the GitHub repo <a href="https://github.com/valohai/dl4j-nlp-cuda-example/">https://github.com/valohai/dl4j-nlp-cuda-example/</a> on the Repository tab of the Settings page (https://app.valohai.com/p/[your-user-id]/dl4j-nlp-cuda-example/settings/repository/)</li></ul><pre>$ vh project open</pre><pre>### Go to the Settings page &gt; Repository tab and update the git repo address with https://github.com/valohai/dl4j-nlp-cuda-example/</pre><ul><li>update <a href="https://valohai.com/">Valohai</a> project with the latest commits from the git repo</li></ul><pre>$ vh project fetch</pre><p>Now you’re ready to start using the power of performing Machine Learning tasks from the command-line.</p><p><em>See </em><a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/README.md"><em>Advanced installation and setup section in the README</em></a><em> to find out what we need to install and configure on your system to run the app and experiments on your local machine or inside a Docker container — this is not necessary for this post at the moment but you can try it out at a later time.</em></p><h4>About <a href="https://docs.valohai.com/valohai-yaml/index.html">valohai.yaml</a></h4><p>You will have noticed we have a <a href="https://docs.valohai.com/valohai-yaml/index.html">valohai.yaml</a> in the git repo and our <a href="https://github.com/neomatrix369/dl4j-nlp-cuda-example/blob/master/valohai.yaml">valohai.yaml</a> file contains several steps that you can use, we have enlisted them by their names, which we will use when running our steps:</p><ul><li><strong>build-cpu-gpu-uberjar</strong>: build our uber jar (both CPU and GPU versions) on <a href="https://www.google.com/url?q=https://valohai.com&amp;sa=D&amp;ust=1572263065713000">Valohai</a></li><li><strong>train-cpu-linux</strong>: run the NLP training using the CPU-version of uber jar on <a href="https://www.google.com/url?q=https://valohai.com&amp;sa=D&amp;ust=1572263065714000">Valohai</a></li><li><strong>train-gpu-linux</strong>: run the NLP training using the GPU-version of uber jar on <a href="https://www.google.com/url?q=https://valohai.com&amp;sa=D&amp;ust=1572263065714000">Valohai</a></li><li><strong>evaluate-model-linux</strong>: evaluate the trained NLP model from one of the above <strong>train-*</strong> execution steps</li><li><strong>know-your-gpus</strong>: run on any instance to gather GPU/Nvidia related details on that instance, we run the same script with the other steps above (both the build and run steps)</li></ul><h4>Building the Java app from the command line</h4><p>Assuming you are all set up we will start by building the Java app on the <a href="https://valohai.com/">Valohai</a> platform from the command prompt, which is as simple as running one of the two commands:</p><pre>$ vh exec run build-cpu-gpu-uberjar [--adhoc]<br><br>### Run `vh exec run --help` to find out more about this command</pre><p>And you will be prompted with the execution counter, which is nothing by a number:</p><pre>&lt;--snipped--&gt;<br>😼  Success! Execution #1 created. See https://app.valohai.com/p/valohai/dl4j-nlp-cuda-example/execution/016dfef8-3a72-22d4-3d9b-7f992e6ac94d/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*hkMzjolCp4cdhj4s.jpg" /></figure><p><em>Note: use </em><em>--adhoc only if you have not setup your </em><a href="https://valohai.com/"><em>Valohai</em></a><em> project with a git repo or have unsaved commits and want to experiment before being sure of the configuration.</em></p><p>You can watch your execution by:</p><pre>$ vh watch 1<br><br>### the parameter 1 is the counter returned by the `vh exec run build-cpu-gpu-uberjar` operation above, it is the index to refer to that execution run</pre><p>and you can see either we are waiting for an instance to be allocated or console messages move past the screen when the execution has kicked off. You can see the same via the web interface as well.</p><p><em>Note: instances are available based on how popular they are and also how much quota you have left on them, if they have been used recently they are more likely to be available next.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KSpEp59ue8DE6usA.png" /></figure><p>Once the step is completed, you can see it results in a few artifacts, called outputs in the <a href="https://valohai.com/">Valohai</a> terminology, we can see them by:</p><pre>$ vh outputs 1<br><br>### Run `vh outputs --help` to find out more about this command</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*GjlPMTKBGFmeTkKf.png" /></figure><p>We will need the URLs that look like datum://[....some sha like notation...] for our next steps. You can see we have a log file that has captured the GPU related information about the running instance, you can download this file by:</p><pre>$ vh outputs --download . --filter *.logs 1<br><br>### Run `vh outputs --help` to find out more about this command</pre><h4>Running the NLP training process for CPU/GPU from the command-line</h4><p>We will use the built artifacts namely the uber jars for the CPU and GPU backends to run our training process:</p><pre>### Running the CPU uberjar<br>$ vh exec run train-cpu-linux --cpu-linux-uberjar=datum://016dff00-43b7-b599-0e85-23a16749146e [--adhoc]<br><br>### Running the GPU uberjar<br>$ vh exec run train-gpu-linux --gpu-linux-uberjar=datum://016dff00-2095-4df7-5d9e-02cb7cd009bb [--adhoc]<br><br>### Note these datum:// link will vary in your case<br>### Run `vh exec run train-cpu-linux --help` to get more details on its usage</pre><p><em>Note: take a look at the </em><a href="https://docs.valohai.com/valohai-cli/using-inputs.html"><em>Inputs with Valohai CLI</em></a><em> docs to see how to write commands like the above.</em></p><p>We can watch the process if we like but it can be lengthy so we can switch to another task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TAYgqS5DYEETSUg3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UkCOtzdlnHEbvbUk.png" /></figure><p>The above execution runs finish with saving the model into the ${VH_OUTPUTS} folder to enable it to be archived by <a href="https://valohai.com/">Valohai</a>. The model names get suffix to their names, to keep a track of how they were produced.</p><p>At any point during our building, training or evaluation steps, we can stop an ongoing execution (queued or running) by just doing this:</p><pre>$ vh stop 3<br>(Resolved stop to execution stop.)<br>⌛   Stopping #3...<br>=&gt;   {&quot;message&quot;:&quot;Stop signal sent&quot;}<br>😁  Success! Done.</pre><h4>Downloading the saved model post successful training</h4><p>We can query the outputs of execution by its counter number and download it using:</p><pre>$ vh outputs 2<br>$ vh outputs --download . --filter Cnn*.pb  2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e0Gb5eA2l1_YZEoc.png" /></figure><p><em>See how you </em><a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/docs/running-local-machine.md#run-the-app-on-your-local-machine"><em>can evaluate the downloaded model on your local machine</em></a><em>, both the models created by the </em><a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/docs/running-local-machine.md#evaluating"><em>CPU</em></a><em> and </em><a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/docs/running-local-machine.md#evaluating-1"><em>GPU</em></a><em> based processes (respective uber jars). Just pass in the name of the downloaded model as a parameter to the </em><a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/runUberJar.sh"><em>runner shell script</em></a><em> provided.</em></p><h4>Evaluating the saved NLP model from a previous training execution</h4><pre>### Running the CPU uberjar and evaluating the CPU-verion of the model<br>$ vh exec run evaluate-model-linux --uber-jar=datum://016dff00-43b7-b599-0e85-23a16749146e --model=datum://016dff2a-a0d4-3e63-d8da-6a61a96a7ba6 [--adhoc]<br><br>### Running the GPU uberjar and evaluating the GPU-verion of the model<br>$ vh exec run evaluate-model-linux --uber-jar=datum://016dff00-2095-4df7-5d9e-02cb7cd009bb --model=datum://016dff2a-a0d4-3e63-d8da-6a61a96a7ba6 [--adhoc]<br><br>### Note these datum:// link will vary in your case<br>### Run `vh exec run train-cpu-linux --help` to get more details on its usage</pre><p>And at the end of the model evaluation we get the below, model evaluation metrics and confusion matrix after running a test set on the model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6n3-watQUSmH4bIF.png" /></figure><p><em>Note: the </em><a href="https://github.com/valohai/dl4j-nlp-cuda-example/tree/master/src/main"><em>source code</em></a><em> contains ML and NLP-related explanations at various stages in the form of inline comments.</em></p><h4>Capturing the environment information about Nvidia’s GPU and CUDA drivers</h4><p>This step is unrelated to the whole process of building and running a Java app on the cloud and controlling and viewing it remotely using the client tool, although it is useful to be able to know on what kind of system we ran our training on, especially for the GPU aspect of the training:</p><pre>$ vh exec run know-your-gpus [--adhoc]<br><br>### Run `vh exec run --help` to get more details on its usage</pre><h4>Keeping track of your experiments</h4><ul><li>While writing this post, I ran several experiments and to keep track of the successful versus failed experiments in an efficient manner, I was able to use <a href="https://valohai.com/">Valohai</a>’s version control facilities baked into its design by</li><li>filtering for executions</li><li>searching for specific execution by “token”</li><li>re-running the successful and failed executions</li><li>confirming that the executions were successful and a failure for the right reasons</li><li>also, checkout <a href="https://blog.valohai.com/blog-building-a-data-catalog-for-machine-learning">data-catalogues</a> and <a href="https://blog.valohai.com/automatic-data-provenance-for-your-ml-pipeline">data provenance</a> on the <a href="https://valohai.com/">Valohai</a> platform below is an example of my project (look for the <strong>Trace</strong> button):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rbyqBwINW40FOBj9.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eZFh6u-XZ252fKxO.png" /></figure><h4>Comparing the CPU and GPU based processes</h4><p>We could have discussed comparisons between the CPU and GPU based processes in terms of these:</p><ul><li>app-building performance</li><li>model training speed</li><li>model evaluation accuracy</li></ul><p>But we won’t cover these topics in this post, although you have access to the metrics you need for it, in case you wish to investigate further.</p><h4>Necessary configuration file(s) and shells scripts</h4><p>All the necessary scripts can be found on the <a href="https://github.com/valohai/dl4j-nlp-cuda-example">GitHub repo</a>, they can be found in:</p><ul><li>the root folder of the project</li><li>docker folder</li><li>resources-archive folder</li></ul><p>Please also have a look at the <a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/README.md">README.md</a> file for further details on their usages and other additional information that we haven’t mentioned in this post here.</p><h3>Valohai — Orchestration</h3><p>If we have noticed all the above tasks were orchestrating the tasks via a few tools at different levels of abstractions:</p><ul><li>docker to manage infrastructure and platform-level configuration and version control management</li><li>java to be able to run our apps on any platform of choice</li><li>shell scripts to be able to again run both building and execution commands in a platform-agnostic manner and also be able to make exceptions for the absence of resources i.e. GPU on MacOSX</li><li>a client tool to connect with the remote cloud service i.e. <a href="https://docs.valohai.com/tutorials/quick-start-cli.html?highlight%3Dcli">Valohai CLI</a>, and view, control executions and download the end-results</li></ul><p>You are orchestrating your tasks from a single point making use of the tools and technologies available to do various Data and Machine Learning tasks.</p><figure><img alt="Image source by Mark Rasmuson" src="https://cdn-images-1.medium.com/proxy/0*R45wYWZ6SPo56jNh" /><figcaption><a href="https://unsplash.com/photos/yri82tuk2TQ">Image source</a> by <a href="https://unsplash.com/@mrasmuson">Mark Rasmuson</a></figcaption></figure><h3>Conclusion</h3><p>We have seen that NLP is a resource-consuming task and having the right methods and tools in hands certainly helps. Once again the <a href="https://deeplearning4j.org/">DeepLearning4J</a> library from <a href="https://skymind.ai/">Skymind</a> and the <a href="https://valohai.com/">Valohai</a> platform have come to our service. Thanks to the creators of both platform. Also, we can see the below benefits (and more) this post highlights.</p><h3>Benefits</h3><p>We gain a bunch of things by doing the way we did the things above:</p><ul><li>not have to worry about hardware and/or software configuration and version control management — <a href="https://hub.docker.com/r/neomatrix369/dl4j-nlp-cuda">docker containers</a> FTW</li><li>able to run manual one-off building, training and evaluation tasks — <a href="https://docs.valohai.com/tutorials/quick-start-cli.html?highlight%3Dcli">Valohai CLI</a> tool FTW</li><li>automate regularly use tasks for your team to be able to run tasks on remote cloud infrastructure — <a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/valohai.yaml">infrastructure-as-code</a> FTW</li><li>overcome the limitations of an old or slow machine or a Mac with no access to the onboard GPU — <a href="https://github.com/valohai/dl4j-nlp-cuda-example/tree/master/docker">CUDA-enabled docker image scripts</a> FTW</li><li>overcome situations when not enough resources are available on the local or server infrastructure, and still be able to run experiments requiring high-throughput and performant environments — a cloud-provider agnostic platform i.e <a href="https://docs.valohai.com/valohai-cli/using-environments.html?highlight%3Denvironment">Valohai environments</a> FTW</li><li>run tasks and not have to wait for them to finish and be able to run multiple tasks — concurrently and in-parallel on remote resources in a cost-effective manner — a cloud-provider agnostic platform i.e <a href="https://docs.valohai.com/tutorials/quick-start-cli.html?highlight%3Dcli">Valohai CLI</a><a href="https://www.google.com/url?q=https://docs.valohai.com/tutorials/quick-start-cli.html?highlight%3Dcli&amp;sa=D&amp;ust=1572263065733000"> </a>tool FTW</li><li>remotely view, control both configuration and executions and even download the end-results after a successful execution — a cloud-provider agnostic platform i.e <a href="https://docs.valohai.com/tutorials/quick-start-cli.html?highlight%3Dcli">Valohai CLI</a> tool FTW</li><li>and many others you will spot yourself</li></ul><h3>Suggestions</h3><ul><li><strong>using provided CUDA-enabled docker container:</strong> highly recommend not to start installing Nvidia drivers or CUDA or cuDNN on your local machine (Linux or Windows-based) — shelve this for later experimentation</li><li><strong>use provided shell scripts and configuration files:</strong> try not to perform manual CLI command instead use shells scripts to automate repeated tasks, provided examples are a good starting point and take it further from there</li><li><strong>try to learn as much</strong>: about GPUs, CUDA, cuDNN from resources provided and look for more (see<strong> Resources</strong> section at the bottom of the post)</li><li>use version control and infrastructure-as-code systems: git and the <a href="https://docs.valohai.com/valohai-yaml/index.html">valohai.yaml</a> are great examples of this</li></ul><p>I felt very productive and my time and resources were effectively used while doing all of the above, and above all, I can share it with others and everyone can just reuse all of this work directly — just <a href="https://github.com/valohai/dl4j-nlp-cuda-example">clone the repo</a> and<em> off you go</em>.</p><p>What we didn’t cover and is potentially a great topic to talk about, is the <a href="https://docs.valohai.com/core-concepts/pipelines.html?highlight%3Dpipeline">Valohai Pipelines</a> in some future post!</p><h3>Resources</h3><ul><li><a href="https://github.com/valohai/dl4j-nlp-cuda-example">dl4j-nlp-cuda-example</a> project on GitHub</li><li><a href="https://hub.docker.com/r/neomatrix369/dl4j-nlp-cuda">CUDA enabled docker container</a> on <a href="https://hub.docker.com/">Docker Hub</a> (use the latest tag: <a href="https://hub.docker.com/layers/neomatrix369/dl4j-nlp-cuda/v0.5/images/sha256-fcfcc2dcdf00839d918a0c475c39733d777181abb1a3c34d8dea68339369b137">v0.5</a>)</li><li><a href="https://github.com/valohai/dl4j-nlp-cuda-example/blob/master/docs/gpu-related-resources.md">GPU, Nvidia, CUDA and cuDNN</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/">Awesome AI/ML/DL resources</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/README-details.md#java">Java AI/ML/DL resources</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/README-details.md#deep-learning">Deep Learning and DL4J Resources</a></li><li>Awesome AI/ML/DL: <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/natural-language-processing#natural-language-processing-nlp">NLP resources</a></li><li>DL4J NLP resources</li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nlp-overview">Language processing</a></li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-config-gpu-cpu">ND4J backends for GPUs and CPUs</a></li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nlp-vocabulary-cache">How the Vocab Cache Works</a></li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nlp-word2vec">Word2Vec, Doc2vec &amp; GloVe: Neural Word Embeddings for Natural Language Processing</a></li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nlp-doc2vec">Doc2Vec, or Paragraph Vectors, in Deeplearning4j</a></li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nlp-sentence-iterator">Sentence iterator</a></li><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nlp-tokenization">What is Tokenization?</a></li><li>Examples</li><li><a href="https://github.com/eclipse/deeplearning4j-examples/tree/master/dl4j-examples">https://github.com/eclipse/deeplearning4j-examples/tree/master/dl4j-examples</a></li><li><a href="https://github.com/eclipse/deeplearning4j/tree/master/deeplearning4j/deeplearning4j-nlp-parent">https://github.com/eclipse/deeplearning4j/tree/master/deeplearning4j/deeplearning4j-nlp-parent</a></li></ul><p><strong>Valohai resources</strong></p><ul><li><a href="https://www.valohai.com/">valohai</a> | <a href="https://docs.valohai.com/">docs</a> | <a href="https://blogs.valohai.com/">blogs</a> | <a href="https://github.com/valohai">GitHub</a> | <a href="https://www.youtube.com/channel/UCiR8Fpv6jRNphaZ99PnIuFg/videos">Videos</a> | <a href="https://valohai.com/showcase/">Showcase</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/data/about-Valohai.md#valohai">About valohai</a> | <a href="http://community-slack.valohai.com/">Slack</a> | <a href="https://twitter.com/@valohaiai">@valohaiai</a></li><li><a href="https://docs.valohai.com/search.html?q=%3Cany+topic%3E">Search for any topic in the Documentation</a></li><li>Blog posts on how to use the Valohai CLI tool: <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-cli">[1]</a> | <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-part-2">[2]</a></li><li><a href="https://docs.valohai.com/guides/build-docker-image.html">Custom Docker Images</a></li></ul><p><strong>Other resources</strong></p><ul><li><a href="https://github.com/neomatrix369/awesome-graal">Awesome Graal</a> | <a href="https://www.graalvm.org/">graalvm.org</a></li></ul><p><strong>Other related posts</strong></p><ul><li><a href="https://blog.valohai.com/how-to-do-deep-learning-for-java-on-the-valohai-platform">How to do Deep Learning for Java on the Valohai Platform?</a></li><li>Blog posts on how to use the Valohai CLI tool: <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-cli">[1]</a> | <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-part-2">[2]</a></li></ul><h3><em>Originally published at </em><a href="https://blog.valohai.com/nlp_with_dl4j_in_java_all_from_the_command-line?from=3oxenia9mtr6"><em>https://blog.valohai.com</em></a><em>.</em></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1225dd591e80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/applying-nlp-in-java-all-from-the-command-line-1225dd591e80">Applying NLP in Java, all from the command-line</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Apache Zeppelin on Oracle Cloud Infrastructure]]></title>
            <link>https://medium.com/oracledevs/running-apache-zeppelin-on-oracle-cloud-infrastructure-b0aecc79597a?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0aecc79597a</guid>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[notebook]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Mon, 14 Oct 2019 01:43:43 GMT</pubDate>
            <atom:updated>2019-10-15T03:37:34.719Z</atom:updated>
            <content:encoded><![CDATA[<h3>Running Apache Zeppelin on the cloud</h3><h3>Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*B-IHJgSACsuZ37T-" /></figure><p>This post is going to be a composition of the practical parts of two posts, one written late last year and the other a couple of months ago respectively. The posts being <a href="https://medium.com/@neomatrix369/apache-zeppelin-stairway-to-notes-haven-28ec413a185a?source=---------6------------------">Apache Zeppelin: stairway to notes* haven!</a> (late Dec 2018) and <a href="https://medium.com/@neomatrix369/running-your-jupyter-notebooks-on-the-cloud-ed970326649f?source=---------4------------------">Running your JuPyTer notebooks on Oracle Cloud Infrastructure</a> (early September 2019). Although this time we are going to make <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> run on the <a href="http://cloud.oracle.com/">Oracle Cloud Infrastructure</a>.</p><p>We will follow a similar structure like in the previous posts for ease of reading and understanding.</p><p>Also for brevity, we will use the term <a href="http://cloud.oracle.com/">OCI</a> when referring to <a href="http://cloud.oracle.com/">Oracle Cloud Infrastructure</a> throughout the rest of the post. In some cases, I have hyperlinked and redirected the reader (with a bit of narration) with repeated steps in the post, and in some cases, I have expressed those steps literally in the post adapted to the current theme i.e. <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> on <a href="http://cloud.oracle.com/">OCI</a>.</p><p><em>Please do not literally use information like DNS or IP addresses or any other details directly from the screenshots or text areas in this post and from the linked ones. These details may differ in your case so please try to follow the ideas and principles behind the process. You should use the details that show up on your console or browser interface when you are setting up at your end, as instructed in the post.</em></p><h3>OCI: get started quickly</h3><p>So to get started we need to have an account on <a href="http://cloud.oracle.com/">OCI</a>, which is super simple to set up. I suggest reading the below sections from the post <a href="https://medium.com/@neomatrix369/running-your-jupyter-notebooks-on-the-cloud-ed970326649f?source=---------4------------------">Running your JuPyTer notebooks on Oracle Cloud Infrastructure</a> (provided screenshots to help navigate through the steps):</p><ul><li><strong>Introduction</strong></li><li><strong>Signing up</strong></li><li><strong>Setup</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rwYizRWA72NQlohx.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/0*mLaVK4k-Hsgoq4a5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/0*ZviE5liyTj_dlWh5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HffnjdsXWG7z4pM5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q_ddsgFGj_XOsBDV.png" /></figure><ul><li><strong>Actions to get on the cloud</strong></li></ul><p>And we stop the moment we reach the end of the <strong>Actions to get on the cloud </strong>section. But please ensure you install everything along the way to have to hand the tools you need for the rest of the post. Skip anything that appears <em>Jupyter notebooks</em> related as we will be setting up <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> next.</p><p>When we have finished the above we are at a good point, as we will have a VM instance accessible from both the browser as well as from the CLI. And we can then do further steps to install <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> and kick-off. Make a note of the <strong>Public IP Address </strong>of the VM instance created above before proceeding, in my case it is <strong>132.145.60.249</strong>.</p><h3>Zeppelin: get started quickly</h3><p>If you already know Zeppelin and feel at home with it, and are confident after skimming through the post: <a href="https://medium.com/@neomatrix369/apache-zeppelin-stairway-to-notes-haven-28ec413a185a?source=---------6------------------">Apache Zeppelin: stairway to notes* haven!</a> you can directly go to the next section in the post i.e <strong>Running Apache Zeppelin</strong>.</p><p>But to gain familiarity with <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> if you haven’t used it in the past, I suggest to slowly go through the post: <a href="https://medium.com/@neomatrix369/apache-zeppelin-stairway-to-notes-haven-28ec413a185a?source=---------6------------------">Apache Zeppelin: stairway to notes* haven!</a> and get it to work on your local machine. We will be doing further steps to make it work on the cloud i.e. <a href="http://cloud.oracle.com/">OCI</a>. Just for your information, when the post was written we used Apache Zeppelin 0.8.0, Spark 2.4.3 and ran it on top of GraalVM 1.0.0-rc10, as was bundled in the docker image <a href="https://hub.docker.com/layers/neomatrix369/zeppelin/0.1/images/sha256-0fb412fe5ba7cf69e4cd681786b92cd87f3c73019850238609dce145b0786d51">neomatrix369/zeppelin:0.1</a> since then things have moved on. For this post, we have decided to use more recent versions i.e. Apache Zeppelin 0.8.1, Spark 2.4.4 and GraalVM 19.2.0.1 and you can access this via the docker image <a href="https://hub.docker.com/layers/neomatrix369/zeppelin/0.2/images/sha256-d9b7f16c514ddcfe01d758f84251b5b82b1e06ffc4bd58aeed4582545ea5a00f">neomatrix369/zeppelin:0.2</a>.</p><p><strong><em>Note:</em></strong><em> I have steered away from Apache Zeppelin 0.8.0 and 0.8.2 for this post as it has introduced new things that cause regression in our workflow, for all intent and purpose of this post we can use Apache Zeppelin 0.8.1. Version 0.8.0 produces </em><a href="https://github.com/apache/zeppelin/pull/3206"><em>this error</em></a><em> (resolved in version 0.8.1) when we try to run a paragraph with Scala code.</em></p><p>Also, if you have already noticed, the Zeppelin world call <em>notebooks</em> as <em>notes</em>, <em>cells</em> as <em>paragraphs</em> and so on.</p><h3>Running Apache Zeppelin</h3><p>We will be running <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> on the cloud directly now since we have had the experience of running it on the local machine already. For some of you, this might now be a no-brainer, as the steps are not many and its pretty simple to go about as we have already laid the ground for it. Just to be clear, the same instructions are applicable on a bare-metal or VM instance.</p><h3>Logging into the VM instance</h3><p>You can then <strong><em>ssh</em></strong> into the box (see <a href="https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/accessinginstance.htm?Highlight=ssh">docs on connecting via ssh</a>) and proceed with rest of the actions below:</p><pre>### Oracle Linux and CentOS images, user name: opc<br>### the Ubuntu image, user name: ubuntu</pre><pre>$ ssh -i ~/.ssh/id_rsa ubuntu@132.145.60.249</pre><pre>or</pre><pre>$ ssh ubuntu@132.145.60.249</pre><p>and we get the next prompt, to which we answer ‘yes’:</p><pre>The authenticity of host &#39;132.145.60.249 (132.145.60.249)&#39; can&#39;t be established. <br>ECDSA key fingerprint is SHA256:USafjsySmPItXTdBOsQyiYbEdiFSa7Cs1so+9EnKC4M. <br>Are you sure you want to continue connecting (yes/no)? yes</pre><p>which is followed by this console — a sign that you are now logged into the VM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/0*1EemxavLsIFzN8xH.png" /></figure><h3>Cloning the git repo</h3><p>Now that we are logged in and that we have all the scripts we need at <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/apache-zeppelin">https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/apache-zeppelin</a>, we can clone it and run them.</p><p>If you haven’t this yet, then please run the below commands:</p><pre>$ git clone <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/">https://github.com/neomatrix369/awesome-ai-ml-dl/</a><br>$ cd examples/apache-zeppelin</pre><h3>Installing Docker</h3><p>The Docker docs for installing Docker on Ubuntu can be found on <a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">the Docker site</a>. A bash-script has also been provided to quicken the process, although the target OS here is Ubuntu 16.04 or higher:</p><pre>$ ./installDocker.sh</pre><p><strong><em>Note:</em></strong><em> in case you choose another OS image during VM creation, you will have to install Docker manually with the docs from Docker or modify the above script to make it work for the target OS.</em></p><h3>Building Apache Zeppelin Docker image (optional)</h3><p><strong>Achtung! really sorry, this process can take longer, so please go away and make yourself and others coffee, read </strong><a href="https://www.xkcd.com/"><strong>xkcd</strong></a><strong>, watch a comedy and then come back in 15–20 mins or so (depending on your network bandwidth)!</strong></p><p>Hence we can choose to continue or skip to the next step and use an older version of the docker image:</p><p>We can start by running the build script to build our <a href="https://hub.docker.com/layers/neomatrix369/zeppelin/0.2/images/sha256-d9b7f16c514ddcfe01d758f84251b5b82b1e06ffc4bd58aeed4582545ea5a00f">latest Zeppelin Docker</a> container:</p><pre>$ DOCKER_USER_NAME=&lt;your Docker Hub username&gt; IMAGE_VERSION=0.2 ./buildZeppelinDockerImage.sh</pre><p>and we see these messages flying by:</p><pre>Sending build context to Docker daemon  34.82kB</pre><pre>Step 1/21 : ARG ZEPPELIN_VERSION<br>Step 2/21 : FROM apache/zeppelin:${ZEPPELIN_VERSION}<br>---&gt; 353d7641c769</pre><pre>Step 3/21 : ARG SPARK_VERSION<br>---&gt; Using cache<br>---&gt; 2ca1b6703dd7</pre><pre>Step 4/21 : ENV SPARK_VERSION=${SPARK_VERSION:-2.4.3}<br>---&gt; Using cache<br>---&gt; f507d31d0aca</pre><pre>Step 5/21 : RUN echo &quot;$LOG_TAG Download Spark binary&quot; &amp;&amp;     wget -O /tmp/spark-${SPARK_VERSION}-bin-hadoop2.7.tgz <a href="http://archive.apache.org/dist/spark/spark-$%7BSPARK_VERSION%7D/spark-$%7BSPARK_VERSION%7D-bin-hadoop2.7.tgz">http://archive.apache.org/dist/spark/spark-${SPARK_VERSION}/spark-${SPARK_VERSION}-bin-hadoop2.7.tgz</a><br>---&gt; Running in c94542e7eb00</pre><pre>[ZEPPELIN_0.8.1]: Download Spark binary<br>--2019-10-13 19:55:16--  <a href="http://archive.apache.org/dist/spark/spark-2.4.4/spark-2.4.4-bin-hadoop2.7.tgz">http://archive.apache.org/dist/spark/spark-2.4.4/spark-2.4.4-bin-hadoop2.7.tgz</a><br>Saving to: ‘/tmp/spark-2.4.4-bin-hadoop2.7.tgz’</pre><pre>[--snipped--]</pre><pre>213350K .......... .......... .......... .......... .......... 94% 51.4K 3m0s<br>213400K .......... .......... .......... .......... .......... 94% 88.1K 2m59s<br>213450K .......... .......... .......... .......... .......... 95% 58.7K 2m59s<br>213500K .......... .......... .......... .......... .......... 95% 45.5K 2m58s<br>213550K .......... .......... .......... .......... .......... 95% 4.40M 2m57s<br>213600K .......... .......... .......... .......... .......... 95% 83.8K 2m56s<br>213650K .......... .......... .......... .......... .......... 95% 91.9K 2m55s<br>213700K .......... .......... .......... .......... .......... 95% 67.2K 2m55s<br>213750K .......... .......... .......... .......... .......... 95%  166K 2m54s<br>213800K .......... .......... .......... .......... .......... 95% 79.8K 2m53s</pre><pre>[--snipped--]</pre><pre>Step 21/21 : CMD [&quot;bin/zeppelin.sh&quot;]<br>---&gt; Running in 843684f60302</pre><pre>Removing intermediate container 843684f60302<br>---&gt; 5833f13ff7c7</pre><pre>Successfully built 5833f13ff7c7<br>Successfully tagged neomatrix369/zeppelin:0.2</pre><p>You have noticed, we have a few changes:</p><ul><li>amendments made to Zeppelin-Dockerfile)</li><li>the build and run scripts also looks different (buildZeppelinDockerImage.sh and runZeppelinDockerImage.sh)</li><li>and we are also using to 0.2 see CLI usages in the post</li></ul><p>Hope all of this starts to make sense (I gave hints when we said things have moved on…).</p><h3>Pushing the Docker Image to Docker Hub (optional)</h3><p>Once we have a successfully built the docker image containing Apache Zeppelin from the above step we can easily upload the image from our local repository to the remote one via:</p><pre>$ DOCKER_USER_NAME=&lt;your Docker Hub username&gt; IMAGE_VERSION=0.2 ./push-apache-zeppelin-docker-image-to-hub.sh</pre><p>Although take note that it expects a couple of things:</p><ul><li>an account on Docker Hub (i.e. <a href="https://hub.docker.com/u/neomatrix369">neomatrix369</a>) — <em>of course, your own account</em></li><li>you are logged into your Docker Hub account locally</li><li>you have set up the DOCKER_USER_NAME with your Docker hub account</li></ul><p>Otherwise you will get error messages, hopefully, they will guide you through till you upload it.</p><p><strong><em>Note:</em></strong><em> in our case, we have access to the docker image on Docker hub, see </em><a href="https://hub.docker.com/r/neomatrix369/zeppelin"><em>neomatrix369/zeppelin on Docker Hub</em></a><em>.</em></p><h3>Running Apache Zeppelin from the Docker Image</h3><p>We will download the already created images hosted on Docker Hub:</p><p><strong>Version 0.1 (Apache Zeppelin 0.8.0, Spark 2.4.3, GraalVM 1.0.0-rc10) — older image</strong></p><pre>$ docker pull neomatrix369/zeppelin:0.1<br>$ ./runZeppelinDockerContainer.sh</pre><p><strong>or</strong></p><p><strong>Version 0.2 (Apache Zeppelin 0.8.1, Spark 2.4.4, GraalVM 19.2.0.1) — new image</strong></p><pre>$ docker pull neomatrix369/zeppelin:0.2<br>$ IMAGE_VERSION=0.2 ./runZeppelinDockerContainer.sh</pre><p>the above commands should result in the output:</p><pre>ubuntu@instance-20191014-0101:~/awesome-ai-ml-dl/examples/apache-zeppelin$ IMAGE_VERSION=0.2 ./runZeppelinDockerContainer.sh</pre><pre>Please wait till the log messages stop moving, it will be a sign that the service is ready! (about a minute or so)</pre><pre>Once the service is ready, go to http://localhost:8080 to open the Apache Zeppelin homepage</pre><pre>Pid dir doesn&#39;t exist, create /zeppelin/run</pre><pre>OpenJDK GraalVM CE 19.0.0 warning: ignoring option MaxPermSize=512m; support was removed in 8.0</pre><pre>SLF4J: Class path contains multiple SLF4J bindings.</pre><pre>SLF4J: Found binding in [jar:file:/zeppelin/lib/interpreter/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]</pre><pre>SLF4J: Found binding in [jar:file:/zeppelin/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]</pre><pre>SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.</pre><pre>SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]</pre><pre>[---snipped---]</pre><pre>WARNING: A HTTP GET method, public javax.ws.rs.core.Response org.apache.zeppelin.rest.CredentialRestApi.getCredentials(java.lang.String) throws java.io.IOException,java.lang.IllegalArgumentException, should not consume any entity.</pre><pre>WARNING: The (sub)resource method createNote in org.apache.zeppelin.rest.NotebookRestApi contains empty path annotation.</pre><pre>WARNING: The (sub)resource method getNoteList in org.apache.zeppelin.rest.NotebookRestApi contains empty path annotation.</pre><h4>Opening the Apache Zeppelin notes in your browser</h4><p>Go to the browser and try to open this:</p><pre><a href="http://132.145.60.249:8080/">http://132.145.60.249:8080</a></pre><p>But this won’t work because we haven’t opened up the port 8080 from within our cloud network (via <strong>Ingress Rules, </strong>read more about it <a href="https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/securityrules.htm?Highlight=egress">here</a>) to the outside world (public):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n8zo_AES9IwHJGOh.png" /></figure><p>We would need to add the above entry to the <strong>Ingress Rules</strong> section, you can get to <strong>Ingress Rules</strong> page via the navigation menu: <strong>Networking</strong> &gt; <strong>Virtual Cloud Networks</strong> &gt; <strong>Virtual Cloud Network Details </strong><em>(by clicking on a VCN entry)</em> &gt; <strong>Security Lists, </strong>which brings you to the page with the <strong>Default Security Lists</strong>.<strong> </strong>On clicking the Security List that corresponds to your <strong>Virtual Cloud Network (VCN)</strong> you will land on the above <strong>Ingress Rules</strong> page.</p><p>In case, you are still not able to find it, search for the term <strong><em>security</em></strong><em> </em>using the search facility on any page in the Cloud Console (see the magnifying glass 🔍at the top of the page). This will show you all the <strong>Default Security Lists </strong>and clicking on it will bring you to the <strong>Ingress Rules</strong> page above (you might have just one Security List entry). <strong><em>Note: Ingress means traffic coming into the network/VM instance.</em></strong></p><p>Why port 8080, that’s because we set it up like that in the docker scripts, have a look at the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/apache-zeppelin#apache-zeppelin--">sources</a> to find out why and how.</p><p>Having done all of the above: voila! We see the <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> startup page in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KgMaDrIt107dUpVb.png" /></figure><h3>Using Apache Zeppelin notes</h3><p>Take a look at the section <strong>Importing a note</strong> in <a href="https://medium.com/@neomatrix369/apache-zeppelin-stairway-to-notes-haven-28ec413a185a?source=---------6------------------">Apache Zeppelin: stairway to notes* haven!</a> this section onwards you can see how to import existing notes and execute them. Once we import and open a <em>note</em>, and run it, it would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U8xjozZ3PYdvcTlt.png" /></figure><p>Importing this note also creates a <em>“notes.json”</em> file in the <em>~/awesome-ai-ml-dl/examples/apache-zeppelin/notebook</em> folder of the VM instance.</p><p>Further examples can be found on <a href="https://github.com/dylanmei/docker-zeppelin">https://github.com/dylanmei/docker-zeppelin</a>, although these would need additional installation and configuration to the <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> build.</p><h3>Create a custom image for reuse</h3><p>As we have been able to successfully run <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> from inside a VM instance, we can save this image for future re-use or share with others. Before doing that, I would delete the <strong><em>logs</em></strong> and <strong><em>notebook</em></strong> folders from the <em>~/awesome-ai-ml-dl/examples/apache-zeppelin</em> of the VM instance.</p><p>Creating an image of the VM instance can be done via <strong>Compute&gt; Instances &gt; Instance Details</strong> the navigation menu, and Create Custom Image from the Actions drop-down menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HUsKbtETaEfCds5P.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/0*IjnhYApjwAmPsuvc.png" /></figure><p><strong><em>Note:</em></strong><em> whilst in the process of creating a custom image, your original VM instance is shut-down. This can take under a couple of minutes to complete depending on the size of the original VM instance.</em></p><p>When successfully created, it becomes available among the list of Custom Images to choose from, the next time we go to create a new VM instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jTbBXaxX7we3N2RN.png" /></figure><h3>Power-user</h3><p>If all of this was piece of cake for you or you have survived without much hassle, then try out all the deep-dive stuff mentioned in the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/JuPyteR#jupyter">README page here</a>.</p><p>To be able to code in other JVM languages in the <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> environment all you need is additional extensions — it’s only a matter of installing and configuring. You can learn all about them <a href="https://zeppelin.apache.org/docs/0.5.6-incubating/manual/interpreters.html">here</a>, you can see you can also code in Python on <a href="http://zeppelin.apache.org/">Apache Zeppelin</a>. Find out how you can write your <a href="https://zeppelin.apache.org/docs/0.5.6-incubating/development/writingzeppelininterpreter.html">own interpreters for Apache Zeppelin</a>. Both the notebook and interpreters can be accessed via <a href="https://zeppelin.apache.org/docs/0.5.6-incubating/rest-api/rest-notebook.html">Notebook API</a> and <a href="https://zeppelin.apache.org/docs/0.5.6-incubating/rest-api/rest-interpreter.html">Interpreter API</a> respectively.</p><h3>Signing off</h3><pre>[--snipped--]</pre><pre>Oct 14, 2019 1:02:40 AM org.glassfish.jersey.internal.Errors logErrors<br>WARNING: The following warnings have been detected: WARNING: A HTTP GET method, public javax.ws.rs.core.Response org.apache.zeppelin.rest.InterpreterRestApi.listInterpreter(java.lang.String), should not consume any entity.<br>WARNING: A HTTP GET method, public javax.ws.rs.core.Response org.apache.zeppelin.rest.CredentialRestApi.getCredentials(java.lang.String) throws java.io.IOException,java.lang.IllegalArgumentException, should not consume any entity.<br>WARNING: The (sub)resource method createNote in org.apache.zeppelin.rest.NotebookRestApi contains empty path annotation.<br>WARNING: The (sub)resource method getNoteList in org.apache.zeppelin.rest.NotebookRestApi contains empty path annotation.</pre><pre>^C</pre><p>In case, you have created a note, it gets saved in the sub-directory called (apache zeppelin directory), you can retrieve this using <strong><em>scp</em></strong> from your local machine (see <a href="https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/">here</a> on how to do that).</p><p>Make sure you have <strong><em>signed out of both</em></strong> the <a href="http://oracle.com/">oracle.com</a> and <a href="http://cloud.oracle.com/">cloud.oracle.com</a> login sessions, it’s easy to forget one or the other. But before doing that please also have a look at the <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/terminating_resources.htm">Cleaning up of resources</a> page in the docs — you don’t want your instance running forever while you are not looking at it!</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*0MJQb42w8rQfEZQ0" /></figure><p>After doing this, it looks like a no brainer to run a notebook service i.e. <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> on a cloud provider like <a href="http://cloud.oracle.com/">OCI</a> (<a href="http://cloud.oracle.com/">Oracle Cloud Infrastructure</a>).</p><p>In effect, if we summarise the conclusions of the two posts, <a href="https://medium.com/@neomatrix369/apache-zeppelin-stairway-to-notes-haven-28ec413a185a?source=---------6------------------">Apache Zeppelin: stairway to notes* haven!</a> and <a href="https://medium.com/@neomatrix369/running-your-jupyter-notebooks-on-the-cloud-ed970326649f?source=---------4------------------">Running your JuPyTer notebooks on Oracle Cloud Infrastructure</a> we will more or less say:</p><p>Apache Zeppelin gives us:</p><ul><li>similar flexibility as Jupyter notebooks, and allows extending functionality via configurations and extensions</li><li>execution progress per paragraph (per cell) is always displayed (in real-time) unlike Jupyter notebooks</li><li>lazy execution to help efficiency</li><li>round-trip navigability between table data and visualisation in the cell (paragraph)</li><li>execution may appear a bit slower than Jupyter notebooks at times</li><li>but there are solutions to speed this up (for future posts to cover)</li><li>all-in-all a great place for Java/JVM developers to feel at home and do ML experiments on the JVM</li></ul><p><a href="http://cloud.oracle.com/">OCI</a> gives us:</p><ul><li>an easy-to-use cloud environment</li><li>quickly set up our environment to get to market with our apps and solutions we want to bring to market quick</li><li>enables us to run <a href="http://zeppelin.apache.org/">Apache Zeppelin</a> (natively or via Docker image)</li><li>instances that can be shared publicly or privately depending on your network security settings</li><li>provides ways to secure your infrastructure on the cloud (we didn’t cover it with much depth here), but please check out the docs on <a href="https://docs.cloud.oracle.com/iaas/Content/Security/Concepts/security.htm">Security on the OCI docs page</a> to learn more.</li></ul><p><strong><em>Please keep an eye on this space, and share your comments, feedback or any contributions which will help us all learn and grow to </em></strong><a href="http://twitter.com/@theNeomatrix369"><strong><em>@theNeomatrix369</em></strong></a><strong>, <em>you can find more about me via the</em> </strong><a href="http://neomatrix369.worpress.com/aboutme"><strong><em>About me page</em></strong></a><strong><em>.</em></strong></p><h3>Resources</h3><p><strong>Apache Zeppelin</strong></p><ul><li><a href="http://zeppelin.apache.org/">Apache Zeppelin</a></li><li><a href="https://zeppelin.apache.org/docs/0.6.0/development/writingzeppelininterpreter.html">an interpreter for that thing has been provided</a></li><li><a href="https://zeppelin.apache.org/download.html">Download page</a></li><li>Apache Zeppelin: <a href="https://zeppelin.apache.org/docs/0.8.0/quickstart/install.html">Quick Start page</a></li><li><a href="https://zeppelin.apache.org/docs/0.8.0/quickstart/explore_ui.html">Exploring Zeppelin UI</a></li><li><a href="https://issues.apache.org/jira/browse/ZEPPELIN-3586">https://issues.apache.org/jira/browse/ZEPPELIN-3586</a></li><li><a href="https://gist.github.com/conker84/4ffc9a2f0125c808b4dfcf3b7d70b043#file-zeppelin-dockerfile">https://gist.github.com/conker84/4ffc9a2f0125c808b4dfcf3b7d70b043#file-zeppelin-dockerfile</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/apache-zeppelin">https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/apache-zeppelin</a></li><li><a href="https://zeppelin.apache.org/docs/0.5.6-incubating/development/writingzeppelininterpreter.html">Write your own interpreters for Apache Zeppelin</a></li><li><a href="https://zeppelin.apache.org/docs/0.5.6-incubating/rest-api/rest-notebook.html">Notebook API</a></li><li><a href="https://zeppelin.apache.org/docs/0.5.6-incubating/rest-api/rest-interpreter.html">Interpreter API</a></li><li><strong><em>Examples to try</em></strong></li><li><a href="https://github.com/dylanmei/docker-zeppelin">https://github.com/dylanmei/docker-zeppelin</a></li><li><a href="https://github.com/mmatloka/machine-learning-by-example-workshop">https://github.com/mmatloka/machine-learning-by-example-workshop</a></li><li><a href="https://raw.githubusercontent.com/mmatloka/machine-learning-by-example-workshop/master/Workshop.json">https://raw.githubusercontent.com/mmatloka/machine-learning-by-example-workshop/master/Workshop.json</a></li></ul><p><strong>Docker</strong></p><ul><li><a href="https://hub.docker.com/signup">Docker Hub signup</a></li><li><a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">Install Docker on Ubuntu 16.04 or higher</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/apache-zeppelin/buildZeppelinDockerImage.sh">Bash Script to build Docker container</a></li><li><a href="https://www.javaadvent.com/2018/12/apache-zeppelin-stairway-to-notes-haven.html"><em>https://github.com/dylanmei/docker-zeppelin</em></a><em>.</em></li></ul><p><strong>OCI/Cloud</strong></p><ul><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Concepts/baremetalintro.htm">Getting Started</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Reference/overviewworkflow.htm">Tutorial to setup a VM instance</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliinstall.htm">Install CLI</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/API/Concepts/cliconcepts.htm?Highlight=CLI">CLI docs</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/terminating_resources.htm">Cleaning up of resources</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/accessinginstance.htm?Highlight=ssh">Docs on connecting via ssh to OCI</a></li><li>New Sign-in: <a href="https://cloud.oracle.com/en_US/sign-in">https://cloud.oracle.com/en_US/sign-in</a></li><li>Traditional Sign-in: <a href="https://myaccount.cloud.oracle.com/">https://myaccount.cloud.oracle.com/</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/contactingsupport.htm">Contact Support</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/devtoolshome.htm?tocpath=Developer%20Tools%20%7C_____0">Developer Tools</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/home.htm">Documentation</a></li><li><a href="https://cloudcustomerconnect.oracle.com/resources/9c8fa8f96f/summary">Oracle Cloud Community Forum</a></li><li><a href="https://cloud.oracle.com/en_US/cloud-compliance">Oracle Cloud Compliance</a></li><li><a href="https://blogs.oracle.com/cloud-infrastructure/">Oracle Cloud Infrastructure Blog</a></li></ul><p><strong>Security</strong></p><ul><li><a href="https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/securityrules.htm?Highlight=egress">Security Rules / Ingress Rules</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/Security/Concepts/security.htm">OCI Security docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0aecc79597a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/running-apache-zeppelin-on-oracle-cloud-infrastructure-b0aecc79597a">Running Apache Zeppelin on Oracle Cloud Infrastructure</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running your JuPyTeR notebooks on the cloud]]></title>
            <link>https://medium.com/oracledevs/running-your-jupyter-notebooks-on-the-cloud-ed970326649f?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed970326649f</guid>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[graalvm]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Sun, 08 Sep 2019 17:18:08 GMT</pubDate>
            <atom:updated>2019-09-15T14:51:15.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/416/0*_73ULqxQfyJdht1Z.jpg" /></figure><h3>Introduction</h3><p>On the back of my previous share on how to <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/JuPyteR#jupyter">build and run a docker container with Jupyter</a>, I’ll be taking this further on how we can make this run on a cloud platform.</p><p>We’ll try to do this on <a href="http://cloud.oracle.com/">Oracle Cloud Infrastructure (OCI)</a>. In theory, we should be able to do everything in the blog on any VM or Baremetal instance. If you are new to Oracle Cloud, I would suggest getting familiar with the <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Concepts/baremetalintro.htm">docs</a> and <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Concepts/baremetalintro.htm">Getting Started</a> sections of the <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Concepts/baremetalintro.htm">docs</a>. You will also find several informative links at the bottom of this post, in the <strong>Resources</strong> section.</p><p>I found the <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Reference/overviewworkflow.htm">tutorial to setup a VM instance</a> simple and useful — I recommend having a glance and following the steps. Take note of the pre-requisites before actually getting downing to creating a VM instance and <strong><em>ssh</em></strong>-ing into it — it will involve Creating Compartments, Subnets, Security Lists, among other things before you can create a VM.</p><h3>Signing up</h3><p>You will have noticed you have to have an account to be able to get access to the Cloud Dashboard and proceed.</p><p>You can sign up by going to <a href="http://oracle.com/">oracle.com</a> and also to <a href="https://myservices.us.oraclecloud.com/mycloud/signup?sourceType=_ref_coc-asset-opcSignIn&amp;language=en">cloud.oracle.com</a> — recommend signing up via these portals. You might even be eligible for <strong>FREE</strong> credits once you do that (enough to spend your weekend running your favourite instances).</p><h3>Setup</h3><p><strong>Dashboard — sign-in</strong></p><p>Once you are signed up, you sign-in via <a href="https://cloud.oracle.com/sign-in">cloud.oracle.com/sign-in</a> which will take you to a page like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bmsehoRRIZ3BXe5F.png" /></figure><p>Follow the instructions as described in the <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Reference/overviewworkflow.htm">tutorial to setup a VM instance</a> and give your VM and other resources names (use initials as a prefix) you can identify easily. This will kick off the request to create the VM (if all your entries are valid) — and in less than 15 seconds you should have a VM ready to be used.</p><p>Once the VM instance is created, make a note of the <strong>Public IP Address</strong> of the instance. All running VMs can be found on by going to the <strong>Compute &gt; Instance </strong>on the navigation menu on the left:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/0*g0NsbLE6B-oy_Pva.png" /></figure><p>Select the running VM by clicking it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fSnyOupmBeemvNPVWMMFgw.png" /></figure><p>which will take you to the VM details page, where you can spot the <strong>Public IP Address</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oBRoXojahvyHq11qL3XIxQ.png" /></figure><p><strong><em>Note: the Public IP Address will be different for every VM created, the above is temporary.</em></strong></p><p><strong>CLI</strong></p><p>OCI can be accessed with a command-line tool called <strong>oci-cli</strong> which can be <a href="https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliinstall.htm">installed by following instructions</a> mention in the <a href="https://docs.cloud.oracle.com/iaas/Content/API/Concepts/cliconcepts.htm?Highlight=CLI">CLI docs</a>. Once installed the command to invoke it is called <strong>oci</strong> and you can invoke it by doing the below:</p><h3>Actions to get on the cloud</h3><pre>$ oci --help</pre><pre>Usage: oci [OPTIONS] COMMAND [ARGS]...</pre><pre>Oracle Cloud Infrastructure command line interface, with support for<br>Audit, Block Volume, Compute, Database, IAM, Load Balancing, Networking, DNS, File Storage, Email Delivery and Object Storage Services.</pre><pre>Most commands must specify a service, followed by a resource type and then an action. For example, to list users (where $T contains the OCID of the current tenant):</pre><pre>oci iam user list --compartment-id $T</pre><pre>Output is in JSON format.</pre><pre>For information on configuration, see<br><a href="https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm">https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm</a>.</pre><pre>Options:<br>&lt;-- snipped --&gt;</pre><pre>Commands:<br>&lt;-- snipped --&gt;</pre><p>As such we won’t need the dashboard for the most part here onwards. We will also NOT be covering the use of the CLI tool in this post.</p><p><strong>Logging into the VM instance</strong></p><p>You can then <strong><em>ssh</em></strong> into the box (see <a href="https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/accessinginstance.htm?Highlight=ssh">docs on connecting via ssh</a>) and proceed with rest of the actions below:</p><pre>### Oracle Linux and CentOS images, user name: opc<br>### the Ubuntu image, user name: ubuntu</pre><pre>$ ssh -i ~/.ssh/id_rsa ubuntu@132.145.78.136</pre><pre>or</pre><pre>$ ssh ubuntu@132.145.78.136</pre><p><strong>Installing git</strong></p><p>For this blog post, we selected the <strong>Canonical Ubuntu Linux </strong>(<em>Canonical-Ubuntu-16.04–2019.08.14–0</em>) as our OS image, which comes with <strong><em>apt-get </em></strong>and <strong><em>git</em></strong> installed so we don’t need to do anything there.</p><h3>Running Jupyter Notebooks</h3><p><strong>Cloning our repo</strong></p><p>We can clone our repo and perform the rest of the steps:</p><pre>$ git clone <a href="https://github.com/neomatrix369/awesome-ai-ml-dl">https://github.com/neomatrix369/awesome-ai-ml-dl</a><br>$ cd awesome-ai-ml-dl/examples/JuPyteR</pre><p><strong>Installing Docker</strong></p><p>The Docker docs for installing Docker on Ubuntu can be found on <a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">the Docker site</a>. A bash-script has also been provided to quicken the process, although the target OS here is Ubuntu 16.04 or higher:</p><pre>$ cd build-docker-image<br>$ ./installDocker.sh</pre><p><strong><em>Note:</em></strong><em> in case you choose another OS image during VM creation, you will have to install Docker manually with the docs from Docker or modify the above script to make it work for the target OS.</em></p><p><strong>Building the Jupyter Docker Image</strong></p><pre>$ cd build-docker-image<br>$ sudo ./buildDockerImage.sh</pre><p><em>In this specific environment, we need to pass the </em><strong><em>sudo</em></strong><em> keyword before every docker command. You may not have to do that in your local environment or elsewhere.</em></p><p><strong>Running the Jupyter notebook as a Docker container</strong></p><pre>$ cd [back into the project root folder]<br>$ sudo ./runDockerContainer.sh</pre><p>This will show you a console like this:</p><pre>&lt;--- snipped ---&gt;</pre><pre>OpenJDK Runtime Environment (build 9.0.4+11)<br>OpenJDK 64-Bit Server VM (build 9.0.4+11, mixed mode)<br>PATH=/home/jupyter/.local/bin:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</pre><pre>~~~ JDK9, Linux only: We are enabling JVMCI flags (enabling Graal as Tier-2 compiler) ~~~<br>~~~ Graal setting: please check docs for higher versions of Java and for other platforms ~~~<br>JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler<br>JAVA_TOOL_OPTIONS=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler</pre><pre>Available kernels:<br>  python2    /home/jupyter/.local/share/jupyter/kernels/python2<br>  java       /usr/share/jupyter/kernels/java</pre><pre>[I 13:39:35.993 NotebookApp] Writing notebook server cookie secret to /home/jupyter/.local/share/jupyter/runtime/notebook_cookie_secret<br>[I 13:39:36.293 NotebookApp] Serving notebooks from local directory: /home/jupyter<br>[I 13:39:36.294 NotebookApp] The Jupyter Notebook is running at:<br>[I 13:39:36.295 NotebookApp] <a href="http://(81dde8675279/">http://(81dde8675279</a> or 127.0.0.1):8888/?token=bb0c81ef7e9f3932355b953163702aa2d9f75e18005e6e48<br>[I 13:39:36.297 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).<br>[C 13:39:36.310 NotebookApp]</pre><pre>To access the notebook, open this file in a browser:<br>        file:///home/jupyter/.local/share/jupyter/runtime/nbserver-28-open.html<br>    Or copy and paste one of these URLs:<br>        <a href="http://(81dde8675279/">http://(81dde8675279</a> or 127.0.0.1):8888/?token=bb0c81ef7e9f3932355b953163702aa2d9f75e18005e6e48</pre><p>Make a note of the URL, and replace the <em>127.0.0.1</em> with your <strong>Public IP Address </strong>i.e. <em>132.145.78.136</em>.</p><p>You can also see from the above logs we are using Java 9 (built on the <a href="http://adoptopenjdk.net/">AdoptOpenJDK</a> farm) and enabling the <a href="https://github.com/oracle/graal/blob/master/compiler/README.md">GraalVM compiler</a> as HotSpot’s <a href="http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html">C2 compiler</a> (see <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/JuPyteR/README.md#switches-to-enable-the-graalvm-compiler-in-java-9">Switches to enable the GraalVM compiler in Java 9</a> to enabled the <a href="https://github.com/oracle/graal/blob/master/compiler/README.md">GraalVM compiler</a>). It’s also because the <a href="https://github.com/SpencerPark/IJava">Java extension for Jupyter</a> requires Java 9 or higher to work.</p><p><strong>Opening the Jupyter notebook in your browser</strong></p><p>Go to the browser and try to open this:</p><pre><a href="http://132.145.78.136:8888/?token=bb0c81ef7e9f3932355b953163702aa2d9f75e18005e6e48">http://132.145.78.136:8888/?token=bb0c81ef7e9f3932355b953163702aa2d9f75e18005e6e48</a></pre><p>Aargh! It does NOT work!</p><p>That is because we haven’t opened up the port 8888 from within our cloud network (via <strong>Ingress Rules, </strong>read more about it <a href="https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/securityrules.htm?Highlight=egress">here</a>) to the outside world (public):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*40xrtw73GvkKkIgK.png" /></figure><p>We would need to add the above entry to the <strong>Ingress Rules</strong> section, you can get to <strong>Ingress Rules</strong> page via the navigation menu: <strong>Networking</strong> &gt; <strong>Virtual Cloud Networks</strong> &gt; <strong>Virtual Cloud Network Details</strong> &gt; <strong>Security Lists, </strong>which brings you to the page with the <strong>Default Security Lists</strong>.<strong> </strong>On clicking the Security List that corresponds to your <strong>Virtual Cloud Network (VCN)</strong> you will land on the above <strong>Ingress Rules</strong> page.</p><p>In case, you are still not able to find it, search for the term <strong><em>security</em></strong><em> </em>using the search facility on any page in the Cloud Console (see the magnifying glass 🔍at the top of the page). This will show you all the <strong>Default Security Lists </strong>and clicking on it will bring you to the <strong>Ingress Rules</strong> page above (you might have just one Security List entry). <strong><em>Note: Ingress means traffic coming into the network/VM instance.</em></strong></p><p>Why port 8888, that’s because we set it up like that in the docker scripts, have a look at the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/JuPyteR#jupyter">sources</a> to find out why and how.</p><p>Having done all of the above: voila! We see the Jupyter startup page in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iMaX8fhr3Kd_Jdrp.png" /></figure><p>And you can see a Java-based notebook is available to play with! Try out the below by creating a new Java notebook in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rquvjgoX8Ra1QT0K.png" /></figure><p><a href="https://github.com/ligee/kotlin-jupyter/raw/master/samples/ScreenShotInJupyter.png">https://github.com/ligee/kotlin-jupyter/raw/master/samples/ScreenShotInJupyter.png</a></p><p>You are free to create Python notebooks as well, not just Java ones — this is the beauty of Jupyter notebooks.</p><h3>Installing Jupyter on a bare-metal or VM environment</h3><p>For brevity, we didn’t cover this aspect, but if you look at the scripts associated with building and running the Jupyter instance, you will see that the docker build scripts build and run the instance with the help of individual scripts that can be executed on its own in this order:</p><pre>$ cd build-docker-image<br>$ [<em>install Java 9 SDK and set the PATH and JAVA_HOME]</em><br>$ ./install-jupyter-notebooks.sh<br>$ ./install-java-kernel.sh<br>$ ./runLocal.sh</pre><p>If you want to see how this would work, run the above scripts in the local environment of the instance, the rest of the instructions should work as expected.</p><h3>Create custom image for reuse</h3><p>As we have been able to successfully run Jupyter Notebook from inside a VM instance, we can save this image for future re-use or share with others. Creating an image of the VM instance can be done via <strong>Compute&gt; Instances &gt; Instance Details</strong> the navigation menu, and Create Custom Image from the Actions drop-down menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0c2CNpEQ4DBVE8mP6If4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*zhaCtQeh4_h4IICLqRKRyw.png" /></figure><p><strong><em>Note:</em></strong><em> whilst in the process of creating a custom image, your original VM instance is shut-down. This can take under a couple of minutes to complete depending on the size of the original VM instance.</em></p><p>When successfully created, it becomes available among the list of Custom Images to choose from, the next time we go to create a new VM instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*waim__0FsC1ApNoRnqwj8w.png" /></figure><h3>Power-user</h3><p>If all of this was piece of cake for you or you have survived without much hassle, then try out all the deep-dive stuff mentioned in the <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/JuPyteR#jupyter">README page here</a>.</p><p>To be able to code in other languages in the Jupyter environment all you need is a Jupyter extension — it’s only a matter of installing and configuring. You can learn all about this <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/JuPyteR#get-started-manual-steps-via-cli">here</a>.</p><h3>Signing off</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gRwXOOQ8q2TtHmnO.png" /></figure><p>In case you have created a notebook, it gets saved in the sub-directory called <em>jupyter/notebooks</em>, you can retrieve this using <strong><em>scp</em></strong> from your local machine (see <a href="https://linuxize.com/post/how-to-use-scp-command-to-securely-transfer-files/">here</a> on how to do that).</p><p>Make sure you have <strong><em>signed out of both</em></strong> the <a href="http://oracle.com/">oracle.com</a> and <a href="http://cloud.oracle.com/">cloud.oracle.com</a> login sessions, it’s easy to forget one or the other. But before doing that please also have a look at the <a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/terminating_resources.htm">Cleaning up of resources</a> page in the docs — you don’t want your instance running forever while you are not looking at it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*5nGRERE0QjgFgfD-" /></figure><h3>Conclusion</h3><p>A good set of scripts (including Docker) and an easy-to-use cloud environment can help in many ways. In this case, enabling us to run a Jupyter notebook instance that can be shared publicly or privately depending on your network security settings.</p><p>The Jupyter environment is flexible and allows extending functionality via configurations and extensions.</p><p>We didn’t cover things like cloud security and partitioning of user instances — which is sort of out of scope for this post. Please look into this further, if they are important to you. Please do ensure it meets the necessary levels of security for your application or use-case. Check out the docs on <a href="https://docs.cloud.oracle.com/iaas/Content/Security/Concepts/security.htm">Security on the OCI docs page</a> to learn more.</p><h3>Resources</h3><p><strong>General</strong></p><ul><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/tree/master/examples/JuPyteR#jupyter">Build and run a docker container with Jupyter</a></li><li><a href="http://github.com/neomatrix369/awesome-graal">Awesome Graal</a></li><li><a href="http://github.com/neomatrix369/awesome-ai-ml-dl">Awesome AI-ML-DL</a></li></ul><p><strong>Docker</strong></p><ul><li><a href="https://hub.docker.com/signup">Docker Hub signup</a></li><li><a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">Install Docker on Ubuntu 16.04 or higher</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/JuPyteR/buildJuPyteRDockerImage.sh">Bash Script to build Docker container</a></li></ul><p><strong>OCI/Cloud</strong></p><ul><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Concepts/baremetalintro.htm">Getting Started</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Reference/overviewworkflow.htm">Tutorial to setup a VM instance</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliinstall.htm">Install CLI</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/API/Concepts/cliconcepts.htm?Highlight=CLI">CLI docs</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/terminating_resources.htm">Cleaning up of resources</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/accessinginstance.htm?Highlight=ssh">Docs on connecting via ssh to OCI</a></li><li>New Sign-in: <a href="https://cloud.oracle.com/en_US/sign-in">https://cloud.oracle.com/en_US/sign-in</a></li><li>Traditional Sign-in: <a href="https://myaccount.cloud.oracle.com/">https://myaccount.cloud.oracle.com/</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/GSG/Tasks/contactingsupport.htm">Contact Support</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/devtoolshome.htm?tocpath=Developer%20Tools%20%7C_____0">Developer Tools</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/home.htm">Documentation</a></li><li><a href="https://cloudcustomerconnect.oracle.com/resources/9c8fa8f96f/summary">Oracle Cloud Community Forum</a></li><li><a href="https://cloud.oracle.com/en_US/cloud-compliance">Oracle Cloud Compliance</a></li><li><a href="https://blogs.oracle.com/cloud-infrastructure/">Oracle Cloud Infrastructure Blog</a></li></ul><p><strong>Security</strong></p><ul><li><a href="https://docs.cloud.oracle.com/iaas/Content/Network/Concepts/securityrules.htm?Highlight=egress">Security Rules / Ingress Rules</a></li><li><a href="https://docs.cloud.oracle.com/iaas/Content/Security/Concepts/security.htm">OCI Security docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed970326649f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/running-your-jupyter-notebooks-on-the-cloud-ed970326649f">Running your JuPyTeR notebooks on the cloud</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do Deep Learning for Java?]]></title>
            <link>https://medium.com/data-science/how-to-do-deep-learning-for-java-on-the-valohai-platform-eec8ba9f71d8?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/eec8ba9f71d8</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Fri, 30 Aug 2019 18:32:46 GMT</pubDate>
            <atom:updated>2020-11-01T22:05:59.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*wMzchr59FY8hDZA8" /><figcaption><a href="https://unsplash.com/photos/jEqyV_rumuU"><em>Image</em></a><em> source (unsplash) via </em><a href="https://unsplash.com/@biscket">Praveen Thotagamuwa</a></figcaption></figure><h3>Introduction</h3><p>Some time ago I came across this life-cycle management tool (or cloud service) called <a href="https://valohai.com/">Valohai</a> and I was quite impressed by its user-interface and simplicity of design and layout. I had a good chat about the service at that time with one of the members of <a href="https://valohai.com/">Valohai</a> and was given a demo. Previous to that I had written a simple pipeline using <a href="https://www.gnu.org/software/parallel/">GNU Parallel</a>, JavaScript, Python and Bash — and another one purely using <a href="https://www.gnu.org/software/parallel/">GNU Parallel</a>, and Bash. Also thought about replacing the moving parts with ready-to-use task/workflow management tools like Jenkins X, Jenkins Pipeline, Concourse or Airflow but due to various reasons, I did not proceed with the idea.</p><p>Coming back to our original conversation, I noticed a lot of the examples and docs on <a href="https://valohai.com/">Valohai</a> were based on Python, R and the respective frameworks and libraries. There was a lack of Java/JVM based examples or docs. So I took this opportunity to do something about that.</p><p>I was encouraged by <a href="https://valohai.com/">Valohai</a> to implement something using the famous Java library called <a href="https://deeplearning4j.org/">DL4J — Deep Learning for Java</a>.</p><p>My initial experience with <a href="https://valohai.com/">Valohai</a> already gave me a good impression after getting an understanding of its design, layout and workflow. That it was developer-friendly and the makers already took into consideration various facets of both developer and infrastructure workflows. In our worlds, the latter is mostly run by DevOps or SysOps teams and we know the nuances and pain-points attached to it. You can find out more about its features from the <a href="https://valohai.com/features/">Features section</a> of the site.</p><p><strong>Achtung!</strong> Just to let you know that from here onwards the post will be a bit more technical and may contain code snippets and mention of deep learning/machine learning and infrastructure-related terminologies.</p><h3>What do we need and how?</h3><p>For any machine learning or deep learning project or initiative, these days the two important components (from a high-level perspective) are code that will create and serve the model and infrastructure where this whole life-cycle will be executed.</p><p>Of course, there are going to be steps and components needed before, during and after the above, but to keep things simple let’s say we need code and infrastructure.</p><p><strong>Code</strong></p><p>For code I have chosen a modified example using DL4J, it’s an <a href="https://en.wikipedia.org/wiki/MNIST_database">MNist project</a> with a training set of 60,000 images and test set of 10,000 images of hand-written digits. This dataset is available via the DL4J library (just like <a href="https://keras.io/">Keras</a> provides a stock of them). Look for the <a href="https://github.com/eclipse/deeplearning4j/blob/master/deeplearning4j/deeplearning4j-data/deeplearning4j-datasets/src/main/java/org/deeplearning4j/datasets/iterator/impl/MnistDataSetIterator.java">MnistDataSetIterator</a> under <a href="https://github.com/eclipse/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/iterator/DataSetIterator.java">DatasetIterators</a> in the <a href="https://deeplearning4j.org/docs/latest/deeplearning4j-cheat-sheet">DL4J Cheatsheet</a> for further details on this particular dataset.</p><p>Have a look at the source code we will be using before getting started, the main Java class is called <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/cloud-devops-infra/valohai/MLPMnist/src/main/java/org/deeplearning4j/feedforward/mnist/MLPMnistSingleLayerRunner.java">org.deeplearning4j.feedforward.mnist.MLPMnistSingleLayerRunner</a>.</p><p><strong>Infrastructure</strong></p><p>As it is obvious by now, we have decided to try out the Java example using <a href="https://valohai.com/">Valohai</a> as our infrastructure to run our experiments (training and evaluation of the model). <a href="https://valohai.com/">Valohai</a> recognizes git repositories and directly hooks into them and allows execution of our code, irrespective of platform or language — we will see how this works. This also means if you are a strong supporter of GitOps or Infrastructure-As-Code you will appreciate the workflow.</p><p>For this we just need an account on <a href="https://valohai.com/">Valohai</a>, we can avail a <a href="https://valohai.com/pricing/">Free-tier account</a> and have access to several instances of various configurations when we <a href="https://app.valohai.com/accounts/signup/">sign up</a>. See Free-tier under <a href="https://valohai.com/pricing/">Plans and Pricing</a> and the comparison chart for more details. For what we would like to do, the Free-tier is more than enough for now.</p><h3>Deep Learning for Java and Valohai</h3><p>As we agreed, we’re going to use these two technologies to achieve our goal of training a single layer model and evaluating it, as well as seeing what the end-to-end experience is like on <a href="https://valohai.com/">Valohai</a>.</p><p>We will bundle the necessary build and run-time dependencies into the Docker image and use it to build our Java app, train a model and evaluate it on the <a href="https://valohai.com/">Valohai</a> platform via a simple <a href="https://github.com/valohai/mlpmnist-dl4j-example/blob/master/valohai.yaml">valohai.yaml</a> file which is placed in the root folder of the project repository.</p><h3>Deep Learning for Java: DL4J</h3><p>The easy part is, we won’t need to do much here, just build the jar and download the dataset into the Docker container. We have a pre-built Docker image that contains all the dependencies needed to build a Java app. We have pushed this image into <a href="https://hub.docker.com/">Docker Hub</a>, you can find it by searching for <a href="https://hub.docker.com/r/neomatrix369/dl4j-mnist-single-layer">dl4j-mnist-single-layer</a> (we will be using a specific tag as defined in the YAML file). We have chosen to use <a href="https://github.com/oracle/graal">GraalVM 19.1.1</a> as our Java build and runtime for this project, and so it is embedded into the Docker image (see <a href="https://github.com/valohai/mlpmnist-dl4j-example/blob/master/Dockerfile">Dockerfile</a> for the definition of the Docker image). To learn more about GraalVM check out the resources at the official site of <a href="https://www.graalvm.org/">graalvm.org</a> and <a href="https://github.com/neomatrix369/awesome-graal">Awesome Graal</a>.</p><p><strong>Orchestration</strong></p><p>When the uber jar is invoked from the command-line, we land into the MLPMnistSingleLayerRunner class which directs us to the intended action depending on the parameters passed in:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16807810eb189cd43855e50805a0b5eb/href">https://medium.com/media/16807810eb189cd43855e50805a0b5eb/href</a></iframe><p>The parameters passed into the uber jar are received by this class and handled by the execute() method.</p><p>We can create a model via the --action train parameter and evaluate the created model via the --action evaluate parameter respectively passed to the Java app (uber jar).</p><p>The main parts of the Java app that does this work can be found in the two Java classes mentioned in the sections below.</p><p><strong>Train a model</strong></p><p>Can be invoked from the command-line via:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20e3ef8d8a5ac984de56eaff08e59a99/href">https://medium.com/media/20e3ef8d8a5ac984de56eaff08e59a99/href</a></iframe><p>This creates the model (when successful, at the end of the execution) by the name mlpmnist-single-layer.pb in the folder specified by the --output-dir passed in at the beginning of the execution. From the perspective of <a href="https://valohai.com/">Valohai</a>, it should be placed into the ${VH_OUTPUTS_DIR} which is what we do (see <a href="https://github.com/valohai/mlpmnist-dl4j-example/blob/master/valohai.yaml">valohai.yaml</a> file).</p><p>For source code, see class <a href="https://github.com/valohai/mlpmnist-dl4j-example/blob/master/src/main/java/org/deeplearning4j/feedforward/mnist/MLPMnistSingleLayerTrain.java">MLPMNistSingleLayerTrain.java</a>.</p><p><strong>Evaluate a model</strong></p><p>Can be invoked from the command-line via:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/875aa5ae4dfdd7e891acc6f11aeb6358/href">https://medium.com/media/875aa5ae4dfdd7e891acc6f11aeb6358/href</a></iframe><p>This expects a model (created by the training step) by the name mlpmnist-single-layer.pb to be present in the folder specified by the --input-dir passed in when the app has been called.</p><p>For source code, see class <a href="https://github.com/valohai/mlpmnist-dl4j-example/blob/master/src/main/java/org/deeplearning4j/feedforward/mnist/MLPMnistSingleLayerEvaluate.java">MLPMNistSingleLayerEvaluate.java</a>.</p><p>I hope this short illustration makes it clear how the Java app that trains and evaluates the model works in general.</p><p>That’s all is needed of us, but feel free to play with the rest of the <a href="https://github.com/valohai/mlpmnist-dl4j-example">source</a> (along with the <a href="https://github.com/valohai/mlpmnist-dl4j-example#mlpmnist-dl4j-example-mlpmnist-single-layer-">README.md</a> and bash scripts) and satisfy your curiosity and understanding on how this is done! Further resources on how to use DL4J has been provided in the <strong>Resources</strong> section at the end of the post.</p><h3>Valohai</h3><p><a href="https://valohai.com/">Valohai</a> as a platform allows us to loosely couple our runtime environment, our code, and our dataset, as you can see from the structure of the YAML file below. That way the different components can evolve independently without impeding or being dependent on one another. Hence our Docker container only has the build and runtime time components packed into it. At execution time we build the uber jar in the Docker container, upload it to some internal or external storage, and then via another execution step download the uber jar and dataset from storage (or another location) to run the training. This way the two execution steps are decoupled; we can e.g. build the jar once and run hundreds of training steps on the same jar. As the build and runtime environments should not change that often we can cache them and the code, dataset and model sources can be made dynamically available during execution time.</p><p><a href="https://docs.valohai.com/valohai-yaml/index.html"><strong>valohai.yaml</strong></a></p><p>The heart of integrating our Java project with the <a href="https://valohai.com/">Valohai</a> infrastructure is defining the steps of <a href="https://docs.valohai.com/core-concepts/executions.html">execution</a> of the steps in the <a href="https://docs.valohai.com/valohai-yaml/index.html">valohai.yaml</a> file placed in the root of your project folder. Our <a href="https://github.com/valohai/mlpmnist-dl4j-example/blob/master/valohai.yaml">valohai.yaml</a> looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffeb8dcf128820d7fc01d459d49deaf9/href">https://medium.com/media/ffeb8dcf128820d7fc01d459d49deaf9/href</a></iframe><p><strong>Explanation of the step Build-dl4j-mnist-single-layer-java-app</strong></p><p>From the YAML file, we can see that we define this step by first using the Docker image and then run the build script to build the uber jar. Our docker image has the build environment dependencies setup (i.e. GraalVM JDK, Maven, etc…) to build a Java app. We do not specify any inputs or parameters as this is the build step. Once the build will be successful we want to copy the uber jar called MLPMnist-1.0.0-bin.jar (original name) to the /valohai/outputs folder (represented by ${VH_OUTPUTS_DIR}). Everything within this folder automatically gets persisted within your project&#39;s storage, e.g. an AWS S3 bucket. Finally, we define our job to run in the AWS environment.</p><p>Note: <em>The </em><a href="https://valohai.com/"><em>Valohai</em></a><em> free tier does not have network access from inside the Docker container (this is disabled by default), please contact support to enable this option (I had to do the same), or else we cannot download our Maven and other dependencies during build time.</em></p><p><strong>Explanation of the step Run-dl4j-mnist-single-layer-train-model</strong></p><p>The semantics of the definition is similar to the previous step except we specify two inputs one for the uber jar (MLPMnist-1.0.0.jar) and the other for the dataset (to be unpacked into the${HOME}/.deeplearning4j folder). We will be passing the two parameters --action train and --output-dir /valohai/outputs. The model created from this step is collected into the /valohai/outputs/model folder (represented by ${VH_OUTPUTS_DIR}/model).</p><p>Note: <em>In the Input fields in the Executions tab of the Valohai Web UI, we can select the outputs from previous executions by using the execution number i.e. </em><em>#1 or </em><em>#2 , in addition to using datum:// or http:// URLs. Typing in the few letters of the name of the file also helps search through the whole list.</em></p><p><strong>Explanation of the step Run-dl4j-mnist-single-layer-evaluate-model</strong></p><p>Again, this step is similar to the previous step, except that we will be passing in the two parameters --action evaluate and --input-dir /valohai/inputs/model. Also, we have again specified two inputs: sections defined in the YAML file called dl4j-java-app and model with no default set for both of them. This will allow us to select the uber jar and the model we wish to evaluate - that was created by the step <strong>Run-dl4j-mnist-single-layer-train-model</strong>, using the web interface.</p><p>Hope this explains the steps in the above definition file but if you require further help, please do not hesitate to look at the <a href="https://docs.valohai.com/index.html">docs</a> and <a href="https://docs.valohai.com/tutorials/index.html">tutorials</a>.</p><p>Once we have an account, we can <a href="https://app.valohai.com/accounts/login/">sign-in</a> and continue with creating a project by the name mlpmnist-single-layer and link the git repo <a href="https://github.com/valohai/mlpmnist-dl4j-example">https://github.com/valohai/mlpmnist-dl4j-example</a> to the project and save the project, have a quick look at the tutorials to see <a href="https://docs.valohai.com/tutorials/index.html">how to create a project using the web interface</a>.</p><p>Now you can execute a step and see how it pans out!</p><h4>Building the DL4J Java app step</h4><p>Go to the <strong>Executions</strong> tab in the web interface, either copy an existing or create a new execution using the <strong>[Create execution]</strong> button, all the necessary default options will be populated, select Step <strong>Build-dl4j-mnist-single-layer-java-app.</strong></p><p>For <em>Environment</em> I would select <em>AWS eu-west-1 g2.2xlarge</em> and click on the <strong>[Create execution]</strong> button at the bottom of the page, to see the execution kick-off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7t0fjo-_p-Doo09u.png" /></figure><h4>Training the model step</h4><p>Go to the <strong>Executions</strong> tab in the web interface, and do the same as the previous step and select Step <strong>Run-dl4j-mnist-single-layer-train-model</strong>. You will have to select the Java app (just type jar in the field) built in the previous step, the dataset has already been pre-populated via the <strong>valohai.yaml</strong> file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cyy14Lb8JSfJZrdz.png" /></figure><p>Click on<strong> [Create execution]</strong> to kick off this step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A8BZUz7_k5MG371Y.png" /></figure><p>You will see the model summary fly by in the log console:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/385c80fb6b84ac8244996f6ae4149a0e/href">https://medium.com/media/385c80fb6b84ac8244996f6ae4149a0e/href</a></iframe><p>The models created can be found under the <strong>Outputs</strong> sub-tab in the <strong>Executions</strong> main tab, during and at the end of the execution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MgtDO7qLplEnTAVS.png" /></figure><p>You might have noticed several artifacts in the <strong>Outputs</strong> sub-tab. That’s because we save a checkpoint at the end of each epoch! Look out for these in the execution logs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c8705137170dd97580746d73c82d31c/href">https://medium.com/media/1c8705137170dd97580746d73c82d31c/href</a></iframe><p>The checkpoint zip contains the state of the model training at that point, saved in three of these files:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97c1cc3e810ad3ce907278eaf0d3d721/href">https://medium.com/media/97c1cc3e810ad3ce907278eaf0d3d721/href</a></iframe><p><strong>Training the model &gt; Metadata</strong></p><p>You might have noticed these notations fly by in the execution logs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45d78fd2a2e13479c8e9b9f6645fef4c/href">https://medium.com/media/45d78fd2a2e13479c8e9b9f6645fef4c/href</a></iframe><p>These notations trigger <a href="https://valohai.com/">Valohai</a> to pickup these values (in JSON format) to be used to plot execution metrics, which can be seen during and after the execution under the <strong>Metadata</strong> sub-tab in the <strong>Executions</strong> main tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SwM_Lc3efuH7h_9P.png" /></figure><p>We were able to do this by hooking a listener class (called <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/examples/cloud-devops-infra/valohai/MLPMnist/src/main/java/org/deeplearning4j/feedforward/mnist/ValohaiMetadataCreator.java">ValohaiMetadataCreator</a>) into the model, such that during training attention is passed on to this listener class at the end of each iteration. In the case of this class, we print the <strong>epoch count</strong>, <strong>iteration count</strong> and <strong>the score (the loss function value)</strong>, here is a code snippet from the class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7f0de85a08311e0d38552815d63b689/href">https://medium.com/media/c7f0de85a08311e0d38552815d63b689/href</a></iframe><h4>Evaluating the model step</h4><p>Once the model has been successfully created via the previous step, we are ready to evaluate it. We create a new execution just like we did previously but this time select the <strong>Run-dl4j-mnist-single-layer-evaluate-model</strong> step. We will need to select the Java app (<strong>MLPMnist-1.0.0.jar</strong>) again and the created model (<strong>mlpmnist-single-layer.pb</strong>) before kicking off the execution (as shown below):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X9kILtQUEgZtY-91.png" /></figure><p>After selecting the desired model as input, click on the <strong>[Create execution]</strong> button. It is a quicker execution step than the previous one and we will see the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*azaua3UlAyVkPSPX.png" /></figure><p>The <strong>Evaluation Metrics</strong> and <strong>Confusion Matrix</strong> post model analysis will be displayed in the console logs.</p><p>We can see our training activity has resulted in the model that is near <strong>97%</strong> accurate <em>based on the test dataset</em>. The confusion matrix helps point out the instances a digit has been incorrectly predicted as another digit. Maybe this is good feedback to the creator of the model and maintainer of the dataset to do some further investigations.</p><p>The question remains (and is outside the scope of this post) — how good is the model when faced with <em>real-world data</em>?</p><p>It’s easy to install and get started with the CLI tool, see <a href="https://docs.valohai.com/valohai-cli/installation.html?highlight=cli">Command-line Usage</a>.</p><p>If you haven’t yet cloned the git repository then here’s what to do:</p><pre>$ git clone <a href="https://github.com/valohai/mlpmnist-dl4j-example">https://github.com/valohai/mlpmnist-dl4j-example</a></pre><p>We then need to link our <a href="https://valohai.com/">Valohai</a> project created via the web interface in the above section to the project stored on our local machine (the one we just cloned). Run the below commands to do that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35a0c711768a9335ccd079aa52e6f1f1/href">https://medium.com/media/35a0c711768a9335ccd079aa52e6f1f1/href</a></iframe><p>You will be shown something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aaf4f4cc1ed232aff984e6f0c6c3778d/href">https://medium.com/media/aaf4f4cc1ed232aff984e6f0c6c3778d/href</a></iframe><p>Select 1 (or the selection appropriate for you) and you should see this message:</p><p>😁 Success! Linked /path/to/mlpmnist-dl4j-example to mlpmnist-single-layer.</p><p>The quickest way to know of all the CLI options with the CLI tool is:</p><pre>$ vh — help</pre><p>One more thing, before going any further ensure that your <a href="https://valohai.com/">Valohai</a> project is in sync with the latest git project, by doing this:</p><pre>$ vh project fetch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9b0OmE6SelZXsvZ6.png" /></figure><p>(on the top right side in your web interface, shown with the two-arrows-pointing-to-each-other icon).</p><p>Now we can execute the steps from the CLI with:</p><pre>$ vh exec run Build-dl4j-mnist-single-layer-java-app</pre><p>Once the execution is on, we can inspect and monitor it via:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef8eaec7daccf4cd2ead0d0c70cc3301/href">https://medium.com/media/ef8eaec7daccf4cd2ead0d0c70cc3301/href</a></iframe><p>We can also see the above updates via the web interface at the same time.</p><p>Further resources on how to go about with <a href="https://valohai.com/">Valohai</a> has been provided in the Resources section at the end of the post, there are a couple of blog posts on how to use the CLI tool, see <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-cli">[1]</a> | <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-part-2">[2]</a>.</p><h3>Conclusion</h3><p>As you have seen both <a href="https://deeplearning4j.org/">DL4J</a> and <a href="https://valohai.com/">Valohai</a> individually or combined are fairly easy to get started with. Further, we can develop on the different components that make up our experiments i.e. build/runtime environment, code, and dataset and integrate them into an execution in a loosely coupled manner.</p><p>The template examples used in this post are a good way to get started to build more complex projects. That you can use either the web interface or the CLI to get your job done with <a href="https://valohai.com/">Valohai</a>! With the CLI you can also integrate it with your setup and scripts (or even with CRON or CI/CD jobs).</p><p>Also, it’s clear that if I’m working on an AI/ML/DL related project <em>I don’t need to concern myself with creating and maintaining</em> an end-to-end pipeline (which many others and I have had to do in the past) — thanks to the good work by the folks at <a href="https://valohai.com/">Valohai</a>.</p><p><em>Thanks to both </em><a href="https://skymind.ai/"><em>Skymind</em></a><em> (the startup behind </em><a href="https://deeplearning4j.org/"><em>DL4J</em></a><em>, for creating, maintaining and keeping free) and </em><a href="https://valohai.com/"><em>Valohai</em></a><em> for making this tool and cloud-service available for both free and commercial use.</em></p><p><em>Please do let me know if this is helpful by dropping a line in the comments below or by tweeting at </em><a href="https://twitter.com/theNeomatrix369"><em>@theNeomatrix369</em></a><em>, and I would also welcome feedback.</em></p><h3>Resources</h3><ul><li><a href="https://github.com/valohai/mlpmnist-dl4j-example">mlpmnist-dl4j-examples project on GitHub</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/">Awesome AI/ML/DL resources</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/README-details.md#java">Java AI/ML/DL resources</a></li><li><a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/README-details.md#deep-learning">Deep Learning and DL4J Resources</a></li></ul><p><strong>Additional DL4J resources</strong></p><p>Loss functions</p><ul><li><a href="https://deeplearning4j.org/api/latest/org/nd4j/linalg/lossfunctions/ILossFunction.html">Loss function Interface by DL4J</a></li><li><a href="https://heartbeat.fritz.ai/5-regression-loss-functions-all-machine-learners-should-know-4fb140e9d4b0">5 Regression Loss Functions All Machine Learners Should Know</a></li></ul><p>Evaluation</p><ul><li><a href="https://deeplearning4j.org/docs/latest/deeplearning4j-nn-evaluation">https://deeplearning4j.org/docs/latest/deeplearning4j-nn-evaluation</a></li></ul><p><strong>Valohai resources</strong></p><ul><li><a href="https://valohai.com/">valohai </a>| <a href="https://docs.valohai.com/">docs</a> | <a href="https://blog.valohai.com/">blogs</a> | <a href="https://github.com/valohai">GitHub</a> | <a href="https://www.youtube.com/channel/UCiR8Fpv6jRNphaZ99PnIuFg">Videos</a> | <a href="https://valohai.com/showcase/">Showcase</a> | <a href="https://github.com/neomatrix369/awesome-ai-ml-dl/blob/master/data/about-Valohai.md#valohai">About Valohai</a> | <a href="http://community-slack.valohai.com/">Slack</a> | <a href="http://twitter.com/valohaiai">@valohaiai</a></li><li>Blog posts on how to use the CLI tool: <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-cli">[1]</a> | <a href="https://blog.valohai.com/from-zero-to-hero-with-valohai-part-2">[2]</a></li></ul><p><strong>Other resources</strong></p><ul><li><a href="https://github.com/neomatrix369/awesome-graal">Awesome Graal</a> | <a href="https://www.graalvm.org/">graalvm.org</a></li></ul><h3>Originally published at <a href="https://blog.valohai.com/how-to-do-deep-learning-for-java-on-the-valohai-platform?from=3oxenia9mtr6">https://blog.valohai.com</a>.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eec8ba9f71d8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-to-do-deep-learning-for-java-on-the-valohai-platform-eec8ba9f71d8">How to do Deep Learning for Java?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build Graal-enabled JDK8 on CircleCI?]]></title>
            <link>https://medium.com/oracledevs/how-to-build-graal-enabled-jdk8-on-circleci-3e20ae07a5d3?source=rss-6e56fdbd9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e20ae07a5d3</guid>
            <category><![CDATA[jvcmi]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[jdk]]></category>
            <category><![CDATA[graal]]></category>
            <dc:creator><![CDATA[Mani Sarkar]]></dc:creator>
            <pubDate>Tue, 06 Aug 2019 21:16:47 GMT</pubDate>
            <atom:updated>2019-08-28T12:54:44.541Z</atom:updated>
            <content:encoded><![CDATA[<h4>A post on how to build a JDK8 binary with the GraalVM compiler embedded in it, in a CI/CD environment like CircleCI.</h4><figure><img alt="Created by Luca Galli — https://www.flickr.com/photos/lucagalli/, see https://www.flickr.com/photos/lucagalli/8878889367/in" src="https://cdn-images-1.medium.com/max/502/1*PUXF-PaXKzRD5y4xXrzenA.png" /></figure><p>The <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a> is a replacement to HotSpot’s server-side <a href="https://dzone.com/articles/just-time-compiler-jit-hotspot">JIT compiler</a> widely known as the <a href="http://openjdk.java.net/groups/hotspot/docs/HotSpotGlossary.html">C2 compiler</a>. It is written in Java with the goal of better performance (among other goals) as compared to the C2 compiler. New changes starting with Java 9 mean that we can now plug in our own hand-written C2 compiler into the JVM, thanks to <a href="https://openjdk.java.net/jeps/243">JVMCI</a>. The researchers and engineers at <a href="https://labs.oracle.com/pls/apex/f?p=LABS:10::::::">Oracle Labs</a> have created a variant of JDK8 with JVMCI enabled which can be used to build the <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a>. The <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a> is open source and is <a href="http://github.com/oracle/graal">available on GitHub</a> (along with the <a href="https://github.com/graalvm/graal-jvmci-8">HotSpot JVMCI sources</a> needed to build the <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a>). This gives us the ability to fork/clone it and build our own version of the <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a>.</p><p>In this post, we are going to build the <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a> with JDK8 on CircleCI. The resulting artifacts are going to be:</p><ul><li>JDK8 embedded with the GraalVM compiler, and</li><li>a zip archive containing Graal &amp; Truffle modules/components.</li></ul><p><strong><em>Note: we are not covering how to build the whole of the GraalVM suite in this post, that can be done via another post. Although these scripts can be used to that, and there exists a </em></strong><a href="https://github.com/neomatrix369/awesome-graal/tree/build-graalvm-suite"><strong><em>branch which contains the rest of the steps</em></strong></a><strong><em>.</em></strong></p><h3>Why use a CI tool to build the GraalVM compiler?</h3><figure><img alt="Created by fklv (Obsolete hipster), see https://www.flickr.com/photos/fklv/9518664878/in/photolist-fv8DrG-j6wh3a-eVYANz-hNoEg" src="https://cdn-images-1.medium.com/max/323/0*b9PQO76-z5XmIcc7" /></figure><p>Continuous integration (CI) and continuous deployment (CD) tools have many benefits. One of the greatest is the ability to check the health of the code-base. Seeing why your builds are failing provides you with an opportunity to make a fix faster. For this project, it is important that we are able to verify and validate the scripts required to build the <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a> for <strong><em>Linux</em></strong> and <strong><em>macOS</em></strong>, both locally and in a Docker container. A CI/CD tool lets us add automated tests to ensure that we get the desired outcome from our scripts when every PR is merged. In addition to ensuring that our new code does not introduce a breaking change, another great feature of CI/CD tools is that we can automate the creation of binaries and the automatic deployment of those binaries, making them available for open source distribution.</p><h3>Let’s get started</h3><p>During the process of researching <a href="http://circleci.com/">CircleCI</a> as a CI/CD solution to build the GraalVM compiler, I learned that we could run builds via two different approaches, namely:</p><ul><li>A CircleCI build with a standard Docker container (longer build time, longer config script)</li><li>A CircleCI build with a pre-built and optimised Docker container (shorter build time, shorter config script)</li></ul><p>We will now go through the two approaches mentioned above and see the pros and cons of both of them.</p><h3>Approach 1: using a standard Docker container</h3><p>For this approach, CircleCI requires a docker image that is available in <a href="https://hub.docker.com/">Docker Hub</a> or another public/private registry it has access to. We will have to install the necessary dependencies in this available environment in order for a successful build. We expect the build to run longer the first time and, depending on the levels of caching, it will speed up.</p><p>To understand how this is done, we will be going through the CircleCI configuration file section-by-section (stored in .circleci/circle.yml), see <a href="https://github.com/neomatrix369/awesome-graal/blob/build-on-circleci/.circleci/config.yml">config.yml in .circleci</a> for the full listing, see commit <a href="https://github.com/neomatrix369/awesome-graal/commit/df28ee78be289a364dcdf3bdd626bd4a40460a28">df28ee7</a> for the source changes.</p><h3>Explaining sections of the config file</h3><p>The below lines in the configuration file will ensure that our installed applications are cached (referring to the two specific directories) so that we don’t have to reinstall the dependencies each time a build occurs:</p><pre>    dependencies:<br>      cache_directories:<br>        - &quot;vendor/apt&quot;<br>        - &quot;vendor/apt/archives&quot;</pre><p>We will be referring to the docker image by its full name (as available on <a href="http://hub.docker.com/">http://hub.docker.com</a> under the account name used — <em>adoptopenjdk</em>). In this case, it is a standard docker image containing JDK8 made available by the good folks behind the <a href="http://ci.adoptopenjdk.net/">Adopt OpenJDK build farm</a>. In theory, we can use any image as long as it supports the build process. It will act as the base layer on which we will install the necessary dependencies:</p><pre>        docker:<br>          - image: adoptopenjdk/openjdk8:jdk8u152-b16</pre><p>Next, in the pre-Install Os dependencies step, we will restore the cache, if it already exists, this may look a bit odd, but for unique key labels, the below implementation is <a href="https://circleci.com/docs/2.0/configuration-reference/#restore_cache">recommended by the docs</a>:</p><pre>          - restore_cache:<br>              keys:<br>                - os-deps-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>                - os-deps-{{ arch }}-{{ .Branch }}</pre><p>Then, in the Install Os dependencies step, we run the respective shell script to install the dependencies needed. We have set this step to timeout if the operation takes longer than 2 minutes to complete (see <a href="https://discuss.circleci.com/t/how-to-increase-timeout-for-command-in-circle-2-0/20254">docs for timeout</a>):</p><pre>          - run:<br>              name: Install Os dependencies<br>              command: ./build/x86_64/linux_macos/osDependencies.sh<br>              timeout: 2m</pre><p>Then, in then post-Install Os dependencies step, we save the results of the previous step — the layer from the above run step (the key name is formatted to ensure uniqueness, and the specific paths to save are included):</p><pre>          - save_cache:<br>              key: os-deps-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>              paths:<br>                - vendor/apt<br>                - vendor/apt/archives</pre><p>Then, in the pre-Build and install make via script step, we restore the cache if one already exists:</p><pre>          - restore_cache:<br>              keys:<br>                - make-382-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>                - make-382-{{ arch }}-{{ .Branch }}</pre><p>Then, in the Build and install make via script step we run the shell script to install a specific version of make and it is set to timeout if step takes longer than 1 minute to finish:</p><pre>          - run:<br>              name: Build and install make via script<br>              command: ./build/x86_64/linux_macos/installMake.sh<br>              timeout: 1m</pre><p>Then, in the post Build and install make via script step, we save the results of the above action to the cache:</p><pre>          - save_cache:<br>              key: make-382-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>              paths:<br>                - /make-3.82/<br>                - /usr/bin/make<br>                - /usr/local/bin/make<br>                - /usr/share/man/man1/make.1.gz<br>                - /lib/</pre><p>Then, we define environment variables to update <em>JAVA_HOME</em> and <em>PATH</em> at runtime. Here the environment variables are sourced so that we remember them for the next subsequent steps till the end of the build process (please keep this in mind):</p><pre>          - run:<br>              name: Define Environment Variables and update JAVA_HOME and PATH at Runtime<br>              command: |<br>                echo &#39;....&#39;     &lt;== a number of echo-es displaying env variable values<br>                source ${BASH_ENV}</pre><p>Then, in the step to Display Hardware, Software, Runtime environment and dependency versions, as best practice we display environment-specific information and record it into the logs for posterity (also useful during debugging when things go wrong):</p><pre>          - run:<br>              name: Display HW, SW, Runtime env. info and versions of dependencies<br>              command: ./build/x86_64/linux_macos/lib/displayDependencyVersion.sh</pre><p>Then, we run the step to setup MX — this is important from the point of view of the GraalVM compiler (<a href="https://github.com/graalvm/mx"><em>mx</em></a> is a specialised build system created to facilitate compiling and building Graal/GraalVM and it’s components):</p><pre>          - run:<br>              name: Setup MX<br>              command: ./build/x86_64/linux_macos/lib/setupMX.sh ${BASEDIR}</pre><p>Then, we run the important step to Build JDK JVMCI (we build the JDK with JVMCI enabled here) and timeout, if the process takes longer than 15 minutes without any output or if the process takes longer than 20 minutes in total to finish:</p><pre>          - run:<br>              name: Build JDK JVMCI<br>              command: ./build/x86_64/linux_macos/lib/build_JDK_JVMCI.sh ${BASEDIR} ${MX}<br>              timeout: 20m<br>              no_output_timeout: 15m</pre><p>Then, we run the step Run JDK JVMCI Tests, which runs tests as part of the sanity check after building the JDK JVMCI:</p><pre>          - run:<br>              name: Run JDK JVMCI Tests<br>              command: ./build/x86_64/linux_macos/lib/run_JDK_JVMCI_Tests.sh ${BASEDIR} ${MX}</pre><p>Then, we run the step Setting up the environment and Build GraalVM Compiler, to set up the build environment with the necessary environment variables which will be used by the steps to follow:</p><pre>          - run:<br>              name: Setting up environment and Build GraalVM Compiler<br>              command: |<br>                echo &quot;&gt;&gt;&gt;&gt; Currently JAVA_HOME=${JAVA_HOME}&quot;<br>                JDK8_JVMCI_HOME=&quot;$(cd ${BASEDIR}/graal-jvmci-8/ &amp;&amp; ${MX} --java-home ${JAVA_HOME} jdkhome)&quot;<br>                echo &quot;export JVMCI_VERSION_CHECK=&#39;ignore&#39;&quot; &gt;&gt; ${BASH_ENV}<br>                echo &quot;export JAVA_HOME=${JDK8_JVMCI_HOME}&quot; &gt;&gt; ${BASH_ENV}<br>                source ${BASH_ENV}</pre><p>Then, we run the step Build the GraalVM Compiler and embed it into the JDK (JDK8 with JVMCI enabled) which timeouts if the process takes longer than 7 minutes without any output or longer than 10 minutes in total to finish:</p><pre>          - run:<br>              name: Build the GraalVM Compiler and embed it into the JDK (JDK8 with JVMCI enabled)<br>              command: |<br>                echo &quot;&gt;&gt;&gt;&gt; Using JDK8_JVMCI_HOME as JAVA_HOME (${JAVA_HOME})&quot;<br>                ./build/x86_64/linux_macos/lib/buildGraalCompiler.sh ${BASEDIR} ${MX} ${BUILD_ARTIFACTS_DIR}<br>              timeout: 10m<br>              no_output_timeout: 7m</pre><p>Then, we run the simple sanity checks to verify the validity of the artifacts created once a build has been completed, just before archiving the artifacts:</p><pre>          - run:<br>              name: Sanity check artifacts<br>              command: |<br>                ./build/x86_64/linux_macos/lib/sanityCheckArtifacts.sh ${BASEDIR} ${JDK_GRAAL_FOLDER_NAME}<br>              timeout: 3m<br>              no_output_timeout: 2m</pre><p>Then, we run the step Archiving artifacts (means compressing and copying final artifacts into a separate folder) which timeouts if the process takes longer than 2 minutes without any output or longer than 3 minutes in total to finish:</p><pre>          - run:<br>              name: Archiving artifacts<br>              command: |<br>                ./build/x86_64/linux_macos/lib/archivingArtifacts.sh ${BASEDIR} ${MX} ${JDK_GRAAL_FOLDER_NAME} ${BUILD_ARTIFACTS_DIR}<br>              timeout: 3m<br>              no_output_timeout: 2m</pre><p>For posterity and debugging purposes, we capture the generated logs from the various folders and archive them:</p><pre>          - run:<br>              name: Collecting and archiving logs (debug and error logs)<br>              command: |<br>                ./build/x86_64/linux_macos/lib/archivingLogs.sh ${BASEDIR}<br>              timeout: 3m<br>              no_output_timeout: 2m<br>              when: always<br>          - store_artifacts:<br>              name: Uploading logs<br>              path: logs/</pre><p>Finally, we store the generated artifacts at a specified location — the below lines will make the location available on the CircleCI interface (we can download the artifacts from here):</p><pre>          - store_artifacts:<br>              name: Uploading artifacts in jdk8-with-graal-local<br>              path: jdk8-with-graal-local/</pre><h3>Approach 2: using a pre-built optimised Docker container</h3><p>For approach 2, we will be using a pre-built docker container, that has been created and built locally with all necessary dependencies, the docker image saved and then pushed to a remote registry for e.g. <a href="https://hub.docker.com/">Docker Hub</a>. And then we will be referencing this docker image in the CircleCI environment, via the configuration file. This saves us time and effort for running all the commands to install the necessary dependencies to create the necessary environment for this approach (see the details steps in the <strong>Approach 1 </strong>section).</p><p>We expect the build to run for a shorter time as compared to the previous build and this speedup is a result of the pre-built docker image (we will see in the <strong><em>Steps to build the pre-built docker image </em></strong>section, to see how this is done). The additional speed benefit comes from the fact that CircleCI caches the docker image layers which in turn results in a quicker startup of the build environment.</p><p>We will be going through the CircleCI configuration file section-by-section (stored in .circleci/circle.yml) for this approach, see <a href="https://github.com/neomatrix369/awesome-graal/blob/build-on-circleci-using-pre-built-docker-container/.circleci/config.yml">config.yml in .circleci</a> for the full listing, see commit <a href="https://github.com/neomatrix369/awesome-graal/commit/e5916f1ffbc6ca0b8f5cd2ed71a6883e5a2de031">e5916f1</a> for the source changes.</p><h3>Explaining sections of the config file</h3><p>Here again, we will be referring to the docker image by its full name. It is a pre-built docker image <a href="https://hub.docker.com/r/neomatrix369/graalvm-suite-jdk8">neomatrix369/graalvm-suite-jdk8</a> made available by <a href="https://hub.docker.com/u/neomatrix369">neomatrix369</a>. It was built and uploaded to <a href="https://hub.docker.com/">Docker Hub</a> in advance before the CircleCI build was started. It contains the necessary dependencies for the <a href="https://github.com/oracle/graal/tree/master/compiler">GraalVM compiler</a> to be built:</p><pre>      docker:<br>          - image: neomatrix369/graal-jdk8:${IMAGE_VERSION:-python-2.7}<br>        steps:<br>          - checkout</pre><p>All the sections below do the exact same tasks (and for the same purpose) as in Approach 1, see the <strong><em>Explaining sections of the config file</em></strong><em> section</em>.</p><p>Except, we have removed the below sections as they are no longer required for <strong>Approach 2:</strong></p><pre>    - restore_cache:<br>              keys:<br>                - os-deps-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>                - os-deps-{{ arch }}-{{ .Branch }}<br>          - run:<br>              name: Install Os dependencies<br>              command: ./build/x86_64/linux_macos/osDependencies.sh<br>              timeout: 2m<br>          - save_cache:<br>              key: os-deps-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>              paths:<br>                - vendor/apt<br>                - vendor/apt/archives<br>          - restore_cache:<br>              keys:<br>                - make-382-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>                - make-382-{{ arch }}-{{ .Branch }}<br>          - run:<br>              name: Build and install make via script<br>              command: ./build/x86_64/linux_macos/installMake.sh<br>              timeout: 1m<br>          - save_cache:<br>              key: make-382-{{ arch }}-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}<br>              paths:<br>                - /make-3.82/<br>                - /usr/bin/make<br>                - /usr/local/bin/make<br>                - /usr/share/man/man1/make.1.gz</pre><p>In the following section, I will go through the steps to show how to build the pre-built docker image. It will involve running the bash scripts <em>./build/x86_64/linux_macos/osDependencies.sh </em>and <em>./build/x86_64/linux_macos/installMake.sh</em> to install the necessary dependencies as part of building a docker image. And, finally pushing the image to <a href="https://hub.docker.com/">Docker Hub</a> (can be pushed to any other remote registry of your choice).</p><h3>Steps to build the pre-built docker image</h3><ul><li>Run build-docker-image.sh (see bash script source) which depends on the presence of Dockerfile (see docker script source). The Dockerfile does all the necessary tasks of running the dependencies inside the container i.e. runs the bash scripts <em>./build/x86_64/linux_macos/osDependencies.sh </em>and <em>./build/x86_64/linux_macos/installMake.sh</em>:</li></ul><pre>$ ./build-docker-image.sh</pre><ul><li>Once the image has been built successfully, run <em>push-graal-docker-image-to-hub.sh</em> after setting the <em>USER_NAME</em> and <em>IMAGE_NAME</em> (see source code), otherwise, it will use the default values as set in the bash script:</li></ul><pre>$ USER_NAME=&quot;[your docker hub username]&quot; IMAGE_NAME=&quot;[any image name]&quot; ./push-graal-docker-image-to-hub.sh </pre><h3>CircleCI config file statistics: Approach 1 versus Approach 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*gg8Z_mxPa3H-5obcXX-3Xw.png" /></figure><h3>What not to do?</h3><p><strong>Approach 1 issues</strong></p><p>I came across things that wouldn’t work initially, but were later fixed with changes to the configuration file or the scripts:</p><ul><li>please make sure the <em>.circleci/config.yml</em> is always in the root directory of the folder</li><li>when using the store_artifacts directive in the .circleci/config.yml file setting, set the value to a fixed folder name i.e. <em>jdk8-with-graal-local/</em> in our case, setting the path to <em>${BASEDIR}/project/jdk8-with-graal</em> didn’t create the resulting artifact once the build was finished hence the fixed path name suggestion.</li><li>environment variables: when working with environment variables, keep in mind that each command runs in its own shell hence the values set to environment variables inside the shell execution environment isn’t visible outside, follow the method used in the context of this post. Set the environment variables such that all the commands can see its required value to avoid misbehaviours or unexpected results at the end of each step.</li><li>caching: use the caching functionality after reading about it, for more details on <strong>CircleCI</strong> caching refer to the <a href="https://circleci.com/docs/2.0/caching/">caching docs</a>. See how it has been implemented in the context of this post. This will help avoid confusions and also help make better use of the functionality provided by <strong>CircleCI</strong>.</li></ul><p><strong>Approach 2 issues</strong></p><ul><li>Caching: check the docs when trying to use the <a href="https://circleci.com/docs/2.0/docker-layer-caching/">Docker Layer Caching</a> (DLC) option as it is a paid feature, once this is known the doubts about “why CircleCI keeps downloading all the layers during each build” will be clarified, for Docker Layer Caching details refer to <a href="https://circleci.com/docs/2.0/docker-layer-caching/">docs</a>. It can also clarify why in non-paid mode my build is still not as fast as I would like it to be.</li></ul><p><strong>General note:</strong></p><ul><li>Light-weight instances: to avoid the pitfall of thinking we can run heavy-duty builds, check the documentation on the technical specifications of the instances. If we run the standard Linux commands to probe the technical specifications of the instance we may be misled by thinking that they are high specification machines. See the step that enlists the Hardware and Software details of the instance (see the <strong><em>Display HW, SW, Runtime env. info and versions of dependencies </em></strong><em>section</em>). The instances are actually Virtual Machines or Container like environments with resources like 2CPU/4096MB. This means we can’t run long-running or heavy-duty builds like building the GraalVM suite. Maybe there is another way to handle these kinds of builds, or maybe such builds need to be decomposed into smaller parts.</li><li>Global environment variables: as each run line in the config.yml, runs in its own shell context, from within that context environment variables set by other executing contexts do not have access to these values. Hence in order to overcome this, we have adopted two methods:</li><li>pass as variables as parameters to calling bash/shell scripts to ensure scripts are able to access the values in the environment variables</li><li>use the source command as a run step to make environment variables accessible globally</li></ul><h3>End result and summary</h3><p>We see the below screen (the last step i.e. Updating artifacts enlists where the artifacts have been copied) after a build has been successfully finished:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jxsWnONj0BVas_hT.png" /></figure><p>The artifacts are now placed in the right folder for download. We are mainly concerned about the jdk8-with-graal.tar.gz artifact.</p><h3>Performance</h3><p>Before writing this post, I ran multiple passes of both the approaches and jotted down the time taken to finish the builds, which can be seen below:</p><p><strong>Approach 1:</strong> standard CircleCI build (caching enabled)</p><ul><li>13 mins 28 secs</li><li>13 mins 59 secs</li><li>14 mins 52 secs</li><li>10 mins 38 secs</li><li>10 mins 26 secs</li><li>10 mins 23 secs</li></ul><p><strong>Approach 2:</strong> using pre-built docker image (caching enabled, <a href="https://circleci.com/docs/2.0/docker-layer-caching/">DLC</a> feature unavailable)</p><ul><li>13 mins 15 secs</li><li>15 mins 16 secs</li><li>15 mins 29 secs</li><li>15 mins 58 secs</li><li>10 mins 20 secs</li><li>9 mins 49 secs</li></ul><p><strong>Note:</strong><em> </em><strong><em>Approach 2</em></strong><em> should show better performance when using a paid tier, as </em><a href="https://circleci.com/docs/2.0/docker-layer-caching/"><em>Docker Layer Caching</em></a><em> is available as part of this plan.</em></p><h3>Sanity check</h3><p>In order to be sure that by using both the above approaches we have actually built a valid JDK embedded with the GraalVM compiler, we perform the following steps with the created artifact:</p><ul><li>Firstly, download the jdk8-with-graal.tar.gz artifact from under the <strong>Artifacts tab</strong> on the CircleCI dashboard (needs sign-in):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HNK9i44AW0C_6ilP.png" /></figure><ul><li>Then, unzip the .tar.gz file and do the following:</li></ul><pre>tar xvf jdk8-with-graal.tar.gz</pre><ul><li>Thereafter, run the below command to check the JDK binary is valid:</li></ul><pre>cd jdk8-with-graal</pre><pre>./bin/java -version</pre><ul><li>And finally, check if we get the below output:</li></ul><pre>openjdk version &quot;1.8.0-internal&quot;</pre><pre>OpenJDK Runtime Environment (build 1.8.0-internal-jenkins_2017_07_27_20_16-b00)</pre><pre>OpenJDK 64-Bit Graal:compiler_ab426fd70e30026d6988d512d5afcd3cc29cd565:compiler_ab426fd70e30026d6988d512d5afcd3cc29cd565 (build 25.71-b01-internal-jvmci-0.46, mixed mode)</pre><ul><li>Similarly, to confirm if the JRE is valid and has the GraalVM compiler built-in, we do this:</li></ul><pre>./bin/jre/java -version</pre><ul><li>And check if we get a similar output as above:</li></ul><pre>openjdk version &quot;1.8.0-internal&quot;</pre><pre>OpenJDK Runtime Environment (build 1.8.0-internal-jenkins_2017_07_27_20_16-b00)</pre><pre>OpenJDK 64-Bit Graal:compiler_ab426fd70e30026d6988d512d5afcd3cc29cd565:compiler_ab426fd70e30026d6988d512d5afcd3cc29cd565 (build 25.71-b01-internal-jvmci-0.46, mixed mode)</pre><p>With this, we have successfully built JDK8 with the GraalVM compiler embedded in it and also bundled the Graal and Truffle components in an archive file, both of which are available for download via the CircleCI interface.</p><p><strong><em>Note: </em></strong><em>you will notice that we do perform sanity checks of the binaries built just before we pack them into compressed archives, as part of the build steps (see bottom section of CircleCI the configuration files).</em></p><h3>Nice badges!</h3><p>We all like to show-off and also like to know the current status of our build jobs. A green-colour, build status icon is a nice indication of success, which looks like the below on a markdown README page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UwVjnAw09mkOstIW.png" /></figure><p>We can very easily embed both of these status badges displaying the build status of our project (branch-specific i.e. master or another branch you have created) built on CircleCI (see <a href="https://circleci.com/docs/2.0/status-badges/">docs</a> on how to do that).</p><h3>Conclusions</h3><p>We explored two approaches to build the GraalVM compiler using the CircleCI environment. They were good experiments to compare performance between the two approaches and also how we can do them with ease. We also saw a number of things <em>to avoid</em> or <em>not to do</em> and also saw how useful some of the CircleCI features are. The documentation and forums do good justice when trying to make a build work or if you get stuck with something.</p><p>Once we know the CircleCI environment, it’s pretty easy to use and always gives us the exact same response (consistent behaviour) every time we run it. Its ephemeral nature means we are guaranteed a clean environment before each run and clean up after it finishes. We can also set up checks on build time for every step of the build, and abort a build if the time taken to finish a step surpasses the threshold time-period.</p><p>The ability to use pre-built docker images coupled with <a href="https://circleci.com/docs/2.0/docker-layer-caching/">Docker Layer Caching</a> on CircleCI can be a major performance boost (saves us build time needed to reinstall any necessary dependencies at every build). Additional performance speedups are available on CircleCI, with caching of the build steps — this again saves build time by not having to re-run the same steps if they haven’t changed.</p><p>There are a lot of useful features available on CircleCI with plenty of documentation and everyone on the community forum are helpful and questions are answered pretty much instantly.</p><p>Next, let’s build the same and more on another build environment / build farm — hint, hint, are you think the same as me? <a href="http://ci.adoptopenjdk.net/">Adopt OpenJDK build farm</a>? We can give it a try!</p><p><strong><em>Thanks and credits to </em></strong><a href="https://twitter.com/whyd0my3y3shurt?lang=en"><strong><em>Ron Powell</em></strong></a><strong><em> from </em></strong><a href="http://circleci.com/"><strong><em>CircleCI</em></strong></a><strong><em> and </em></strong><a href="https://twitter.com/shelajev"><strong><em>Oleg Šelajev</em></strong></a><strong><em> from </em></strong><a href="https://labs.oracle.com/"><strong><em>Oracle Labs</em></strong></a><strong><em> for proof-reading and giving constructive feedback.</em></strong></p><p><strong>Please do let me know if this is helpful by dropping a line in the comments below or by tweeting at </strong><a href="http://twitter.com/@theNeomatrix369"><strong>@theNeomatrix369</strong></a><strong>, and I would also welcome feedback, see how you can </strong><a href="https://neomatrix369.wordpress.com/about/"><strong>reach me</strong></a><strong>, above all please check out the links mentioned above.</strong></p><h3>Useful resources</h3><p>Links to useful CircleCI docs</p><ul><li><a href="https://circleci.com/docs/2.0/getting-started/">About Getting started</a> | <a href="https://www.youtube.com/watch?v=otBELDgOo3o">Videos</a></li><li><a href="https://circleci.com/docker/">About Docker</a></li><li><a href="https://circleci.com/docs/2.0/docker-layer-caching/">Docker Layer Caching</a></li><li><a href="https://circleci.com/docs/2.0/caching/">About Caching</a></li><li><a href="https://circleci.com/docs/2.0/ssh-access-jobs/">About Debugging via SSH</a></li><li><a href="https://devhints.io/circle">CircleCI cheatsheet</a></li><li><a href="https://discuss.circleci.com/">CircleCI Community (Discussions)</a></li><li><a href="https://discuss.circleci.com/c/community">Latest community topics</a></li><li>CircleCI configuration and supporting files</li><li><strong>Approach 1:</strong> <a href="https://github.com/neomatrix369/awesome-graal/tree/build-on-circleci">https://github.com/neomatrix369/awesome-graal/tree/build-on-circleci</a><a href="https://github.com/neomatrix369/awesome-graal/tree/build-on-circleci-inside-docker-container"> </a>(config file and other supporting files i.e. scripts, directory layout, etc…)</li><li><strong>Approach 2:</strong> <a href="https://github.com/neomatrix369/awesome-graal/tree/build-on-circleci-using-pre-built-docker-container">https://github.com/neomatrix369/awesome-graal/tree/build-on-circleci-using-pre-built-docker-container</a> (config file and other supporting files i.e. scripts, directory layout, etc…)</li><li><a href="https://github.com/neomatrix369/awesome-graal/tree/master/build/x86_64/linux_macos">Scripts to build Graal on Linux, MacOS and inside the Docker container</a></li><li><a href="https://medium.com/p/d33f0d96b78?source=user_profile---------8------------------">Truffle served in a Holy Graal: Graal and Truffle for polyglot language interpretation on the JVM</a></li><li><a href="https://medium.com/p/6cc161e01442?source=user_profile---------7------------------">Learning to use Wholly GraalVM!</a></li><li><a href="https://medium.com/p/1d2f8dacc3a7?source=user_profile---------6------------------">Building Wholly Graal with Truffle!</a></li><li><a href="https://github.com/neomatrix369/awesome-graal">Awesome Graal GitHub resources</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e20ae07a5d3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/how-to-build-graal-enabled-jdk8-on-circleci-3e20ae07a5d3">How to build Graal-enabled JDK8 on CircleCI?</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>