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 Mistral support + benchmark results #5

Closed tomaarsen closed 10 months ago

tomaarsen commented 10 months ago

Hello!

Pull Request overview

Details

As simple as

from attention_sinks import AutoModel

model = AutoModel.from_pretrained("mistralai/Mistral-7B-v0.1", device_map="auto")

Benchmarks

python benchmark/perplexity.py --model_name_or_path mistralai/Mistral-7B-v0.1 --experiment attention_sinks --output_dir benchmark/outputs_mistral_7b --num_tokens 16384
python benchmark/perplexity.py --model_name_or_path mistralai/Mistral-7B-v0.1 --experiment transformers --output_dir benchmark/outputs_mistral_7b --num_tokens 14000
python benchmark/perplexity.py --model_name_or_path mistralai/Mistral-7B-v0.1 --experiment windowed --output_dir benchmark/outputs_mistral_7b

python benchmark/plot_perplexity.py --features perplexity vram --title "Log perplexity & VRAM usage of Mistral 7B as a function of input lengths" --output_dir benchmark/outputs_mistral_7b --log_perplexity_limit 4

mistral_7b_ppl_vram_plotted