flare.examples.sentence-classification

Main class for training/testing a bi-lstm sentence classification model for sentences. Running this class as CLI will require an embedding file, as well as train/test files. Format described below:

  • embedding file: text format, each line formatted as: ‘word dimension-1 … dimension-n’ with whitespace delimitation. This is how Glove vectors are distributed as here.
  • train/test file: text format, each line formatted as: ‘label-index word-1 word-2 .. word-n’.The ‘label-index’ is assumed to be an integer representing the label index. The words are treated as strings and joined with the words in the embedding file.

For the introductory Flare blogpost, the Glove Vectors come from 1 and the sentiment examples come from Stanford Sentiment data. The train/test are randomly sampled after concattening positive/negative examples.

-main

(-main & args)

CLI entry point for train/test classifiying a sentence with a single label. See the ns doc for full explanation.

cli-options

cnn-sent-classifier

(cnn-sent-classifier model word-emb num-classes)

get-classifier

(get-classifier model-type model emb lstm-size num-classes)

load-data

(load-data path)

load-embeddings

(load-embeddings opts)

lstm-sent-classifier

(lstm-sent-classifier model word-emb lstm-size num-classes)

train

(train {:keys [lstm-size num-classes train-file test-file model-type], :as opts})