GraySoft
Projects Models About FAQ Contact Download guIDE →
Model Intelligence Sheet

richarderkhov/syzymon_-_long_llama_3b-gguf overview

Colab TLDR | Overview | Usage | LongLLaMA performance | Authors | Citation | License | Acknowledgments

ggufarxiv:2307.03170arxiv:2305.16300endpoints_compatibleregion:us
richarderkhov/syzymon_-_long_llama_3b-gguf visual
Downloads
165
Likes
0
Pipeline
Library
Visibility
Public
Access
Open

Repository Files & Downloads

22 files detected
Direct downloads for all repository files
FileTypeQuantizationSizeLink
long_llama_3b.IQ3_M.gguf GGUF IQ3_M 1.92 GB Download
long_llama_3b.IQ3_S.gguf GGUF IQ3_S 1.84 GB Download
long_llama_3b.IQ3_XS.gguf GGUF IQ3_XS 1.84 GB Download
long_llama_3b.IQ4_NL.gguf GGUF IQ4_NL 1.86 GB Download
long_llama_3b.IQ4_XS.gguf GGUF IQ4_XS 1.86 GB Download
long_llama_3b.Q2_K.gguf GGUF Q2_K 1.84 GB Download
long_llama_3b.Q3_K.gguf GGUF Q3_K 1.99 GB Download
long_llama_3b.Q3_K_L.gguf GGUF Q3_K_L 2.06 GB Download
long_llama_3b.Q3_K_M.gguf GGUF Q3_K_M 1.99 GB Download
long_llama_3b.Q3_K_S.gguf GGUF Q3_K_S 1.84 GB Download
long_llama_3b.Q4_0.gguf GGUF 1.84 GB Download
long_llama_3b.Q4_1.gguf GGUF 2.04 GB Download
long_llama_3b.Q4_K.gguf GGUF Q4_K 2.40 GB Download
long_llama_3b.Q4_K_M.gguf GGUF Q4_K_M 2.40 GB Download
long_llama_3b.Q4_K_S.gguf GGUF Q4_K_S 2.24 GB Download
long_llama_3b.Q5_0.gguf GGUF 2.23 GB Download
long_llama_3b.Q5_1.gguf GGUF 2.42 GB Download
long_llama_3b.Q5_K.gguf GGUF Q5_K 2.57 GB Download
long_llama_3b.Q5_K_M.gguf GGUF Q5_K_M 2.57 GB Download
long_llama_3b.Q5_K_S.gguf GGUF Q5_K_S 2.42 GB Download
long_llama_3b.Q6_K.gguf GGUF Q6_K 3.39 GB Download
long_llama_3b.Q8_0.gguf GGUF 3.39 GB Download

Model Details Live

Model Slug
richarderkhov/syzymon_-_long_llama_3b-gguf
Author
RichardErkhov
Pipeline Task
Library
Created
2024-08-26
Last Modified
2024-08-26
Gated
No
Private
No
HF SHA
a575058857d76c09a1e43eb95123c937d79f3716
License
Unknown
Language
Unknown
Base Model
Unknown

Metadata Inspector

Normalized metadata (stored in metadata_json)
{
  "metadata": {},
  "card_data": {
    "frontmatter": {},
    "hero_image_url": "https://raw.githubusercontent.com/CStanKonrad/long_llama/main/assets/plot_passkey.png",
    "summary": "![Colab](https://colab.research.google.com/github/CStanKonrad/long_llama/blob/main/long_llama_colab.ipynb) TLDR | Overview | Usage | LongLLaMA performance | Authors | Citation | License | Acknowledgments",
    "quick_links": [],
    "benchmark_table_html": "",
    "readme_markdown": "Quantization made by Richard Erkhov.\n\n[Github](https://github.com/RichardErkhov)\n\n[Discord](https://discord.gg/pvy7H8DZMG)\n\n[Request more models](https://github.com/RichardErkhov/quant_request)\n\n\nlong_llama_3b - GGUF\n- Model creator: https://huggingface.co/syzymon/\n- Original model: https://huggingface.co/syzymon/long_llama_3b/\n\n\n| Name | Quant method | Size |\n| ---- | ---- | ---- |\n| [long_llama_3b.Q2_K.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q2_K.gguf) | Q2_K | 1.84GB |\n| [long_llama_3b.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.IQ3_XS.gguf) | IQ3_XS | 1.84GB |\n| [long_llama_3b.IQ3_S.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.IQ3_S.gguf) | IQ3_S | 1.84GB |\n| [long_llama_3b.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q3_K_S.gguf) | Q3_K_S | 1.84GB |\n| [long_llama_3b.IQ3_M.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.IQ3_M.gguf) | IQ3_M | 1.92GB |\n| [long_llama_3b.Q3_K.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q3_K.gguf) | Q3_K | 1.99GB |\n| [long_llama_3b.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q3_K_M.gguf) | Q3_K_M | 1.99GB |\n| [long_llama_3b.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q3_K_L.gguf) | Q3_K_L | 2.06GB |\n| [long_llama_3b.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.IQ4_XS.gguf) | IQ4_XS | 1.86GB |\n| [long_llama_3b.Q4_0.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q4_0.gguf) | Q4_0 | 1.84GB |\n| [long_llama_3b.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.IQ4_NL.gguf) | IQ4_NL | 1.86GB |\n| [long_llama_3b.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q4_K_S.gguf) | Q4_K_S | 2.24GB |\n| [long_llama_3b.Q4_K.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q4_K.gguf) | Q4_K | 2.4GB |\n| [long_llama_3b.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q4_K_M.gguf) | Q4_K_M | 2.4GB |\n| [long_llama_3b.Q4_1.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q4_1.gguf) | Q4_1 | 2.04GB |\n| [long_llama_3b.Q5_0.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q5_0.gguf) | Q5_0 | 2.23GB |\n| [long_llama_3b.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q5_K_S.gguf) | Q5_K_S | 2.42GB |\n| [long_llama_3b.Q5_K.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q5_K.gguf) | Q5_K | 2.57GB |\n| [long_llama_3b.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q5_K_M.gguf) | Q5_K_M | 2.57GB |\n| [long_llama_3b.Q5_1.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q5_1.gguf) | Q5_1 | 2.42GB |\n| [long_llama_3b.Q6_K.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q6_K.gguf) | Q6_K | 3.39GB |\n| [long_llama_3b.Q8_0.gguf](https://huggingface.co/RichardErkhov/syzymon_-_long_llama_3b-gguf/blob/main/long_llama_3b.Q8_0.gguf) | Q8_0 | 3.39GB |\n\n\n\n\nOriginal model description:\n---\nlicense: apache-2.0\ndatasets:\n- togethercomputer/RedPajama-Data-1T\npipeline_tag: text-generation\ntags:\n- text-generation-inference\n---\n# LongLLaMA: Focused Transformer Training for Context Scaling\n[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/CStanKonrad/long_llama/blob/main/long_llama_colab.ipynb)\n\n\n[TLDR](#tldr) | [Overview](#overview) | [Usage](#usage) | [LongLLaMA performance](#longllama-performance) | [Authors](#authors) | [Citation](#citation) | [License](license) | [Acknowledgments](#acknowledgments)\n\n## TLDR\nThis repository contains the research preview of **LongLLaMA, a large language model capable of handling long contexts of 256k tokens or even more**. \n\nLongLLaMA is built upon the foundation of [OpenLLaMA](https://github.com/openlm-research/open_llama) and fine-tuned using the [Focused Transformer (FoT)](https://arxiv.org/abs/2307.03170) method.  We release a smaller 3B variant of the LongLLaMA model on a permissive license (Apache 2.0) and inference code supporting longer contexts on [Hugging Face](https://huggingface.co/syzymon/long_llama_3b). Our model weights can serve as the drop-in replacement of LLaMA in existing implementations (for short context up to 2048 tokens). Additionally, we provide evaluation results and comparisons against the original OpenLLaMA models. Stay tuned for further updates.\n\n\n## Overview\n[Focused Transformer: Contrastive Training for Context Scaling](https://arxiv.org/abs/2307.03170) (FoT) presents a simple method for endowing language models with the ability to handle context consisting possibly of millions of tokens while training on significantly shorter input. FoT permits a subset of attention layers to access a memory cache of (key, value) pairs to extend the context length. The distinctive aspect of FoT is its training procedure, drawing from contrastive learning. Specifically, we deliberately expose the memory attention layers to both relevant and irrelevant keys (like negative samples from unrelated documents). This strategy incentivizes the model to differentiate keys connected with semantically diverse values, thereby enhancing their structure. This, in turn, makes it possible to extrapolate the effective context length much beyond what is seen in training. \n\n\n**LongLLaMA** is an [OpenLLaMA](https://github.com/openlm-research/open_llama) model finetuned with the FoT method,\nwith three layers used for context extension. **Crucially, LongLLama is able to extrapolate much beyond the context length seen in training: 8k. E.g., in the key retrieval task, it can handle inputs of length 256k**.\n\n<center>\n\n|  | [LongLLaMA-3B](https://huggingface.co/syzymon/long_llama_3b) | LongLLaMA-7B<br />*(coming soon)*|  LongLLaMA-13B<br />*(coming soon)*|\n|----------------|----------|-----------|-----------|\n| Source model         | [OpenLLaMA-3B](https://huggingface.co/openlm-research/open_llama_3b_easylm)      | -        | - |\n| Source model tokens     | 1T      | -       | - |\n| Fine-tuning tokens  | 10B     | -     | -|\n| Memory layers         |  6, 12, 18        |  -        | -|\n\n</center>\n\n\n## Usage\n\nSee also: [colab with an example usage of LongLLaMA](https://colab.research.google.com/github/CStanKonrad/long_llama/blob/main/long_llama_colab.ipynb).\n### Requirements\n```\npip install --upgrade pip\npip install transformers==4.30  sentencepiece accelerate\n```\n\n### Loading model\n```python\nimport torch\nfrom transformers import LlamaTokenizer, AutoModelForCausalLM\n\ntokenizer = LlamaTokenizer.from_pretrained(\"syzymon/long_llama_3b\")\nmodel = AutoModelForCausalLM.from_pretrained(\"syzymon/long_llama_3b\", \n                                            torch_dtype=torch.float32, \n                                            trust_remote_code=True)\n```\n\n### Input handling and generation\nLongLLaMA uses the Hugging Face interface, the long input given to the model will be \nsplit into context windows and loaded into the memory cache.\n```python\nprompt = \"My name is Julien and I like to\"\ninput_ids = tokenizer(prompt, return_tensors=\"pt\").input_ids\noutputs = model(input_ids=input_ids)\n```\nDuring the model call, one can provide the parameter `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](#How-LongLLaMA-handles-long-inputs).\n\n```python\ngeneration_output = model.generate(\n    input_ids=input_ids,\n    max_new_tokens=256,\n    num_beams=1,\n    last_context_length=1792,\n    do_sample=True,\n    temperature=1.0,\n)\nprint(tokenizer.decode(generation_output[0]))\n```\n\n### Additional configuration\nLongLLaMA has several other parameters:\n* `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).\n* `mem_dtype` allows changing the type of memory cache\n* `mem_attention_grouping` can trade off speed for reduced memory usage. \n  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).\n\n```python\nimport torch\nfrom transformers import LlamaTokenizer, AutoModelForCausalLM\n\ntokenizer = LlamaTokenizer.from_pretrained(\"syzymon/long_llama_3b\")\nmodel = AutoModelForCausalLM.from_pretrained(\n    \"syzymon/long_llama_3b\", torch_dtype=torch.float32, \n    mem_layers=[], \n    mem_dtype='bfloat16',\n    trust_remote_code=True,\n    mem_attention_grouping=(4, 2048),\n)\n```\n\n\n### Drop-in use with LLaMA code\n LongLLaMA checkpoints can also be used as a drop-in replacement for LLaMA checkpoints in [Hugging Face implementation of LLaMA](https://huggingface.co/docs/transformers/main/model_doc/llama), but in this case, they will be limited to the original context length of 2048.\n\n```python\nfrom transformers import LlamaTokenizer, LlamaForCausalLM\nimport torch\n\ntokenizer = LlamaTokenizer.from_pretrained(\"syzymon/long_llama_3b\")\nmodel = LlamaForCausalLM.from_pretrained(\"syzymon/long_llama_3b\", torch_dtype=torch.float32)\n```\n\n\n### How LongLLaMA handles long inputs\nInputs over 2048 tokens are automatically split into windows w_1, \\ldots, w_m. The first m-2 windows contain 2048 tokens each, w_{m-1} has no more than 2048 tokens, and w_m contains the number of tokens specified by `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.\n\nThe memory cache stores (key, value) pairs for each head of the specified memory layers `mem_layers`. In addition to this, it stores attention masks. \n\nIf `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.\n\nFor simplicity, context extension is realized with a memory cache and full attention in this repo. Replacing this simple mechanism with a KNN search over an external database is possible with systems like [Faiss](https://github.com/facebookresearch/faiss). This potentially would enable further context length scaling. We leave this as a future work.\n\n\n## LongLLaMA performance\nWe present some illustrative examples of LongLLaMA results and refer to our paper [Focused Transformer: Contrastive Training for Context Scaling](https://arxiv.org/abs/2307.03170) for more details.\n\nWe manage to achieve good performance on the passkey retrieval task from [Landmark Attention: Random-Access Infinite Context Length for Transformers](https://arxiv.org/abs/2305.16300). The code for generating the prompt and running the model is located in `examples/passkey.py`. \n\n<p align=\"center\" width=\"100%\">\n<img src=\"https://raw.githubusercontent.com/CStanKonrad/long_llama/main/assets/plot_passkey.png\" alt=\"LongLLaMA\" style=\"width: 70%; min-width: 300px; display: block; margin: auto;\">\n</p>\n\nOur LongLLaMA 3B model also shows improvements when using long context on two downstream tasks, TREC question classification and WebQS question answering. \n<center>\n\n\n| Context/Dataset | TREC  | WebQS |\n| --- | --- | --- |\n| 2K | 67.0 |  21.2 |\n| 4K | 71.6 | 21.4 |\n| 6K | 72.9 | 22.2 |\n| 8K | **73.3** | **22.4** |\n\n</center>\n\nLongLLama retains performance on tasks that do not require long context. We provide a comparison with OpenLLaMA\non [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) in a zero-shot setting. \n<center>\n\n| Task/Metric | OpenLLaMA-3B | LongLLaMA-3B |\n|----------------|----------|-----------|\n| anli_r1/acc | 0.33 | 0.32 |\n| anli_r2/acc | 0.32 | 0.33 |\n| anli_r3/acc | 0.35 | 0.35 |\n| arc_challenge/acc | 0.34 | 0.34 |\n| arc_challenge/acc_norm | 0.37 | 0.37 |\n| arc_easy/acc | 0.69 | 0.68 |\n| arc_easy/acc_norm | 0.65 | 0.63 |\n| boolq/acc | 0.68 | 0.68 |\n| hellaswag/acc | 0.49 | 0.48 |\n| hellaswag/acc_norm | 0.67 | 0.65 |\n| openbookqa/acc | 0.27 | 0.28 |\n| openbookqa/acc_norm | 0.40 | 0.38 |\n| piqa/acc | 0.75 | 0.73 |\n| piqa/acc_norm | 0.76 | 0.75 |\n| record/em | 0.88 | 0.87 |\n| record/f1 | 0.89 | 0.87 |\n| rte/acc | 0.58 | 0.60 |\n| truthfulqa_mc/mc1 | 0.22 | 0.24 |\n| truthfulqa_mc/mc2 | 0.35 | 0.38 |\n| wic/acc | 0.48 | 0.50 |\n| winogrande/acc | 0.62 | 0.60 |\n| Avg score | 0.53 | 0.53 |\n\n</center>\n\n## Authors\n- [Szymon Tworkowski](https://scholar.google.com/citations?user=1V8AeXYAAAAJ&hl=en)\n- [Konrad Staniszewski](https://scholar.google.com/citations?user=CM6PCBYAAAAJ)\n- [Mikołaj Pacek](https://scholar.google.com/citations?user=eh6iEbQAAAAJ&hl=en&oi=ao)\n- [Henryk Michalewski](https://scholar.google.com/citations?user=YdHW1ycAAAAJ&hl=en)\n- [Yuhuai Wu](https://scholar.google.com/citations?user=bOQGfFIAAAAJ&hl=en)\n- [Piotr Miłoś](https://scholar.google.pl/citations?user=Se68XecAAAAJ&hl=pl&oi=ao)\n\n\n## Citation\nTo cite this work please use\n```bibtex\n@misc{tworkowski2023focused,\n      title={Focused Transformer: Contrastive Training for Context Scaling}, \n      author={Szymon Tworkowski and Konrad Staniszewski and Mikołaj Pacek and Yuhuai Wu and Henryk Michalewski and Piotr Miłoś},\n      year={2023},\n      eprint={2307.03170},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\n\n## License\nThe code and checkpoints are licensed under [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).\nSome of the examples use external code (see headers of files for copyright notices and licenses).\n\n## Acknowledgments\nWe gratefully acknowledge the TPU Research Cloud program, which was instrumental to our research by providing significant computational resources. We are also grateful to Xinyang Geng and Hao Liu for releasing [OpenLLaMA](https://github.com/openlm-research/open_llama) checkpoints and the [EasyLM](https://github.com/young-geng/EasyLM) library.\n\n\n",
    "related_quantizations": []
  },
  "tags": [
    "gguf",
    "arxiv:2307.03170",
    "arxiv:2305.16300",
    "endpoints_compatible",
    "region:us"
  ],
  "likes": 0,
  "downloads": 165,
  "gated": false,
  "private": false,
  "last_modified": "2024-08-26T12:19:27.000Z",
  "created_at": "2024-08-26T11:15:21.000Z",
  "pipeline_tag": "",
  "library_name": ""
}
Source payload excerpt (from Hugging Face API)
{
  "_id": "66cc63c9db3bf7b2257fa69a",
  "id": "RichardErkhov/syzymon_-_long_llama_3b-gguf",
  "modelId": "RichardErkhov/syzymon_-_long_llama_3b-gguf",
  "sha": "a575058857d76c09a1e43eb95123c937d79f3716",
  "createdAt": "2024-08-26T11:15:21.000Z",
  "lastModified": "2024-08-26T12:19:27.000Z",
  "author": "RichardErkhov",
  "downloads": 165,
  "likes": 0,
  "gated": false,
  "private": false,
  "pipeline_tag": "",
  "library_name": "",
  "siblings_count": 24
}