Fine-tuning LLMs for Toxic Speech Classification in Gaming

James Poquiz, Han Man, Safa Tinaztepe7 Aug 2023

Problem

A large gaming company wanted to detect toxic language in player voice and text chat. First the excerpt must be marked toxic or not, then assigned to one of the customer's own categories, such as profanity or abusive language. The customer supplied only about 100 labeled samples, far below the roughly 1,000 usually recommended for fine-tuning. Training a custom language model on game chat was ruled out by cost and time limits.

Example from the article: AWS Professional Services built a proof of concept (PoC) from a binary model plus a fine-grained model, then replaced it with one model for production.

Solution in brief

Fine-tune a language model already pre-trained on tweets and further pre-trained on offensive tweets (bertweet-base-offensive), because tweets are short and come from varied authors, like game chat. Pad the 100 customer samples with a public toxicity dataset. For production, merge the two stages into one multi-class model with an extra non-toxic class, trained on about 10,000 samples.

Questions this case answers
  • How to train an accurate text classifier into custom categories when only about a hundred labeled examples exist and training from scratch is too expensive
  • How to decide whether to replace a cascade of classifiers with one multi-class model when maintenance cost matters as much as accuracy
  • How to build a toxic-language classifier for game chat when the customer has only about 100 labeled samples?
  • How to choose a pre-trained model to fine-tune for toxic or offensive text classification?

Tools and methods

  • bertweet-base-offensive — the best of three tested BERTweet checkpoints
  • Transfer learning (supervised fine-tuning) — adapts a pre-trained model to the customer's labels
  • Jigsaw Toxicity dataset — public labeled toxic text used to augment the 100 samples
  • Hugging Face Transformers — loads the checkpoint and runs training
  • Amazon SageMaker notebooks — where the experiments ran
Continue reading — it's free

Google or a one-time email code. No password.