4 Sentence classification

 

This chapter covers

  • Handling variable-length input with recurrent neural networks (RNN)
  • Working with RNNs and their variants (LSTMs and GRUs)
  • Using common evaluation metrics for classification problems
  • Developing and configuring a training pipeline using AllenNLP
  • Building a language detector as a sentence classification task

In this chapter, we are going to study the task of sentence classification, where an NLP model receives a sentence and assigns some label to it. A spam filter is an application of sentence classification. It receives an email message and assigns whether or not it is spam. If you want to classify news articles into different topics (business, politics, sports, and so on), it’s also a sentence-classification task. Sentence classification is one of the simplest NLP tasks that has a wide range of applications, including document classification, spam filtering, and sentiment analysis. Specifically, we are going to revisit the sentiment classifier we introduced in chapter 2 and discuss its components in detail. At the end of this section, we are going to study another application of sentence classification—language detection.

4.1 Recurrent neural networks (RNNs)

 

4.1.1 Handling variable-length input

 
 
 

4.1.2 RNN abstraction

 

4.1.3 Simple RNNs and nonlinearity

 
 
 

4.2 Long short-term memory units (LSTMs) and gated recurrent units (GRUs)

 
 
 
 

4.2.1 Vanishing gradients problem

 
 
 
 

4.2.2 Long short-term memory (LSTM)

 
 
 
 

4.2.3 Gated recurrent units (GRUs)

 
 

4.3 Accuracy, precision, recall, and F-measure

 

4.3.1 Accuracy

 
 

4.3.2 Precision and recall

 
 
 

4.3.3 F-measure

 
 

4.4 Building AllenNLP training pipelines

 
 
 

4.4.1 Instances and fields

 
 
 

4.4.2 Vocabulary and token indexers

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest