Block Transformer: Global-to-Local Language Modeling for Fast Inference

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Ho, Namgyu, Bae, Sangmin, Kim, Taehyeon, Jo, Hyunjik, Kim, Yireun, Schuster, Tal, Fisch, Adam, Thorne, James, Yun, Se-Young
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912099172614144
author Ho, Namgyu
Bae, Sangmin
Kim, Taehyeon
Jo, Hyunjik
Kim, Yireun
Schuster, Tal
Fisch, Adam
Thorne, James
Yun, Se-Young
author_facet Ho, Namgyu
Bae, Sangmin
Kim, Taehyeon
Jo, Hyunjik
Kim, Yireun
Schuster, Tal
Fisch, Adam
Thorne, James
Yun, Se-Young
contents We introduce the Block Transformer which adopts hierarchical global-to-local modeling to autoregressive transformers to mitigate the inference bottlenecks associated with self-attention. Self-attention requires the key-value (KV) cache of all previous sequences to be retrieved from memory at every decoding step to retrieve context information, leading to two primary bottlenecks during batch inference. First, there is a significant delay in obtaining the first token, as the information of the entire prompt must first be processed to prefill the KV cache. Second, computation of subsequent tokens is bottlenecked by the high memory I/O demand of fetching the entire KV cache, which grows linearly with sequence length, incurring quadratic memory reads overall. We design the Block Transformer to strategically mitigate these costs, by incorporating coarsity and locality into an integrated global-to-local architecture. At the lower layers, we aggregate tokens into fixed size blocks to apply attention across the entire sequence at coarse-grained detail, to capture the global context while minimizing KV cache overhead. At upper layers, we apply attention within each block to decode individual tokens, to model fine-grained details with a lightweight local KV cache. We pretrain vanilla and Block Transformers from scratch and demonstrate that Block Transformers reach 10--20x inference throughput compared to vanilla transformers with equivalent perplexity and zero-shot task performance. Code is available at https://github.com/itsnamgyu/block-transformer.
format Preprint
id arxiv_https___arxiv_org_abs_2406_02657
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Block Transformer: Global-to-Local Language Modeling for Fast Inference
Ho, Namgyu
Bae, Sangmin
Kim, Taehyeon
Jo, Hyunjik
Kim, Yireun
Schuster, Tal
Fisch, Adam
Thorne, James
Yun, Se-Young
Computation and Language
Artificial Intelligence
Machine Learning
We introduce the Block Transformer which adopts hierarchical global-to-local modeling to autoregressive transformers to mitigate the inference bottlenecks associated with self-attention. Self-attention requires the key-value (KV) cache of all previous sequences to be retrieved from memory at every decoding step to retrieve context information, leading to two primary bottlenecks during batch inference. First, there is a significant delay in obtaining the first token, as the information of the entire prompt must first be processed to prefill the KV cache. Second, computation of subsequent tokens is bottlenecked by the high memory I/O demand of fetching the entire KV cache, which grows linearly with sequence length, incurring quadratic memory reads overall. We design the Block Transformer to strategically mitigate these costs, by incorporating coarsity and locality into an integrated global-to-local architecture. At the lower layers, we aggregate tokens into fixed size blocks to apply attention across the entire sequence at coarse-grained detail, to capture the global context while minimizing KV cache overhead. At upper layers, we apply attention within each block to decode individual tokens, to model fine-grained details with a lightweight local KV cache. We pretrain vanilla and Block Transformers from scratch and demonstrate that Block Transformers reach 10--20x inference throughput compared to vanilla transformers with equivalent perplexity and zero-shot task performance. Code is available at https://github.com/itsnamgyu/block-transformer.
title Block Transformer: Global-to-Local Language Modeling for Fast Inference
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2406.02657