<?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 Antoine Sauray on Medium]]></title>
        <description><![CDATA[Stories by Antoine Sauray on Medium]]></description>
        <link>https://medium.com/@antoinesauray?source=rss-580a98d9adf7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*T6pP9L71clm8DBXET251LQ.jpeg</url>
            <title>Stories by Antoine Sauray on Medium</title>
            <link>https://medium.com/@antoinesauray?source=rss-580a98d9adf7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:26:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antoinesauray/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[Machine Learning Automation (1): Clipper AI]]></title>
            <link>https://medium.com/analytics-vidhya/machine-learning-automation-1-clipper-ai-7b896890695f?source=rss-580a98d9adf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b896890695f</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Antoine Sauray]]></dc:creator>
            <pubDate>Wed, 23 Oct 2019 07:09:06 GMT</pubDate>
            <atom:updated>2019-11-07T12:26:24.270Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is part of a series that explores machine learning platforms, to understand the service they provide and how they can help you deliver better models in production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*Yex3iKBI7foICdpR-L4LYg.png" /><figcaption>clipper.ai</figcaption></figure><h3>What is Clipper ?</h3><p>Clipper defines itself as:</p><blockquote>a prediction serving system that sits between user-facing applications and a wide range of commonly used machine learning models and frameworks.</blockquote><p>So Clipper is a reverse proxy. It is called via a REST Api and communicates with models through a low overhead protocol built on top of <a href="https://zeromq.org/">zeromq</a>.</p><p><strong>It consists of 3 buildings blocks</strong>:</p><ul><li><strong>Admin </strong>(or management): This service holds the configuration and allows for read and update. It requires a simple Redis database. It is written in Python</li><li><strong>Query Frontend</strong>: This is the reverse proxy, it is written in C++ for performance and to avoid garbage collection. It implements the zeromq protocol and communicate with models that way.</li><li><strong>Model</strong>: Each model is packaged in a container that handles remote procedure calls coming from the query frontend.</li></ul><p>Clipper <strong>drastically simplifies</strong> the deployment step if you use one of the supported orchestrators (Docker Cli, Kubernetes). It is relatively simple to support other orchestrators though, and I will demonstrate this below.</p><h3>From Jupyter Notebook to Deployment on Nomad</h3><p>This following example is based on a PR that is <a href="https://github.com/ucbrise/clipper/pull/750">still in review at the moment</a>.</p><p>Prerequisites:</p><ul><li>You need a Nomad cluster with Consul DNS and Fabio load balancer. You can follow <a href="https://blog.scaleway.com/2016/build-your-infrastructure-with-terraform-nomad-and-consul-on-scaleway/">this tutorial</a> for Scaleway and read the documentations available for <a href="https://www.nomadproject.io/">Nomad</a>, <a href="https://www.consul.io/">Consul</a> and <a href="https://fabiolb.net/">Fabio</a>.</li><li>You need Consul DNS configured on your machine, make sure that you can resolve *.service.consul addresses.</li></ul><p>You can find code samples and resources for nomad deployments on this <a href="https://github.com/hyperplan-io/clipper-nomad-demo">Git repository</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*_Q0P_JjsKNsBQW2UH2U56A.png" /><figcaption>The architecture I used for this demo</figcaption></figure><p>Our goal is to train a simple model on our machine and to deploy it to our Nomad cluster.</p><p>We start by building a simple model with Scikit-Learn. We will train a simple linear regression on the diabetes dataset from Scikit Learn. This fits in a few lines of code.</p><pre>from sklearn import datasets<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LinearRegression</pre><pre>diabetes = datasets.load_diabetes()</pre><pre>X_train, X_test, y_train, y_test = train_test_split(diabetes.data, diabetes.target, test_size=0.2, random_state=0)<br>clf = LinearRegression()<br>clf.fit(X_train, y_train)</pre><h4>Deploying</h4><p>Now that we have our model, we want it to be served to our users through a REST API. Without Clipper, we have to go through a number of steps that are mostly done by developers.</p><ul><li>Create a Flask App and its API</li><li>Create metrics and health checks</li><li>Dockerize the application</li><li>Write a *.nomad script to deploy</li></ul><p>Clipper lets us avoid all of these steps with a few lines of Python code !</p><p>First we create a connection to the Nomad cluster and set a number of parameters, such as the DNS that we use (Consul) and the load balancer (Fabio). You need to <a href="https://fabiolb.net/feature/tcp-proxy/">configure Fabio with tcp proxy enabled</a> on one port. That’s because the <strong>query frontend</strong> and the <strong>model containers</strong> communicate with a TCP procotol. I used the port 7000 in my example.</p><pre>from clipper_admin import ClipperConnection, DockerContainerManager, NomadContainerManager, ConsulDNS, FabioLoadBalancer</pre><pre>nomad_ip_addr = ‘10.65.30.43’</pre><pre>dns = ConsulDNS() # We use Consul for DNS resolution</pre><pre>container_manager = NomadContainerManager(<br>  nomad_ip=nomad_ip_addr,<br>  dns=dns,<br>  load_balancer=FabioLoadBalancer(<br>    address=&#39;fabio.service.consul&#39;, <br>    http_proxy_port=9999, <br>    tcp_proxy_port=7000<br>  )<br>)<br>clipper_conn = ClipperConnection(container_manager)<br>clipper_conn.start_clipper()</pre><pre># use clipper_conn.connect() later</pre><p>Once you execute this code, you should see <strong>three jobs</strong> starting in the Nomad UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*SL84ZCScmmBPPBqc09b_dw.png" /><figcaption>The three jobs, database, management and query-frontend</figcaption></figure><p>To serve a model, you have to create an ‘Application’. You can think of it as a project, which will <strong>regroup</strong> all the algorithms that <strong>complete the same goal</strong>. You specify its name, the input data type that it receive, the default data it will output if an error occurs and a Service Level Objective, which is the speed at which you expect from your predictions to be delivered.</p><p>Clipper will try to find a balance between <strong>latency</strong> and <strong>throughput</strong>, using tricks such as batching.</p><pre>my_application_name = &#39;app-1&#39;<br><br>clipper_conn.register_application(<br>  name=my_application_name, <br>  input_type=&quot;doubles&quot;, <br>  default_output=&quot;-1.0&quot;, <br>  slo_micros=10000000<br>)</pre><p>Once we have created our application, we can query it. This is not really useful yet because we have no model to solve the task.</p><pre>{<br>  &quot;query_id&quot;:13,<br>  &quot;output&quot;:1.0,<br>  &quot;default&quot;:true,<br>  &quot;default_explanation&quot;:&quot;No connected models found for query&quot;<br>}</pre><p>To serve a new model on our application (or project), we use one of the <strong>deployers</strong> available. Clipper provides implementations for a number of frameworks such as TensorFlow, Keras, PyTorch and more. They also have a standard Python Function deployer which we will use to deploy our Scikit Learn model. You only need access to a Docker registry (you can use Docker Hub). In this example, I used a private registry hosted on Scaleway.</p><pre>from clipper_admin.deployers import python as python_deployer</pre><pre>my_model_name=&#39;scikit-learn-model&#39;<br>my_model_version = 1</pre><pre># I use a private registry hosted on Scaleway<br>container_registry = &#39;rg.fr-par.scw.cloud/hyperplan&#39;</pre><pre>python_deployer.deploy_python_closure(<br>  clipper_conn, <br>  name=my_model_name, <br>  version=my_model_version, <br>  input_type=&quot;doubles&quot;, <br>  func=clf.predict,<br>  pkgs_to_install=[&#39;scikit-learn&#39;],<br>  registry=container_registry<br>)</pre><p>If you need some preprocessing, you can modify the <strong>func</strong> argument.</p><pre>def my_prediction_func(model, inputs):<br>    return [model(x) for x in inputs]</pre><p>The deployer function will build a Docker image with all the required dependencies, push it to your container registry and submit a new job to Nomad. You should see the instance in your Nomad UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*VrK8TKTzGvxbe8UxkDNH8Q.png" /><figcaption>Various models being served</figcaption></figure><p>There is one last step before we can use our model, we need to link it with our application.</p><pre>clipper_conn.link_model_to_app(<br>  app_name=my_application_name, <br>  model_name=my_model_name<br>)</pre><p>Let’s test it! We will call it through our fabio load balancer (which listens on port 9999 for http traffic). Clipper is served on the following address.</p><pre><a href="http://fabio.service.consul:9999/clipper/%7Bapp_name%7D/predict">http://fabio.service.consul:9999/clipper/</a></pre><p>You can create prediction on our application (app-1) by calling the route on</p><pre><a href="http://fabio.service.consul:9999/clipper/%7Bapp_name%7D/predict">http://fabio.service.consul:9999/clipper/app-1/predict</a></pre><p>Here is an example with python</p><pre>import requests, json, numpy as np<br>headers = {&quot;Content-type&quot;: &quot;application/json&quot;}<br>requests.post(<br>  &quot;<a href="http://fabio.service.consul:9999/clipper/%7Bapp_name%7D/predict">http://fabio.service.consul:9999/clipper/{app_name}/predict</a>&quot;.format(app_name=my_application_name), <br>  headers=headers, <br>  data=json.dumps({&quot;input&quot;: list(np.random.random(10))})<br>).json()</pre><pre><br>{&#39;query_id&#39;: 12, &#39;output&#39;: 248.95820966558657, &#39;default&#39;: False}</pre><h3>My advice</h3><p>Clipper is a great tool and I recommend it to anyone who has simple needs to serve machine learning models. It is easy to use, extendable and performant. I just have some concerns regarding some design decisions:</p><ul><li><strong>Clipper prefers to not return results</strong> than to return results that are outside the tolerated SLO. I would have preferred monitoring and alerting when this happends.</li><li><strong>1:1 relationship between an application and a model</strong>, with Clipper, you cannot do AB Testing on a model. This means that you either need to add another Http proxy (most likely Flask) on top of the query frontend as stated in <a href="https://github.com/ucbrise/clipper/issues/628">this issue</a>, but Python is a garbage collected language and that would lead to unexpected latencies and overall reduced performance.</li><li><strong>Query Frontend container is stateful</strong>.<strong> </strong>It<strong> </strong>needs<strong> </strong>to hold a connection to at least one instance of each model. As you add a new query frontend instance to the network, you might end up in a situation where it does not hold a connection to each model. Model instances may use DNS to resolve the ip address of the query frontend, giving no guarantees that two instances of model A will connect to the two different instances of query frontends. This is a potential issue. A way to solve this would be to use a <strong>stateless</strong> protocol, such as gRPC, but it would require to make some drastic changes in the architecture of Clipper.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*094y79h0ZonfObiK0ThKJQ.png" /><figcaption>Different scenarios possible, 4 is what we want to avoid</figcaption></figure><p><a href="https://github.com/hyperplan-io/clipper-nomad-demo">You can find my code on Github</a>, with additional code samples and information regarding my infrastructure setup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b896890695f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/machine-learning-automation-1-clipper-ai-7b896890695f">Machine Learning Automation (1): Clipper AI</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three ways to become fluent in English (or any other language)]]></title>
            <link>https://medium.com/@antoinesauray/three-ways-to-become-fluent-in-english-or-any-other-language-fcf3efbb69ba?source=rss-580a98d9adf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcf3efbb69ba</guid>
            <category><![CDATA[language-learning]]></category>
            <category><![CDATA[way-of-life]]></category>
            <category><![CDATA[language]]></category>
            <dc:creator><![CDATA[Antoine Sauray]]></dc:creator>
            <pubDate>Mon, 25 Jan 2016 10:00:41 GMT</pubDate>
            <atom:updated>2016-01-25T10:00:41.437Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnFJKUOPM5vLTlo2vBveIg.jpeg" /><figcaption>Dreaming of living in New-York and speaking a perfect English ?</figcaption></figure><blockquote>“I really want to improve my English communication skills”</blockquote><p>This is a sentence I have heard numerous times in my life.</p><p>I love speaking English. I really experience great times exchanging with people in English. Throughout the years, I have set myself strict rules and goals to achieve a great level of English.</p><p>Nowadays, the most satisfying thing for me is to hear people saying.</p><blockquote>“Oh I can’t believe it, you totally sound like you’re native”</blockquote><blockquote>“No way you are French, they all suck at speaking English”</blockquote><p>My French friends usually ask me how I managed to get to speak fluent English. I’ve came up with three ways to get you to the next level.</p><h3>Number one is passion</h3><blockquote>“Choose a job you love, and you will never have to work a day in your life”</blockquote><p>Passion is about loving what you do. When learning a language, the most important thing is to love it. Love the culture, the energy and the people.</p><p>This is clearly the best way to get involved in your learning. Once you enjoy learning, spending 30 minutes reading or speaking a day will be a piece of cake.</p><h3>Number 2 is goal</h3><p>Most people want to speak a better English, whatever level they have. But what people really lack is a goal to drive themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*LJs1MLCImTzElmvgyhbb9g.png" /><figcaption>A recent survey I have done on about 150 French people, aged between 18 and 25: “Do you want to improve your English skills”</figcaption></figure><p>Sure this is not surprising that 98% of people want to improve. The problem though is that they do not. I came up with the idea that these people need to find themselves a very specific reason to learn.</p><p>I have personally been always passioned by the English and American culture. This passion has led me to set myself the goal of living abroad after my studies. This is something that drives me everyday in my learning. Living with this long term goal can help you achieve your basic daily work.</p><p>So find yourself a goal and do not forget it !</p><h3>Number three is constraint</h3><p>Set yourself rules and constraint. We all experience drops of motivation in our life which can affect our momentary motivation. Rules help keeping up with your goal.</p><p>Find someone who wants to learn just like you and set yourselves rules !</p><h3>Now Go !</h3><p>The whole process depends on you. Trust yourself and get into it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcf3efbb69ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>