<?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 Adrien Ball on Medium]]></title>
        <description><![CDATA[Stories by Adrien Ball on Medium]]></description>
        <link>https://medium.com/@adrien_ball?source=rss-7f9cfdceb822------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*g1ZUcTtNKUYETOmi.jpg</url>
            <title>Stories by Adrien Ball on Medium</title>
            <link>https://medium.com/@adrien_ball?source=rss-7f9cfdceb822------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:01:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adrien_ball/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[An Introduction to Snips NLU, the Open Source Library behind Snips Embedded Voice Platform]]></title>
            <link>https://blog.chatbotslife.com/an-introduction-to-snips-nlu-the-open-source-library-behind-snips-embedded-voice-platform-857038ce394d?source=rss-7f9cfdceb822------2</link>
            <guid isPermaLink="false">https://medium.com/p/857038ce394d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Adrien Ball]]></dc:creator>
            <pubDate>Thu, 23 Aug 2018 13:05:34 GMT</pubDate>
            <atom:updated>2018-08-23T13:05:34.754Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by </em><a href="https://medium.com/u/7f9cfdceb822"><em>Adrien Ball</em></a><em>, </em><a href="https://medium.com/u/d0cd270292b2"><em>Clément Doumouro</em></a><em> and </em><a href="https://medium.com/u/bc6bf6e89e12"><em>Joseph Dureau</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foGKzeUJb9jVKaooLXjHOA.png" /></figure><p>The <a href="https://snips.ai/">Snips Embedded Voice Platform</a> allows any device manufacturer to build a Private by Design voice interface to their product. It handles Wakeword Detection, Speech Recognition, and Natural Language Understanding, fully on-device, so that none of your private voice data goes to the cloud. The Snips platform is also open for non-commercial use, for anyone who’d like to hack a voice assistant at home. With a Raspberry Pi 3, a microphone, and <a href="https://medium.com/snips-ai/build-a-weather-assistant-with-snips-4253541f1684">an hour of your time</a>, you can start controlling your home by voice, keeping full control of your data!</p><p>Today, the Snips team is making an extra step to promote the use of privacy-preserving Artificial Intelligence: we are fully open sourcing <a href="https://github.com/snipsco/snips-nlu">Snips NLU</a>, our Natural Language Understanding library.</p><p>Snips NLU has been developed with accuracy and footprint in mind. We wanted our embedded solution to yield <a href="https://github.com/snipsco/nlu-benchmark/tree/master/2018-01-Braum-et-al-extension">similar or better performances as cloud-based NLU solutions</a> (Dialogflow, Amazon Lex, etc). We also wanted it to run anywhere: not only on servers but also on tablets, mobiles, or any connected device. To achieve this, we had to completely rethink how to build an NLU engine, both in terms of engineering and machine learning. Let us introduce you to Snips NLU.</p><figure><a href="https://www.eventbrite.com/e/chatbot-conference-tickets-45884424549?utm-medium=discovery&amp;utm-campaign=social&amp;utm-content=attendeeshare&amp;aff=escb&amp;utm-source=cp&amp;utm-term=listing"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oyftTzPL9qaCYc8z2EbcHg.png" /></a></figure><h3>Natural Language Understanding</h3><p>NLU engines are used to power any <a href="https://chatbotslife.com/">chatbot</a> or voice assistant. Their objective is to identify the intention of the user (a.k.a <em>intent</em>) and the parameters (a.k.a <em>slots</em>) of the query. The developer can then use this to determine the appropriate action or response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cv78W6hp0EvJZLWnsoIJA.png" /></figure><p>Let’s start by looking at a simple example, and see what you would expect from a good NLU engine. Consider the following dataset, used to train a simple weather assistant with a few query examples:</p><ul><li>Give me the weather for [tomorrow](snips/datetime)</li><li>Show me the [Paris](location)&#39;s weather for [Sunday](snips/datetime)</li></ul><p>And a short list of cities:</p><ul><li>Paris</li><li>New York</li></ul><h3>Top 3 Most Popular Ai Articles:</h3><blockquote><a href="https://chatbotslife.com/introduction-to-deep-learning-on-social-networks-how-to-learn-even-more-about-your-personal-life-cd1da6d67770">1. Intro to Deep Learning in Social Networks</a></blockquote><blockquote><a href="https://chatbotslife.com/ultimate-guide-to-leveraging-nlp-machine-learning-for-you-chatbot-531ff2dd870c">2. Ultimate Guide to Leveraging NLP &amp; NLU for you Chatbot</a></blockquote><blockquote><a href="https://chatbotslife.com/deep-learning-in-7-lines-of-code-7879a8ef8cfb">3. Deep Learning in 7 Lines of Code</a></blockquote><blockquote><a href="https://chatbotslife.com/ai-nlp-workshop-fa39e2eac049">4. AI &amp; NLP Workshop</a></blockquote><h4>Deterministic behavior</h4><p>The first thing you want is that all the examples you give to train the model are correctly supported by the engine. This makes the system predictable and easy to use: if a query is not correctly parsed, then add it to the dataset and it will work right away.</p><h4>Generalization power</h4><p>Having this deterministic behavior is great for robustness and predictability, but a powerful NLU engine also needs to have some generalization power. You want the system not only to recognize patterns provided in the training set, but also all the possible variations that come from speaking naturally. If we go back to the previous dataset, it is reasonable to expect the NLU engine to parse a query like: <em>“What’s the weather in Beijing right now?”</em> even though it is not part of the training examples.</p><h4>Entity resolution</h4><p>Lastly, you need something called Entity Resolution. Essentially, extracting the chunk <em>“the third Sunday of March 2018”</em> from the sentence <em>“I need the weather for the third Sunday of March 2018”</em> is a good first step. However, what you want to do next is call a weather API to get the weather, and there’s little chance that the API will accept raw dates strings as input. It will rather take a date in ISO format: 2018–03–18. The later is referred to as the <em>resolved value</em> of the entity.</p><p>Dates and times are examples of entities that can be resolved. There are many others such as number, temperatures, durations etc. We call this special kind of entities <em>Built-in Entities</em> because the engine supports them natively without requiring the developer to provide examples for them (which is the case for custom entities). The list of built-in entities currently supported by Snips is available <a href="https://github.com/snipsco/snips-nlu-ontology">here</a>, we plan to add more in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ti7i79hqYC-0lEYM." /><figcaption>Snips NLU Processing Pipeline</figcaption></figure><p>In order to satisfy these objectives: deterministic behaviour, generalisation power, and the ability to resolve entities, we built the processing pipeline described on the figure above. It receives text as input, and outputs a structured response containing the intent and the list of slots. The main processing unit of the pipeline is the NLU engine. It contains two intent parsers which are called successively: a deterministic intent parser and a probabilistic one.</p><p>The deterministic parser relies on regular expressions to match intent and slots, which results in perfect behavior on training examples but doesn’t generalize. This parser is the first to be used because of its strictness.</p><p>The probabilistic parser is used whenever the first parser fails to find a match. It uses machine learning to generalize beyond the set of sentences seen at train time, thus mitigating the limitations of the deterministic parser. This parser involves two successive steps: intent classification and slot filling. The intent classification step relies on a logistic regression to identify the intent expressed by the user. Slot filling consists in a linear chain <a href="https://en.wikipedia.org/wiki/Conditional_random_field">Conditional Random Field</a> (CRF), specifically trained to extract the slots of the identified intent.</p><p>Regarding the choice of models, we tried dozens of different architectures, including deep ones. We found that there was no significant gain using deep learning versus CRFs for this task, so we favored the lightest option.</p><p>We also reproduced in January 2018 an <a href="http://www.sigdial.org/workshops/conference18/proceedings/pdf/SIGDIAL22.pdf">academic benchmark</a> published last summer. In this article, authors assessed the performance of API.ai (now Dialogflow, Google), Luis.ai (Microsoft), IBM Watson, and <a href="https://nlu.rasa.ai/">Rasa NLU</a>. For fairness, we used an updated version of Rasa NLU and compared it to the latest version of Snips NLU (both in dark blue).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3wbY-6QtD88qkhUFdogsFQ.png" /><figcaption>Reproducing “<a href="http://www.sigdial.org/workshops/conference18/proceedings/pdf/SIGDIAL22.pdf">Evaluating Natural Language Understanding Services for Conversational Question Answering Systems</a>”. See <a href="https://github.com/snipsco/nlu-benchmark/tree/master/2018-01-Braum-et-al-extension">underlying results</a>.</figcaption></figure><p>The last step after identifying the intent and the slots is to resolve slot values. Converting a raw string into a resolved entity is often a complex task for which we rely on another Snips open source library: <a href="https://github.com/snipsco/rustling-ontology">Rustling</a>. This is an in-house re-implementation of Facebook’s great <a href="https://github.com/facebook/duckling">duckling</a> library in Rust. The original algorithm was modified to make run times more stable with regards to the length of the sentences parsed. It resolves values such as dates, temperatures, durations, etc, as explained previously.</p><p>This whole pipeline has been designed to be both configurable and extensible. For instance, the CRFs in the slot filler can easily be replaced with something else. Each processing unit of the pipeline has its own configuration which can be tuned to adapt to custom use cases.</p><h4>The Snips NLU Ecosystem</h4><p>The Snips NLU ecosystem powers everything NLU-related at Snips. <a href="https://github.com/snipsco/snips-nlu">Snips NLU</a>is used to train models generated in the Snips Web console, on Python workers. <a href="https://github.com/snipsco/snips-nlu-rs">Snips NLU Rust</a> is used to run inference everywhere: in our Web console using a Scala backend, or on-device, whether on Linux, iOS or Android. To get the same code to run in such diverse and constrained environments, <a href="https://blog.mozilla.org/blog/2018/02/21/snips-uses-rust-embedded-voice-assistant/">we heavily bet on Rust</a>. This modern language offers high performance and low memory overhead, as well as memory safety and cross-compilation as first-class citizens. A JSON serialization of trained models is used as the interface across Snips NLU libraries.</p><p>This makes Snips NLU the first open source NLU library which is fully portable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rRjSYIpw-1Uy8nnzPjIZGA.png" /><figcaption>Snips NLU inference runtimes on a typical sentence</figcaption></figure><p>Using Snips NLU on the edge or on premises significantly reduces the inference runtime compared to a roundtrip to an NLU cloud service. The memory footprint ranges from a few hundreds KB of RAM for common cases, to a few MB for the most complex assistants.</p><h3>What’s next?</h3><p>Our focus for the next months will be about improving our models, specifically the intent classification part, improving the way we handle resources, and adding support for more builtin entities and languages. Today, Snips NLU handles English, French, German, Spanish and Korean.</p><p>Last, we will be very attentive to the feedback we get from the community so don’t hesitate to file issues, and make pull requests. 😉</p><h3>Get Started!</h3><p>Check the <a href="https://snips-nlu.readthedocs.io/">documentation</a> to get started, don’t hesitate to dive into the code on <a href="https://github.com/snipsco/snips-nlu">Github</a>. Join us on <a href="https://discordapp.com/invite/3939Kqx">Discord</a> for any question or feedback and start building your own assistant on the <a href="https://console.snips.ai/signup?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=NLU%20open%20source&amp;utm_content=Jo">Snips console</a>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*qlDaZoPwp8ZhLpX17o_A8A.png" /></figure><p><em>If you liked this article and want to support Snips, please share it!</em></p><p><em>Follow us on Twitter </em><a href="https://twitter.com/adrien_ball"><em>adrien_ball</em></a><em>, </em><a href="https://twitter.com/clem_doum"><em>clem_doum</em></a><em>, </em><a href="https://twitter.com/JoDureau"><em>jodureau</em></a><em> and </em><a href="https://twitter.com/snips"><em>snips</em></a><em>.</em></p><p><em>If you want to work on AI + Privacy, check our </em><a href="https://snips.ai/jobs/"><em>jobs page</em></a><em>!</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e59ef%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e59ef&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e59ef%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href">https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href</a></iframe><figure><a href="https://chatbotslife.com/bot-communities-mastermind-group-d2dae9876709#.53x0py6ou"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*6XUspT9JOSq0w0Fi35HIaA.png" /></a></figure><figure><a href="https://m.me/ChatbotsLife"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*c1LDMH5vbnIz9rmAka8Hwg.png" /></a></figure><figure><a href="https://chatbotslife.com/how-to-get-a-free-chatbot-b1fb9dfe109#.z9dtp2sy0"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*D0Jf3dI6ZThtqcfwDYY7mg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=857038ce394d" width="1" height="1" alt=""><hr><p><a href="https://blog.chatbotslife.com/an-introduction-to-snips-nlu-the-open-source-library-behind-snips-embedded-voice-platform-857038ce394d">An Introduction to Snips NLU, the Open Source Library behind Snips Embedded Voice Platform</a> was originally published in <a href="https://blog.chatbotslife.com/">Chatbots Life</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Voice controlled lights with a Raspberry Pi and Snips]]></title>
            <link>https://medium.com/snips-ai/voice-controlled-lights-with-a-raspberry-pi-and-snips-822e53d7ede6?source=rss-7f9cfdceb822------2</link>
            <guid isPermaLink="false">https://medium.com/p/822e53d7ede6</guid>
            <category><![CDATA[smart-home]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[internet-of-things]]></category>
            <category><![CDATA[voice-assistant]]></category>
            <category><![CDATA[how-to]]></category>
            <dc:creator><![CDATA[Adrien Ball]]></dc:creator>
            <pubDate>Sun, 17 Jun 2018 14:48:43 GMT</pubDate>
            <atom:updated>2020-05-16T08:55:35.218Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Important note:</em></strong><em> this article has been moved to </em><a href="https://adrienball.fr/2018/06/17/voice-controlled-lights/"><em>https://adrienball.fr/2018/06/17/voice-controlled-lights</em></a><em>. Read the up-to-date version there.</em></p><p>The objective of this article is to provide a step-by-step tutorial on how to setup a voice controlled light that you can interact with using trigger words.</p><p>This is what you will have at the end of this tutorial:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F275487173%3Fapp_id%3D122963&amp;dntp=1&amp;url=https%3A%2F%2Fvimeo.com%2F275487173&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F707786188_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/7345c42158e5fc6aed7c6dfcd097249b/href">https://medium.com/media/7345c42158e5fc6aed7c6dfcd097249b/href</a></iframe><p>At this point, you probably already have some questions in mind that need to be answered before you can spend more time on this.</p><p><strong>What kind of lights will I be able to control ?</strong><br>Any light that you plug on a power socket.</p><p><strong>What about my privacy? Will my voice be processed on the cloud ?</strong><br>Everything will be processed locally. No server. No cloud. No data leak. Perfect resilience to internet outages.</p><p><strong>Once setup, will it require an internet connection ?</strong><br>No.</p><p><strong>Will I be able to control something else than lights ?</strong><br>Yes. This tutorial focuses on lights, but it is about controlling power sockets and not lights specifically.</p><p><strong>Can I choose other trigger words than the ones in the video ?</strong><br>Yes, and you will have to because these trigger words are customised to recognise your voice specifically.</p><p><strong>Will I be lost if I’m not a hacker ?</strong><br>No, every steps will be well documented assuming almost zero knowledge of software nor hardware.</p><p><strong>How much will it cost me ?</strong><br>Around 105 euros, all included, if you follow my setup which contains some spare pieces. You can probably go a bit cheaper.</p><p><strong>How much time will it take to build ?</strong><br>Between 1 and 2 hours.</p><h3>Hardware requirements</h3><p><strong>Connected Plugs → 31,90€</strong></p><p>The first thing you need is a set of 433MHz remote-controlled power sockets. We will use the <a href="https://www.chacon.be/en/lighting/63-set-of-3-dio-remote-controlled-plugs-5411478547952.html">DIO model from Chacon</a> which works great and is cheap. Alternatively, you can use any other model, provided it uses the 433MHz frequency. If you go for the Chacon’s model, then it is probably a better idea to buy a set of 3 (~10€ / unit) instead of just one (~20€ / unit), as it is much more expensive and it is likely that, if everything goes well, you will want to connect more stuff in your home. 🙂</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYiY4Jw1vKGi6ZVT-er16Q.png" /><figcaption>DI-O Remote controlled plugs by Chacon</figcaption></figure><p><strong>Raspberry Pi 3 → 36€</strong></p><p>The Raspberry Pi 3 will be the main component of this setup, it is a single-board computer which have enough power for our use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*gVemTOmuZJf9gsPooTKcCg.png" /></figure><p><strong>Micro USB charger → 7€</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/1*saft1wqBwojhx5cBbH1vlQ.png" /></figure><p><strong>Micro SD card 4Gb class 10 → 8€</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*oABOumpZQ9_cah-ltipnlQ.png" /></figure><p><strong>PS3 Eye→ 9€</strong></p><p>Surprisingly, this microphone is <a href="https://medium.com/snips-ai/benchmarking-microphone-arrays-respeaker-conexant-microsemi-acuedge-matrix-creator-minidsp-950de8876fda">one of the best option</a> for our use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*po7Ix7zeW0EoJN0JoLWxIA.png" /><figcaption>PS3 Eye</figcaption></figure><p><strong>Radio transmitter → &lt; 10€</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*Na2astfUyvKYPgBcBQTbyw.png" /><figcaption>433MHz RF transmitter</figcaption></figure><p>We will need a 433MHz radio transmitter. You will find tons of models online (just type <em>“rf 433” </em>on Amazon), <a href="https://www.amazon.com/kwmobile-transmitter-receiver-wireless-Raspberry/dp/B01H2D2RH6">the ones from kwmobile</a> seem to be often used in this kind of setup. Note that in most cases you will get both a transmitter and a receiver though we only need the transmitter here.</p><p><strong>Breadboard jumper cables → 1€</strong></p><p>We will need some female/female jumper cables to plug the radio transmitter to the <a href="https://pinout.xyz/">Raspberry Pi GPIO pins</a>. These can be found easily on Amazon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*jV-9FMpvofR5ZhbYSQtIvA.png" /><figcaption>Female / Female jumper cables</figcaption></figure><h3>Hardware setup</h3><p>In all the following steps, make sure that the Raspberry Pi is not powered, otherwise you could damage the hardware and/or yourself.</p><h4>Plug the PS3 Eye microphone</h4><p>Simple as ABC, just use one of the USB plugs of the Raspberry Pi.</p><h4><strong>Plug the RF 433MHz transmitter</strong></h4><p>The radio transmitter has 3 pins: one power pin, one DATA pin and a Ground pin:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*otP8M_bdKUdMnO_iyWPBqA.png" /></figure><p>The power pin can be plugged to the remaining 3v3 power pin on the Pi (pin number 1 in the pinout schema). We will use the pin number 13 (BCM 27) for DATA, and pin 14 for the ground. We plug the transmitter to the Raspberry Pi using the female/female cables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*T-BqbQbKsm5WqHbxjHT96Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dG6ONf7KOTlSnULhC4FrNQ.jpeg" /></figure><h3>Software setup</h3><p>First, we need to install the Raspbian Stretch Lite distribution on the SD card. Insert the SD card in your computer, check the instructions <a href="https://www.raspberrypi.org/documentation/installation/installing-images/">here</a>, download the image and burn it on the SD card using <a href="https://etcher.io/">Etcher</a>.</p><h4>Configure Wifi access</h4><p>Add the following file wpa_supplicant.conf at the root of the boot volume of the SD card (do not forget to update the ssid and psk keys as well as the country key):</p><pre>country=FR<br>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev<br>update_config=1<br>network={<br>    ssid=&quot;Your WiFi network name&quot;<br>    psk=&quot;Your WiFi network password&quot;<br>}</pre><h4>Enable SSH</h4><p>Enable SSH by adding an empty file ssh at the root of the boot volume on your SD card. Insert the SD card into the Raspberry. It will boot in about 20 seconds. If you run into issues check <a href="https://www.raspberrypi.org/documentation/remote-access/ssh/">this</a>.</p><p>You can now access your Raspberry from your computer using ssh pi@raspberrypi.local</p><p><strong>Note:</strong> If you have several Raspberry Pi’s on the same network, it is probably a good idea to <a href="https://www.howtogeek.com/167195/how-to-change-your-raspberry-pi-or-other-linux-devices-hostname/">change their hostname</a> or connect to them using their <a href="https://www.raspberrypi.org/documentation/remote-access/ip-address.md">IP</a>.</p><p>From now on, the next installation commands will have to be run from the Raspberry Pi, through ssh.</p><h4>Setup the radio transmitter</h4><p>In order to command the 433MHz radio transmitter, we first need to install <a href="http://wiringpi.com/download-and-install/">WiringPi</a>. It is a PIN based GPIO access library which will be used by our main program in order to access and control the DATA GPIO pin used by the transmitter. Here are the steps to download and install WiringPi:</p><pre>$ sudo apt-get update<br>$ sudo apt-get upgrade <br>$ sudo apt-get install -y git<br>$ cd<br>$ git clone git://git.drogon.net/wiringPi<br>$ cd wiringPi<br>$ ./build</pre><p>Now that WiringPi is installed, we can install the program that will replicate what the DIO remote control does when you press on and off. This program is written in C and largely inspired by <a href="http://blog.idleman.fr/raspberry-pi-12-allumer-des-prises-distance/">this article</a> (in French) from <a href="http://blog.idleman.fr/">Idleman</a>. Here are the steps to download the C program and compile it:</p><pre>$ cd<br>$ mkdir lights_commands &amp;&amp; cd lights_commands<br>$ wget <a href="https://raw.githubusercontent.com/adrienball/smart-lights/master/chacon_send.cpp">https://raw.githubusercontent.com/adrienball/smart-lights/master/chacon_send.cpp</a><br>$ g++ -o chacon_send chacon_send.cpp -lwiringPi</pre><p>This will generate a binary named chacon_send which we will use to send on and off signals to our DIO connected plug:</p><pre>$ sudo ./chacon_send &lt;wiringPI pin&gt; &lt;controller_code&gt; &lt;outlet_code&gt; &lt;on|off&gt;</pre><ul><li>wiringPI pin: this corresponds to the wiringPi pin number on which we plugged the DATA GPIO pin of the radio transmitter. We used the GPIO pin 13 which corresponds to the wiringPi number 2. If you used another pin, you can refer to the <a href="http://wiringpi.com/pins/">wiringPi mapping</a>, or the table below, to get the corresponding number.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*tvUx-5sniUVDS1qoAqx49w.png" /><figcaption>WiringPi mapping</figcaption></figure><ul><li>controller_code: this is a transmitter id number that we attribute arbitrarily to the RaspberryPi. It allows the power outlet to exclusively accept commands from this transmitter.</li><li>outlet_code: this is a receiver code that you attribute arbitrarily to the DIO outlet that you want to control.</li><li>on|off: the desired state of the outlet.</li></ul><p>The transmitter/receiver synchronisation happens when you plug the power outlet. The Chacon power outlet contains a signal synchronisation module which means that, when you plug the outlet, there will be a short time of 5 seconds during which it will listen for any emitted signal and will remember its attribution codes (controller_code and outlet_code). Thus, for each plug you want to control, you will have to plug it and, within 5 seconds, send a signal using the command described just before (using a different outlet_code for each outlet).</p><p>The power outlet will make some characteristic “clic-clac” sounds to let you know that it has properly recognised and memorised your signal.</p><p>At this point, you can try the radio transmitter by plugging your power outlet and run:</p><pre>$ sudo ./chacon_send 2 12325261 1 on</pre><p>If everything went well, your power outlet should make a clic as it switches on.</p><h4>Setup the microphone</h4><p>Before setting up the audio, plug your USB microphone to the Raspberry Pi, and connect some headphones to the audio jack.</p><p>Start by creating an /etc/asound.conf file:</p><pre>$ sudo nano /etc/asound.conf</pre><pre>pcm.!default {<br>  type asym<br>  playback.pcm {<br>    type plug<br>    slave.pcm &quot;hw:0,0&quot;<br>  }<br>  capture.pcm {<br>    type plug<br>    slave.pcm &quot;hw:1,0&quot;<br>  }<br>}</pre><p>Now, let’s test the audio input. Execute the following command, speak into your microphone, and hit CTRL-C when you are done speaking:</p><pre>$ arecord -f cd out.wav<br>Recording WAVE &#39;out.wav&#39; : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo<br>^CAborted by signal Interrupt...</pre><p>Play the recorded sound to validate that your microphone is working:</p><pre>$ aplay out.wav<br>Playing WAVE &#39;out.wav&#39; : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo</pre><p><strong>Note:</strong> If you have some troubles here, you may want to play with the db gain using the alsamixer command.</p><h4>Setup the Snips platform</h4><p>Now that the communication between the Pi and the power outlet is setup, we can move to the last piece, which is the most interesting one: <strong>make the lights react to your voice !</strong></p><p><em>Disclaimer: I work at Snips.</em></p><p>To do so, we are going to use the <a href="https://snips.ai/">Snips</a> voice platform. It has the unique advantage to provide voice recognition directly on device, which means <em>everything will run locally on the RaspberryPi</em>, removing the need for a cloud based solution. Snips provides three main components:</p><ul><li><strong>Wake word detector</strong>: a component responsible for detecting a trigger word (think <em>Ok Google</em> or <em>Hey Siri</em>), that you can customise.</li><li><strong>Automatic Speech Recognition Engine</strong>: this component converts your voice to text.</li><li><strong>Natural Language Understanding Engine</strong>: it is responsible for extracting structured data from queries expressed in natural language. This piece is actually <a href="https://github.com/snipsco/snips-nlu">open source</a>.</li></ul><p>For our use case, we will only install the first component: the wake word detector:</p><pre>$ cd<br>$ sudo apt-get install -y dirmngr<br>$ sudo bash -c  &#39;echo &quot;deb <a href="https://raspbian.snips.ai/$(lsb_release">https://raspbian.snips.ai/$(lsb_release</a> -cs) stable main&quot; &gt; /etc/apt/sources.list.d/snips.list&#39;<br>$ sudo apt-key adv --keyserver pgp.mit.edu --recv-keys D4F50CDCA10A2849</pre><pre>$ sudo apt-get update<br>$ sudo apt-get install -y mosquitto<br>$ sudo apt-get install -y snips-audio-server<br>$ sudo apt-get install -y snips-hotword<br>$ git clone <a href="https://github.com/snipsco/snips-record-personal-hotword.git">https://github.com/snipsco/snips-record-personal-hotword.git</a><br>$ cd snips-record-personal-hotword/<br>$ sudo apt-get install -y python-numpy python-pyaudio python-soundfile</pre><h4>Recording the wake words</h4><p>You are now ready to record you personal wake words. You will need to record at least two distinct wake words: one will be used to switch on the light, and the other to switch it off. You can have more than two if you want to support some variations.</p><p>Run the following command, replacing your own wake word name instead of your_hotword_name, and follow the instructions:</p><pre>$ sudo systemctl stop snips-audio-server; python script_recording.py &lt;your_hotword_name&gt;</pre><p>You should have to record three samples before the model is saved. At this point, check where your wake word model has been saved as you will need this information afterwards.</p><p>If you have some troubles recording your wake word, please check the <a href="https://snips.gitbook.io/documentation/advanced-configuration/wakeword/personal-wakeword">Snips documentation</a>.</p><p>Now it’s time to test the model and adjust the sensitivity accordingly. First, run this command:</p><pre>$ sudo systemctl stop snips-hotword; sudo systemctl start snips-audio-server;</pre><p>Then run the following one to launch the wake word detector:</p><pre>$ snips-hotword --model &lt;path_to_your_model&gt;=&lt;sensitivity&gt;</pre><p>As per Snips documentation:</p><p>Once you are happy with your settings, follow the steps described <a href="https://snips.gitbook.io/documentation/advanced-configuration/wakeword/personal-wakeword#5-update-your-assistant-configuration-to-run-your-personal-model">here</a> to finalise the personal wake word setup.</p><p>Make sure that you have correctly restarted the snips-hotword service once you are done:</p><pre>$ sudo systemctl restart snips-hotword</pre><h4>Setup the python handler</h4><p>Finally, the last step of this tutorial consists in plugging everything together, using a small python handler.</p><p>This handler relies on a python library, paho-mqtt that we need to install beforehand:</p><pre>$ sudo apt-get install -y python-pip<br>$ sudo pip install paho-mqtt==1.3.1</pre><p>Then, download the handler:</p><pre>$ cd<br>$ cd lights_commands<br>$ wget <a href="https://raw.githubusercontent.com/adrienball/smart-lights/master/snips_handler.py">https://raw.githubusercontent.com/adrienball/smart-lights/master/snips_handler.py</a></pre><p>Make it executable:</p><pre>$ chmod +x snips_handler.py</pre><p>Now, edit the handler file and update the HOTWORDS_ON and HOTWORDS_OFF variables with the names of the wake words you recorded, e.g.:</p><pre>HOTWORDS_ON = {&quot;illumino&quot;, &quot;lumos&quot;}<br>HOTWORDS_OFF = {&quot;obscuro&quot;, &quot;nocte&quot;}</pre><p>By default this handler is sending the following commands:</p><pre>./chacon_send 2 12325261 1 on<br>./chacon_send 2 12325261 1 off</pre><p>Thus, if you used another wiringPi pin or outlet code (see radio transmitter section), you have to update this part of the handler as well.</p><p>Finally, we are going to convert this python script into a systemd service. Create the smart-lights.service and update the file accordingly:</p><pre>$ sudo nano /etc/systemd/system/multi-user.target.wants/smart-lights.service</pre><pre>[Unit]<br>Description=Smart Lights Service<br>After=multi-user.target</pre><pre>[Service]<br>Type=simple<br>ExecStart=/usr/bin/python /home/pi/lights_commands/snips_handler.py<br>Restart=on-abort</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><p>Now, start the service and check its status:</p><pre>$ sudo systemctl start smart-lights<br>$ sudo systemctl status smart-lights<br>● smart-lights.service - Smart Lights Service<br>   Loaded: loaded (/etc/systemd/system/multi-user.target.wants/smart-lights.service; linked; vendor preset: enabled)<br>   Active: active (running) since Sun 2018-06-17 12:52:07 UTC; 1min 34s ago<br> Main PID: 11040 (python)<br>   CGroup: /system.slice/smart-lights.service<br>           └─11040 /usr/bin/python /home/pi/lights_commands/snips_handler.py</pre><p>The service should be up and running, and it will restart automatically each time you reboot your Raspberry Pi.</p><h4>Congratulations!</h4><p>That’s it! If you reached this point, then everything is setup and you can now enjoy interacting with your smart light !</p><p><em>If you liked this article, please share it and follow me on </em><a href="https://twitter.com/adrien_ball"><em>Twitter</em></a><em> and </em><a href="https://github.com/adrienball"><em>Github</em></a><em> !</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=822e53d7ede6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snips-ai/voice-controlled-lights-with-a-raspberry-pi-and-snips-822e53d7ede6">Voice controlled lights with a Raspberry Pi and Snips</a> was originally published in <a href="https://medium.com/snips-ai">Snips Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Snips NLU, the Open Source Library behind Snips Embedded Voice Platform]]></title>
            <link>https://medium.com/chat-bots/an-introduction-to-snips-nlu-the-open-source-library-behind-snips-embedded-voice-platform-244783741a3b?source=rss-7f9cfdceb822------2</link>
            <guid isPermaLink="false">https://medium.com/p/244783741a3b</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[nlu]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Adrien Ball]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 16:54:42 GMT</pubDate>
            <atom:updated>2018-05-14T16:30:11.817Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by </em><a href="https://medium.com/u/7f9cfdceb822"><em>Adrien Ball</em></a><em>, </em><a href="https://medium.com/u/d0cd270292b2"><em>Clément Doumouro</em></a><em> and </em><a href="https://medium.com/u/bc6bf6e89e12"><em>Joseph Dureau</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foGKzeUJb9jVKaooLXjHOA.png" /></figure><p>The <a href="https://snips.ai/">Snips Embedded Voice Platform</a> allows any device manufacturer to build a Private by Design voice interface to their product. It handles Wakeword Detection, Speech Recognition, and Natural Language Understanding, fully on-device, so that none of your private voice data goes to the cloud. The Snips platform is also open for non-commercial use, for anyone who’d like to hack a voice assistant at home. With a Raspberry Pi 3, a microphone, and <a href="https://medium.com/snips-ai/build-a-weather-assistant-with-snips-4253541f1684">an hour of your time</a>, you can start controlling your home by voice, keeping full control of your data!</p><p>Today, the Snips team is making an extra step to promote the use of privacy-preserving Artificial Intelligence: we are fully open sourcing <a href="https://github.com/snipsco/snips-nlu">Snips NLU</a>, our Natural Language Understanding library.</p><p>Snips NLU has been developed with accuracy and footprint in mind. We wanted our embedded solution to yield <a href="https://github.com/snipsco/nlu-benchmark/tree/master/2018-01-Braum-et-al-extension">similar or better performances as cloud-based NLU solutions</a> (Dialogflow, Amazon Lex, etc). We also wanted it to run anywhere: not only on servers but also on tablets, mobiles, or any connected device. To achieve this, we had to completely rethink how to build an NLU engine, both in terms of engineering and machine learning. Let us introduce you to Snips NLU.</p><h3>Natural Language Understanding</h3><p>NLU engines are used to power any chatbot or voice assistant. Their objective is to identify the intention of the user (a.k.a <em>intent</em>) and the parameters (a.k.a <em>slots</em>) of the query. The developer can then use this to determine the appropriate action or response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cv78W6hp0EvJZLWnsoIJA.png" /></figure><p>Let’s start by looking at a simple example, and see what you would expect from a good NLU engine. Consider the following dataset, used to train a simple weather assistant with a few query examples:</p><ul><li>Give me the weather for [tomorrow](snips/datetime)</li><li>Show me the [Paris](location)&#39;s weather for [Sunday](snips/datetime)</li></ul><p>And a short list of cities:</p><ul><li>Paris</li><li>New York</li></ul><h4>Deterministic behavior</h4><p>The first thing you want is that all the examples you give to train the model are correctly supported by the engine. This makes the system predictable and easy to use: if a query is not correctly parsed, then add it to the dataset and it will work right away.</p><h4>Generalization power</h4><p>Having this deterministic behavior is great for robustness and predictability, but a powerful NLU engine also needs to have some generalization power. You want the system not only to recognize patterns provided in the training set, but also all the possible variations that come from speaking naturally. If we go back to the previous dataset, it is reasonable to expect the NLU engine to parse a query like: <em>“What’s the weather in Beijing right now?”</em> even though it is not part of the training examples.</p><h4>Entity resolution</h4><p>Lastly, you need something called Entity Resolution. Essentially, extracting the chunk <em>“the third Sunday of March 2018”</em> from the sentence <em>“I need the weather for the third Sunday of March 2018”</em> is a good first step. However, what you want to do next is call a weather API to get the weather, and there’s little chance that the API will accept raw dates strings as input. It will rather take a date in ISO format: 2018–03–18. The later is referred to as the <em>resolved value</em> of the entity.</p><p>Dates and times are examples of entities that can be resolved. There are many others such as number, temperatures, durations etc. We call this special kind of entities <em>Built-in Entities</em> because the engine supports them natively without requiring the developer to provide examples for them (which is the case for custom entities). The list of built-in entities currently supported by Snips is available <a href="https://github.com/snipsco/snips-nlu-ontology">here</a>, we plan to add more in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ti7i79hqYC-0lEYM." /><figcaption>Snips NLU Processing Pipeline</figcaption></figure><p>In order to satisfy these objectives: deterministic behaviour, generalisation power, and the ability to resolve entities, we built the processing pipeline described on the figure above. It receives text as input, and outputs a structured response containing the intent and the list of slots. The main processing unit of the pipeline is the NLU engine. It contains two intent parsers which are called successively: a deterministic intent parser and a probabilistic one.</p><p>The deterministic parser relies on regular expressions to match intent and slots, which results in perfect behavior on training examples but doesn’t generalize. This parser is the first to be used because of its strictness.</p><p>The probabilistic parser is used whenever the first parser fails to find a match. It uses machine learning to generalize beyond the set of sentences seen at train time, thus mitigating the limitations of the deterministic parser. This parser involves two successive steps: intent classification and slot filling. The intent classification step relies on a logistic regression to identify the intent expressed by the user. Slot filling consists in a linear chain <a href="https://en.wikipedia.org/wiki/Conditional_random_field">Conditional Random Field</a> (CRF), specifically trained to extract the slots of the identified intent.</p><p>Regarding the choice of models, we tried dozens of different architectures, including deep ones. We found that there was no significant gain using deep learning versus CRFs for this task, so we favored the lightest option.</p><p>We also reproduced in January 2018 an <a href="http://www.aclweb.org/anthology/W17-5522">academic benchmark</a> published last summer. In this article, authors assessed the performance of API.ai (now Dialogflow, Google), Luis.ai (Microsoft), IBM Watson, and <a href="https://nlu.rasa.ai/">Rasa NLU</a>. For fairness, we used an updated version of Rasa NLU and compared it to the latest version of Snips NLU (both in dark blue).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3wbY-6QtD88qkhUFdogsFQ.png" /><figcaption>Reproducing “<a href="http://www.sigdial.org/workshops/conference18/proceedings/pdf/SIGDIAL22.pdf">Evaluating Natural Language Understanding Services for Conversational Question Answering Systems</a>”. See <a href="https://github.com/snipsco/nlu-benchmark/tree/master/2018-01-Braum-et-al-extension">underlying results</a>.</figcaption></figure><p>The last step after identifying the intent and the slots is to resolve slot values. Converting a raw string into a resolved entity is often a complex task for which we rely on another Snips open source library: <a href="https://github.com/snipsco/rustling-ontology">Rustling</a>. This is an in-house re-implementation of Facebook’s great <a href="https://github.com/facebook/duckling">duckling</a> library in Rust. The original algorithm was modified to make run times more stable with regards to the length of the sentences parsed. It resolves values such as dates, temperatures, durations, etc, as explained previously.</p><p>This whole pipeline has been designed to be both configurable and extensible. For instance, the CRFs in the slot filler can easily be replaced with something else. Each processing unit of the pipeline has its own configuration which can be tuned to adapt to custom use cases.</p><h4>The Snips NLU Ecosystem</h4><p>The Snips NLU ecosystem powers everything NLU-related at Snips. <a href="https://github.com/snipsco/snips-nlu">Snips NLU</a>is used to train models generated in the Snips Web console, on Python workers. <a href="https://github.com/snipsco/snips-nlu-rs">Snips NLU Rust</a> is used to run inference everywhere: in our Web console using a Scala backend, or on-device, whether on Linux, iOS or Android. To get the same code to run in such diverse and constrained environments, <a href="https://blog.mozilla.org/blog/2018/02/21/snips-uses-rust-embedded-voice-assistant/">we heavily bet on Rust</a>. This modern language offers high performance and low memory overhead, as well as memory safety and cross-compilation as first-class citizens. A JSON serialization of trained models is used as the interface across Snips NLU libraries.</p><p>This makes Snips NLU the first open source NLU library which is fully portable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rRjSYIpw-1Uy8nnzPjIZGA.png" /><figcaption>Snips NLU inference runtimes on a typical sentence</figcaption></figure><p>Using Snips NLU on the edge or on premises significantly reduces the inference runtime compared to a roundtrip to an NLU cloud service. The memory footprint ranges from a few hundreds KB of RAM for common cases, to a few MB for the most complex assistants.</p><h3>What’s next?</h3><p>Our focus for the next months will be about improving our models, specifically the intent classification part, improving the way we handle resources, and adding support for more builtin entities and languages. Today, Snips NLU handles English, French, German, Spanish and Korean.</p><p>Last, we will be very attentive to the feedback we get from the community so don’t hesitate to file issues, and make pull requests. 😉</p><h3>Get Started!</h3><p>Check the <a href="https://snips-nlu.readthedocs.io/">documentation</a> to get started, don’t hesitate to dive into the code on <a href="https://github.com/snipsco/snips-nlu">Github</a>. Join us on <a href="https://discordapp.com/invite/3939Kqx">Discord</a> for any question or feedback and start building your own assistant on the <a href="https://console.snips.ai/signup?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=NLU%20open%20source&amp;utm_content=Jo">Snips console</a>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*qlDaZoPwp8ZhLpX17o_A8A.png" /></figure><p><em>If you liked this article and want to support Snips, please share it!</em></p><p><em>Follow us on Twitter </em><a href="https://twitter.com/adrien_ball"><em>adrien_ball</em></a><em>, </em><a href="https://twitter.com/clem_doum"><em>clem_doum</em></a><em>, </em><a href="https://twitter.com/JoDureau"><em>jodureau</em></a><em> and </em><a href="https://twitter.com/snips"><em>snips</em></a><em>.</em></p><p><em>If you want to work on AI + Privacy, check our </em><a href="https://snips.ai/jobs/"><em>jobs page</em></a><em>!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=244783741a3b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chat-bots/an-introduction-to-snips-nlu-the-open-source-library-behind-snips-embedded-voice-platform-244783741a3b">An Introduction to Snips NLU, the Open Source Library behind Snips Embedded Voice Platform</a> was originally published in <a href="https://medium.com/chat-bots">Chatbots Magazine</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Snips NLU, the Open Source Library behind Snips Embedded Voice Platform]]></title>
            <link>https://medium.com/snips-ai/an-introduction-to-snips-nlu-the-open-source-library-behind-snips-embedded-voice-platform-b12b1a60a41a?source=rss-7f9cfdceb822------2</link>
            <guid isPermaLink="false">https://medium.com/p/b12b1a60a41a</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Adrien Ball]]></dc:creator>
            <pubDate>Wed, 07 Mar 2018 14:32:46 GMT</pubDate>
            <atom:updated>2018-06-13T17:28:15.653Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by </em><a href="https://medium.com/u/7f9cfdceb822"><em>Adrien Ball</em></a><em>, </em><a href="https://medium.com/u/d0cd270292b2"><em>Clément Doumouro</em></a><em> and </em><a href="https://medium.com/u/bc6bf6e89e12"><em>Joseph Dureau</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*foGKzeUJb9jVKaooLXjHOA.png" /></figure><p>The <a href="https://snips.ai/">Snips Embedded Voice Platform</a> allows any device manufacturer to build a Private by Design voice interface to their product. It handles Wakeword Detection, Speech Recognition, and Natural Language Understanding, fully on-device, so that none of your private voice data goes to the cloud. The Snips platform is also open for non-commercial use, for anyone who’d like to hack a voice assistant at home. With a Raspberry Pi 3, a microphone, and <a href="https://medium.com/snips-ai/build-a-weather-assistant-with-snips-4253541f1684">an hour of your time</a>, you can start controlling your home by voice, keeping full control of your data!</p><p>Today, the Snips team is making an extra step to promote the use of privacy-preserving Artificial Intelligence: we are fully open sourcing <a href="https://github.com/snipsco/snips-nlu">Snips NLU</a>, our Natural Language Understanding library.</p><p>Snips NLU has been developed with accuracy and footprint in mind. We wanted our embedded solution to yield <a href="https://github.com/snipsco/nlu-benchmark/tree/master/2018-01-Braum-et-al-extension">similar or better performances as cloud-based NLU solutions</a> (Dialogflow, Amazon Lex, etc). We also wanted it to run anywhere: not only on servers but also on tablets, mobiles, or any connected device. To achieve this, we had to completely rethink how to build an NLU engine, both in terms of engineering and machine learning. Let us introduce you to Snips NLU.</p><h3>Natural Language Understanding</h3><p>NLU engines are used to power any chatbot or voice assistant. Their objective is to identify the intention of the user (a.k.a <em>intent</em>) and the parameters (a.k.a <em>slots</em>) of the query. The developer can then use this to determine the appropriate action or response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4cv78W6hp0EvJZLWnsoIJA.png" /></figure><p>Let’s start by looking at a simple example, and see what you would expect from a good NLU engine. Consider the following dataset, used to train a simple weather assistant with a few query examples:</p><ul><li>Give me the weather for [tomorrow](snips/datetime)</li><li>Show me the [Paris](location)&#39;s weather for [Sunday](snips/datetime)</li></ul><p>And a short list of cities:</p><ul><li>Paris</li><li>New York</li></ul><h4>Deterministic behavior</h4><p>The first thing you want is that all the examples you give to train the model are correctly supported by the engine. This makes the system predictable and easy to use: if a query is not correctly parsed, then add it to the dataset and it will work right away.</p><h4>Generalization power</h4><p>Having this deterministic behavior is great for robustness and predictability, but a powerful NLU engine also needs to have some generalization power. You want the system not only to recognize patterns provided in the training set, but also all the possible variations that come from speaking naturally. If we go back to the previous dataset, it is reasonable to expect the NLU engine to parse a query like: <em>“What’s the weather in Beijing right now?”</em> even though it is not part of the training examples.</p><h4>Entity resolution</h4><p>Lastly, you need something called Entity Resolution. Essentially, extracting the chunk <em>“the third Sunday of March 2018”</em> from the sentence <em>“I need the weather for the third Sunday of March 2018”</em> is a good first step. However, what you want to do next is call a weather API to get the weather, and there’s little chance that the API will accept raw dates strings as input. It will rather take a date in ISO format: 2018–03–18. The later is referred to as the <em>resolved value</em> of the entity.</p><p>Dates and times are examples of entities that can be resolved. There are many others such as number, temperatures, durations etc. We call this special kind of entities <em>Built-in Entities</em> because the engine supports them natively without requiring the developer to provide examples for them (which is the case for custom entities). The list of built-in entities currently supported by Snips is available <a href="https://github.com/snipsco/snips-nlu-ontology">here</a>, we plan to add more in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ti7i79hqYC-0lEYM." /><figcaption>Snips NLU Processing Pipeline</figcaption></figure><p>In order to satisfy these objectives: deterministic behaviour, generalisation power, and the ability to resolve entities, we built the processing pipeline described on the figure above. It receives text as input, and outputs a structured response containing the intent and the list of slots. The main processing unit of the pipeline is the NLU engine. It contains two intent parsers which are called successively: a deterministic intent parser and a probabilistic one.</p><p>The deterministic parser relies on regular expressions to match intent and slots, which results in perfect behavior on training examples but doesn’t generalize. This parser is the first to be used because of its strictness.</p><p>The probabilistic parser is used whenever the first parser fails to find a match. It uses machine learning to generalize beyond the set of sentences seen at train time, thus mitigating the limitations of the deterministic parser. This parser involves two successive steps: intent classification and slot filling. The intent classification step relies on a logistic regression to identify the intent expressed by the user. Slot filling consists in a linear chain <a href="https://en.wikipedia.org/wiki/Conditional_random_field">Conditional Random Field</a> (CRF), specifically trained to extract the slots of the identified intent.</p><p>Regarding the choice of models, we tried dozens of different architectures, including deep ones. We found that there was no significant gain using deep learning versus CRFs for this task, so we favored the lightest option.</p><p>We also reproduced in January 2018 an <a href="http://www.aclweb.org/anthology/W17-5522">academic benchmark</a> published last summer. In this article, authors assessed the performance of API.ai (now Dialogflow, Google), Luis.ai (Microsoft), IBM Watson, and <a href="https://nlu.rasa.ai/">Rasa NLU</a>. For fairness, we used an updated version of Rasa NLU and compared it to the latest version of Snips NLU (both in dark blue).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3wbY-6QtD88qkhUFdogsFQ.png" /><figcaption>Reproducing “<a href="http://www.sigdial.org/workshops/conference18/proceedings/pdf/SIGDIAL22.pdf">Evaluating Natural Language Understanding Services for Conversational Question Answering Systems</a>”. See <a href="https://github.com/snipsco/nlu-benchmark/tree/master/2018-01-Braum-et-al-extension">underlying results</a>.</figcaption></figure><p>The last step after identifying the intent and the slots is to resolve slot values. Converting a raw string into a resolved entity is often a complex task for which we rely on another Snips open source library: <a href="https://github.com/snipsco/rustling-ontology">Rustling</a>. This is an in-house re-implementation of Facebook’s great <a href="https://github.com/facebook/duckling">duckling</a> library in Rust. The original algorithm was modified to make run times more stable with regards to the length of the sentences parsed. It resolves values such as dates, temperatures, durations, etc, as explained previously.</p><p>This whole pipeline has been designed to be both configurable and extensible. For instance, the CRFs in the slot filler can easily be replaced with something else. Each processing unit of the pipeline has its own configuration which can be tuned to adapt to custom use cases.</p><h4>The Snips NLU Ecosystem</h4><p>The Snips NLU ecosystem powers everything NLU-related at Snips. <a href="https://github.com/snipsco/snips-nlu">Snips NLU</a> is used to train models generated in the Snips Web console, on Python workers. <a href="https://github.com/snipsco/snips-nlu-rs">Snips NLU Rust</a> is used to run inference everywhere: in our Web console using a Scala backend, or on-device, whether on Linux, iOS or Android. To get the same code to run in such diverse and constrained environments, <a href="https://blog.mozilla.org/blog/2018/02/21/snips-uses-rust-embedded-voice-assistant/">we heavily bet on Rust</a>. This modern language offers high performance and low memory overhead, as well as memory safety and cross-compilation as first-class citizens. A JSON serialization of trained models is used as the interface across Snips NLU libraries.</p><p>This makes Snips NLU the first open source NLU library which is fully portable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rRjSYIpw-1Uy8nnzPjIZGA.png" /><figcaption>Snips NLU inference runtimes on a typical sentence</figcaption></figure><p>Using Snips NLU on the edge or on premises significantly reduces the inference runtime compared to a roundtrip to an NLU cloud service. The memory footprint ranges from a few hundreds KB of RAM for common cases, to a few MB for the most complex assistants.</p><h3>What’s next?</h3><p>Our focus for the next months will be about improving our models, specifically the intent classification part, improving the way we handle resources, and adding support for more builtin entities and languages. Today, Snips NLU handles English, French, German, Spanish and Korean.</p><p>Last, we will be very attentive to the feedback we get from the community so don’t hesitate to file issues, and make pull requests. 😉</p><h3>Get Started!</h3><p>Check the <a href="https://snips-nlu.readthedocs.io/">documentation</a> to get started, don’t hesitate to dive into the code on <a href="https://github.com/snipsco/snips-nlu">Github</a>. Join us on <a href="https://discordapp.com/invite/3939Kqx">Discord</a> for any question or feedback and start building your own assistant on the <a href="https://console.snips.ai/signup?utm_source=medium&amp;utm_medium=blog&amp;utm_campaign=NLU%20open%20source&amp;utm_content=Jo">Snips console</a>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*qlDaZoPwp8ZhLpX17o_A8A.png" /></figure><p><em>If you liked this article and want to support Snips, please share it!</em></p><p><em>Follow us on Twitter </em><a href="https://twitter.com/adrien_ball"><em>adrien_ball</em></a><em>, </em><a href="https://twitter.com/clem_doum"><em>clem_doum</em></a><em>, </em><a href="https://twitter.com/JoDureau"><em>jodureau</em></a><em> and </em><a href="https://twitter.com/snips"><em>snips</em></a><em>.</em></p><p><em>If you want to work on AI + Privacy, check our </em><a href="https://snips.ai/jobs/"><em>jobs page</em></a><em>!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b12b1a60a41a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/snips-ai/an-introduction-to-snips-nlu-the-open-source-library-behind-snips-embedded-voice-platform-b12b1a60a41a">An Introduction to Snips NLU, the Open Source Library behind Snips Embedded Voice Platform</a> was originally published in <a href="https://medium.com/snips-ai">Snips Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>