Giter VIP home page Giter VIP logo

imessage-chatbot's Introduction

imessage-rnn

In-progress project: Building a neural network to learn an individual's style of speaking, and respond in their manner.

Current State: Trained on my iMessages from the past year (many of which are with my mom). ~60% accuracy in letter-by-letter message generation. Disclaimer: I am not responsible for what the neural network generates! Live Chat.

Technologies

  • Training messages obtained with SQL
  • Recurrent Neural Network (RNN) built with TensorFlow
  • Flask app responds with generated messages to a Twilio SMS webhook
  • AWS EC2: Trained RNN on p2.xlarge instance, message generator deployed through t2.micro instance

Implementation

1. Extract Data

Data was extracted from the iMessage sqlite3 database, located in /Library/Messages/chat.db.

Getting all messages from yourself:

SELECT text FROM message WHERE is_from_me = 1;

Getting all messages from another person:

-- get their handle_id
SELECT * FROM handle WHERE id="(their_phone_number)";
-- use it to extract their messages
SELECT text FROM message WHERE handle_id = "(handle_id)" AND is_from_me = 0;

Save the ascii messages to a .txt file and format it (ie; deal with emojis).

2. Process Data

With dataset.py, process the text data with parameters from config.py into batches. The input shape for the recurrent neural network is: (None, 32, 62, 256).

3. Train the Recurrent Neural Network model

Now draw the rest of the owl

4. Use the model to generate text

When a text is sent to our Twilio webhook, it hits out app, which generates a message and responds.

Chatbot available through both SMS and online chat.

Our app is very basic. It has two backend routes, one to respond to texts via Twilio and one that responds to messages on the online app version.

@app.route("/sms", methods=['GET', 'POST'])
def sms_reply():
    resp = MessagingResponse()
    rnn_message = generate_message(459)
    resp.message(rnn_message)
    return str(resp)

@app.route("/message", methods=['GET'])
def message_reply():
    return str(generate_message(459))

The current step is to generate responses of varying natural lengths ๐Ÿค”.

Next Steps

  • Add a second layer to the model
  • Improve RNN performance with LSTM cells
  • In progress: Build web app version with React
  • In progress: Generate responses of varying lengths
  • Look into Natural Language Processing (NLP)
  • Increase training data

imessage-chatbot's People

Contributors

anastassia-b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.