tomaarsen / attention_sinks

Extend existing LLMs way beyond the original training length with constant memory usage, without retraining
https://huggingface.co/blog/tomaarsen/attention-sinks
Apache License 2.0
650 stars 41 forks source link

Add BTLM support + benchmark results #29

Closed tomaarsen closed 8 months ago

tomaarsen commented 8 months ago

Hello!

Pull Request overview

Details

As simple as

from attention_sinks import AutoModel

model = AutoModel.from_pretrained("cerebras/btlm-3b-8k-base", device_map="auto", trust_remote_code=True)

Benchmarks

python benchmark/perplexity.py --model_name_or_path cerebras/btlm-3b-8k-base --experiment attention_sinks --output_dir benchmark/outputs_btlm_3b_8k_base_2k_win --trust_remote_code --num_tokens 16384 --window_size 2048
python benchmark/perplexity.py --model_name_or_path cerebras/btlm-3b-8k-base --experiment transformers --output_dir benchmark/outputs_btlm_3b_8k_base_2k_win --trust_remote_code --num_tokens 16384
python benchmark/perplexity.py --model_name_or_path cerebras/btlm-3b-8k-base --experiment windowed --output_dir benchmark/outputs_btlm_3b_8k_base_2k_win --trust_remote_code --num_tokens 16384 --window_size 2048

python benchmark/plot_perplexity.py --features perplexity vram --title "Log perplexity & VRAM usage of BTLM-3B-8k-base\nas a function of input lengths" --output_dir benchmark/outputs_btlm_3b_8k_base_2k_win --log_perplexity_limit 4

btlm_3b_8k_base_ppl_vram_plotted