Building Efficient Universal Classifiers with Natural Language Inference

Moritz Laurer, Wouter van Atteveldt, Andreu Casas, Kasper Welbers
12/29/2023
cs.CLcs.AI

No official code found. Best implementation: MoritzLaurer/zeroshot-classifier (140 stars, Apache-2.0, last commit 2024-12-28).

Abstract

Generative Large Language Models (LLMs) have become the mainstream choice for fewshot and zeroshot learning thanks to the universality of text generation. Many users, however, do not need the broad capabilities of generative LLMs when they only want to automate a classification task. Smaller BERT-like models can also learn universal tasks, which allow them to do any text classification task without requiring fine-tuning (zeroshot classification) or to learn new tasks with only a few examples (fewshot), while being significantly more efficient than generative LLMs. This paper (1) explains how Natural Language Inference (NLI) can be used as a universal classification task that follows similar principles as instruction fine-tuning of generative LLMs, (2) provides a step-by-step guide with reusable Jupyter notebooks for building a universal classifier, and (3) shares the resulting universal classifier that is trained on 33 datasets with 389 diverse classes. Parts of the code we share has been used to train our older zeroshot classifiers that have been downloaded more than 55 million times via the Hugging Face Hub as of December 2023. Our new classifier improves zeroshot performance by 9.4%.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Notebooks for training universal 0-shot classifiers on many different tasks

14013Shell, PythonSep 28, 20231 years agoApache-2.0

Similar Papers

Cite this paper

@article{laurer2023building,
  title  = {Building Efficient Universal Classifiers with Natural Language Inference},
  author = {Moritz Laurer and Wouter van Atteveldt and Andreu Casas and Kasper Welbers},
  year   = {2023},
  eprint = {2312.17543},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2312.17543v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2312.17543.svg)](https://codeofpaper.com/paper/2312.17543)

Discussion