How UltraFastBERT Cuts the Neurons Needed for Inference
Neutral Language models By What The Future Newsroom · December 5, 2023 · 2 min read

How UltraFastBERT Cuts the Neurons Needed for Inference

Researchers at ETH Zurich changed how BERT handles feedforward computations, allowing UltraFastBERT to use 12 of 4,095 neurons per layer for inference. It reached up to 96 % of the original BERT's performance on GLUE, though practical speed gains still depend on software optimization.

Large language models spend much of their computation in feedforward networks. Researchers at ETH Zurich have developed UltraFastBERT, a way to restructure those components so a model computes only selected neurons for a given task. In tests, the approach sharply reduced the neurons used while retaining much of the original BERT model's performance.

“UltraFastBERT is a routine efficiency improvement that reduces inference computation while retaining much of BERT’s benchmark performance.”Why it scores Neutral

Changing which neurons do the work

Transformer-based language models bundle substantial computation and parameters into feedforward networks. The researchers replaced these layers with a differently structured component called a fast feedforward network.

That change turns the usual dense matrix multiplications into conditional matrix multiplications. A dense operation works across every input parameter and neuron; the conditional approach identifies the neurons needed for a task and computes those using binary decision trees.

For inference with UltraFastBERT, only 12 out of 4,095 neurons per layer were sufficient to produce results described as similarly good as those from the unmodified model. The researchers report this represents 0.3 percent of the original number of neurons required for inference.

Performance and speed are separate measures

On the GLUE language comprehension benchmark, UltraFastBERT achieved up to 96 % of the performance of the original BERT model. That result suggests the reduced computation can preserve much of the model's benchmark performance, but it does not mean every task or measure is unchanged.

The neuron reduction also does not automatically translate into the same reduction in elapsed time. The conditional operations need efficient software to realize their potential, and the researchers say that implementation work remains necessary.

Why the theoretical gains are hard to realize

The researchers see especially large theoretical potential for very large language models. For example, they estimate the number of neurons required per inference in GPT-3 could be reduced to just 0.03 % of the previous amount.

Turning that theoretical reduction into practical speed requires efficient conditional matrix multiplication. The article reports a potential speed-up factor of 341 with such an implementation, while noting that current software limitations stand in the way.

Dense matrix multiplication has received extensive optimization across memory, chips, instruction sets and software routines. Some of those advances are kept confidential or made available only through restrictive programming interfaces. The researchers argue that this leaves implementations of conditional matrix multiplication relying on combinations of high-level linear-algebra routines, reducing the speed-up they can achieve.

A first implementation milestone

The researchers have written working CPU-level code as an initial step. It achieved a 78-fold speedup over the optimized baseline feedforward implementation.

That result is a comparison against a particular baseline implementation, while the larger figures describe potential under more efficient software. Together, they show both the promise of changing the computation pattern and the importance of engineering work to make conditional operations run efficiently.

UltraFastBERT's central idea is to avoid calculating every neuron when only a small subset is needed. The reported benchmark performance and CPU implementation offer evidence of progress, while the gap between theoretical potential and practical execution remains a key part of the story.

Artificial intelligenceLanguage modelsComputing
← Back to the wire

Read next