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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
---
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
license: other
|
7 |
+
library_name: transformers
|
8 |
+
tags:
|
9 |
+
- mergekit
|
10 |
+
- merge
|
11 |
+
- GGUF
|
12 |
+
base_model:
|
13 |
+
- meta-llama/Meta-Llama-3-8B-Instruct
|
14 |
+
quantized_by: andrijdavid
|
15 |
+
---
|
16 |
+
# Meta-Llama-3-13B-Instruct-GGUF
|
17 |
+
- Original model: [Meta-Llama-3-13B-Instruct](https://huggingface.co/andrijdavid/Meta-Llama-3-13B-Instruct)
|
18 |
+
|
19 |
+
<!-- description start -->
|
20 |
+
## Description
|
21 |
+
|
22 |
+
This repo contains GGUF format model files for [Meta-Llama-3-13B-Instruct](https://huggingface.co/andrijdavid/Meta-Llama-3-13B-Instruct).
|
23 |
+
|
24 |
+
<!-- description end -->
|
25 |
+
<!-- README_GGUF.md-about-gguf start -->
|
26 |
+
### About GGUF
|
27 |
+
GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp.
|
28 |
+
Here is an incomplete list of clients and libraries that are known to support GGUF:
|
29 |
+
* [llama.cpp](https://github.com/ggerganov/llama.cpp). This is the source project for GGUF, providing both a Command Line Interface (CLI) and a server option.
|
30 |
+
* [text-generation-webui](https://github.com/oobabooga/text-generation-webui), Known as the most widely used web UI, this project boasts numerous features and powerful extensions, and supports GPU acceleration.
|
31 |
+
* [Ollama](https://github.com/jmorganca/ollama) Ollama is a lightweight and extensible framework designed for building and running language models locally. It features a simple API for creating, managing, and executing models, along with a library of pre-built models for use in various applications
|
32 |
+
* [KoboldCpp](https://github.com/LostRuins/koboldcpp), A comprehensive web UI offering GPU acceleration across all platforms and architectures, particularly renowned for storytelling.
|
33 |
+
* [GPT4All](https://gpt4all.io), This is a free and open source GUI that runs locally, supporting Windows, Linux, and macOS with full GPU acceleration.
|
34 |
+
* [LM Studio](https://lmstudio.ai/) An intuitive and powerful local GUI for Windows and macOS (Silicon), featuring GPU acceleration.
|
35 |
+
* [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui). A notable web UI with a variety of unique features, including a comprehensive model library for easy model selection.
|
36 |
+
* [Faraday.dev](https://faraday.dev/), An attractive, user-friendly character-based chat GUI for Windows and macOS (both Silicon and Intel), also offering GPU acceleration.
|
37 |
+
* [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), A Python library equipped with GPU acceleration, LangChain support, and an OpenAI-compatible API server.
|
38 |
+
* [candle](https://github.com/huggingface/candle), A Rust-based ML framework focusing on performance, including GPU support, and designed for ease of use.
|
39 |
+
* [ctransformers](https://github.com/marella/ctransformers), A Python library featuring GPU acceleration, LangChain support, and an OpenAI-compatible AI server.
|
40 |
+
* [localGPT](https://github.com/PromtEngineer/localGPT) An open-source initiative enabling private conversations with documents.
|
41 |
+
<!-- README_GGUF.md-about-gguf end -->
|
42 |
+
|
43 |
+
<!-- compatibility_gguf start -->
|
44 |
+
## Explanation of quantisation methods
|
45 |
+
<details>
|
46 |
+
<summary>Click to see details</summary>
|
47 |
+
The new methods available are:
|
48 |
+
|
49 |
+
* GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
|
50 |
+
* GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
|
51 |
+
* GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
|
52 |
+
* GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
|
53 |
+
* GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw.
|
54 |
+
</details>
|
55 |
+
<!-- compatibility_gguf end -->
|
56 |
+
|
57 |
+
<!-- README_GGUF.md-how-to-download start -->
|
58 |
+
## How to download GGUF files
|
59 |
+
|
60 |
+
**Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single folder.
|
61 |
+
|
62 |
+
The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
|
63 |
+
|
64 |
+
* LM Studio
|
65 |
+
* LoLLMS Web UI
|
66 |
+
* Faraday.dev
|
67 |
+
|
68 |
+
### In `text-generation-webui`
|
69 |
+
|
70 |
+
Under Download Model, you can enter the model repo: LiteLLMs/Meta-Llama-3-13B-Instruct-GGUF and below it, a specific filename to download, such as: Q4_0/Q4_0-00001-of-00009.gguf.
|
71 |
+
|
72 |
+
Then click Download.
|
73 |
+
|
74 |
+
### On the command line, including multiple files at once
|
75 |
+
|
76 |
+
I recommend using the `huggingface-hub` Python library:
|
77 |
+
|
78 |
+
```shell
|
79 |
+
pip3 install huggingface-hub
|
80 |
+
```
|
81 |
+
|
82 |
+
Then you can download any individual model file to the current directory, at high speed, with a command like this:
|
83 |
+
|
84 |
+
```shell
|
85 |
+
huggingface-cli download LiteLLMs/Meta-Llama-3-13B-Instruct-GGUF Q4_0/Q4_0-00001-of-00009.gguf --local-dir . --local-dir-use-symlinks False
|
86 |
+
```
|
87 |
+
|
88 |
+
<details>
|
89 |
+
<summary>More advanced huggingface-cli download usage (click to read)</summary>
|
90 |
+
|
91 |
+
You can also download multiple files at once with a pattern:
|
92 |
+
|
93 |
+
```shell
|
94 |
+
huggingface-cli download LiteLLMs/Meta-Llama-3-13B-Instruct-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
|
95 |
+
```
|
96 |
+
|
97 |
+
For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
|
98 |
+
|
99 |
+
To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
|
100 |
+
|
101 |
+
```shell
|
102 |
+
pip3 install huggingface_hub[hf_transfer]
|
103 |
+
```
|
104 |
+
|
105 |
+
And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
|
106 |
+
|
107 |
+
```shell
|
108 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download LiteLLMs/Meta-Llama-3-13B-Instruct-GGUF Q4_0/Q4_0-00001-of-00009.gguf --local-dir . --local-dir-use-symlinks False
|
109 |
+
```
|
110 |
+
|
111 |
+
Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
|
112 |
+
</details>
|
113 |
+
<!-- README_GGUF.md-how-to-download end -->
|
114 |
+
<!-- README_GGUF.md-how-to-run start -->
|
115 |
+
## Example `llama.cpp` command
|
116 |
+
|
117 |
+
Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
|
118 |
+
|
119 |
+
```shell
|
120 |
+
./main -ngl 35 -m Q4_0/Q4_0-00001-of-00009.gguf --color -c 8192 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<PROMPT>"
|
121 |
+
```
|
122 |
+
|
123 |
+
Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
|
124 |
+
|
125 |
+
Change `-c 8192` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
|
126 |
+
|
127 |
+
If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
|
128 |
+
|
129 |
+
For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
|
130 |
+
|
131 |
+
## How to run in `text-generation-webui`
|
132 |
+
|
133 |
+
Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
|
134 |
+
|
135 |
+
## How to run from Python code
|
136 |
+
|
137 |
+
You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
|
138 |
+
|
139 |
+
### How to load this model in Python code, using llama-cpp-python
|
140 |
+
|
141 |
+
For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
|
142 |
+
|
143 |
+
#### First install the package
|
144 |
+
|
145 |
+
Run one of the following commands, according to your system:
|
146 |
+
|
147 |
+
```shell
|
148 |
+
# Base ctransformers with no GPU acceleration
|
149 |
+
pip install llama-cpp-python
|
150 |
+
# With NVidia CUDA acceleration
|
151 |
+
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
|
152 |
+
# Or with OpenBLAS acceleration
|
153 |
+
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
|
154 |
+
# Or with CLBLast acceleration
|
155 |
+
CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
|
156 |
+
# Or with AMD ROCm GPU acceleration (Linux only)
|
157 |
+
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
|
158 |
+
# Or with Metal GPU acceleration for macOS systems only
|
159 |
+
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
|
160 |
+
# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
|
161 |
+
$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
|
162 |
+
pip install llama-cpp-python
|
163 |
+
```
|
164 |
+
|
165 |
+
#### Simple llama-cpp-python example code
|
166 |
+
|
167 |
+
```python
|
168 |
+
from llama_cpp import Llama
|
169 |
+
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
170 |
+
llm = Llama(
|
171 |
+
model_path="./Q4_0/Q4_0-00001-of-00009.gguf", # Download the model file first
|
172 |
+
n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
|
173 |
+
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
|
174 |
+
n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
|
175 |
+
)
|
176 |
+
# Simple inference example
|
177 |
+
output = llm(
|
178 |
+
"<PROMPT>", # Prompt
|
179 |
+
max_tokens=512, # Generate up to 512 tokens
|
180 |
+
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
|
181 |
+
echo=True # Whether to echo the prompt
|
182 |
+
)
|
183 |
+
# Chat Completion API
|
184 |
+
llm = Llama(model_path="./Q4_0/Q4_0-00001-of-00009.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
|
185 |
+
llm.create_chat_completion(
|
186 |
+
messages = [
|
187 |
+
{"role": "system", "content": "You are a story writing assistant."},
|
188 |
+
{
|
189 |
+
"role": "user",
|
190 |
+
"content": "Write a story about llamas."
|
191 |
+
}
|
192 |
+
]
|
193 |
+
)
|
194 |
+
```
|
195 |
+
|
196 |
+
## How to use with LangChain
|
197 |
+
|
198 |
+
Here are guides on using llama-cpp-python and ctransformers with LangChain:
|
199 |
+
|
200 |
+
* [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
|
201 |
+
* [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
|
202 |
+
|
203 |
+
<!-- README_GGUF.md-how-to-run end -->
|
204 |
+
|
205 |
+
<!-- footer end -->
|
206 |
+
|
207 |
+
<!-- original-model-card start -->
|
208 |
+
# Original model card: Meta-Llama-3-13B-Instruct
|
209 |
+
|
210 |
+
# Meta-Llama-3-13B-Instruct
|
211 |
+
|
212 |
+
Meta-Llama-3-13B-Instruct is a [meta-llama/Meta-Llama-3-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3-8B-Instruct) self-merge made with [MergeKit](https://github.com/arcee-ai/mergekit/tree/main).
|
213 |
+
|
214 |
+
## Configuration
|
215 |
+
|
216 |
+
The following YAML configuration was used to produce this model:
|
217 |
+
|
218 |
+
```yaml
|
219 |
+
slices:
|
220 |
+
- sources:
|
221 |
+
- layer_range: [0, 16]
|
222 |
+
model: meta-llama/Meta-Llama-3-8B-Instruct
|
223 |
+
- sources:
|
224 |
+
- layer_range: [4, 24]
|
225 |
+
model: meta-llama/Meta-Llama-3-8B-Instruct
|
226 |
+
- sources:
|
227 |
+
- layer_range: [8, 31]
|
228 |
+
model: meta-llama/Meta-Llama-3-8B-Instruct
|
229 |
+
merge_method: passthrough
|
230 |
+
dtype: float16
|
231 |
+
|
232 |
+
```
|
233 |
+
|
234 |
+
## Usage
|
235 |
+
|
236 |
+
```python
|
237 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
238 |
+
import torch
|
239 |
+
|
240 |
+
model_id = "andrijdavid/Meta-Llama-3-13B-Instruct"
|
241 |
+
|
242 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
243 |
+
model = AutoModelForCausalLM.from_pretrained(
|
244 |
+
model_id,
|
245 |
+
torch_dtype=torch.bfloat16,
|
246 |
+
device_map="auto",
|
247 |
+
)
|
248 |
+
|
249 |
+
messages = [
|
250 |
+
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
|
251 |
+
{"role": "user", "content": "Who are you?"},
|
252 |
+
]
|
253 |
+
|
254 |
+
input_ids = tokenizer.apply_chat_template(
|
255 |
+
messages,
|
256 |
+
add_generation_prompt=True,
|
257 |
+
return_tensors="pt"
|
258 |
+
).to(model.device)
|
259 |
+
|
260 |
+
terminators = [
|
261 |
+
tokenizer.eos_token_id,
|
262 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
263 |
+
]
|
264 |
+
|
265 |
+
outputs = model.generate(
|
266 |
+
input_ids,
|
267 |
+
max_new_tokens=256,
|
268 |
+
eos_token_id=terminators,
|
269 |
+
do_sample=True,
|
270 |
+
temperature=0.6,
|
271 |
+
top_p=0.9,
|
272 |
+
)
|
273 |
+
response = outputs[0][input_ids.shape[-1]:]
|
274 |
+
print(tokenizer.decode(response, skip_special_tokens=True))
|
275 |
+
|
276 |
+
```
|
277 |
+
|
278 |
+
<!-- original-model-card end -->
|