{"id":96664,"date":"2020-10-24T13:00:55","date_gmt":"2020-10-24T10:00:55","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-create-an-ai-that-chats-like-you-on-whatsapp\/"},"modified":"2020-10-24T13:00:55","modified_gmt":"2020-10-24T10:00:55","slug":"how-to-create-an-ai-that-chats-like-you-on-whatsapp","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-create-an-ai-that-chats-like-you-on-whatsapp\/","title":{"rendered":"#How to create an AI that chats like you on WhatsApp"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a387517ebe07\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a387517ebe07\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-create-an-ai-that-chats-like-you-on-whatsapp\/#21_Google_Colab\" >2.1 Google Colab<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-create-an-ai-that-chats-like-you-on-whatsapp\/#22_Start_the_notebook\" >2.2 Start the notebook<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-create-an-ai-that-chats-like-you-on-whatsapp\/#23_Load_the_data\" >2.3 Load the data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-create-an-ai-that-chats-like-you-on-whatsapp\/#24_Parse_the_data\" >2.4 Parse the data<\/a><\/li><\/ul><\/nav><\/div>\n<p>&#8220;<strong>#How to create an AI that chats like you on <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">WhatsApp<\/a><\/strong>&#8221;<\/p>\n<div>\n<p id=\"43ef\" class=\"jw jx fv jy b hf jz jd ka hi kb jh kc kd ke kf kg kh ki kj kk kl km kn ko kp em hd\" data-selectable-paragraph=\"\">To train a GPT-2 neural network, first of all we need to pre-process the data, in order to obtain a single\u00a0.txt\u00a0with a machine-learning compatible structure.<\/p>\n<h2 id=\"0d8f\" class=\"lu iz fv at ja lv lw hh je lx ly hk ji hl lz hn jm ho ma hq jq hr mb ht ju gc hd\" data-selectable-paragraph=\"\"><span class=\"ez-toc-section\" id=\"21_Google_Colab\"><\/span>2.1 Google Colab<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"9d69\" class=\"jw jx fv jy b hf jz jd ka hi kb jh kc kd ke kf kg kh ki kj kk kl km kn ko kp em hd\" data-selectable-paragraph=\"\">For the sake of simplicity and since the machine learning model we will use requires a GPU to work, we\u2019re going to use Google Colab for the next step.<\/p>\n<p id=\"6260\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp em hd\" data-selectable-paragraph=\"\">If you don\u2019t know what Google Colab is, check this other article <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/towardsdatascience.com\/getting-started-with-google-colab-f2fff97f594c\">here<\/a>.<\/p>\n<h2 id=\"ff73\" class=\"lu iz fv at ja lv lw hh je lx ly hk ji hl lz hn jm ho ma hq jq hr mb ht ju gc hd\" data-selectable-paragraph=\"\"><span class=\"ez-toc-section\" id=\"22_Start_the_notebook\"><\/span>2.2 Start the notebook<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"29f6\" class=\"jw jx fv jy b hf jz jd ka hi kb jh kc kd ke kf kg kh ki kj kk kl km kn ko kp em hd\" data-selectable-paragraph=\"\">Open this\u00a0<a rel=\"nofollow noopener noreferrer\" target=\"_blank\" class=\"co fs\" href=\"https:\/\/colab.research.google.com\/drive\/1T4-Gk-mlAWJkX9RuRd3_EiS5JBP5UvyV?usp=sharing\">Colab notebook<\/a>\u00a0and follow these steps:<\/p>\n<ol class=\"\">\n<li id=\"f6b3\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp kv kw kx hd\" data-selectable-paragraph=\"\">Run the first block of cells called under the \u201c0\ufe0f\u20e3 Init\u201d chapter<\/li>\n<li id=\"aab6\" class=\"jw jx fv jy b hf ky jd ka hi kz jh kc kd la kf kg kh lb kj kk kl lc kn ko kp kv kw kx hd\" data-selectable-paragraph=\"\">Press \u201cRun Anyway\u201d on the pop-up<\/li>\n<li id=\"4077\" class=\"jw jx fv jy b hf ky jd ka hi kz jh kc kd la kf kg kh lb kj kk kl lc kn ko kp kv kw kx hd\" data-selectable-paragraph=\"\">Make sure that the first command\u00a0<em class=\"lg\">!nvidia-smi<\/em>\u00a0shows that a GPU is connected (p100 is suggested)<\/li>\n<li id=\"fb58\" class=\"jw jx fv jy b hf ky jd ka hi kz jh kc kd la kf kg kh lb kj kk kl lc kn ko kp kv kw kx hd\" data-selectable-paragraph=\"\">If no GPU is connected, go to\u00a0<em class=\"lg\">Runtime &gt; Change Runtime type &gt; Hardware accelerator &gt; GPU<\/em>\n<\/li>\n<\/ol>\n<figure class=\"lh li lj lk ll ex ed ee paragraph-image\">\n<div class=\"ey ez ab fa s\">\n<div class=\"ed ee ng\">\n<div class=\"fg u ab fh\">\n<div class=\"nh fj u\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"ut uu cy fc eh fd s c lazy\" alt=\"Image for post\" width=\"864\" height=\"577\" src=\"https:\/\/miro.medium.com\/max\/864\/1*kEqM-4t9czcasfv9MVZlEw.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/neural\/2020\/10\/24\/how-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fneural%2F2020%2F10%2F24%2Fhow-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Example output when a Tesla T4 GPU is properly connected. | Image by Author\" data-title=\"Share Example output when a Tesla T4 GPU is properly connected. | Image by Author on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Example output when a Tesla T4 GPU is properly connected. | Image by Author on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Example output when a Tesla T4 GPU is properly connected. | Image by Author<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/figure>\n<h2 id=\"9f9c\" class=\"lu iz fv at ja lv lw hh je lx ly hk ji hl lz hn jm ho ma hq jq hr mb ht ju gc hd\" data-selectable-paragraph=\"\"><span class=\"ez-toc-section\" id=\"23_Load_the_data\"><\/span>2.3 Load the data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"c698\" class=\"jw jx fv jy b hf jz jd ka hi kb jh kc kd ke kf kg kh ki kj kk kl km kn ko kp em hd\" data-selectable-paragraph=\"\">To work with the data, we need to upload them on Colab, into the right folders.<\/p>\n<p id=\"32a7\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp em hd\" data-selectable-paragraph=\"\">WhatsApp chats<br \/>Select all your .txt files and upload everything into the following notebook folder:<br \/><em class=\"lg\">.\/messaging-chat-parser\/data\/chat_raw\/whatsapp\/<\/em><\/p>\n<p id=\"ee9f\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp em hd\" data-selectable-paragraph=\"\">Telegram JSON<br \/>Get the file\u00a0<em class=\"lg\">telegram_dump.json\u00a0<\/em>and upload it into the following notebook folder:<br \/><em class=\"lg\">.\/messaging-chat-parser\/data\/chat_raw\/telegram\/<\/em><\/p>\n<figure class=\"lh li lj lk ll ex ed ee paragraph-image\">\n<div class=\"ed ee ni\">\n<div class=\"fg u ab fh\">\n<div class=\"nj fj u\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"ut uu cy fc eh fd s c lazy\" sizes=\"auto, 528px\" alt=\"Image for post\" width=\"528\" height=\"648\" src=\"https:\/\/miro.medium.com\/max\/528\/1*AGCxi_dx2WZCFXXWOX-tXQ.png\" data-lazy=\"true\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*AGCxi_dx2WZCFXXWOX-tXQ.png 276w, https:\/\/miro.medium.com\/max\/528\/1*AGCxi_dx2WZCFXXWOX-tXQ.png 528w\"\/><figcaption><a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/neural\/2020\/10\/24\/how-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fneural%2F2020%2F10%2F24%2Fhow-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Example of the notebook files after the chats are uploaded | Image by Author\" data-title=\"Share Example of the notebook files after the chats are uploaded | Image by Author on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Example of the notebook files after the chats are uploaded | Image by Author on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Example of the notebook files after the chats are uploaded | Image by Author<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/figure>\n<h2 id=\"f3e1\" class=\"lu iz fv at ja lv lw hh je lx ly hk ji hl lz hn jm ho ma hq jq hr mb ht ju gc hd\" data-selectable-paragraph=\"\"><span class=\"ez-toc-section\" id=\"24_Parse_the_data\"><\/span>2.4 Parse the data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p id=\"e161\" class=\"jw jx fv jy b hf jz jd ka hi kb jh kc kd ke kf kg kh ki kj kk kl km kn ko kp em hd\" data-selectable-paragraph=\"\">Now, run all the cells up until the block \u201c2\ufe0f\u20e3 Parse the data\u201d.<\/p>\n<p id=\"0639\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp em hd\" data-selectable-paragraph=\"\">Here we need to replace the variable \u201cwhatsapp_user_name\u201d with your WhatsApp name, called\u00a0<em class=\"lg\">&lt;YourName&gt;\u00a0<\/em>on the 1.1 chapter.<\/p>\n<p id=\"c3de\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp em hd\" data-selectable-paragraph=\"\">You can also change the date format parsing system if some of the exported data show a different format due to local time formatting.<\/p>\n<figure class=\"lh li lj lk ll ex ed ee paragraph-image\">\n<div class=\"ed ee nk\">\n<div class=\"fg u ab fh\">\n<div class=\"nl fj u\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"ut uu cy fc eh fd s c lazy\" sizes=\"auto, 542px\" alt=\"Image for post\" width=\"542\" height=\"105\" src=\"https:\/\/miro.medium.com\/max\/542\/1*Z2FbkTWl_N3l7xXeTr-vRg.png\" data-lazy=\"true\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*Z2FbkTWl_N3l7xXeTr-vRg.png 276w, https:\/\/miro.medium.com\/max\/542\/1*Z2FbkTWl_N3l7xXeTr-vRg.png 542w\"\/><figcaption><a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/neural\/2020\/10\/24\/how-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fneural%2F2020%2F10%2F24%2Fhow-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Cells used to set the user name. | Image by Author\" data-title=\"Share Cells used to set the user name. | Image by Author on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Cells used to set the user name. | Image by Author on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Cells used to set the user name. | Image by Author<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<\/figure>\n<p id=\"958e\" class=\"jw jx fv jy b hf kq jd ka hi kr jh kc kd ks kf kg kh kt kj kk kl ku kn ko kp em hd\" data-selectable-paragraph=\"\">So, for example, if my name is \u201cBob\u201d and I\u2019m from America, the code I should use is the following:<\/p>\n<p data-selectable-paragraph=\"\">\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1325160 lazy\" alt=\"\" width=\"698\" height=\"213\" sizes=\"auto, (max-width: 698px) 100vw, 698px\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/10\/Screen-Shot-2020-10-23-at-11.42.19-AM.png\" data-lazy=\"true\" srcset=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/10\/Screen-Shot-2020-10-23-at-11.42.19-AM.png 698w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/10\/Screen-Shot-2020-10-23-at-11.42.19-AM-280x85.png 280w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/10\/Screen-Shot-2020-10-23-at-11.42.19-AM-540x165.png 540w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/10\/Screen-Shot-2020-10-23-at-11.42.19-AM-270x82.png 270w\"\/><\/figure>\n<\/p>\n<\/div>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><script data-src=\"https:\/\/connect.facebook.net\/en_US\/sdk.js#xfbml=1&amp;appId=378011798897423&amp;version=v2.6\" id=\"socialSrcFacebook\" type=\"text\/template\"><\/script><\/p>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener noreferrer\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/thenextweb.com\/neural\/2020\/10\/24\/how-to-create-an-ai-that-chats-like-you-on-whatsapp-syndication\/\" target=\"_blank\" rel=\"noopener noreferrer\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to create an AI that chats like you on WhatsApp&#8221; To train a GPT-2 neural network, first of all we need to pre-process the data, in order to obtain a single\u00a0.txt\u00a0with a machine-learning compatible structure. 2.1 Google Colab For the sake of simplicity and since the machine learning model we will use requires a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":96665,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/img-cdn.tnwcdn.com\/image\/neural?filter_last=1&fit=1280,640&url=https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2020\/10\/image-5-7.png&signature=f2d9b9111aaa2d4272cf0949631b9418","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-96664","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/96664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=96664"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/96664\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/96665"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=96664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=96664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=96664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}