Research Notes

Six ways to make an NLP model smaller

Large language models made natural language processing far more capable, and far more expensive to run. The tutorial on compression of deep learning models for NLP, given at IJCAI-PRICAI 20 and CIKM 2020, grouped the ways of shrinking them into six families. This note is a short, plain-language walk through those families for readers who want the map before the references.

Why compression matters

A model that needs several gigabytes of memory and a data-centre GPU cannot answer quickly on a phone, and costs real money for every request on a server. Real applications want small models, low response times and low power use. Compression trades a little accuracy, sometimes none, for a model that fits where it is needed.

Pruning

Pruning removes parts of a network that contribute little. The simplest form zeroes out individual weights with small magnitude. More structured forms remove whole neurons, blocks of a matrix or entire attention heads, which is easier to turn into real speed-ups on standard hardware. Pruning can be done once after training or adjusted dynamically as training continues.

Quantization

Quantization stores each weight with fewer bits. Instead of 32-bit floating point numbers, weights can be held as 8-bit integers, as three values (ternary) or even as two (binary). The model keeps its shape but takes much less memory, and integer arithmetic is cheaper on many chips. The challenge is keeping accuracy when precision drops sharply.

Knowledge distillation

Distillation trains a small student model to imitate a large teacher. The student learns from the teacher’s soft output distribution, and sometimes from its intermediate representations, rather than only from hard labels. Variants use several teachers, several students learning from each other, or unlabelled data to give the student more examples to copy.

Parameter sharing

Sharing reuses the same parameters in more than one place. Layers in a Transformer can share weights, embedding matrices can be shared between input and output, and hashing tricks can map many virtual weights onto a smaller real set. The number of distinct values the model stores falls, often with little loss.

Matrix decomposition

Large weight matrices can often be approximated by the product of smaller ones. Low-rank factorisation, singular value decomposition and tensor-train or block-term decompositions all replace one big matrix with a few compact pieces. Factorising the embedding layer is a common first step, because embeddings are a large share of the parameters in many NLP models.

Transformer-specific methods

The sixth family changes the architecture itself: compressing the vocabulary, restructuring attention, or replacing a deep stack of layers with a model that reaches the same result in fewer distinct parameters. These methods are newer and more varied than the other five.

Combining the families

The families are not exclusive. A distilled student can be pruned and then quantized, and many deployed systems use more than one method. The full outline, with references for each method and application area, is in the tutorial article.