Views
No views yet
| Name | Quant method | Size |
|---|---|---|
| long_llama_3b.Q2_K.gguf | Q2_K | 1.84GB |
| long_llama_3b.IQ3_XS.gguf | IQ3_XS | 1.84GB |
| long_llama_3b.IQ3_S.gguf | IQ3_S | 1.84GB |
| long_llama_3b.Q3_K_S.gguf | Q3_K_S | 1.84GB |
| long_llama_3b.IQ3_M.gguf | IQ3_M | 1.92GB |
| long_llama_3b.Q3_K.gguf | Q3_K | 1.99GB |
| long_llama_3b.Q3_K_M.gguf | Q3_K_M | 1.99GB |
| long_llama_3b.Q3_K_L.gguf | Q3_K_L | 2.06GB |
| long_llama_3b.IQ4_XS.gguf | IQ4_XS | 1.86GB |
| long_llama_3b.Q4_0.gguf | Q4_0 | 1.84GB |
| long_llama_3b.IQ4_NL.gguf | IQ4_NL | 1.86GB |
| long_llama_3b.Q4_K_S.gguf | Q4_K_S | 2.24GB |
| long_llama_3b.Q4_K.gguf | Q4_K | 2.4GB |
| long_llama_3b.Q4_K_M.gguf | Q4_K_M | 2.4GB |
| long_llama_3b.Q4_1.gguf | Q4_1 | 2.04GB |
| long_llama_3b.Q5_0.gguf | Q5_0 | 2.23GB |
| long_llama_3b.Q5_K_S.gguf | Q5_K_S | 2.42GB |
| long_llama_3b.Q5_K.gguf | Q5_K | 2.57GB |
| long_llama_3b.Q5_K_M.gguf | Q5_K_M | 2.57GB |
| long_llama_3b.Q5_1.gguf | Q5_1 | 2.42GB |
| long_llama_3b.Q6_K.gguf | Q6_K | 3.39GB |
| long_llama_3b.Q8_0.gguf | Q8_0 | 3.39GB |
| LongLLaMA-3B | LongLLaMA-7B (coming soon) | LongLLaMA-13B (coming soon) | |
|---|---|---|---|
| Source model | OpenLLaMA-3B | - | - |
| Source model tokens | 1T | - | - |
| Fine-tuning tokens | 10B | - | - |
| Memory layers | 6, 12, 18 | - | - |
pip install --upgrade pip
pip install transformers==4.30 sentencepiece accelerate1import torch
2from transformers import LlamaTokenizer, AutoModelForCausalLM
3
4tokenizer = LlamaTokenizer.from_pretrained("syzymon/long_llama_3b")
5model = AutoModelForCausalLM.from_pretrained("syzymon/long_llama_3b",
6 torch_dtype=torch.float32,
7 trust_remote_code=True)1prompt = "My name is Julien and I like to"
2input_ids = tokenizer(prompt, return_tensors="pt").input_ids
3outputs = model(input_ids=input_ids)last_context_length (default 1024), which specifies the number of tokens left in the last context window. Tuning this parameter can improve generation as the first layers do not have access to memory. See details in How LongLLaMA handles long inputs.1generation_output = model.generate(
2 input_ids=input_ids,
3 max_new_tokens=256,
4 num_beams=1,
5 last_context_length=1792,
6 do_sample=True,
7 temperature=1.0,
8)
9print(tokenizer.decode(generation_output[0]))mem_layers specifies layers endowed with memory (should be either an empty list or a list of all memory layers specified in the description of the checkpoint).mem_dtype allows changing the type of memory cachemem_attention_grouping can trade off speed for reduced memory usage.
When equal to (4, 2048), the memory layers will process at most 4*2048 queries at once (4 heads and 2048 queries for each head).1import torch
2from transformers import LlamaTokenizer, AutoModelForCausalLM
3
4tokenizer = LlamaTokenizer.from_pretrained("syzymon/long_llama_3b")
5model = AutoModelForCausalLM.from_pretrained(
6 "syzymon/long_llama_3b", torch_dtype=torch.float32,
7 mem_layers=[],
8 mem_dtype='bfloat16',
9 trust_remote_code=True,
10 mem_attention_grouping=(4, 2048),
11)1from transformers import LlamaTokenizer, LlamaForCausalLM
2import torch
3
4tokenizer = LlamaTokenizer.from_pretrained("syzymon/long_llama_3b")
5model = LlamaForCausalLM.from_pretrained("syzymon/long_llama_3b", torch_dtype=torch.float32)last_context_length. The model processes the windows one by one extending the memory cache after each. If use_cache is True, the last window will not be loaded to the memory cache but to the local (generation) cache.mem_layers. In addition to this, it stores attention masks.use_cache=True (which is the case in generation), LongLLaMA will use two caches: the memory cache for the specified layers and the local (generation) cache for all layers. When the local cache exceeds 2048 elements, its content is moved to the memory cache for the memory layers.examples/passkey.py.
| Context/Dataset | TREC | WebQS |
|---|---|---|
| 2K | 67.0 | 21.2 |
| 4K | 71.6 | 21.4 |
| 6K | 72.9 | 22.2 |
| 8K | 73.3 | 22.4 |
| Task/Metric | OpenLLaMA-3B | LongLLaMA-3B |
|---|---|---|
| anli_r1/acc | 0.33 | 0.32 |
| anli_r2/acc | 0.32 | 0.33 |
| anli_r3/acc | 0.35 | 0.35 |
| arc_challenge/acc | 0.34 | 0.34 |
| arc_challenge/acc_norm | 0.37 | 0.37 |
| arc_easy/acc | 0.69 | 0.68 |
| arc_easy/acc_norm | 0.65 | 0.63 |
| boolq/acc | 0.68 | 0.68 |
| hellaswag/acc | 0.49 | 0.48 |
| hellaswag/acc_norm | 0.67 | 0.65 |
| openbookqa/acc | 0.27 | 0.28 |
| openbookqa/acc_norm | 0.40 | 0.38 |
| piqa/acc | 0.75 | 0.73 |
| piqa/acc_norm | 0.76 | 0.75 |
| record/em | 0.88 | 0.87 |
| record/f1 | 0.89 | 0.87 |
| rte/acc | 0.58 | 0.60 |
| truthfulqa_mc/mc1 | 0.22 | 0.24 |
| truthfulqa_mc/mc2 | 0.35 | 0.38 |
| wic/acc | 0.48 | 0.50 |
| winogrande/acc | 0.62 | 0.60 |
| Avg score | 0.53 | 0.53 |
1@misc{tworkowski2023focused,
2 title={Focused Transformer: Contrastive Training for Context Scaling},
3 author={Szymon Tworkowski and Konrad Staniszewski and Mikołaj Pacek and Yuhuai Wu and Henryk Michalewski and Piotr Miłoś},
4 year={2023},
5 eprint={2307.03170},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}