HiRED: Eliminazione Selettiva di Token con Guida dell'Attenzione per Inferenza Efficiente di Modelli Visione-Linguaggio ad Alta Risoluzione in Ambienti con Risorse Limitati
HiRED: Attention-Guided Token Dropping for Efficient Inference of High-Resolution Vision-Language Models in Resource-Constrained Environments
August 20, 2024
Autori: Kazi Hasan Ibn Arif, JinYi Yoon, Dimitrios S. Nikolopoulos, Hans Vandierendonck, Deepu John, Bo Ji
cs.AI
Abstract
I modelli visione-linguaggio ad alta risoluzione (VLMs) sono ampiamente utilizzati in compiti multimodali per migliorare l'accuratezza preservando le informazioni dettagliate delle immagini. Tuttavia, questi modelli spesso generano un eccesso di token visivi a causa della codifica di più partizioni dell'immagine di input. Elaborare questo eccesso di token visivi è computazionalmente impegnativo, specialmente in ambienti con risorse limitate e GPU di fascia consumer. Per supportare immagini ad alta risoluzione rispettando i vincoli di risorse, proponiamo High-Resolution Early Dropping (HiRED), uno schema di eliminazione dei token che opera con un budget fisso di token prima della fase del Large Language Model (LLM). HiRED può essere integrato con i VLMs ad alta risoluzione esistenti in modalità plug-and-play, poiché non richiede ulteriore addestramento pur mantenendo un'accuratezza superiore. Utilizziamo strategicamente l'attenzione dell'encoder visivo negli strati iniziali per valutare il contenuto visivo di ciascuna partizione dell'immagine e allocare il budget di token di conseguenza. Quindi, utilizzando l'attenzione nello strato finale, selezioniamo i token visivi più importanti da ciascuna partizione nel budget allocato, eliminando il resto. Empiricamente, applicando HiRED a LLaVA-Next-7B su GPU NVIDIA TESLA P40 con un budget del 20% di token, si ottiene un aumento del throughput di generazione dei token di 4,7 volte, una riduzione della latenza di generazione del primo token di 15 secondi e un risparmio di 2,3 GB di memoria GPU per una singola inferenza.
English
High-resolution Vision-Language Models (VLMs) have been widely used in
multimodal tasks to enhance accuracy by preserving detailed image information.
However, these models often generate excessive visual tokens due to encoding
multiple partitions of the input image. Processing these excessive visual
tokens is computationally challenging, especially in resource-constrained
environments with commodity GPUs. To support high-resolution images while
meeting resource constraints, we propose High-Resolution Early Dropping
(HiRED), a token-dropping scheme that operates within a fixed token budget
before the Large Language Model (LLM) stage. HiRED can be integrated with
existing high-resolution VLMs in a plug-and-play manner, as it requires no
additional training while still maintaining superior accuracy. We strategically
use the vision encoder's attention in the initial layers to assess the visual
content of each image partition and allocate the token budget accordingly.
Then, using the attention in the final layer, we select the most important
visual tokens from each partition within the allocated budget, dropping the
rest. Empirically, when applied to LLaVA-Next-7B on NVIDIA TESLA P40 GPU, HiRED
with a 20% token budget increases token generation throughput by 4.7, reduces
first-token generation latency by 15 seconds, and saves 2.3 GB of GPU memory
for a single inference.