Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
[ICLR 2024] Efficient Streaming Language Models with Attention Sinks
| Date | Stars |
|---|---|
| 2026-07-31 | 7253 |
| 2026-08-02 | 7253 |
| 2026-08-12 | 7259 |
| 2026-08-18 | 7263 |
| 2026-08-19 | 7262 |
| 2026-08-21 | 7263 |
| 2026-08-22 | 7264 |
| 2026-08-25 | 7266 |
| 2026-08-27 | 7268 |
| 2026-08-31 | 7267 |
| 2026-09-01 | 7268 |
| 2026-09-04 | 7267 |
| 2026-09-05 | 7268 |
| 2026-09-06 | 7267 |
| 2026-09-07 | 7268 |
| 2026-09-08 | 7267 |
| 2026-09-10 | 7266 |
| 2026-09-11 | 7267 |
| 2026-09-13 | 7267 |
| 2026-09-15 | 7268 |
| 2026-09-18 | 7267 |
| 2026-09-19 | 7266 |
| 2026-09-20 | 7266 |
Today
— stars today
This week
-1 stars this week
This month
+3 stars this month
Momentum
0.0
growth rate 0.00%/day
# Efficient Streaming Language Models with Attention Sinks
[[paper](http://arxiv.org/abs/2309.17453)] [[slides](assets/StreamingLLM.pdf)][[video](https://youtu.be/hvJsEzP34o8)]

https://github.com/mit-han-lab/streaming-llm/assets/40906949/2bd1cda4-a0bd-47d1-a023-fbf7779b8358
## TL;DR
We deploy LLMs for infinite-length inputs without sacrificing efficiency and performance.
## News
- [2024/02] StreamingLLM is covered by [MIT News as a spotlight](https://news.mit.edu/2024/new-way-let-ai-chatbots-converse-all-day-without-crashing-0213)!
- [2024/01] StreamingLLM is integrated by HPC-AI Tech [SwiftInfer](https://github.com/hpcaitech/SwiftInfer) to support infinite input length for LLM inference.
- [2024/01] StreamingLLM is integrated by NVIDIA [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM/tree/main/examples/llama#run-llama-with-streamingllm)!
- [2023/12] StreamingLLM is integrated by CMU, UW, and OctoAI, enabling endless and efficient LLM generation on [iPhone](https://x.com/davidpissarra/status/1735761373261427189?s=20)!
- [2023/12] StreamingLLM is integrated by HuggingFace Transformers [PR](https://github.com/huggingface/transformers/pull/26681).
- [2023/10] StreamingLLM is integrated into [Intel Extension for Transformers](https://github.com/intel/intel-extension-for-transformers).
- [2023/10] [Attention Sinks](https://github.com/tomaarsen/attention_sinks), a third-party implementation enables StreamingLLM on more Huggingface LLMs.
## Abstract
Deploying Large Language Models (LLMs) in streaming applications such as multi-round dialogue, where long interactions are expected, is urgently needed but poses two major challenges. Firstly, during the decoding stage, caching previous tokens' Key and Value states (KV) consumes extensive memory. Secondly, popular LLMs cannot generalize to longer texts than the training sequence length. Window attention, where only the most recent KVs are cached, is a natural approach --- but we show that it fails when the text length surpasses the cache size. We observe an interesting phenomenon, namely attention sink, that keeping the KV of initial tokens will largely recover the performance of window attention. In this paper, we first demonstrate that the emergence of attention sink is due to the strong attention scores towards initial tokens as a ``sink'' even if they are not semantically important. Based on the above analysis, we introduce StreamingLLM, an efficient framework that enables LLMs trained with a finite length attention window to generalize to infinite sequence length without any fine-tuning. We show that StreamingLLM can enable Llama-2, MPT, Falcon, and Pythia to perform stable and efficient language modeling with up to 4 million tokens and more. In addition, we discover that adding a placeholder token as a dedicated attention sink during pre-training can further improve streaming deployment. In streaming settings, StreamingLLM outperforms the sliding window recomputation baseline by up to 22.2x speedup.
## Usage
### Environment Setup
```bash
conda create -yn streaming python=3.8
conda activate streaming
pip install torch torchvision torchaudio
pip install transformers==4.33.0 accelerate datasets evaluate wandb scikit-learn scipy sentencepiece
python setup.py develop
```
### Run Streaming Llama Chatbot
```bash
CUDA_VISIBLE_DEVICES=0 python examples/run_streaming_llama.py --enable_streaming
```
## FAQ
1. **What does "working on infinite-length inputs" imply for LLMs?**
Handling infinite-length text with LLMs presents challenges. Notably, storing all previous Key and Value (KV) states demands significant memory, and models might struggle to generate text beyond their training sequence length. StreamingLLM addresses this by retaining only the most recent tokens and attention sinks, discarding intermediate tokens. This enables the model to generate coherent text from recent tokens without a cache reset — a capability not seen in eExcerpt of 6,828 characters
Read on GitHubGuangxuan Xiao · Thinking Machines Lab · United States
29
Song · MIT, NVIDIA
3
Matt Rickard
1
Tom Aarsen · @huggingface · Netherlands
1
Cosmo · @marderlab
1
Would you bet a product on this? Bounded 0–100 and slow moving.
matched fp:c678873675745406, llm:Repository title and description: 'Efficient Streaming Language Models with Attention Sinks' (ICLR 2024). Python implementation for streaming LLMs.
matched fp:c678873675745406, llm:Repository title and description: 'Efficient Streaming Language Models with Attention Sinks' (ICLR 2024). Python implementation for streaming LLMs.
matched fp:c678873675745406, llm:Repository title and description: 'Efficient Streaming Language Models with Attention Sinks' (ICLR 2024). Python implementation for streaming LLMs.