File size: 5,409 Bytes
46fd347
 
 
54f0697
df2e092
 
5379f81
 
0092bc7
1985113
 
 
 
 
 
 
 
 
 
 
 
 
 
6c37c0a
 
 
 
1985113
5b59a12
 
 
 
 
 
 
 
 
1985113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b59a12
 
 
 
 
d1f50dc
 
 
5b59a12
 
 
 
 
d1f50dc
 
5b59a12
 
 
 
 
01bc567
5b59a12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
01bc567
 
68af73a
efe584c
01bc567
68af73a
 
 
 
 
31e2dc0
efe584c
 
 
 
 
 
 
 
 
f4391ef
68af73a
 
 
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
---
language:
- en
result:
- task: null
  type: text-generation
license: other
license_name: llama3
license_link: LICENSE
tags:
  - facebook
  - meta
  - pytorch
  - llama
  - llama-3
model_name: Meta-Llama-3-8B
arxiv: 2307.09288
base_model: meta-llama/Meta-Llama-3-8B
inference: false
model_creator: Meta Llama 3
model_type: llama
pipeline_tag: text-generation
prompt_template: >
  <|begin_of_text|><|start_header_id|>system<|end_header_id|>
  {{ system_prompt }}<|eot_id|><|start_header_id|>user<|end_header_id|>
  {{ user_message }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>

quantized_by: Orneyfish
---
# Meta-Llama-3-8B-GGUF

- This is a GGUF quantized version of [Meta-Llama-3-8B](https://huggingface.co/meta-llama/Meta-Llama-3-8B/edit/main/README.md).

## Model Details

* Meta developed and released the Meta Llama 3 family of large language models (LLMs) based on the Transformer architecture.
* Model Architecture: Transformer-based with 8.5 billion parameters.
* GGUF Quantization: Currently only availabel in f_16, Q8_0 version.

## 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. GGUF offers numerous advantages over GGML, such as better tokenisation, and support for special tokens. It is also supports metadata, and is designed to be extensible.

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

llama.cpp. The source project for GGUF. Offers a CLI and a server option.
text-generation-webui, the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
KoboldCpp, a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
LM Studio, an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
LoLLMS Web UI, a great web UI with many interesting and unique features, including a full model library for easy model selection.
Faraday.dev, an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
ctransformers, a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
llama-cpp-python, a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
candle, a Rust ML framework with a focus on performance, including GPU support, and ease of use.

## Intended Use

* This model is intended for research and experimentation in understanding and advancing language model capabilities.
* Sample Use Cases:
  * Text generation of various kinds (creative, factual, etc.)
  * Summarization
  * Question-answering

## Performance & Limitations

* Performance Metrics: Report speed improvements, performance changes compared to the original model.
* Limitations:
    May still generate unsafe or biased outputs, use with caution.
    Performance changes compared to the original due to quantization.

## How to Use

1. **Load the model and tokenizer:**
```python
##### Llama3 Inference #############
from huggingface_hub import hf_hub_download
import time
from llama_cpp.llama import Llama, LlamaGrammar
import httpx
import json
import torch
import multiprocessing as mp

number_of_cpu = mp.cpu_count()
grammar_text = httpx.get("https://raw.githubusercontent.com/ggerganov/llama.cpp/master/grammars/json.gbnf").text
grammar = LlamaGrammar.from_string(grammar_text)
model_name_or_path = "Orneyfish/Meta-Llama-3-8B_F_16.gguf"
model_basename = "Meta-Llama-3-8B_F_16.gguf" # the model is in bin format


model_path = hf_hub_download(repo_id=model_name_or_path, filename=model_basename, local_dir='models/')
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

# Callbacks support token-wise streaming
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
# Verbose is required to pass to the callback manager
n_gpu_layers = 40 # Change this value based on your model and your GPU VRAM pool.
n_batch = 1024 # Should be between 1 and n_ctx, consider the amount of VRAM in your GPU.

# Loading model,
llm = Llama(
model_path=model_path,
n_threads=number_of_cpu,
n_gpu_layers=n_gpu_layers,
n_batch=n_batch,
n_threads_batch = 512,
# use_mlock =True,
callback_manager=callback_manager,
verbose=True,
n_ctx=8196, # Context window
stop = ['USER:'], # Dynamic stopping when such token is detected.
temperature = 0.2,
# use_mmap = False,
)
```

## Prompt Template
**1. System prompt message added to a single user message**

```python
prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{{ system_prompt }}<|eot_id|><|start_header_id|>user<|end_header_id|>
{{ user_message }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>"""

```
**2. System prompt and multiple turn conversation between the user and assistant**

```python
prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{{ system_prompt }}<|eot_id|><|start_header_id|>user<|end_header_id|>
{{ user_message_1 }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
{{ model_answer_1 }}<|eot_id|><|start_header_id|>user<|end_header_id|>
{{ user_message_2 }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>"""

```


## Please test the model out