Giter Site home page Giter Site logo

keras-glove's Introduction

This repo contains an implementation of the popular GloVe in Python with Keras/Tensorflow.

Introduction

Similarly to Word2Vec , GloVe is an unsupervised algorithm which learns vector representations for words. It is trained on aggregated word-word co-occurrence statistics and the resulting vectors expose linear substructures. For more detailed information the interested user should refer to the original web site

Implemented so far

  1. Model architecture in Keras with a custom loss function
  2. Helper functions for data loading and transformations

Pending

  • A new version with less memory requirements.

Setup

Datasets

You need to download a corpus in order to run the algorithm. Some suggestions:

The files should be unzipped and by convention are placed into the data folder

Output

All the generated files are stored in the output folder

Requirements

  • Python 3.6
  • virtualenv

Start a new virtual environment as:

virtualenv --no-site-packages -p python3.6 venv

and then activate it with

. venv/bin/activate

You can install the library either with

python setup.py install

or

python setup.py develop

if you want to stay up to date

Running the code

Currently there are two commands available. The first performs the actual training based on the given corpus. For example, the command:

kglove train data/my_corpus.txt -n 5000 -v 30 -e 3 -b 4098

will read the first 5000 lines from my_corpus.txt, it will train the model for 3 epochs with batch size 4098 producing 30-dimensional vectors. Look in orchestrator.py for the different options available

The second command returns the closest neighbours for a (comma separated) list of words:

kglove closest dirty,polite

will produce the following output:

Most similar words to dirty:
[('laid', 0.9819546), ('smelled', 0.98293394), ('dark', 0.98691344), ('worn', 0.99096316)]:

Most similar words to polite:
[('accomodating', 0.9964925), ('courteous', 0.9968112), ('professional', 0.9969903), ('accommodating', 0.99781287)]:

keras-glove's People

Contributors

erwtokritos avatar

Watchers

James Cloos 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.