Detecting offensive messages using Deep Learning: A micro-service based approach

Alizishaan Khatri (~alizishaan)




Offensive / abusive content is a major issue for social-media and digital interaction platforms. In some jurisdictions (Eg: Europe), platform providers are required by law to remove such content within 24 hours of posting or risk hefty fines (upto €50M in Germany). In order to meet the governance mandate, we need to have systems in place that can automatically detect abusive content at scale. This talk is based on my practical experience of building an automated solution to solve this problem.

This talk begins with discussing some of the approaches currently being employed for offensive content detection at scale: word filtering, rule-based systems and actual human annotation.

The former two are restricted by the following:

  • Offensive content is context specific. A given word (f*ck) can be used in both positive (that’s f*cking awesome) and negative (that’s f*cking terrible) contexts.
  • Robustness to spelling variations (The word ‘shit’ can be spelt as ‘sh*t’, ‘sh!t’, etc)
  • Failure to detect content that is offensive in idea but uses non-offensive words. (Eg: your mom is a fat cow, X people are inferior, etc)

Manual human annotation is notoriously hard and expensive to scale. The talk presents a Deep neural network based approach to overcome the previously mentioned limitations. It introduces and discusses the building blocks of model architecture (deep convolutional networks, word embeddings, etc).

The second half of the talk focuses on implementing the model to solve the problem at scale as a RESTful micro-service using python, Django, Tensorflow and Docker. This architecture can also be used to implement other text classification systems (eg: sentiment detection, user intent detection systems, topic-of-discussion classifiers, etc.), making the talk relevant for a wider user base.

Attendees will:

  • Gain insights into building deep learning based text-classification systems that can scale
  • Learn the nitty gritties of the offensive content detection and text classification
  • Learn about the basic concepts of Deep Learning and NLP (convolutional neural nets, multi-layer perceptron, word embeddings, etc.)
  • Understand the scientific and software challenges involved in text classification and learn to overcome them
  • Be able to apply the learnings from here to other text classification problems as well


  • Elementary knowledge of Python
  • Basic understanding of machine learning (nice to have, not mandatory)
  • An open mind ;)

Content URLs:

A similar version of this talk was recently delivered at Pycon APAC2018 (Singapore).

Speaker Info:

Alizishaan's professional passions revolve around two things : using technology to solve real-world problems and sharing solutions with the community. Over the summer of 2017, he designed and built an offensive content detection system for a Silicon Valley company. Past industry projects include a price-prediction system for cars and a status communication system that minimized false alerts. He is currently employed as a Machine Learning Engineer.

Outside of work, Alizishaan's passions include mountaineering, skiing, travelling and photography.

Speaker Links:

Id: 836
Section: Data science
Type: Talks
Target Audience: Beginner
Last Updated: