<?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 Thomas Vrancken on Medium]]></title>
        <description><![CDATA[Stories by Thomas Vrancken on Medium]]></description>
        <link>https://medium.com/@thomas.vrancken?source=rss-c538404aa69d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Gc39uPzgs7jkxboU</url>
            <title>Stories by Thomas Vrancken on Medium</title>
            <link>https://medium.com/@thomas.vrancken?source=rss-c538404aa69d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 15:41:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thomas.vrancken/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[NLP Trend: A few examples on how to process long documents]]></title>
            <link>https://medium.com/ml6team/nlp-trend-a-few-examples-on-how-to-process-long-documents-b0d5c4df2801?source=rss-c538404aa69d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0d5c4df2801</guid>
            <category><![CDATA[natural-language]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[document-ai]]></category>
            <dc:creator><![CDATA[Thomas Vrancken]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 15:39:31 GMT</pubDate>
            <atom:updated>2021-12-06T15:39:31.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zh7LwJ5K4pvNZeaynwtDMQ.jpeg" /></figure><p>Machine Learning is at its most disruptive time, being more and more impactful in real world applications. This is especially the case in one domain: <strong>Long document processing</strong>.</p><p>Businesses in industries such as media, finance, jurisdiction, education, etc. tend to accumulate a large quantity of medium to long documents. More often than not, the documents and the database containing them are not so well structured. It’s a big opportunity cost not to be able to organize and extract any valuable information from them.</p><p>And yet, from a technical stand point it’s very challenging to process such long documents. Indeed, the NLP research world is all about benchmarking models on small text tasks. The state of the art models coming out of that usually have a maximum number of input token allowed - i.e. roughly a maximum number of words allowed in your input text.</p><p>But our team of experts at ML6 needs to find creative solutions on how to tackle that problem. Here are a few examples on how they do just that:</p><ol><li>Models adapted to long documents</li><li>Splitting up long documents</li><li>Summarizing long documents</li></ol><h3>Models adapted to long documents 📄</h3><p>In a nutshell: some models can handle long sequences better, though they’re still limited on input size and aren’t necessarily adapted to every task. We benchmarked some of those models, to see which would be the most performant. You can find our results <a href="https://github.com/ml6team/quick-tips/tree/main/nlp/2021_06_29_long_range_transformers">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_9NQvGZYZLqHyWD8e4-Fg.jpeg" /></figure><p>More technically speaking: as said before, typical NLP model are quite limited on their <em>input size</em>. Traditional RNN/LSTM and now Transformers model are trained with a fixed one. To make it a tad more specific, models like BERT with a full attention mechanism become quadratic dependent on it (training one with long maximum input size makes your memory explode). Typically, a transformer model will have a maximum input size of 512 tokens. So for a traditional model this blogpost could already be too long to process (about ~800 words).</p><p>Now the smart people of the Allen Institute for AI and of Google Research saw that problem and implemented respectively the <strong>Longformer</strong> model (see <a href="https://arxiv.org/abs/2004.05150">paper</a>) and the <strong>Big Bird</strong> model (see <a href="https://arxiv.org/abs/2007.14062">paper</a>). By combining random, window and global attention mechanisms (so essentially sparse attention layers), these models would only get linearly impacted by input length. They could outperform models like RoBERTa on longer input tasks and provide input length of up to 4096 tokens (BigBird).</p><p>If you want some more info about it, head to our <a href="https://github.com/ml6team/quick-tips/tree/main/nlp/2021_06_29_long_range_transformers"><em>quick-tip</em></a><em> </em>(codes included) about it.</p><h3>Divide to conquer ⚔️</h3><p>Note that the problem here is to tackle long <em>documents</em> and not just text. One approach we took for a large scale project we had is break down documents in <em>clauses</em>, which can then be tackled by a language model individually.</p><p>In this case, we relied on an object detection model. Essentially, we worked on scans of documents and the model could visualize where different clauses were. Typically this kind of method works very well to extract structured information, like tables or IDs. You can learn more about our solution in <a href="https://www.youtube.com/watch?v=0Q8zUEV2JeI&amp;ab_channel=ML6">this video</a> (also includes some more info about the context and what is done on the text of each clause).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*FWnnecAEYVUS4xePh-pOeA.gif" /><figcaption>Extract from: <a href="https://www.youtube.com/watch?v=0Q8zUEV2JeI&amp;ab_channel=ML6">https://www.youtube.com/watch?v=0Q8zUEV2JeI&amp;ab_channel=ML6</a></figcaption></figure><p>For each problem its solution: This type of project usually require a pretty custom approach. It can for instance use manual rules to extract specific section of the text (e.g. find contact information in a large database of job offers).</p><h3>Why not just make the text shorter? 🐜</h3><p>A less conventional approach is to use <em>extractive text summarization</em>. So you use an extra model to extract the most relevant piece of your text.</p><p>That means combining a summarization model on top of the other modeling techniques you’ll use on its output → more chance of issues. Not necessarily recommended.</p><p>But yet again, in specific use cases it can be a convenient tool (e.g. summarizing long meetings to then extract relevant piece of information). You can have a glimpse of what is possible with summarization models in this <a href="https://blog.ml6.eu/multi-article-summarization-a-building-blocks-approach-d197b6e43a4">blogpost</a> and even try it yourself with this <a href="https://newssummarizer.ml6.eu/">demo</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Meqc1eV8BWbhjfkmwqsAwQ.gif" /><figcaption>Using the summarization service — Check out <a href="https://newssummarizer.ml6.eu/">newssummarizer.ml6.eu</a>!</figcaption></figure><h3>Wrapping up</h3><p>It is clear that being able to process and extract key information from a database of large documents is extremely valuable for a lot of institutions. Data is the new oil, we now need ways of drilling it.</p><p>On the other hand, it is very challenging from a technical stand point to process those long documents. We did face that challenge at ML6 and tried to layout few ways of doing so.</p><p>Hope you learned something!</p><h3>About ML6</h3><p>We are a team of AI experts and the fastest-growing AI company in Belgium. With offices in Ghent, Amsterdam, Berlin, and London, we build and implement self-learning systems across different sectors to help our clients operate more efficiently. We do this by staying on top of research, innovation, and applying our expertise in practice. To find out more, please visit <a href="http://www.ml6.eu/">www.ml6.eu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0d5c4df2801" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/nlp-trend-a-few-examples-on-how-to-process-long-documents-b0d5c4df2801">NLP Trend: A few examples on how to process long documents</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making our office safer by detecting (missing) face masks]]></title>
            <link>https://medium.com/ml6team/making-our-office-safer-by-detecting-missing-face-masks-2ad439b506c8?source=rss-c538404aa69d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ad439b506c8</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[coronavirus]]></category>
            <category><![CDATA[office]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Thomas Vrancken]]></dc:creator>
            <pubDate>Mon, 04 May 2020 16:07:35 GMT</pubDate>
            <atom:updated>2020-05-04T17:22:26.623Z</atom:updated>
            <content:encoded><![CDATA[<p>As the world is going through the Corona crisis, more and more applications are created to help fighting it. At ML6, we wanted to use our expertise in Machine Learning to help with that effort. One way to minimize the risk of propagation of the virus is to wear protective face masks. Many governments are already asking their citizens to wear them in public places. We wanted to show that computer vision could help making sure that everybody is being safe. So we built an app that uses a camera feed and detects if anybody on the video is not wearing a protective mask.</p><p>We made a setup at our office with a Raspberry Pi and camera running at the entrance of our office. When a person correctly wears a mouth mask nothing should happen. But when someone enters our office without wearing one, the RaspberryPi will make a sound alert asking the person to wear a mask. This can help many offices to monitor whether safety measures are being respected, and to help remind people of the rules. Here is a video of it in action:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPs12uY_QZio%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPs12uY_QZio&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPs12uY_QZio%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/412496e7ebf40b267d443294fe546cf8/href">https://medium.com/media/412496e7ebf40b267d443294fe546cf8/href</a></iframe><p>Big thanks to everybody who worked on it, especially <a href="https://medium.com/u/ae1531f0dd00">Juta Staes</a> and <a href="https://medium.com/u/9914fcc3faf2">Rebekka Moyson</a>.</p><h4>How we created a proof of concept in less then 4 days</h4><p>We did so by using some powerful image processing tools and two consecutive object detectors. We use <a href="https://opencv.org/">OpenCV</a> to stream, process and modify the camera images. We then have a first model that will detect faces. For that we use <a href="https://github.com/ipazc/mtcnn">MTCNN</a>, a pre-trained face recognition model. We then trained our own <a href="https://arxiv.org/abs/1506.02640">Tiny YOLO</a> model for detecting the person’s mouth for each detected face. The assumption is that if we can see a person’s mouth then the person is not using a face mask. This particular two stage design was very useful in several ways:</p><ul><li>It allowed us to capitalise on pre-trained SOTA models as the MTCNN face detector.</li><li>It consequently reduced the problem complexity for the custom mouth detector (detecting a mouth on a cropped face is much easier than on a full room image).</li><li>Detecting <em>mouths</em> by opposition to masks allowed us to capitalise on already labeled data. To our knowledge there are no labeled data sets of protective masks available for computer vision. Furthermore detecting a protective mask is not necessary for this task, as the desired outcome is to detect people who are not wearing them.</li><li>By using small models like Tiny Yolo we could make it work on a live stream of images.</li></ul><p>Note that you can find all the codes in our <a href="https://bitbucket.org/ml6team/corona-vision-public/">bitbucket repo</a>. Let’s now take a deeper dive in how it was implemented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*wrt9AXKWvkEopfjTHG6qUw.jpeg" /></figure><h3>Implementation</h3><p>Developing this app was done in two stages. First we needed to train our individual models. Then we needed to develop the actual app, which would stream a camera’s images, apply the two consecutive models to do the predictions and make a sound alert in case someone is not wearing a mouth mask.</p><h4>1. Training</h4><p>The good news for us was that there already exists some pre-trained face detection models. We used <a href="https://github.com/ipazc/mtcnn">MTCNN</a>, which is fast and performs well. Here is a quick code snippet of how you can get started with it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3fd24cb039ddb3e38839dca6dbf47a9c/href">https://medium.com/media/3fd24cb039ddb3e38839dca6dbf47a9c/href</a></iframe><p>The MTCNN face detection module also detects facial landmarks, meaning it also detects the coordinates of the mouth’s corners. However in practice this model always assumes that a mouth is present, and it will generate the mouth keypoints even if a person’s mouth is covered. So instead we decided to train our own mouth detection model. We decided to detect mouths instead of masks as we could find a large dataset of already labeled data for that task.</p><p>The model we wanted to create should take the cropped faces and predict whether there is a mouth on them. We decided to use <a href="https://arxiv.org/abs/1506.02640">Tiny YOLO</a> for that part, from the <a href="https://github.com/zzh8829/yolov3-tf2">yolov3-tf2</a> repo. It is a well performing and computationally efficient model, light enough to be hosted on a Raspberry Pi or a light weight computer in production environments. We generated training records from the <a href="https://www.kaggle.com/jessicali9530/celeba-dataset">CelebA</a> data set, a large Kaggle data set of celebrities pictures including some information like <em>mouth coordinates</em>. Note that we first used the MTCNN model on it to crop every face it could detect. Then we adapted the mouth coordinates and trained our Tiny YOLO on that. We did so using a batch_size of 16 and 5 epochs. This is how we trained our model:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/feadd01addac2c2a58c71d163ec5379f/href">https://medium.com/media/feadd01addac2c2a58c71d163ec5379f/href</a></iframe><p>Here is an example showing green boxes for the detected faces wearing a mask and red boxes when no mask is detected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*qjdgjpntbVBRRUib3__juQ.png" /><figcaption>image source: <a href="https://www.enterprisersuite.com/more-than-370000-people-have-recovered-from-covid-19-heres-what-we-know-about-coronavirus-survivors/">https://www.enterprisersuite.com/more-than-370000-people-have-recovered-from-covid-19-heres-what-we-know-about-coronavirus-survivors/</a></figcaption></figure><h4>2. App</h4><p>Now let’s look at how we built the demo pipeline. The demo will stream a camera’s images, apply predictions on it and play a sound alert if somebody is not wearing a mask. Let’s see what’s under the hood of this pipeline.</p><p>There are two ways of running the app. For testing you can run it locally on your pc, or for the setup at our office we run it on a Raspberry Pi.</p><p>Once the app is started it will start streaming the camera’s image. If you are running it on your computer, it will automatically use your webcam. On a Rasberry Pi it will connect with your Pi camera. A nice feature of it is that every frame will be taken as soon as all operations on the previous frame are done. Which means that if your models are a bit slow, the application will not freeze.</p><h3>Conclusion</h3><p>It was challenging to come up with a model detecting face masks. Two key designs helped us in solving it:</p><ul><li>Flipping the problem around. Detecting <em>mouths</em> instead of masks allowed us to use existing data sets without having to label anything ourselves.</li><li>The two stage model combination allowed us to capitalize on an existing model and focus the custom part to a simpler task. The task would have been much harder if it would have been to detect mouths on the entire image.</li></ul><p>That’s why one of the takeaways from this project is to be creative in your model architecture design. Even though using two models brings more risk of one of them failing.</p><p>Note that this app will not store any data. It is purely executed on edge and is meant as an example of the possibilities of Computer Vision. When putting such app in production we strongly suggest to carry out a Data Processing Impact Assessment (Art. 35 GDPR) to identify, manage and mitigate the privacy risks related with this technology.</p><h3>About ML6</h3><p>We are a team of AI experts and the fastest growing AI company in Belgium. With offices in Ghent, Amsterdam, Berlin and London, we build and implement self learning systems across different sectors to help our clients operate more efficiently. We do this by staying on top of research, innovation and applying our expertise in practice. To find out more, please visit <a href="http://www.ml6.eu/">www.ml6.eu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ad439b506c8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/making-our-office-safer-by-detecting-missing-face-masks-2ad439b506c8">Making our office safer by detecting (missing) face masks</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPT-2 Artificial Intelligence Song Generator: Let’s Get Groovy]]></title>
            <link>https://medium.com/ml6team/gpt-2-artificial-intelligence-song-generator-lets-get-groovy-3e7c1f55030f?source=rss-c538404aa69d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e7c1f55030f</guid>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Thomas Vrancken]]></dc:creator>
            <pubDate>Mon, 20 Jan 2020 15:28:54 GMT</pubDate>
            <atom:updated>2020-01-20T15:28:54.417Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F26DOs997h6fgsCthu%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F26DOs997h6fgsCthu%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F26DOs997h6fgsCthu%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/53a02b907754b269581f0345f7c28415/href">https://medium.com/media/53a02b907754b269581f0345f7c28415/href</a></iframe><p>This blog-post will show how we can use NLP’s magic to generate our own song lyrics. We will use the power of <a href="https://openai.com/blog/better-language-models/">GPT-2</a>, a large pre-trained model developed by OpenAI. The codebase can be found in <a href="https://colab.research.google.com/drive/13PbF0NQLrTEgIbXnEahp0atRVzWL0Fy7">this notebook</a> (it’s in view only mode but you can make a copy to run it).</p><p>Special thanks to <a href="https://medium.com/u/42421f0cbdbe">Thomas Dehaene</a>, <a href="https://medium.com/u/33767efd5b9a">Koen Verschaeren</a>, <a href="https://medium.com/u/a3546bf75dff">Mats Uytterhoeven</a> and <a href="https://medium.com/u/75b2f923f859">Anna Krogager</a> for their contribution.</p><h3>I. The model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OkH4E0s3wp4Ynw0a1T7MbQ.jpeg" /></figure><p>GPT-2 has been the cool kid on the block of NLP models since its release in February 2019. It’s a pre-trained model, trained over a large database to simply predict the next word of a sentence, and can now be fine-tuned on a smaller database to solve different problems. In our case, generating a bunch of legendary songs. It uses the <a href="https://arxiv.org/abs/1706.03762">transformer</a> network architecture (introduced by Google in 2017), based on attention mechanisms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*aRB3-9JpDyxXZpejlzfitA.png" /></figure><p>Though the core strength of GPT-2 lies in the gigantic amount of data used to train it. The OpenAI team used around 40 GB worth of text extracted from the internet (i.e. outgoing links from Reddit posts with a karma of at least 3). In comparison, all of Shakespeare’s work combined has an estimated size of about 5.6MB. They trained 4 different models with respectively 124M, 355M, 774M and 1.5B parameters (more parameters leads to more complexity, larger size of the model and higher performance).</p><h3>II. The data</h3><p>We used a music lyric database extracted from <a href="https://www.kaggle.com/mousehead/songlyrics">this Kaggle Kernel</a>. It contains 57.650 music lyrics, mostly in english. They were originally scraped from <a href="https://www.lyricsfreak.com/">LyricsFreak</a>. There are a lot of fun analyses to be performed on this data, such as <a href="https://www.kaggle.com/devisangeetha/sing-a-song-lyrics-is-here">sentiment analysis</a> or <a href="https://drive.google.com/file/d/1FyLJcy4VKPaMMQlI3TBSZ5oV_lneyeEE/view?usp=sharing">calculating which artists have the widest vocabulary</a> (spoiler alert, it’s the Wu-Tang Clan, with the Backstreet Boys being the most shallow of them all).</p><h3>III. The implementation</h3><p>We implemented the code in Colaboratory, a tool from Google to run Python notebooks in your web browser. It’s free and lets you use GPU-accelerated processing! This will make your life easier with the model fine tuning.</p><p>First, we load our libraries. We will use the <a href="https://github.com/minimaxir/gpt-2-simple">gpt-2-simple</a> library to conveniently play around with GPT-2. Note that Tensorflow 2.0 removed the “contrib” feature, which is needed in gpt-2-simple. Therefore, we force Colab to use Tensorflow 1.x with the %tensorflow_version 1.x command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1cfe568edacf81603f204261848bfe8/href">https://medium.com/media/f1cfe568edacf81603f204261848bfe8/href</a></iframe><p>We then load our data. It was saved into a public Github repository to make it more convenient to be read into Colab:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3dc202be521cf307a180f2c8aa49238/href">https://medium.com/media/f3dc202be521cf307a180f2c8aa49238/href</a></iframe><p>We then save this file on our VM’s directory, under a “content” folder. GPT-2 will directly load it from there. You can see the files saved on your VM on the left hand side of your Colab notebook, under the folder tab.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21076305462a0fffa5cfd1360cf54b14/href">https://medium.com/media/21076305462a0fffa5cfd1360cf54b14/href</a></iframe><p>Next, we download the GPT-2 models. Note that you can restrict this list to the model(s) you will be using.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d5d159e45da51abfc4a402aaa113fad/href">https://medium.com/media/2d5d159e45da51abfc4a402aaa113fad/href</a></iframe><p>Now we set some hyperparameters and start a session.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7644a9804f32d524a5062c0484e2ac8/href">https://medium.com/media/f7644a9804f32d524a5062c0484e2ac8/href</a></iframe><p>Next, we start the fine tuning. It can take a while (e.g. about 22min for 500 steps with the 774M model). Some useful parameters:</p><ul><li><strong>restore_from</strong>: Set to fresh to start training from the base GPT-2, or set to latest to restart training from an existing checkpoint</li><li><strong>sample_every</strong>: Number of steps to print example output</li><li><strong>print_every</strong>: Number of steps to print training progress</li><li><strong>learning_rate</strong>: Learning rate for the training. (default 1e-4, can lower to 1e-5 if you have &lt;1MB input data)</li><li><strong>run_name</strong>: Subfolder within checkpoint to save the model. This is useful if you want to work with multiple models (will also need to specify run_name when loading the model)</li><li><strong>overwrite</strong>: Set to True if you want to continue finetuning an existing model (w/ restore_from=&#39;latest&#39;) without creating duplicate copies</li><li><strong>steps</strong>: How many training steps to be performed.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c415db6ce7a0883a1fa2b4588dcb03c/href">https://medium.com/media/7c415db6ce7a0883a1fa2b4588dcb03c/href</a></iframe><p>The artist is officially born…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F39pru9GPwMT6cEafLy%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F39pru9GPwMT6cEafLy%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F39pru9GPwMT6cEafLy%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/346e7ad091377bda3e2368ba8ff146c1/href">https://medium.com/media/346e7ad091377bda3e2368ba8ff146c1/href</a></iframe><p>You will see that the model prints a couple of sample generated texts every print_every steps. It is very nice to see how it evolves.</p><p>Something to keep in mind here is that your Colab session can expire during the training (if using a large dataset or number of steps). However, you can retrieve your previous model with the restore_from feature.</p><p>Once your model is trained, you can use the gpt2.generate command to produce some lyrics.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28a355694aa0b89e4dd007792593235e/href">https://medium.com/media/28a355694aa0b89e4dd007792593235e/href</a></iframe><p>You can pass a prefix into the generate function to force the text to start with a given character sequence and generate text from there (good if you add an indicator when the text starts).</p><p>The nsamples parameters allows you to generate multiple texts in one run. It can be used with batch_size to compute them in parallel, giving the whole process a massive speedup (in Colaboratory, set a maximum of 20 for batch_size).</p><p>Other optional-but-helpful parameters for gpt2.generate:</p><ul><li><strong>length</strong>: Number of tokens to generate (default 1023, the maximum)</li><li><strong>temperature</strong>: The higher the temperature, the crazier the text (default 0.7, recommended to keep between 0.7 and 1.0)</li><li><strong>top_k</strong>: Limits the generated guesses to the top k guesses (default 0 which disables the behaviour; if the generated output is super crazy, you may want to set top_k=40)</li><li><strong>top_p</strong>: Nucleus sampling: limits the generated guesses to a cumulative probability. (gets good results on a dataset with top_p=0.9)</li><li><strong>truncate</strong>: Truncates the input text until a given sequence, excluding that sequence (e.g. if truncate=’&lt;|endoftext|&gt;’, the returned text will include everything before the first &lt;|endoftext|&gt;). It may be useful to combine this with a smaller length if the input texts are short</li><li><strong>include_prefix</strong>: If using truncate and include_prefix = False, the specified prefix will not be included in the returned text</li></ul><h3>IV. The songs</h3><p>We have trained a model with the 774M model and 500 steps and used it to generate 100 songs. The entire set of masterpieces can be found <a href="https://drive.google.com/file/d/16P5EbvOf0NtZTTf6qFZHTrdLi7-mfmXl/view?usp=sharing">here</a>. It had a lot of inspiration, leading to some interesting songs (we had to create titles for them ourselves):</p><ul><li><strong><em>“The story of Atlas V”</em></strong>: Here the bot was slightly dramatic, and developed a weird fixation on “<em>Atlas V</em>” though that word cannot be found in the training data set…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*V5xBVGPy-qWaRlrnBVSfmA.png" /><figcaption><strong><em>The story of Atlas V</em></strong></figcaption></figure><ul><li><strong><em>“Mmmh”</em></strong>: In this song, the artist gets stuck in a suave showcase of its pretty voice, repeating “Mmmh” the entire time. In text generation it is pretty common for the model to get stuck in a loop and repeat the same word (series of words) over and over again. It is likely that our training data increased that effect, as many songs have some repetitions of a single word.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*THMEY492Zb80vllqyuAd1w.png" /><figcaption><strong><em>Mmmh</em></strong></figcaption></figure><ul><li><strong><em>“No Uber on the Highway”:</em></strong> Our artist tells about the time the truck broke down on the highway. Not a great memory apparently.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eM3SJ8AZnuKcDon1KzRyTQ.png" /><figcaption><strong><em>No Uber on the Highway</em></strong></figcaption></figure><ul><li><strong><em>“Do you have the keys of the kingdom, yo ?”</em></strong><em>: </em>Starting with a “What’s my name?”, one could think that our artist was hyping up the crowd for a sick hip-hop solo. However, it quickly evolves into some intense questioning, under the suspicion that somebody might be hiding the keys of a certain kingdom. Then it just gets very melancholic and intense.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*xxVw8_LrgDWuo9T9pXBwPA.png" /><figcaption><strong><em>Do you have the keys of the kingdom, yo ?</em></strong></figcaption></figure><p>Overall, the results look pretty good. It seems that our artist has some nice poetic inspiration. Yet, it is worth checking these masterpieces against plagiarism. That is, to see if our artist didn’t just copied some songs (or part of songs) from the training data set. For that, we split each of its <a href="https://drive.google.com/file/d/16P5EbvOf0NtZTTf6qFZHTrdLi7-mfmXl/view?usp=sharing">100 songs</a> in lists of sequential N-grams (i.e. N following words). We then check how many of these N sequential words can be found in the original data set. The following figure plots the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*zWQ0gDE38la_8wW8lCK7Mw.png" /></figure><p>For instance, we checked and the 5-Gram “why did you love me?” (from the tube <em>Do you have the keys of the kingdom, yo?</em>) already exists as is in the training set. It is part of the ~35% of repeating 5-Grams. However, the rest of that track is an original work from our artist. As expected, we have less repetitions for larger values of N. In total it seems our artist has a fair amount of inspiration and originality. It is worth noting augmenting the temperature parameter when generating texts should decrease these values.</p><p>Another thing that surprised us is how dramatic the 100 songs can be. Just scrolling through them shows a lot of melancholy from our artist. Most likely, the data set just happens to contain more sad songs than happy ones. It might be worth filtering them with some sentiment analysis for training a happy singing bot. Some further fun work could also be to train hiphop/metal head/pop bots.</p><p>Finally, we trained several other GPT-2 models on different data sets. That is, we trained models to:</p><ul><li>Generate speeches from His Majesty King Philippe I of Belgium (in French and Dutch)</li><li>Generate Antwerp Hip-Hop</li><li>Generate Bol.com product descriptions</li></ul><p>It led to interesting results. However, those datasets were all much smaller than the English songs data set described in this blog post. Hence, the texts generated were not as good.</p><p>So our final tip is to try to find a large and good quality database, then just have fun generating a lot of texts.</p><h4><strong>About ML6</strong></h4><p>We are a team of ML experts composing the fastest growing AI company in Belgium. With offices in Ghent, Amsterdam, Berlin and London, we implement self learning systems across different sectors to improve and optimise our clients operations. We do this by staying on top of research, innovation and practical applications. Find out more at <a href="http://www.ml6.eu/">www.ml6.eu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e7c1f55030f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/gpt-2-artificial-intelligence-song-generator-lets-get-groovy-3e7c1f55030f">GPT-2 Artificial Intelligence Song Generator: Let’s Get Groovy</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLP Meetup: Designing NLP for Production Systems at ML6]]></title>
            <link>https://medium.com/ml6team/nlp-meetup-designing-nlp-for-production-systems-at-ml6-475a8a945a0f?source=rss-c538404aa69d------2</link>
            <guid isPermaLink="false">https://medium.com/p/475a8a945a0f</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Thomas Vrancken]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 16:02:02 GMT</pubDate>
            <atom:updated>2019-12-10T16:02:02.381Z</atom:updated>
            <content:encoded><![CDATA[<p>On the 3rd of December we had the pleasure to host the 12th edition of the Natural Language Processing (NLP) Meetup here at ML6, in Ghent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ZUBB7Kc9APfP22ztsc9qaw.jpeg" /></figure><p>A crowd of about 80 NLP enthusiasts were there to follow three technical talks. The first of which was co-presented by <a href="https://medium.com/u/75b2f923f859">Anna Krogager</a> and myself, <a href="https://medium.com/u/c538404aa69d">Thomas Vrancken</a>. We tackled the complexity of putting NLP applications to production, all based on our own experience of developing a large scale recommender system. It included insights on how we managed to update our live models without any downtime, using Kubeflow Pipeline. More details can be found in the slides below:</p><p><a href="https://drive.google.com/file/d/1w8ZCBcuTqki0Ch-Az8e1SvmE0dbnU-ay/view?usp=sharing">Designing real-world NLP for production systems.pdf</a></p><p>The two following talks were about:</p><ul><li>Embedding Rare Words: how (not) to get the most out of sparse data<br>(by Jeroen Van Hautte, TechWolf)</li><li>Information Extraction from Medical Notes for Early Birth Risk Prediction<br>(by Lucas Sterckx, UGent-imec)</li></ul><p>Join the below meetup page for more information about the next NLP meetups. See you guys there!</p><p><a href="https://www.meetup.com/fr-FR/Belgium-NLP-Meetup">Belgium NLP Meetup (Louvain, Belgique)</a></p><p><strong>About ML6</strong></p><p>We are a team of ML experts composing the fastest growing AI company in Belgium. With offices in Ghent, Amsterdam, Berlin and London, we implement self learning systems across different sectors to improve and optimise our clients operations. We do this by staying on top of research, innovation and practical applications. Find out more at <a href="http://www.ml6.eu/">www.ml6.eu</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=475a8a945a0f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ml6team/nlp-meetup-designing-nlp-for-production-systems-at-ml6-475a8a945a0f">NLP Meetup: Designing NLP for Production Systems at ML6</a> was originally published in <a href="https://medium.com/ml6team">ML6team</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>