Giter Club home page Giter Club logo

gibbspos's Introduction

GibbsPOS

Experimental code to run gibbs sampling for unsupervised part of speech, in both scala and c++ flavors. Code mostly implements a combination of models from Crouching Dirichlet, Hidden Markov Model by Moon, Erk and Baldridge and Simple Type-Level Unsupervised POS Tagging by Lee, Haghighi and Barzilay. In fact the original inspiration of the code came from a post in Haghighi's blog where he walked through an implementation of the ideas in his paper in Clojure.

Installing

There are two seperate implementations in this project. The original and fuller Scala version uses SBT to compile. Hopefully that actually works.

For the C++ code just running make should suffice (you may want to change compiler parameters in the Makefile). The C++ version was made after the original Scala version proved to be a bit slow. I was curious how much of a slow down actually existed, so I reimplimented it in C++ and acheived a considerable speedup (25-30x) with virtually the same code. After having less than sucess using java profilers on scala code, I still haven't quite tracked down where the code is spending so much time. My current guess is somewhere in auto boxing and unboxing of scala types, but I am not positive.

Running

Both basic versions of gibbsPOS take the same arguments (short form for c++, longer form in parenthesis for scala code):

  • -f (or last argument in scala) the POS column file for training
  • -N number of hidden states
  • -i (-iter) maximum number of iterations
  • -e (-emit) Emission prior
  • -t (-trans) Transition prior

The specification of the Emission and Transition priors contains the magic of the Crouching Dirichlet paper; different priors can be specified for different states. The rough intuition behind a different prior for each state is so that most states will emit fewer words (closed class), while some may emit many words (open class). The format for specifying this prior on the command line is as follows:

-e n_1:p_1,n_2:p_2,...,p

so the first n_1 states get prior p_1, the next n_2 states get prior p_2, and the rest of the states get default prior p. For example, to specify that the first five states are open class and thus have a flatter prior, while the rest of the states have a spikier prior, we would use (annoyingly I coded the 0th state as a special sentence boundary state, so need to include a count for it at the beginning):

./gibbsPOS -N 50 -e 1:0.001,5:0.1,0.0001 -t 0.1 -t 10000 -f training file

The column format specifies one word per line, empty line between sentences. In each line the first column is the POS tag, second column is word. If there are any other features those can be included in other columns and they may be used during inference, although I have not had much luck with extra features in this simple model.

gibbspos's People

Contributors

mconnor2 avatar

Stargazers

Pantelis Koukousoulas avatar Patrick Shields avatar  avatar

Watchers

 avatar James Cloos avatar Kyle avatar

Forkers

kalep

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.