Deep Learning On Sports Forum Discussions

d481a-startup-photos28129.jpg

Having some well-deserved spare time between finishing big projects (e.g. building fintech solutions from scratch for FinAccel) is an awesome opportunity to relax… or in our case an awesome opportunity to try out new things! One thing that we wanted to experiment with for a while was how well deep learning works on languages other than English. Character level learning got quite a bit of attention thanks to Andrej Karpathy’s work described in The Unreasonable Effectiveness of Recurrent Neural Networks using his char-rnn and Recurrent Neural Networks to learn generative language models. Many people used it for many different things from automatically generating Irish folk songs (here), click-bait headlines (here) or Obama speeches (here).

Po skončení viacerých väčších projektov (napr. stavanie kompletného FinTech riešenia pre indonézsky startup FinAccel) sme konečne mali nejaký čas nazvyš aj na skúšanie nových zaujímavých vecí. Jedna téma, ktorú som chcel už dlhšie vyskúšať bola ako dobre funguje deep learning na jazykoch iných ako angličtina. Záujem o character level learning vzrástol vďaka práci Andreja Karpathyho v blogu The Unreasonable Effectiveness of Recurrent Neural Networks, v ktorom použil jeho implementáciu char-rnn a Recurrent Neural Networks na učenie generatívnych modelov jazyka. Veľa ľudí použilo jeho kód na rôzne zaujímavé veci, od automatického generovania írskych ľudových pesničiek (tu), click-bait headlinov (tu)až po prejavy amerického prezidenta Obamu (tu).

Long Short Term Memory Network (http://slideplayer.com/slide/5251503/)

Long Short Term Memory Network (http://slideplayer.com/slide/5251503/)

We took data from the sports community website sport.sk from Slovakia, infamous for very heated discussions in the forums, which frequently turn into serious trash-talking. We wanted to see, whether we could teach a model to generate these comments automatically from all the past comments we got and if it was going to learn the structures and nuances used in them.

Zobrali sme dáta zo slovenskej športovej stránky sport.sk, známej najmä zanietenými diskusiami, ktoré sa veľakrát zvrhnú do ohnivej výmeny názorov. Zaujímalo nás, či bude možné generovať tieto komenty a celé diskusie automaticky na základe minulých príspevkov, a či bude model schopný naučiť sa ich jazykovú štruktúru a špecifiká.

Data:

We scraped the data from discussion forums of sport.sk, crawling all the discussions on the website. We managed to collect over 200 k unique comments (the replies to a comment are part of the original comment from the site structure) and pasted them all together into one text. The final size of the data in the text format was ~37MB organized in the following way:

Zoscrapovali sme dáta z diskusii na sport.sk, použitím crawlera, ktorý prechádzal cez všetky historické diskusie. Pozbierali sme vyše 200 000 unikátnych komentárov (odpovede na komentáre sú na sport.sk súčasťou originálneho komentu) a spojili ich dohromady do jedného dlhého textu. Finálny dataset v textovej podobe mal veľkosť  približne 37 MB a vyzeral takto:

/* EXAMPLE FROM DATA */
miki50
pan Weiss som dlhodobo fanusik Slovana a iba tolko,,zbalte si kufre a nechajte Slovan Slovanom,,robite nam iba hambu aj s tym vasim Gasparom

kurri44
dobra robota Slovan!

aleg966
treba ignorovat celu slovensku ligu jednoducho tam nechodit na tie baletky sa divat

voivod07
Ked samotni slovanisti neurobia nic, tak Vas Weiss tu bude strasit este zo 10 rokov.

giza69
mantaci, nasadte tam radsej zemaky, bude to lacnejsie a bude z toho nejaky uzitok :)))


Algorithm:

The algorithm that we decided to use was a spin-off library torch-rnn made by JC Johnson. This provides speed and memory improvements over the original implementation and is currently recommended to be the go-to version according to Andrej Karpathy. We used the Long Short Term Memory model to learn the character sequences. We ran the model training on AWS GPU instance g2.xlarge (setup here). The execution time was something over 17 hours. Our data would require a bigger machine (with more GPU power) to unlock its full power (as it was quite big comparing to other applications), however, as a startup there is only so much resources we wanted to allocate for a blog post ;).

Algoritmus, ktorý sme sa rozhodli použiť bola spin-off implementácia torch-rnn, ktorej autorom je JC Johnson. Je rýchlejšia a používa menej pamäte ako originálna implementácia a je momentálne odporúčaná ako default verzia Andrejom Karpathy-m. Použili sme Long Short Term Memory model na naučenie sekvencii symbolov v texte. Model sme zbehli na AWS GPU serveri g2.xlarge (setup tu). Trénovanie modelu trvalo vyše 17 hodín. Naše dáta by potrebovali silnejší server (viac GPU sily) na odhalenie všetkého, čo sa v nich skrýva (nakoľko boli pomerne veľké v porovnaní s inými aplikáciami). Ako startup sme ale neboli príliš ochotní obetovať priveľa zdrojov na jeden blog ;).

Results:

Finally we let the model generate some comments for us. First thing we realized was that the model complexity really wasn’t enough to capture the complexities of Slovak language, so the generated text as a whole seemed senseless and kind of random. At a closer look, there are quite a few things, which were really cool considering the toy character of the project:

Nakoniec sme nechali model vygenerovať zopár diskusii. Na prvý pohľad je zrejmé, že komplexnosť modelu nebola dostatočná na zachytenie zložitosti slovenčiny, takže ako celok vyzerajú generované diskusie chaoticky a trochu náhodne. Pri bližšom skúmaní sme si všimli niekoľko vecí, ktoré sú naozaj cool na to, že to je iba “hračkársky” projekt:

/* EXAMPLE GENERATED DISCUSSION STRUCTURE*/Bobetpo0es15989existuje a priatel je stala a to ukazal bez Tour Drnay ostane a neznamena v blavu a chyb zo vsak v tisete :)ivan7777Jarozinu), bol sme mali skor v NHL a nastupca na zem strely. Viazny-Slovaci je...nevies?ardzna hlou Trnavy aj ty jsi za to kde nechytaval si tahna.. teraz toto podla mna v existuje....

  1. Discussion structure: The model learned perfectly the structure of the discussion with usernames followed by the comments. See above.

  2. Štruktúra diskusie:Model sa naučil dokonale imitovať štruktúru diskusie, kde username používateľa je vždy pred komentom v rozumnej dĺžke. Príklad hore.

  3. Generated real usernames: We compared a couple of the usernames used by the model against the original dataset and (some) of the comments generated are masked to come from actual users (not given here for privacy reasons).

  4. Generuje naozajstné loginy: Porovnali sme niekoľko mien autorov komentárov, ktoré model vygeneroval s pôvodným datasetom a zistili sme, že model píše (niektoré) komentáre v mene reálnych užívateľov (neuvádzame ich kvôli ochrane osobných údajov).

  5. Censored swear words: The model learned things like ***ti and ***ol, which any Slovak speaker immediately recognizes as censored vulgar comments used in the discussion.

  6. Cenzúrované nadávky:Model sa naučil písať veci ako ***ti a ***ol, ktoré sú očividne spôsoby akými užívatelia nahrádzajú na fórach vulgarizmy.

  7. Using sport.sk specific terms: The model also managed to learn terms and words used abundantly in the discussions, which are not used in normal language, such as Coboli (the term used for players of the team currently hated on in the discussion:))

  8. Používanie slov špecifických pre sport.sk: Model sa tiež naučil používať slová a slovné spojenia charakteristické pre konverzácie na sport.sk, ktoré sa nevyskytujú v bežnej slovenčine, ako napríklad Čoboli (označuje hráčov týmu, ktorých v danej konverzácii ľudia hejtujú :))

  9. Emotions in the discussions: There are a lot of emoticons, capitalization, and multiple punctuation used, expressing stress or emotion.

  10. Emotívne diskusie:V generovanom texte je veľa emotikonov, slov začínajúcich veľkými písmenami a nadmernej interpunkcie, ktoré vyjadrujú emócie alebo dôraz.

/* EXAMPLE */ahlaniskrajeuMS talian pomoc Vasi s bodym narofci-i nejlepsi????? lebo sa hrali pekne milionomLikan739to je to keciar. ;-)MLUSePamchalani si tim nejakel tak je prosim hladovani! ;))

There is undoubtedly more hidden in the data and if anyone would like to look into it, please get in touch with us.

V týchto dátach je určite skrytého oveľa viac a ak by mal niekto záujem sa na ne pozrieť, neváhajte nás kontaktovať.

Knoyd

BONUS PRE SLOVÁKOV:

Model nam dal tiež možnosť zadať začiatok komentu a vygeneroval nám najpravdepodobnjšie ukončenie. Tu je zopár, ktoré sa podarili:

  1. Sagan bude… ...na vecnost, a super na drese

  2. Real Madrid vyhra… ...ju, su ako susene United. Za Skrtela sa hanbim.

  3. Slovensko a Nemecko… ...a je to Nemecko

Za ten posledný sa ospravedlňujeme a model ideme okamžite vymazať ;) Slovenskoooo!!!

Previous
Previous

ATTENTION Movie Fans! Learn How To Make The Most Of Your Geeky San-Francisco-Film-Locations Tour!

Next
Next

One Week, Three capitals, Three Conferences