aashish1904 commited on
Commit
78d7e62
1 Parent(s): 2511b64

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +121 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ license: llama2
5
+ datasets:
6
+ - togethercomputer/RedPajama-Data-1T
7
+ - togethercomputer/RedPajama-Data-Instruct
8
+ - EleutherAI/pile
9
+ - togethercomputer/Long-Data-Collections
10
+ language:
11
+ - en
12
+ library_name: transformers
13
+
14
+ ---
15
+
16
+ [![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
17
+
18
+
19
+ # QuantFactory/LLaMA-2-7B-32K-GGUF
20
+ This is quantized version of [togethercomputer/LLaMA-2-7B-32K](https://huggingface.co/togethercomputer/LLaMA-2-7B-32K) created using llama.cpp
21
+
22
+ # Original Model Card
23
+
24
+
25
+ # LLaMA-2-7B-32K
26
+
27
+ ## Model Description
28
+
29
+ LLaMA-2-7B-32K is an open-source, long context language model developed by Together, fine-tuned from Meta's original Llama-2 7B model.
30
+ This model represents our efforts to contribute to the rapid progress of the open-source ecosystem for large language models.
31
+ The model has been extended to a context length of 32K with position interpolation,
32
+ allowing applications on multi-document QA, long text summarization, etc.
33
+
34
+ ## What's new?
35
+
36
+ This model introduces several improvements and new features:
37
+
38
+ 1. **Extended Context:** The model has been trained to handle context lengths up to 32K, which is a significant improvement over the previous versions.
39
+
40
+ 2. **Pre-training and Instruction Tuning:** We have shared our data recipe, which consists of a mixture of pre-training and instruction tuning data.
41
+
42
+ 3. **Fine-tuning Examples:** We provide examples of how to fine-tune the model for specific applications, including book summarization and long context question and answering.
43
+
44
+ 4. **Software Support:** We have updated both the inference and training stack to allow efficient inference and fine-tuning for 32K context.
45
+
46
+ ## Model Architecture
47
+
48
+ The model follows the architecture of Llama-2-7B and extends it to handle a longer context. It leverages the recently released FlashAttention-2 and a range of other optimizations to improve the speed and efficiency of inference and training.
49
+
50
+ ## Training and Fine-tuning
51
+
52
+ The model has been trained using a mixture of pre-training and instruction tuning data.
53
+ - In the first training phase of continued pre-training, our data mixture contains 25% RedPajama Book, 25% RedPajama ArXiv (including abstracts), 25% other data from RedPajama, and 25% from the UL2 Oscar Data, which is a part of OIG (Open-Instruction-Generalist), asking the model to fill in missing chunks, or complete the text.
54
+ To enhance the long-context ability, we exclude data shorter than 2K word. The inclusion of UL2 Oscar Data is effective in compelling the model to read and utilize long-range context.
55
+ - We then fine-tune the model to focus on its few shot capacity under long context, including 20% Natural Instructions (NI), 20% Public Pool of Prompts (P3), 20% the Pile. We decontaminated all data against HELM core scenarios . We teach the model to leverage the in-context examples by packing examples into one 32K-token sequence. To maintain the knowledge learned from the first piece of data, we incorporate 20% RedPajama-Data Book and 20% RedPajama-Data ArXiv.
56
+
57
+ Next, we provide examples of how to fine-tune the model for specific applications.
58
+ The example datasets are placed in [togethercomputer/Long-Data-Collections](https://huggingface.co/datasets/togethercomputer/Long-Data-Collections)
59
+ You can use the [OpenChatKit](https://github.com/togethercomputer/OpenChatKit) to fine-tune your own 32K model over LLaMA-2-7B-32K.
60
+ Please refer to [OpenChatKit](https://github.com/togethercomputer/OpenChatKit) for step-by-step illustrations.
61
+
62
+ 1. Long Context QA.
63
+
64
+ We take as an example the multi-document question answering task from the paper “Lost in the Middle: How Language Models Use Long Contexts”. The input for the model consists of (i) a question that requires an answer and (ii) k documents, which are passages extracted from Wikipedia. Notably, only one of these documents contains the answer to the question, while the remaining k − 1 documents, termed as "distractor" documents, do not. To successfully perform this task, the model must identify and utilize the document containing the answer from its input context.
65
+
66
+ With OCK, simply run the following command to fine-tune:
67
+ ```
68
+ bash training/finetune_llama-2-7b-32k-mqa.sh
69
+ ```
70
+
71
+ 2. Summarization.
72
+
73
+ Another example is BookSum, a unique dataset designed to address the challenges of long-form narrative summarization. This dataset features source documents from the literature domain, including novels, plays, and stories, and offers human-written, highly abstractive summaries. We here focus on chapter-level data. BookSum poses a unique set of challenges, necessitating that the model comprehensively read through each chapter.
74
+
75
+ With OCK, simply run the following command to fine-tune:
76
+ ```
77
+ bash training/finetune_llama-2-7b-32k-booksum.sh
78
+ ```
79
+
80
+
81
+ ## Inference
82
+
83
+ You can use the [Together API](https://together.ai/blog/api-announcement) to try out LLaMA-2-7B-32K for inference.
84
+ The updated inference stack allows for efficient inference.
85
+
86
+ To run the model locally, we strongly recommend to install Flash Attention V2, which is necessary to obtain the best performance:
87
+ ```
88
+ # Please update the path of `CUDA_HOME`
89
+ export CUDA_HOME=/usr/local/cuda-11.8
90
+ pip install transformers==4.31.0
91
+ pip install sentencepiece
92
+ pip install ninja
93
+ pip install flash-attn --no-build-isolation
94
+ pip install git+https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/rotary
95
+ ```
96
+
97
+ You can use this model directly from the Hugging Face Model Hub or fine-tune it on your own data using the OpenChatKit.
98
+
99
+ ```python
100
+ from transformers import AutoTokenizer, AutoModelForCausalLM
101
+
102
+ tokenizer = AutoTokenizer.from_pretrained("togethercomputer/LLaMA-2-7B-32K")
103
+ model = AutoModelForCausalLM.from_pretrained("togethercomputer/LLaMA-2-7B-32K", trust_remote_code=True, torch_dtype=torch.float16)
104
+
105
+ input_context = "Your text here"
106
+ input_ids = tokenizer.encode(input_context, return_tensors="pt")
107
+ output = model.generate(input_ids, max_length=128, temperature=0.7)
108
+ output_text = tokenizer.decode(output[0], skip_special_tokens=True)
109
+ print(output_text)
110
+ ```
111
+
112
+ Alternatively, you can set `trust_remote_code=False` if you prefer not to use flash attention.
113
+
114
+
115
+ ## Limitations and Bias
116
+
117
+ As with all language models, LLaMA-2-7B-32K may generate incorrect or biased content. It's important to keep this in mind when using the model.
118
+
119
+ ## Community
120
+
121
+ Join us on [Together Discord](https://discord.gg/6ZVDU8tTD4)