« KV Cache » : différence entre les versions


Aucun résumé des modifications
Aucun résumé des modifications
 
Ligne 2 : Ligne 2 :


== Définition ==
== Définition ==
XXXXXXXXX
Technique utilisée pour accélérer l''''[[inférence]]''' dans les '''[[Modèle|modèles]]''' d''''[[apprentissage automatique]]''', en particulier dans les '''[[Modèle autorégressif|modèles autorégressifs]]'''. Elle consiste à cacher les clés et les valeurs antérieures afin d'éliminer le besoin de les recalculer pour chaque nouveau '''[[segment textuel]]'''. Ceci réduit considérablement la taille des '''[[Matrice|matrices]]''' utilisées dans les calculs et accélère les multiplications matricielles.
 
Autrement dit, le modèle utilisant cette technique réutilise les calculs passés pour obtenir des résultats plus rapides, ce qui lui permet de rester rapide même avec des textes plus longs et d'éviter les calculs répétitifs.


== Français ==
== Français ==
Ligne 10 : Ligne 12 :
'''KV Cache'''
'''KV Cache'''


a KV cache stores intermediate key (K) and value (V) computations for reuse during inference (after training), which results in a substantial speed-up when generating text. The downside of a KV cache is that it adds more complexity to the code, increases memory requirements (the main reason I initially didn't include it in the book), and can't be used during training. However, the inference speed-ups are often well worth the trade-offs in code complexity and memory when using LLMs in production.
''A technique used to accelerate the inference process in machine learning models, particularly in autoregressive models. It involves caching the previous keys and values, so we don’t need to recalculate them for each new token, thus reducing the size of matrices used in calculations, making matrix multiplications faster. The model employing this technique reuses past calculations for faster results, so it stays fast even with longer texts by avoiding repeated work.''
  KV cache is a technique used in transformer models to improve inference efficiency by storing key (K) and value (V) states of previously computed tokens. This allows the model to avoid redundant computations during the generation of new tokens, thereby reducing the time and resources required for inference
 
 
 


<!-- a KV cache stores intermediate key (K) and value (V) computations for reuse during inference (after training), which results in a substantial speed-up when generating text. The downside of a KV cache is that it adds more complexity to the code, increases memory requirements (the main reason I initially didn't include it in the book), and can't be used during training. However, the inference speed-ups are often well worth the trade-offs in code complexity and memory when using LLMs in production.
  KV cache is a technique used in transformer models to improve inference efficiency by storing key (K) and value (V) states of previously computed tokens. This allows the model to avoid redundant computations during the generation of new tokens, thereby reducing the time and resources required for inference-->
== Sources ==
== Sources ==
[https://arxiv.org/html/2407.18003v1  Source : Arxiv]
[https://arxiv.org/html/2407.18003v1  Source : Arxiv]

Dernière version du 9 novembre 2025 à 12:13

en construction

Définition

Technique utilisée pour accélérer l'inférence dans les modèles d'apprentissage automatique, en particulier dans les modèles autorégressifs. Elle consiste à cacher les clés et les valeurs antérieures afin d'éliminer le besoin de les recalculer pour chaque nouveau segment textuel. Ceci réduit considérablement la taille des matrices utilisées dans les calculs et accélère les multiplications matricielles.

Autrement dit, le modèle utilisant cette technique réutilise les calculs passés pour obtenir des résultats plus rapides, ce qui lui permet de rester rapide même avec des textes plus longs et d'éviter les calculs répétitifs.

Français

XXXXXXXXX

Anglais

KV Cache

A technique used to accelerate the inference process in machine learning models, particularly in autoregressive models. It involves caching the previous keys and values, so we don’t need to recalculate them for each new token, thus reducing the size of matrices used in calculations, making matrix multiplications faster. The model employing this technique reuses past calculations for faster results, so it stays fast even with longer texts by avoiding repeated work.

Sources

Source : Arxiv

Source : huggingface

Source : The Large Language Model Playbook

Contributeurs: Arianne Arel, wiki