llamafile
jartine commited on
Commit
8f0f80d
·
verified ·
1 Parent(s): 228b027

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +186 -0
README.md ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - llamafile
4
+ license: bigcode-openrail-m
5
+ quantized_by: jartine
6
+ ---
7
+
8
+ # LLaMA 3.2 1B Instruct - llamafile
9
+
10
+ - Model creator: [bigcode](https://huggingface.co/bigcode)
11
+ - Original model:
12
+ - [bigcode/starcoder2-15b](https://huggingface.co/bigcode/starcoder2-15b)
13
+ - [bigcode/starcoder2-7b](https://huggingface.co/bigcode/starcoder2-7b)
14
+ - [bigcode/starcoder2-3b](https://huggingface.co/bigcode/starcoder2-3b)
15
+
16
+ Mozilla packaged starcoder2 into executable weights that we call
17
+ [llamafiles](https://github.com/Mozilla-Ocho/llamafile). This gives you
18
+ the easiest fastest way to use the model on Linux, MacOS, Windows,
19
+ FreeBSD, OpenBSD and NetBSD systems you control on both AMD64 and ARM64.
20
+
21
+ *Software Last Updated: 2024-11-23*
22
+
23
+ ## Quickstart
24
+
25
+ To get started, run:
26
+
27
+ ```
28
+ wget https://huggingface.co/Mozilla/starcoder2-llamafile/resolve/main/starcoder2-7b.Q6_K.gguf
29
+ chmod +x starcoder2-7b.Q6_K.gguf
30
+ ./starcoder2-7b.Q6_K.gguf
31
+ ```
32
+
33
+ This is a base model, so it'll behave as a text completion interface
34
+ rather than a chatbot. In the CLI chatbot, you should type in your
35
+ prefix text and press enter. If you click the URL to use the web GUI
36
+ then you should press the "completion" radio button at the top of the
37
+ page, to put the web UI in completion (rather than chatbot) mode.
38
+
39
+ ---
40
+
41
+ # StarCoder2
42
+
43
+ <center>
44
+ <img src="https://huggingface.co/datasets/bigcode/admin_private/resolve/main/starcoder2_banner.png" alt="SC2" width="900" height="600">
45
+ </center>
46
+
47
+ ## Table of Contents
48
+
49
+ 1. [Model Summary](#model-summary)
50
+ 2. [Use](#use)
51
+ 3. [Limitations](#limitations)
52
+ 4. [Training](#training)
53
+ 5. [License](#license)
54
+ 6. [Citation](#citation)
55
+
56
+ ## Model Summary
57
+
58
+ StarCoder2-15B model is a 15B parameter model trained on 600+ programming languages from [The Stack v2](https://huggingface.co/datasets/bigcode/the-stack-v2-train), with opt-out requests excluded. The model uses [Grouped Query Attention](https://arxiv.org/abs/2305.13245), [a context window of 16,384 tokens](https://arxiv.org/abs/2205.14135) with [a sliding window attention of 4,096 tokens](https://arxiv.org/abs/2004.05150v2), and was trained using the [Fill-in-the-Middle objective](https://arxiv.org/abs/2207.14255) on 4+ trillion tokens.
59
+ The model was trained with [NVIDIA NeMo™ Framework](https://www.nvidia.com/en-us/ai-data-science/generative-ai/nemo-framework/) using the [NVIDIA Eos Supercomputer](https://blogs.nvidia.com/blog/eos/) built with [NVIDIA DGX H100](https://www.nvidia.com/en-us/data-center/dgx-h100/) systems.
60
+
61
+ - **Project Website:** [bigcode-project.org](https://www.bigcode-project.org)
62
+ - **Paper:** [Link](https://huggingface.co/papers/2402.19173)
63
+ - **Point of Contact:** [[email protected]](mailto:[email protected])
64
+ - **Languages:** 600+ Programming languages
65
+
66
+ ## Use
67
+
68
+ ### Intended use
69
+
70
+ The model was trained on GitHub code as well as additional selected data sources such as Arxiv and Wikipedia. As such it is _not_ an instruction model and commands like "Write a function that computes the square root." do not work well.
71
+
72
+ ### Generation
73
+ Here are some examples to get started with the model. You can find a script for fine-tuning in StarCoder2's [GitHub repository](https://github.com/bigcode-project/starcoder2).
74
+
75
+ First, make sure to install `transformers` from source:
76
+ ```bash
77
+ pip install git+https://github.com/huggingface/transformers.git
78
+ ```
79
+
80
+ #### Running the model on CPU/GPU/multi GPU
81
+ * _Using full precision_
82
+ ```python
83
+ # pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
84
+ from transformers import AutoModelForCausalLM, AutoTokenizer
85
+
86
+ checkpoint = "bigcode/starcoder2-15b"
87
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
88
+
89
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
90
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
91
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
92
+
93
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
94
+ outputs = model.generate(inputs)
95
+ print(tokenizer.decode(outputs[0]))
96
+ ```
97
+
98
+ * _Using `torch.bfloat16`_
99
+ ```python
100
+ # pip install accelerate
101
+ import torch
102
+ from transformers import AutoTokenizer, AutoModelForCausalLM
103
+
104
+ checkpoint = "bigcode/starcoder2-15b"
105
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
106
+
107
+ # for fp16 use `torch_dtype=torch.float16` instead
108
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
109
+
110
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
111
+ outputs = model.generate(inputs)
112
+ print(tokenizer.decode(outputs[0]))
113
+ ```
114
+ ```bash
115
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
116
+ Memory footprint: 32251.33 MB
117
+ ```
118
+
119
+ #### Quantized Versions through `bitsandbytes`
120
+ * _Using 8-bit precision (int8)_
121
+
122
+ ```python
123
+ # pip install bitsandbytes accelerate
124
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
125
+
126
+ # to use 4bit use `load_in_4bit=True` instead
127
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
128
+
129
+ checkpoint = "bigcode/starcoder2-15b"
130
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
131
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
132
+
133
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
134
+ outputs = model.generate(inputs)
135
+ print(tokenizer.decode(outputs[0]))
136
+ ```
137
+ ```bash
138
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
139
+ # load_in_8bit
140
+ Memory footprint: 16900.18 MB
141
+ # load_in_4bit
142
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
143
+ Memory footprint: 9224.60 MB
144
+ ```
145
+ ### Attribution & Other Requirements
146
+
147
+ The pretraining dataset of the model was filtered for permissive licenses and code with no license only. Nevertheless, the model can generate source code verbatim from the dataset. The code's license might require attribution and/or other specific requirements that must be respected. We provide a [search index](https://huggingface.co/spaces/bigcode/search-v2) that let's you search through the pretraining data to identify where generated code came from and apply the proper attribution to your code.
148
+
149
+ # Limitations
150
+
151
+ The model has been trained on source code from 600+ programming languages. The predominant language in source is English although other languages are also present. As such the model is capable to generate code snippets provided some context but the generated code is not guaranteed to work as intended. It can be inefficient, contain bugs or exploits. See [the paper](https://huggingface.co/papers/2402.19173) for an in-depth discussion of the model limitations.
152
+
153
+ # Training
154
+
155
+ ## Model
156
+
157
+ - **Architecture:** Transformer decoder with grouped-query and sliding window attention and Fill-in-the-Middle objective
158
+ - **Pretraining steps:** 1 million
159
+ - **Pretraining tokens:** 4+ trillion
160
+ - **Precision:** bfloat16
161
+
162
+ ## Hardware
163
+
164
+ - **GPUs:** 1024 x H100
165
+
166
+ ## Software
167
+
168
+ - **Framework:** [NeMo Framework](https://www.nvidia.com/en-us/ai-data-science/generative-ai/nemo-framework/)
169
+ - **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)
170
+
171
+ # License
172
+
173
+ The model is licensed under the BigCode OpenRAIL-M v1 license agreement. You can find the full agreement [here](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement).
174
+
175
+ # Citation
176
+
177
+ ```bash
178
+ @misc{lozhkov2024starcoder,
179
+ title={StarCoder 2 and The Stack v2: The Next Generation},
180
+ author={Anton Lozhkov and Raymond Li and Loubna Ben Allal and Federico Cassano and Joel Lamy-Poirier and Nouamane Tazi and Ao Tang and Dmytro Pykhtar and Jiawei Liu and Yuxiang Wei and Tianyang Liu and Max Tian and Denis Kocetkov and Arthur Zucker and Younes Belkada and Zijian Wang and Qian Liu and Dmitry Abulkhanov and Indraneil Paul and Zhuang Li and Wen-Ding Li and Megan Risdal and Jia Li and Jian Zhu and Terry Yue Zhuo and Evgenii Zheltonozhskii and Nii Osae Osae Dade and Wenhao Yu and Lucas Krauß and Naman Jain and Yixuan Su and Xuanli He and Manan Dey and Edoardo Abati and Yekun Chai and Niklas Muennighoff and Xiangru Tang and Muhtasham Oblokulov and Christopher Akiki and Marc Marone and Chenghao Mou and Mayank Mishra and Alex Gu and Binyuan Hui and Tri Dao and Armel Zebaze and Olivier Dehaene and Nicolas Patry and Canwen Xu and Julian McAuley and Han Hu and Torsten Scholak and Sebastien Paquet and Jennifer Robinson and Carolyn Jane Anderson and Nicolas Chapados and Mostofa Patwary and Nima Tajbakhsh and Yacine Jernite and Carlos Muñoz Ferrandis and Lingming Zhang and Sean Hughes and Thomas Wolf and Arjun Guha and Leandro von Werra and Harm de Vries},
181
+ year={2024},
182
+ eprint={2402.19173},
183
+ archivePrefix={arXiv},
184
+ primaryClass={cs.SE}
185
+ }
186
+ ```