Text Classification

Text classification models take a sequence of text as input and classify it into one of several classes.

Input: Text sequence

Output: Class label


class deep_qa.models.text_classification.classification_model.ClassificationModel(params: deep_qa.common.params.Params)[source]

Bases: deep_qa.training.text_trainer.TextTrainer

A TextTrainer that simply takes word sequences as input (could be either sentences or logical forms), encodes the sequence using a sentence encoder, then uses a few dense layers to decide on some classification label for the text sequence (currently hard-coded for a binary classification decision, but that’s easy to fix if we need to).

We don’t really expect this model to work for question answering - it’s just a sentence classification model. The best it can do is basically to learn word cooccurrence information, similar to how the Salience solver works, and I’m not at all confident that this does that job better than Salience. We’ve implemented this mostly as a simple baseline.

Note that this also can’t actually answer questions at this point. You have to do some post-processing to get from true/false decisions to question answers, and I removed that from TextTrainer to make the code simpler.

train_input: numpy array: int32 (samples, num_words). Left padded arrays of word indices
from sentences in training data

This gets called when loading a saved model. It is analogous to _set_padding_lengths, but needs to set all of the values set in that method just by inspecting the loaded model. If we didn’t have this, we would not be able to correctly pad data after loading a model.