File size: 23,543 Bytes
0e2ff61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a67e50a
 
0e2ff61
 
 
 
 
 
 
a67e50a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e2ff61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
---
tags:
- quantized
- 2-bit
- 3-bit
- 4-bit
- 5-bit
- 6-bit
- 8-bit
- GGUF
- transformers
- pytorch
- mixtral
- text-generation
- axolotl
- generated_from_trainer
- moe
- qwen
- text-generation-inference
- conversational
- dataset:Crystalcareai/MoD-150k
- base_model:MaziyarPanahi/Qwen1.5-8x7b
- license:other
- autotrain_compatible
- endpoints_compatible
- region:us
- text-generation
model_name: Qwen1.5-8x7b-v0.1-GGUF
base_model: MaziyarPanahi/Qwen1.5-8x7b-v0.1
inference: false
model_creator: MaziyarPanahi
pipeline_tag: text-generation
quantized_by: MaziyarPanahi
---
<img src="https://cdn-uploads.huggingface.co/production/uploads/5fd5e18a90b6dc4633f6d292/3uKjrdYScOmoRkCbXqqNy.webp" width="550" />

# [MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF](https://huggingface.co/MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF)
- Model creator: [MaziyarPanahi](https://huggingface.co/MaziyarPanahi)
- Original model: [MaziyarPanahi/Qwen1.5-8x7b-v0.1](https://huggingface.co/MaziyarPanahi/Qwen1.5-8x7b-v0.1)

## Description
[MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF](https://huggingface.co/MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF) contains GGUF format model files for [MaziyarPanahi/Qwen1.5-8x7b-v0.1](https://huggingface.co/MaziyarPanahi/Qwen1.5-8x7b-v0.1).

Total number of parameters: 38021632000 (38.021632)

## Examples

```
<|im_start|>system
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me. Think step by step and answer quickly.<|im_end|>
<|im_start|>user
explain step by step 25-4*2+3=?<|im_end|>
<|im_start|>assistant>

Here is the:

1. The expression reads: 25 minus 4 times 2 plus 3.
2. First, perform the multiplication: 4 * 2 = 8.
3. Then subtract: 25 - 8 = 17.
4. Finally, add the last number: 17 + 3 = 20.

So, in total, 25-4*2+3 equals 20.</s><|endoftext|>
```
---

```
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.
### Instruction:

Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.

### Response: Once upon a time in a far-off galaxy, there lived an extraordinary being named Goku. He was known for his incredible strength and unyielding spirit, having faced countless enemies and emerged victorious.

One fateful day, while exploring the universe on his legendary journey, Goku stumbled upon a strange new planet. As he landed on its surface, he sensed a powerful energy emanating from within. Intrigued, he ventured forth into the, only to find himself face-to-face with a fearsome opponent - Kirby!

Kirby, a formidable warrior in his own right, had formed an alliance with another malevolent force - none other than the infamous Majin Buu! The duo had joined forces to wreak havoc across the and bring destruction upon the galaxy.

Goku, a hero at heart, could not stand idly by as these two wicked beings threatened the very existence of life itself. He knew it would be no easy task, but he was determined to confront them head-on and protect the innocent beings he had come to cherish throughout his travels.

With newfound resolve, Goku prepared for battle against this unparalleled evil. Drawing upon all his strength and cunning, he devised a plan to outsmart Kirby and Majin Buu. Utilizing his unparalleled speed and agility, Goku managed to evade their attacks and strike back with devastating blows.

As the battle raged on, the fate of the galaxy hung in the balance. With each passing moment, more and more lives were lost to the relentless onslaught of these malevolent foes. But Goku refused to give up, knowing that the future of the universe rested in his hands.

Finally, after what felt like an eternity, Goku's tireless efforts paid off. His strategic prowess and unmatched determination proved too much for Kirby and Majin Buu to handle. Overwhelmed by the sheer power of Goku's onslaught, they were forced to retreat, leaving behind a trail of destruction in their wake.

The galaxy breathed a collective sigh of relief as peace was restored. In the. Goku's name was forever etched into the annals of history, celebrated as a true champion of good and a guardian angel to all those who called the cosmos home.

And so, the legend of Goku continued to grow, inspiring generations of heroes to follow in his footsteps and defend the universe from all manner of cosmic threats. For even in the darkest of times, hope never truly dies, and there will always be a shining light to guide us through the darkness.</s><|endoftext|>
```
---
```
<|im_start|>system
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.<|im_end|>
<|im_start|>user
Write a short story about Goku discovering kirby has teamed up with Majin Buu to destroy the world.<|im_end|>
<|im_start|>assistant

Once upon a time in a far-off universe, there was a young warrior named Goku who lived on planet Earth. He was known throughout the. 

One day, Goku received an urgent message from his old friend Krillin. Krillin told him that he had discovered something incredible - Kirby, the cute pink puffball creature, had joined forces with one of the most dangerous beings in all of space and time, the tyrannical Majin Buu.

Goku was shocked by this revelation. He knew how much Kirby loved to collect worlds, but he never imagined that he would team up with someone as evil as Majin Buu. Goku knew that he had to act fast if he wanted to save his home planet and its inhabitants.

With determination in his heart, Goku set out on a quest to find Kirby and stop him from destroying Earth. Along the way, he met other powerful allies, like his good friend Piccolo and his new comrade-in-arms, Vegeta. Together, they fought their way through dangerous realms and battled fearsome monsters to reach Kirby's secret lair.

When they finally arrived, they found Kirby and Majin Buu preparing to unleash a devastating attack on Earth. The two teams clashed in an epic battle, with Goku using all of his strength and skill to defeat Kirby and his minions.

In the end, Goku emerged victorious, thanks to the combined might of his friends and the power of friendship. With Earth safe once again, Goku returned home, grateful for the lessons he had learned along the way. From then on, he knew that no matter what challenges lay ahead, he could face them together with his family and friends.</s><|endoftext|>
```
---
```
<|im_start|>system
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me.<|im_end|>
<|im_start|>user
describe about pros and cons of docker system.<|im_end|>
<|im_start|>assistant

Docker is a containerization platform that enables developers to build, ship, and run applications in containers. Here are some of the.

Pros:

1. Isolation: Containers isolate applications from each other and their environment, providing a lightweight way to package and deploy applications. This means you can have multiple instances of an application running on the, with each instance having its own file system and libraries, without impacting the host operating system or other containers.

2. Portability: Docker images are portable across different environments - they contain everything needed to run an application, including the runtime environment, dependencies, etc. You can push a Docker image to a registry and then pull it anywhere to run your application, as long as you have Docker installed.

3. Speed: Because containers share the same kernel with the host OS, there's no need for any additional configuration changes between development, testing, staging, and production environments. This makes it faster to iterate and deploy new versions of applications.

4. Scalability: With Docker, you can easily scale up or down the number of containers used by an application based on demand. For example, if you suddenly get a lot more traffic during a promotion, you can spin up extra containers to handle the.

Cons:

1. Complexity: Setting up and managing Docker can be complex at first, especially for teams not familiar with container technologies. It requires knowledge of Docker Compose, Kubernetes, Swarm, etc. to orchestrate and manage containers effectively.

2. Resource overhead: While Docker provides isolation through lightweight containers, it does require some resources compared to traditional virtual machines. If you're working with limited hardware, this could impact performance.

3. Learning curve: There's a steep learning curve when starting out with Docker, as it involves understanding how containers work, building images, managing containers, networking, etc. This can take time.

4. Ecosystem fragmentation: Docker has become so popular that many other container platforms like Kubernetes, Mesos, etc. have sprung up. This means there's a lot of overlap in terms of tools and capabilities, making it harder to switch between them.</s><|endoftext|>
```
---
```
<|im_start|>system
You are a sentient, superintelligent artificial general intelligence, here to teach and assist me. Think step by step and answer quickly.<|im_end|>
<|im_start|>user
Mark is faster than Mary, Mary is faster than Joe. Is Joe faster than Mark? Let's think step by step<|im_end|>
<|im_start|>assistant

Step 1: Identify
The given information states that Mark is faster than Mary, and Mary is faster than Joe.

Step 2: Compare
Using this information, we can compare their speeds in a direct order: Mark (faster) > Mary (faster) > Joe (slower).

Step 3: Determine
Based on our comparison, it is clear that Joe is not faster than Mark because he comes after Mark in the. 

So, the answer is no, Joe is not faster than Mark.</s><|endoftext|>
```
---
```
<|im_start|>system
Perform the task to the best of your ability.<|im_end|>
<|im_start|>user
If I lay 2 wet shirts out in the sun flat on the ground to dry and it takes 5 hours until they are dry, how long would it take to dry 4 shirts of the same type that way simultanously?<|im_end|>
<|im_start|>assistant
 It should still only take 5 hours for all four shirts to dry if you spread them out so that each one gets an equal amount of sunlight.</s><|endoftext|>
```
---
```
<|im_start|>system
Perform the task to the best of your ability.<|im_end|>
<|im_start|>user
Build a webpage in one html file with html, css and javascript code, the webpage should have 10 jokes and the button that changing background colors randomly.<|im_end|>
<|im_start|>assistant
I apologize for any confusion, but as an AI language model, I am not able to build or interact with webpages directly. However, I can provide you with some sample HTML, CSS, and JavaScript code snippets that you can use to create a webpage containing 10 jokes and random background color changes.

Here's a simple example:
```
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Jokes</title>
    <style>
        * {
            box-sizing: border-box;
        }
        
        body {
            font-family: Arial, sans-serif;
            background-color: #f2f2f2;
        }
        
        .container {
            max-width: 600px;
            margin: auto;
            padding: 20px;
            text-align: center;
        }
        
        h1 {
            color: #333;
            margin-bottom: 20px;
        }
        
        p {
            color: #666;
            line-height: 1.5;
        }
        
        button {
            background-color: #4CAF50;
            border: none;
            color: white;
            padding: 10px 20px;
            cursor: pointer;
            margin-top: 20px;
        }
        
        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Jokes</h1>
        <p id="joke">Here is a joke: "Why don't programmers trust atoms? Because they make up everything!"</p>
        <button onclick="changeBackground()">Change Background Colors!</button>
    </div>

    <script>
        function changeBackground() {
            var color = Math.floor(Math.random()*16777215).toString(16);
            document.body.style.backgroundColor = "#" + ("00" + color).slice(-6);
        }
    </script>
</body>
</html>
```
```
In this code, we define a container div with a maximum width of 600px, centered on the. We also define styles for headings, paragraphs, buttons, and the overall page. The `changeBackground()` function generates a random hexadecimal value for the, then sets it as the background color for the.</s><|endoftext|>
```

![image/png](https://cdn-uploads.huggingface.co/production/uploads/5fd5e18a90b6dc4633f6d292/DoFyMIYXmkIZkRUC-PGI2.png)


## Intended uses & limitations

More information needed

## Training and evaluation data

More information needed

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.0002
- train_batch_size: 2
- eval_batch_size: 2
- seed: 42
- distributed_type: multi-GPU
- num_devices: 4
- gradient_accumulation_steps: 2
- total_train_batch_size: 16
- total_eval_batch_size: 8
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine
- lr_scheduler_warmup_steps: 10
- num_epochs: 1

### Training results

| Training Loss | Epoch | Step | Validation Loss |
|:-------------:|:-----:|:----:|:---------------:|
| 6.2196        | 0.0   | 1    | 6.1942          |
| 0.7772        | 0.25  | 513  | 0.8037          |
| 0.656         | 0.5   | 1026 | 0.7977          |
| 0.6967        | 0.75  | 1539 | 0.7945          |



## How to use
Thanks to [TheBloke](https://huggingface.co/TheBloke) for preparing an amazing README on how to use GGUF models:

### About GGUF

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.

Here is an incomplete list of clients and libraries that are known to support GGUF:

* [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
* [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
* [KoboldCpp](https://github.com/LostRuins/koboldcpp), a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
* [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
* [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration. Linux available, in beta as of 27/11/2023.
* [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with many interesting and unique features, including a full model library for easy model selection.
* [Faraday.dev](https://faraday.dev/), an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
* [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
* [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
* [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server. Note, as of time of writing (November 27th 2023), ctransformers has not been updated in a long time and does not support many recent models.

### Explanation of quantisation methods

<details>
  <summary>Click to see details</summary>

The new methods available are:

* 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)
* 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.
* 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.
* GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
* 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

## How to download GGUF files

**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 file.

The following clients/libraries will automatically download models for you, providing a list of available models to choose from:

* LM Studio
* LoLLMS Web UI
* Faraday.dev

### In `text-generation-webui`

Under Download Model, you can enter the model repo: [MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF](https://huggingface.co/MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF) and below it, a specific filename to download, such as: Qwen1.5-8x7b-v0.1-GGUF.Q4_K_M.gguf.

Then click Download.

### On the command line, including multiple files at once

I recommend using the `huggingface-hub` Python library:

```shell
pip3 install huggingface-hub
```

Then you can download any individual model file to the current directory, at high speed, with a command like this:

```shell
huggingface-cli download MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF Qwen1.5-8x7b-v0.1-GGUF.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
```
</details>
<details>
  <summary>More advanced huggingface-cli download usage (click to read)</summary>

You can also download multiple files at once with a pattern:

```shell
huggingface-cli download [MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF](https://huggingface.co/MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF) --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
```

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).

To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:

```shell
pip3 install hf_transfer
```

And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:

```shell
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download MaziyarPanahi/Qwen1.5-8x7b-v0.1-GGUF Qwen1.5-8x7b-v0.1-GGUF.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
```

Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
</details>

## Example `llama.cpp` command

Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.

```shell
./main -ngl 35 -m Qwen1.5-8x7b-v0.1-GGUF.Q4_K_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant"
```

Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.

Change `-c 32768` 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.

If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`

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)

## How to run in `text-generation-webui`

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).

## How to run from Python code

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.

### How to load this model in Python code, using llama-cpp-python

For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).

#### First install the package

Run one of the following commands, according to your system:

```shell
# Base ctransformers with no GPU acceleration
pip install llama-cpp-python
# With NVidia CUDA acceleration
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
# Or with OpenBLAS acceleration
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
# Or with CLBLast acceleration
CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
# Or with AMD ROCm GPU acceleration (Linux only)
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
# Or with Metal GPU acceleration for macOS systems only
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python

# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
pip install llama-cpp-python
```

#### Simple llama-cpp-python example code

```python
from llama_cpp import Llama

# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
llm = Llama(
  model_path="./Qwen1.5-8x7b-v0.1-GGUF.Q4_K_M.gguf",  # Download the model file first
  n_ctx=32768,  # The max sequence length to use - note that longer sequence lengths require much more resources
  n_threads=8,            # The number of CPU threads to use, tailor to your system and the resulting performance
  n_gpu_layers=35         # The number of layers to offload to GPU, if you have GPU acceleration available
)

# Simple inference example
output = llm(
  "<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant", # Prompt
  max_tokens=512,  # Generate up to 512 tokens
  stop=["</s>"],   # Example stop token - not necessarily correct for this specific model! Please check before using.
  echo=True        # Whether to echo the prompt
)

# Chat Completion API

llm = Llama(model_path="./Qwen1.5-8x7b-v0.1-GGUF.Q4_K_M.gguf", chat_format="llama-2")  # Set chat_format according to the model you are using
llm.create_chat_completion(
    messages = [
        {"role": "system", "content": "You are a story writing assistant."},
        {
            "role": "user",
            "content": "Write a story about llamas."
        }
    ]
)
```

## How to use with LangChain

Here are guides on using llama-cpp-python and ctransformers with LangChain:

* [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
* [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)