Giter VIP home page Giter VIP logo

structured_embeddings's Introduction

Structured Embeddings

This repository contains code for analyzing how word usage differs across related groups of text data. The corresponding publication is

M. Rudolph, F. Ruiz, S. Athey, D. Blei, Structured Embedding Models for Grouped Data, Neural Information Processing Systems, 2017

Also, check out the NIPS 2017 Spotlight Video:

NIPS 2017 Spotlight video

The code in this repository contains 3 models you can fit to grouped text data:

  • global Bernoulli embeddings (no variations between groups)
  • hierarchical Bernoulli embeddings (embeddings share statistical strength through hierarchical prior)
  • amortized Bernoulli embeddings (embeddings share statistical strength through amortization)

We use these models to analyze how the language of Senators differs according to their home state and party affiliation and how scientific language varies in differerent sections of the ArXiv.

How to Run Structured Embeddings

All code in this repo has been run and tested on Linux, with Python 2.7 and Tensorflow 1.3.0.

The input format, and how to prepare the data so it has the required input format is described in the dat/ subfolder of this repo. Follow the instructions in the README, code is provided.

To fit the models, go into the source folder (src/) and run

python main.py --fpath [path/to/data]

substitute the path to the folder where you put the data for [path/to/data]. For example, after running the python scripts step_1 through step_4 in the dat folder, you can run python main.py --fpath lorem_ipsum --K 5 to run Bernoulli embeddings on the provided test data dat/lorem_ipsum.

For all commandline options run:

python main.py --help

For fastest convergence we recommend a 2-step training procedure. Step 1 fits a Bernoulli embedding which is then used to initialize a structured embedding.

First run

python main.py --fpath [path/to/data]

This executes Bernoulli embeddings without structure. The script uses the current timestamp to create a folder where the results are saved ([path/to/results/]). We will use these results to initialize the structured embeddings:

python main.py --hierarchical True --fpath [path/to/data] --init [path/to/result]/variational0.dat

or

python main.py --amortized True --fpath [path/to/data] --init [path/to/result]/variational0.dat

Make sure to use the same --K for both runs.

structured_embeddings's People

Contributors

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

Watchers

 avatar  avatar  avatar  avatar  avatar

structured_embeddings's Issues

Shopping data

Hi. Can I confirm that this code does not work with shopping data?

Help with model evaluation

Thanks to this project! I trained my model, now how can I evaluate my dynamic embeddings on the test set?
I see the function "eval_log_like" in model.py but I do not know how to properly use it. Some help, please (:

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.