/friend-emulator

Generate a NLP Model to replicate and replace your friends on WhatsApp

Primary LanguagePython

Friend-Emulator

More & more of my friends are moving away from where I live, some across different time zones. To keep myself from becoming lonely, I figured the next best thing to physical human contact would be a bot that can convincingly mimic the speaking style of my friends. Now you can do the same!

Setup

chats

WhatsApp allows you to export the chat log for any group chat or contact. Simply go to your settings in the app, hit 'Chats' and then 'Chat history'. Select the chat and you will receive it in a text file via e-mail.

Put any number of these files into the same directory as the emulate script.

Requirements

To run this Emulator you need Python and some other requirements like TensorFlow, you can install them using:

pip install -r requirements.txt -U

Running

python emulate.py

Run it and watch the magic happen! At first, the chats will be nonsense jumbles of words, but after a couple epochs you will start to notice the network replicating the chat format nicely.

Specifics

The script will separate your chats into 7-word sequences, then try to learn the probability distribution of the following words given the sequence. At the end of each epoch of training, the script generates chats by the following steps:

  1. Take a random 7-word sequence from the chat
  2. Predict the following word
  3. Add the predicted word to the end of the sequence and omit the first
  4. Repeat steps 1-3 for 150 words

It does this through a multi-layer LSTM network. The network also has learnable embeddings so your friends' non-standard vocabulary will be conserved.

Examples

I can't give you my personal WhatsApp data if that's what you're looking for, you scum, but here are a few of my favourite dialogues generated by this script:

raddish : guys 
raddish : what are you saying tonight ? 
raddish : what you doing brownie ticket ? 
orr: approx time we going tonight ? 
metcalfe : sometime after 8:00 id imagine 
hyde : thats not a time
raddish : and hotel included ? !
hackney : yeah fam
raddish : oh fuck
raddish : thats
raddish : so drill
joyce : drill
raddish : on the drill
raddish : man

Please leave me yours!