Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
thumbnail: "https://assets-global.website-files.com/646b351987a8d8ce158d1940/64ec9e96b4334c0e1ac41504_Logo%20with%20white%20text.svg"
|
3 |
+
metrics:
|
4 |
+
- memory_disk
|
5 |
+
- memory_inference
|
6 |
+
- inference_latency
|
7 |
+
- inference_throughput
|
8 |
+
- inference_CO2_emissions
|
9 |
+
- inference_energy_consumption
|
10 |
+
tags:
|
11 |
+
- pruna-ai
|
12 |
+
---
|
13 |
+
<!-- header start -->
|
14 |
+
<!-- 200823 -->
|
15 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
16 |
+
<a href="https://www.pruna.ai/" target="_blank" rel="noopener noreferrer">
|
17 |
+
<img src="https://i.imgur.com/eDAlcgk.png" alt="PrunaAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
18 |
+
</a>
|
19 |
+
</div>
|
20 |
+
<!-- header end -->
|
21 |
+
|
22 |
+
[![Twitter](https://img.shields.io/twitter/follow/PrunaAI?style=social)](https://twitter.com/PrunaAI)
|
23 |
+
[![GitHub](https://img.shields.io/github/followers/PrunaAI?label=Follow%20%40PrunaAI&style=social)](https://github.com/PrunaAI)
|
24 |
+
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/company/93832878/admin/feed/posts/?feedType=following)
|
25 |
+
[![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.com/invite/vb6SmA3hxu)
|
26 |
+
|
27 |
+
## This repo contains GGUF versions of the AdaptLLM/medicine-chat model.
|
28 |
+
|
29 |
+
# Simply make AI models cheaper, smaller, faster, and greener!
|
30 |
+
|
31 |
+
- Give a thumbs up if you like this model!
|
32 |
+
- Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
|
33 |
+
- Request access to easily compress your *own* AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
34 |
+
- Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
|
35 |
+
- Join Pruna AI community on Discord [here](https://discord.com/invite/vb6SmA3hxu) to share feedback/suggestions or get help.
|
36 |
+
|
37 |
+
**Frequently Asked Questions**
|
38 |
+
- ***How does the compression work?*** The model is compressed with GGUF.
|
39 |
+
- ***How does the model quality change?*** The quality of the model output might vary compared to the base model.
|
40 |
+
- ***What is the model format?*** We use GGUF format.
|
41 |
+
- ***What calibration data has been used?*** If needed by the compression method, we used WikiText as the calibration data.
|
42 |
+
- ***How to compress my own models?*** You can request premium access to more compression methods and tech support for your specific use-cases [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
43 |
+
|
44 |
+
# Downloading and running the models
|
45 |
+
|
46 |
+
You can download the individual files from the Files & versions section. Here is a list of the different versions we provide. For more info checkout [this chart](https://gist.github.com/Artefact2/b5f810600771265fc1e39442288e8ec9) and [this guide](https://www.reddit.com/r/LocalLLaMA/comments/1ba55rj/overview_of_gguf_quantization_methods/):
|
47 |
+
|
48 |
+
| Quant type | Description |
|
49 |
+
|------------|--------------------------------------------------------------------------------------------|
|
50 |
+
| Q5_K_M | High quality, recommended. |
|
51 |
+
| Q5_K_S | High quality, recommended. |
|
52 |
+
| Q4_K_M | Good quality, uses about 4.83 bits per weight, recommended. |
|
53 |
+
| Q4_K_S | Slightly lower quality with more space savings, recommended. |
|
54 |
+
| IQ4_NL | Decent quality, slightly smaller than Q4_K_S with similar performance, recommended. |
|
55 |
+
| IQ4_XS | Decent quality, smaller than Q4_K_S with similar performance, recommended. |
|
56 |
+
| Q3_K_L | Lower quality but usable, good for low RAM availability. |
|
57 |
+
| Q3_K_M | Even lower quality. |
|
58 |
+
| IQ3_M | Medium-low quality, new method with decent performance comparable to Q3_K_M. |
|
59 |
+
| IQ3_S | Lower quality, new method with decent performance, recommended over Q3_K_S quant, same size with better performance. |
|
60 |
+
| Q3_K_S | Low quality, not recommended. |
|
61 |
+
| IQ3_XS | Lower quality, new method with decent performance, slightly better than Q3_K_S. |
|
62 |
+
| Q2_K | Very low quality but surprisingly usable. |
|
63 |
+
|
64 |
+
|
65 |
+
## How to download GGUF files ?
|
66 |
+
|
67 |
+
**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.
|
68 |
+
|
69 |
+
The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
|
70 |
+
|
71 |
+
* LM Studio
|
72 |
+
* LoLLMS Web UI
|
73 |
+
* Faraday.dev
|
74 |
+
|
75 |
+
- **Option A** - Downloading in `text-generation-webui`:
|
76 |
+
- **Step 1**: Under Download Model, you can enter the model repo: AdaptLLM-medicine-chat-GGUF-smashed and below it, a specific filename to download, such as: phi-2.IQ3_M.gguf.
|
77 |
+
- **Step 2**: Then click Download.
|
78 |
+
|
79 |
+
- **Option B** - Downloading on the command line (including multiple files at once):
|
80 |
+
- **Step 1**: We recommend using the `huggingface-hub` Python library:
|
81 |
+
```shell
|
82 |
+
pip3 install huggingface-hub
|
83 |
+
```
|
84 |
+
- **Step 2**: Then you can download any individual model file to the current directory, at high speed, with a command like this:
|
85 |
+
```shell
|
86 |
+
huggingface-cli download AdaptLLM-medicine-chat-GGUF-smashed medicine-chat.IQ3_M.gguf --local-dir . --local-dir-use-symlinks False
|
87 |
+
```
|
88 |
+
<details>
|
89 |
+
<summary>More advanced huggingface-cli download usage (click to read)</summary>
|
90 |
+
Alternatively, you can also download multiple files at once with a pattern:
|
91 |
+
|
92 |
+
```shell
|
93 |
+
huggingface-cli download AdaptLLM-medicine-chat-GGUF-smashed --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
|
94 |
+
```
|
95 |
+
|
96 |
+
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).
|
97 |
+
|
98 |
+
To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
|
99 |
+
|
100 |
+
```shell
|
101 |
+
pip3 install hf_transfer
|
102 |
+
```
|
103 |
+
|
104 |
+
And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
|
105 |
+
|
106 |
+
```shell
|
107 |
+
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download AdaptLLM-medicine-chat-GGUF-smashed medicine-chat.IQ3_M.gguf --local-dir . --local-dir-use-symlinks False
|
108 |
+
```
|
109 |
+
|
110 |
+
Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
|
111 |
+
</details>
|
112 |
+
<!-- README_GGUF.md-how-to-download end -->
|
113 |
+
|
114 |
+
<!-- README_GGUF.md-how-to-run start -->
|
115 |
+
|
116 |
+
## How to run model in GGUF format?
|
117 |
+
- **Option A** - Introductory example with `llama.cpp` command
|
118 |
+
|
119 |
+
Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
|
120 |
+
|
121 |
+
```shell
|
122 |
+
./main -ngl 35 -m medicine-chat.IQ3_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<s>[INST] {{prompt\}} [/INST]"
|
123 |
+
```
|
124 |
+
|
125 |
+
Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
|
126 |
+
|
127 |
+
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.
|
128 |
+
|
129 |
+
If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
|
130 |
+
|
131 |
+
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)
|
132 |
+
|
133 |
+
- **Option B** - Running in `text-generation-webui`
|
134 |
+
|
135 |
+
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-%20Model%20Tab.md#llamacpp).
|
136 |
+
|
137 |
+
- **Option C** - Running from Python code
|
138 |
+
|
139 |
+
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.
|
140 |
+
|
141 |
+
### How to load this model in Python code, using llama-cpp-python
|
142 |
+
|
143 |
+
For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
|
144 |
+
|
145 |
+
#### First install the package
|
146 |
+
|
147 |
+
Run one of the following commands, according to your system:
|
148 |
+
|
149 |
+
```shell
|
150 |
+
# Base ctransformers with no GPU acceleration
|
151 |
+
pip install llama-cpp-python
|
152 |
+
# With NVidia CUDA acceleration
|
153 |
+
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
|
154 |
+
# Or with OpenBLAS acceleration
|
155 |
+
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
|
156 |
+
# Or with CLBLast acceleration
|
157 |
+
CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
|
158 |
+
# Or with AMD ROCm GPU acceleration (Linux only)
|
159 |
+
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
|
160 |
+
# Or with Metal GPU acceleration for macOS systems only
|
161 |
+
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
|
162 |
+
|
163 |
+
# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
|
164 |
+
$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
|
165 |
+
pip install llama-cpp-python
|
166 |
+
```
|
167 |
+
|
168 |
+
#### Simple llama-cpp-python example code
|
169 |
+
|
170 |
+
```python
|
171 |
+
from llama_cpp import Llama
|
172 |
+
|
173 |
+
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
174 |
+
llm = Llama(
|
175 |
+
model_path="./medicine-chat.IQ3_M.gguf", # Download the model file first
|
176 |
+
n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
|
177 |
+
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
|
178 |
+
n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
|
179 |
+
)
|
180 |
+
|
181 |
+
# Simple inference example
|
182 |
+
output = llm(
|
183 |
+
"<s>[INST] {{prompt}} [/INST]", # Prompt
|
184 |
+
max_tokens=512, # Generate up to 512 tokens
|
185 |
+
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
|
186 |
+
echo=True # Whether to echo the prompt
|
187 |
+
)
|
188 |
+
|
189 |
+
# Chat Completion API
|
190 |
+
|
191 |
+
llm = Llama(model_path="./medicine-chat.IQ3_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
|
192 |
+
llm.create_chat_completion(
|
193 |
+
messages = [
|
194 |
+
{{"role": "system", "content": "You are a story writing assistant."}},
|
195 |
+
{{
|
196 |
+
"role": "user",
|
197 |
+
"content": "Write a story about llamas."
|
198 |
+
}}
|
199 |
+
]
|
200 |
+
)
|
201 |
+
```
|
202 |
+
|
203 |
+
- **Option D** - Running with LangChain
|
204 |
+
|
205 |
+
Here are guides on using llama-cpp-python and ctransformers with LangChain:
|
206 |
+
|
207 |
+
* [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
|
208 |
+
* [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
|
209 |
+
|
210 |
+
## Configurations
|
211 |
+
|
212 |
+
The configuration info are in `smash_config.json`.
|
213 |
+
|
214 |
+
## Credits & License
|
215 |
+
|
216 |
+
The license of the smashed model follows the license of the original model. Please check the license of the original model before using this model which provided the base model. The license of the `pruna-engine` is [here](https://pypi.org/project/pruna-engine/) on Pypi.
|
217 |
+
|
218 |
+
## Want to compress other models?
|
219 |
+
|
220 |
+
- Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
|
221 |
+
- Request access to easily compress your own AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|