The Illustrated BCN+ELMo and its Application in Priority Classification

This blog first details the internals of BCN+ELMo model for text classification and then apply it in a real-world classification problem.

Table of Contents

  • Internals of BCN+ELMo for text classification
  • An illustrated example to explain it
  • Its application in prioriy classification for crisis-related tweets
  • Conclusion

1. Internals of BCN+ELMo for text classification

As the example given in AllenNLP, the model is used for SST-5 sentiment analysis. Here, I will talk about how to adapt it to another domain - priority classification for crisis relevant tweets. The dataset can be downloaded through this link. Before going to apply the model into such a real-world use case. It is necessary first to look at the internals of how the model works. The picture below shows the architecture of the BCN integrated with ELMo model.


A good way to know well the internals of the architecture is to apply breakpoint debugging on the implementation by AllenNLP with PyCharm IDE. To avoid hacking code, next I will give an example to explain it and hopefully help understand the model.

2. An illustrated example to explain it

Pending to finish (include a special exmaple to explain the graph, especially the dimention transformation annotated)…

Pending to finish (include source code implemented to adapt the model to a new domain)…

4. Conclusion

Although BCN+ELMo is ranked the second in the state-of-the-art(SOTA) leadboard for SST-5 task, as of writing this blog, knowing its internals and application is a good starting point for subsequent research in NLP, espcially for language classification problems. In order to know the mathematics of the model. Two papers are worth exploring: Peters, Matthew E., et al. 2018 and McCann, Bryan, et al. 2017. Additionally, the blog by Masato Hagiwara also helps a lot understand what is behind the ELMo and how it works.

If you have any doubts or any my mistakes you found in the blog, send me an email via or you are welcome to talk with me about any NLP relevant questions through my Twitter account.

Written on