Initial GPTQ model commit
Browse files
README.md
ADDED
@@ -0,0 +1,324 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
inference: false
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
library_name: transformers
|
6 |
+
license: llama2
|
7 |
+
model_creator: OpenLemur
|
8 |
+
model_link: https://huggingface.co/OpenLemur/lemur-70b-chat-v1
|
9 |
+
model_name: Lemur 70B Chat v1
|
10 |
+
model_type: llama
|
11 |
+
pipeline_tag: text-generation
|
12 |
+
quantized_by: TheBloke
|
13 |
+
tags:
|
14 |
+
- text-generation
|
15 |
+
- code
|
16 |
+
- text-generation-inference
|
17 |
+
widget:
|
18 |
+
- example_title: Lemur favorite fruit
|
19 |
+
group: Python
|
20 |
+
text: What's lemur's favorite fruit?
|
21 |
+
- example_title: Merge Sort
|
22 |
+
group: Python
|
23 |
+
text: Write a Python function to merge two sorted lists into one sorted list without
|
24 |
+
using any built-in sort functions.
|
25 |
+
---
|
26 |
+
|
27 |
+
<!-- header start -->
|
28 |
+
<!-- 200823 -->
|
29 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
30 |
+
<img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
31 |
+
</div>
|
32 |
+
<div style="display: flex; justify-content: space-between; width: 100%;">
|
33 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
34 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
|
35 |
+
</div>
|
36 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end;">
|
37 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
|
38 |
+
</div>
|
39 |
+
</div>
|
40 |
+
<div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
|
41 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
42 |
+
<!-- header end -->
|
43 |
+
|
44 |
+
# Lemur 70B Chat v1 - GPTQ
|
45 |
+
- Model creator: [OpenLemur](https://huggingface.co/OpenLemur)
|
46 |
+
- Original model: [Lemur 70B Chat v1](https://huggingface.co/OpenLemur/lemur-70b-chat-v1)
|
47 |
+
|
48 |
+
<!-- description start -->
|
49 |
+
## Description
|
50 |
+
|
51 |
+
This repo contains GPTQ model files for [OpenLemur's Lemur 70B Chat v1](https://huggingface.co/OpenLemur/lemur-70b-chat-v1).
|
52 |
+
|
53 |
+
Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
|
54 |
+
|
55 |
+
<!-- description end -->
|
56 |
+
<!-- repositories-available start -->
|
57 |
+
## Repositories available
|
58 |
+
|
59 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ)
|
60 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GGUF)
|
61 |
+
* [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference (deprecated)](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GGML)
|
62 |
+
* [OpenLemur's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/OpenLemur/lemur-70b-chat-v1)
|
63 |
+
<!-- repositories-available end -->
|
64 |
+
|
65 |
+
<!-- prompt-template start -->
|
66 |
+
## Prompt template: ChatML
|
67 |
+
|
68 |
+
```
|
69 |
+
<|im_start|>system
|
70 |
+
{system_message}<|im_end|>
|
71 |
+
<|im_start|>user
|
72 |
+
{prompt}<|im_end|>
|
73 |
+
<|im_start|>assistant
|
74 |
+
|
75 |
+
```
|
76 |
+
|
77 |
+
<!-- prompt-template end -->
|
78 |
+
|
79 |
+
<!-- README_GPTQ.md-provided-files start -->
|
80 |
+
## Provided files and GPTQ parameters
|
81 |
+
|
82 |
+
Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
|
83 |
+
|
84 |
+
Each separate quant is in a different branch. See below for instructions on fetching from different branches.
|
85 |
+
|
86 |
+
All GPTQ files are made with AutoGPTQ.
|
87 |
+
|
88 |
+
<details>
|
89 |
+
<summary>Explanation of GPTQ parameters</summary>
|
90 |
+
|
91 |
+
- Bits: The bit size of the quantised model.
|
92 |
+
- GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
|
93 |
+
- Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.
|
94 |
+
- Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
|
95 |
+
- GPTQ dataset: The dataset used for quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
|
96 |
+
- Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
|
97 |
+
- ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama models in 4-bit.
|
98 |
+
|
99 |
+
</details>
|
100 |
+
|
101 |
+
| Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
|
102 |
+
| ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
|
103 |
+
| [main](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ/tree/main) | 4 | None | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 35.33 GB | Yes | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
|
104 |
+
| [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 40.66 GB | Yes | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
|
105 |
+
| [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 37.99 GB | Yes | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
|
106 |
+
| [gptq-4bit-128g-actorder_True](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ/tree/gptq-4bit-128g-actorder_True) | 4 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 36.65 GB | Yes | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
|
107 |
+
| [gptq-3bit--1g-actorder_True](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ/tree/gptq-3bit--1g-actorder_True) | 3 | None | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 26.78 GB | No | 3-bit, with Act Order and no group size. Lowest possible VRAM requirements. May be lower quality than 3-bit 128g. |
|
108 |
+
| [gptq-3bit-128g-actorder_True](https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ/tree/gptq-3bit-128g-actorder_True) | 3 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 28.03 GB | No | 3-bit, with group size 128g and act-order. Higher quality than 128g-False but poor AutoGPTQ CUDA speed. |
|
109 |
+
|
110 |
+
<!-- README_GPTQ.md-provided-files end -->
|
111 |
+
|
112 |
+
<!-- README_GPTQ.md-download-from-branches start -->
|
113 |
+
## How to download from branches
|
114 |
+
|
115 |
+
- In text-generation-webui, you can add `:branch` to the end of the download name, eg `TheBloke/Lemur-70B-Chat-v1-GPTQ:gptq-4bit-32g-actorder_True`
|
116 |
+
- With Git, you can clone a branch with:
|
117 |
+
```
|
118 |
+
git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/Lemur-70B-Chat-v1-GPTQ
|
119 |
+
```
|
120 |
+
- In Python Transformers code, the branch is the `revision` parameter; see below.
|
121 |
+
<!-- README_GPTQ.md-download-from-branches end -->
|
122 |
+
<!-- README_GPTQ.md-text-generation-webui start -->
|
123 |
+
## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
124 |
+
|
125 |
+
Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
126 |
+
|
127 |
+
It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
|
128 |
+
|
129 |
+
1. Click the **Model tab**.
|
130 |
+
2. Under **Download custom model or LoRA**, enter `TheBloke/Lemur-70B-Chat-v1-GPTQ`.
|
131 |
+
- To download from a specific branch, enter for example `TheBloke/Lemur-70B-Chat-v1-GPTQ:gptq-4bit-32g-actorder_True`
|
132 |
+
- see Provided Files above for the list of branches for each option.
|
133 |
+
3. Click **Download**.
|
134 |
+
4. The model will start downloading. Once it's finished it will say "Done".
|
135 |
+
5. In the top left, click the refresh icon next to **Model**.
|
136 |
+
6. In the **Model** dropdown, choose the model you just downloaded: `Lemur-70B-Chat-v1-GPTQ`
|
137 |
+
7. The model will automatically load, and is now ready for use!
|
138 |
+
8. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
|
139 |
+
* Note that you do not need to set GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
|
140 |
+
9. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
|
141 |
+
<!-- README_GPTQ.md-text-generation-webui end -->
|
142 |
+
|
143 |
+
<!-- README_GPTQ.md-use-from-python start -->
|
144 |
+
## How to use this GPTQ model from Python code
|
145 |
+
|
146 |
+
### Install the necessary packages
|
147 |
+
|
148 |
+
Requires: Transformers 4.32.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
|
149 |
+
|
150 |
+
```shell
|
151 |
+
pip3 install transformers>=4.32.0 optimum>=1.12.0
|
152 |
+
pip3 install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ # Use cu117 if on CUDA 11.7
|
153 |
+
```
|
154 |
+
|
155 |
+
If you have problems installing AutoGPTQ using the pre-built wheels, install it from source instead:
|
156 |
+
|
157 |
+
```shell
|
158 |
+
pip3 uninstall -y auto-gptq
|
159 |
+
git clone https://github.com/PanQiWei/AutoGPTQ
|
160 |
+
cd AutoGPTQ
|
161 |
+
pip3 install .
|
162 |
+
```
|
163 |
+
|
164 |
+
### For CodeLlama models only: you must use Transformers 4.33.0 or later.
|
165 |
+
|
166 |
+
If 4.33.0 is not yet released when you read this, you will need to install Transformers from source:
|
167 |
+
```shell
|
168 |
+
pip3 uninstall -y transformers
|
169 |
+
pip3 install git+https://github.com/huggingface/transformers.git
|
170 |
+
```
|
171 |
+
|
172 |
+
### You can then use the following code
|
173 |
+
|
174 |
+
```python
|
175 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
176 |
+
|
177 |
+
model_name_or_path = "TheBloke/Lemur-70B-Chat-v1-GPTQ"
|
178 |
+
# To use a different branch, change revision
|
179 |
+
# For example: revision="gptq-4bit-32g-actorder_True"
|
180 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
181 |
+
torch_dtype=torch.float16,
|
182 |
+
device_map="auto",
|
183 |
+
revision="main")
|
184 |
+
|
185 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
186 |
+
|
187 |
+
prompt = "Tell me about AI"
|
188 |
+
prompt_template=f'''<|im_start|>system
|
189 |
+
{system_message}<|im_end|>
|
190 |
+
<|im_start|>user
|
191 |
+
{prompt}<|im_end|>
|
192 |
+
<|im_start|>assistant
|
193 |
+
|
194 |
+
'''
|
195 |
+
|
196 |
+
print("\n\n*** Generate:")
|
197 |
+
|
198 |
+
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
|
199 |
+
output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
|
200 |
+
print(tokenizer.decode(output[0]))
|
201 |
+
|
202 |
+
# Inference can also be done using transformers' pipeline
|
203 |
+
|
204 |
+
print("*** Pipeline:")
|
205 |
+
pipe = pipeline(
|
206 |
+
"text-generation",
|
207 |
+
model=model,
|
208 |
+
tokenizer=tokenizer,
|
209 |
+
max_new_tokens=512,
|
210 |
+
temperature=0.7,
|
211 |
+
top_p=0.95,
|
212 |
+
repetition_penalty=1.15
|
213 |
+
)
|
214 |
+
|
215 |
+
print(pipe(prompt_template)[0]['generated_text'])
|
216 |
+
```
|
217 |
+
<!-- README_GPTQ.md-use-from-python end -->
|
218 |
+
|
219 |
+
<!-- README_GPTQ.md-compatibility start -->
|
220 |
+
## Compatibility
|
221 |
+
|
222 |
+
The files provided are tested to work with AutoGPTQ, both via Transformers and using AutoGPTQ directly. They should also work with [Occ4m's GPTQ-for-LLaMa fork](https://github.com/0cc4m/KoboldAI).
|
223 |
+
|
224 |
+
[ExLlama](https://github.com/turboderp/exllama) is compatible with Llama models in 4-bit. Please see the Provided Files table above for per-file compatibility.
|
225 |
+
|
226 |
+
[Huggingface Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) is compatible with all GPTQ models.
|
227 |
+
<!-- README_GPTQ.md-compatibility end -->
|
228 |
+
|
229 |
+
<!-- footer start -->
|
230 |
+
<!-- 200823 -->
|
231 |
+
## Discord
|
232 |
+
|
233 |
+
For further support, and discussions on these models and AI in general, join us at:
|
234 |
+
|
235 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
236 |
+
|
237 |
+
## Thanks, and how to contribute.
|
238 |
+
|
239 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
240 |
+
|
241 |
+
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
|
242 |
+
|
243 |
+
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
|
244 |
+
|
245 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
246 |
+
|
247 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
248 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
249 |
+
|
250 |
+
**Special thanks to**: Aemon Algiz.
|
251 |
+
|
252 |
+
**Patreon special mentions**: Kacper Wikieł, knownsqashed, Leonard Tan, Asp the Wyvern, Daniel P. Andersen, Luke Pendergrass, Stanislav Ovsiannikov, RoA, Dave, Ai Maven, Kalila, Will Dee, Imad Khwaja, Nitin Borwankar, Joseph William Delisle, Tony Hughes, Cory Kujawski, Rishabh Srivastava, Russ Johnson, Stephen Murray, Lone Striker, Johann-Peter Hartmann, Elle, J, Deep Realms, SuperWojo, Raven Klaugh, Sebastain Graf, ReadyPlayerEmma, Alps Aficionado, Mano Prime, Derek Yates, Gabriel Puliatti, Mesiah Bishop, Magnesian, Sean Connelly, biorpg, Iucharbius, Olakabola, Fen Risland, Space Cruiser, theTransient, Illia Dulskyi, Thomas Belote, Spencer Kim, Pieter, John Detwiler, Fred von Graf, Michael Davis, Swaroop Kallakuri, subjectnull, Clay Pascal, Subspace Studios, Chris Smitley, Enrico Ros, usrbinkat, Steven Wood, alfie_i, David Ziegler, Willem Michiel, Matthew Berman, Andrey, Pyrater, Jeffrey Morgan, vamX, LangChain4j, Luke @flexchar, Trenton Dambrowitz, Pierre Kircher, Alex, Sam, James Bentley, Edmond Seymore, Eugene Pentland, Pedro Madruga, Rainer Wilmers, Dan Guido, Nathan LeClaire, Spiking Neurons AB, Talal Aujan, zynix, Artur Olbinski, Michael Levine, 阿明, K, John Villwock, Nikolai Manek, Femi Adebogun, senxiiz, Deo Leter, NimbleBox.ai, Viktor Bowallius, Geoffrey Montalvo, Mandus, Ajan Kanaga, ya boyyy, Jonathan Leane, webtim, Brandon Frisco, danny, Alexandros Triantafyllidis, Gabriel Tamborski, Randy H, terasurfer, Vadim, Junyu Yang, Vitor Caleffi, Chadd, transmissions 11
|
253 |
+
|
254 |
+
|
255 |
+
Thank you to all my generous patrons and donaters!
|
256 |
+
|
257 |
+
And thank you again to a16z for their generous grant.
|
258 |
+
|
259 |
+
<!-- footer end -->
|
260 |
+
|
261 |
+
# Original model card: OpenLemur's Lemur 70B Chat v1
|
262 |
+
|
263 |
+
|
264 |
+
# lemur-70b-chat-v1
|
265 |
+
|
266 |
+
<p align="center">
|
267 |
+
<img src="https://huggingface.co/datasets/OpenLemur/assets/resolve/main/lemur_icon.png" width="300" height="300" alt="Lemur">
|
268 |
+
</p>
|
269 |
+
|
270 |
+
<div align="center">
|
271 |
+
<img src="https://huggingface.co/datasets/OpenLemur/assets/resolve/main/lemur_chat_radar.png">
|
272 |
+
</div>
|
273 |
+
|
274 |
+
|
275 |
+
## Use
|
276 |
+
|
277 |
+
### Setup
|
278 |
+
|
279 |
+
First, we have to install all the libraries listed in `requirements.txt` in [GitHub](https://github.com/OpenLemur/lemur-v1):
|
280 |
+
|
281 |
+
```bash
|
282 |
+
pip install -r requirements.txt
|
283 |
+
```
|
284 |
+
|
285 |
+
### Generation
|
286 |
+
|
287 |
+
```python
|
288 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
289 |
+
|
290 |
+
tokenizer = AutoTokenizer.from_pretrained("OpenLemur/lemur-70b-chat-v1")
|
291 |
+
model = AutoModelForCausalLM.from_pretrained("OpenLemur/lemur-70b-chat-v1", device_map="auto", load_in_8bit=True)
|
292 |
+
|
293 |
+
# Text Generation Example
|
294 |
+
prompt = """<|im_start|>system
|
295 |
+
You are a helpful, respectful, and honest assistant.
|
296 |
+
<|im_end|>
|
297 |
+
<|im_start|>user
|
298 |
+
What's a lemur's favorite fruit?<|im_end|>
|
299 |
+
<|im_start|>assistant
|
300 |
+
"""
|
301 |
+
input = tokenizer(prompt, return_tensors="pt")
|
302 |
+
output = model.generate(**input, max_length=50, num_return_sequences=1)
|
303 |
+
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
304 |
+
print(generated_text)
|
305 |
+
|
306 |
+
# Code Generation Example
|
307 |
+
prompt = """<|im_start|>system
|
308 |
+
Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
309 |
+
<|im_end|>
|
310 |
+
<|im_start|>user
|
311 |
+
Write a Python function to merge two sorted lists into one sorted list without using any built-in sort functions.<|im_end|>
|
312 |
+
<|im_start|>assistant
|
313 |
+
"""
|
314 |
+
input = tokenizer(prompt, return_tensors="pt")
|
315 |
+
output = model.generate(**input, max_length=200, num_return_sequences=1)
|
316 |
+
generated_code = tokenizer.decode(output[0], skip_special_tokens=True)
|
317 |
+
print(generated_code)
|
318 |
+
```
|
319 |
+
|
320 |
+
# License
|
321 |
+
The model is licensed under a CC BY-NC-4.0 license focused on research use cases.
|
322 |
+
|
323 |
+
# Acknowledgements
|
324 |
+
The Lemur project is an open collaborative research effort between [XLang Lab](https://www.xlang.ai/) and Salesforce Research. We thank Salesforce, Google Research and Amazon AWS for their gift support.
|