Code Monkey home page Code Monkey logo

languagemodels's Introduction

Word Prediction using Recurrent Neural Networks

Udacity Machine Learning Nanodegree Capstone Project

About

Word prediction, or language modeling, is the task of predicting the most likely words following the preceding text. It has many applications, such as suggesting the next word as text is entered, as an aid in resolving ambiguity in speech and handwriting recognition, and in machine translation.

Goals

  • Implement a recurrent neural network (RNN) language model
  • Implement an n-gram predictor as a baseline model
  • Compare accuracy of the two methods for different training set sizes
  • Compare time and space complexity and usage of the two algorithms
  • Generate some text using both models for qualitative comparison

Report

The final report is available here (PDF).

Usage

The project will work on a default Amazon EC2 AMI distribution if you'd like a clean slate - the base Python used is the Anaconda3 4.2.0 distribution with Python 3.5.2.

  • Select the micro instance (free tier) and launch with a key pair.
  • Login with username ec2-user
  • Download Anaconda3 - wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
  • Make executable - chmod +x Anaconda3-4.2.0-Linux-x86_64.sh
  • Run installer - ./Anaconda3-4.2.0-Linux-x86_64.sh
  • Add path - source .bashrc
  • Test it - ipython
  • Install git - sudo yum install git

Once you have a Python 3.5 system set up,

  • Clone this repository - git clone https://github.com/bburns/LanguageModels
  • CD into the project - cd LanguageModels
  • Install Python packages - pip install -r requirements.txt
  • Run make download to download and unzip the GloVe word vectors (~5 minutes)
  • Run make rnn or make ngram to train and test the different models (the RNN is set up to train on 1% of the data for evaluation purposes)
  • Run make plots to show a plot of accuracy vs train amount for ngram and RNN

Additional data used

Automatically downloaded by make download -

  • GloVe - Wikipedia 2014 + Gigaword 5 (6B tokens, 400K vocab, uncased, 50d, 100d, 200d, & 300d vectors, 822 MB download): glove.6B.zip

languagemodels's People

Contributors

bburns 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

languagemodels's Issues

Question regarding preprocessing

Great project! It has been very helpful so far. However, I don't fully understand how you're presenting the input to the network. Your report states that all text is put in a single string and then "split into paragraphs". So how exactly does an input batch look like? Does each row of an input batch contain one sentence? Or can a row contain the last half of one sentence and the beginning of the next? How long are the "paragraphs"?

And one question regarding your output: if I see it correctly, you feed the network with an input batch of a some size (batch_size, sequence_length) which is mapped to a 3D tensor with (batch_size, sequence_length, embedding_size) and given to the RNN.
The output of the RNN is a vector (batch_size, 1) containing the index of the most likely next word. Is that correct?

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.