TheBloke commited on
Commit
ecd3adf
·
1 Parent(s): 33ef439

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +489 -0
README.md ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: clibrain/Llama-2-7b-ft-instruct-es
3
+ inference: false
4
+ language:
5
+ - es
6
+ library_name: transformers
7
+ license: apache-2.0
8
+ model_creator: CliBrAIn
9
+ model_name: Llama 2 7B FT Instruct ES
10
+ model_type: llama
11
+ pipeline_tag: text-generation
12
+ prompt_template: "A continuaci\xF3n hay una instrucci\xF3n que describe una tarea.\
13
+ \ Escriba una respuesta que complete adecuadamente la solicitud.\n### Instrucci\xF3\
14
+ n:\n{prompt}\n\n### Respuesta:\n"
15
+ quantized_by: TheBloke
16
+ ---
17
+ <!-- markdownlint-disable MD041 -->
18
+
19
+ <!-- header start -->
20
+ <!-- 200823 -->
21
+ <div style="width: auto; margin-left: auto; margin-right: auto">
22
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
23
+ </div>
24
+ <div style="display: flex; justify-content: space-between; width: 100%;">
25
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
26
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
27
+ </div>
28
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
29
+ <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>
30
+ </div>
31
+ </div>
32
+ <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>
33
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
34
+ <!-- header end -->
35
+
36
+ # Llama 2 7B FT Instruct ES - GPTQ
37
+ - Model creator: [CliBrAIn](https://huggingface.co/clibrain)
38
+ - Original model: [Llama 2 7B FT Instruct ES](https://huggingface.co/clibrain/Llama-2-7b-ft-instruct-es)
39
+
40
+ <!-- description start -->
41
+ # Description
42
+
43
+ This repo contains GPTQ model files for [CliBrAIn's Llama 2 7B FT Instruct ES](https://huggingface.co/clibrain/Llama-2-7b-ft-instruct-es).
44
+
45
+ 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.
46
+
47
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
48
+
49
+ <!-- description end -->
50
+ <!-- repositories-available start -->
51
+ ## Repositories available
52
+
53
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-AWQ)
54
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ)
55
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GGUF)
56
+ * [CliBrAIn's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/clibrain/Llama-2-7b-ft-instruct-es)
57
+ <!-- repositories-available end -->
58
+
59
+ <!-- prompt-template start -->
60
+ ## Prompt template: Clibrain-ES
61
+
62
+ ```
63
+ A continuación hay una instrucción que describe una tarea. Escriba una respuesta que complete adecuadamente la solicitud.
64
+ ### Instrucción:
65
+ {prompt}
66
+
67
+ ### Respuesta:
68
+
69
+ ```
70
+
71
+ <!-- prompt-template end -->
72
+ <!-- licensing start -->
73
+ ## Licensing
74
+
75
+ The creator of the source model has listed its license as `apache-2.0`, and this quantization has therefore used that same license.
76
+
77
+ As this model is based on Llama 2, it is also subject to the Meta Llama 2 license terms, and the license files for that are additionally included. It should therefore be considered as being claimed to be licensed under both licenses. I contacted Hugging Face for clarification on dual licensing but they do not yet have an official position. Should this change, or should Meta provide any feedback on this situation, I will update this section accordingly.
78
+
79
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [CliBrAIn's Llama 2 7B FT Instruct ES](https://huggingface.co/clibrain/Llama-2-7b-ft-instruct-es).
80
+ <!-- licensing end -->
81
+
82
+ <!-- README_GPTQ.md-compatible clients start -->
83
+ ## Known compatible clients / servers
84
+
85
+ GPTQ models are currently supported on Linux (NVidia/AMD) and Windows (NVidia only). macOS users: please use GGUF models.
86
+
87
+ These GPTQ models are known to work in the following inference servers/webuis.
88
+
89
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
90
+ - [KoboldAI United](https://github.com/henk717/koboldai)
91
+ - [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui)
92
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
93
+
94
+ This may not be a complete list; if you know of others, please let me know!
95
+ <!-- README_GPTQ.md-compatible clients end -->
96
+
97
+ <!-- README_GPTQ.md-provided-files start -->
98
+ ## Provided files, and GPTQ parameters
99
+
100
+ Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
101
+
102
+ Each separate quant is in a different branch. See below for instructions on fetching from different branches.
103
+
104
+ Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
105
+
106
+ <details>
107
+ <summary>Explanation of GPTQ parameters</summary>
108
+
109
+ - Bits: The bit size of the quantised model.
110
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
111
+ - 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.
112
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
113
+ - GPTQ dataset: The calibration dataset used during quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ calibration 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).
114
+ - 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.
115
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
116
+
117
+ </details>
118
+
119
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
120
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
121
+ | [main](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ/tree/main) | 4 | 128 | Yes | 0.1 | [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish/viewer/) | 4096 | 3.90 GB | Yes | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
122
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish/viewer/) | 4096 | 4.28 GB | Yes | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
123
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish/viewer/) | 4096 | 7.01 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
124
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish/viewer/) | 4096 | 7.16 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
125
+ | [gptq-8bit-32g-actorder_True](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ/tree/gptq-8bit-32g-actorder_True) | 8 | 32 | Yes | 0.1 | [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish/viewer/) | 4096 | 7.62 GB | No | 8-bit, with group size 32g and Act Order for maximum inference quality. |
126
+ | [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [Alpaca Spanish](https://huggingface.co/datasets/bertin-project/alpaca-spanish/viewer/) | 4096 | 4.02 GB | Yes | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. |
127
+
128
+ <!-- README_GPTQ.md-provided-files end -->
129
+
130
+ <!-- README_GPTQ.md-download-from-branches start -->
131
+ ## How to download, including from branches
132
+
133
+ ### In text-generation-webui
134
+
135
+ To download from the `main` branch, enter `TheBloke/Llama-2-7B-ft-instruct-es-GPTQ` in the "Download model" box.
136
+
137
+ To download from another branch, add `:branchname` to the end of the download name, eg `TheBloke/Llama-2-7B-ft-instruct-es-GPTQ:gptq-4bit-32g-actorder_True`
138
+
139
+ ### From the command line
140
+
141
+ I recommend using the `huggingface-hub` Python library:
142
+
143
+ ```shell
144
+ pip3 install huggingface-hub
145
+ ```
146
+
147
+ To download the `main` branch to a folder called `Llama-2-7B-ft-instruct-es-GPTQ`:
148
+
149
+ ```shell
150
+ mkdir Llama-2-7B-ft-instruct-es-GPTQ
151
+ huggingface-cli download TheBloke/Llama-2-7B-ft-instruct-es-GPTQ --local-dir Llama-2-7B-ft-instruct-es-GPTQ --local-dir-use-symlinks False
152
+ ```
153
+
154
+ To download from a different branch, add the `--revision` parameter:
155
+
156
+ ```shell
157
+ mkdir Llama-2-7B-ft-instruct-es-GPTQ
158
+ huggingface-cli download TheBloke/Llama-2-7B-ft-instruct-es-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir Llama-2-7B-ft-instruct-es-GPTQ --local-dir-use-symlinks False
159
+ ```
160
+
161
+ <details>
162
+ <summary>More advanced huggingface-cli download usage</summary>
163
+
164
+ If you remove the `--local-dir-use-symlinks False` parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: `~/.cache/huggingface`), and symlinks will be added to the specified `--local-dir`, pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.
165
+
166
+ The cache location can be changed with the `HF_HOME` environment variable, and/or the `--cache-dir` parameter to `huggingface-cli`.
167
+
168
+ 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).
169
+
170
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
171
+
172
+ ```shell
173
+ pip3 install hf_transfer
174
+ ```
175
+
176
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
177
+
178
+ ```shell
179
+ mkdir Llama-2-7B-ft-instruct-es-GPTQ
180
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/Llama-2-7B-ft-instruct-es-GPTQ --local-dir Llama-2-7B-ft-instruct-es-GPTQ --local-dir-use-symlinks False
181
+ ```
182
+
183
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
184
+ </details>
185
+
186
+ ### With `git` (**not** recommended)
187
+
188
+ To clone a specific branch with `git`, use a command like this:
189
+
190
+ ```shell
191
+ git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/Llama-2-7B-ft-instruct-es-GPTQ
192
+ ```
193
+
194
+ Note that using Git with HF repos is strongly discouraged. It will be much slower than using `huggingface-hub`, and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the `.git` folder as a blob.)
195
+
196
+ <!-- README_GPTQ.md-download-from-branches end -->
197
+ <!-- README_GPTQ.md-text-generation-webui start -->
198
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
199
+
200
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
201
+
202
+ 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.
203
+
204
+ 1. Click the **Model tab**.
205
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Llama-2-7B-ft-instruct-es-GPTQ`.
206
+
207
+ - To download from a specific branch, enter for example `TheBloke/Llama-2-7B-ft-instruct-es-GPTQ:gptq-4bit-32g-actorder_True`
208
+ - see Provided Files above for the list of branches for each option.
209
+
210
+ 3. Click **Download**.
211
+ 4. The model will start downloading. Once it's finished it will say "Done".
212
+ 5. In the top left, click the refresh icon next to **Model**.
213
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Llama-2-7B-ft-instruct-es-GPTQ`
214
+ 7. The model will automatically load, and is now ready for use!
215
+ 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.
216
+
217
+ - Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
218
+
219
+ 9. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
220
+
221
+ <!-- README_GPTQ.md-text-generation-webui end -->
222
+
223
+ <!-- README_GPTQ.md-use-from-tgi start -->
224
+ ## Serving this model from Text Generation Inference (TGI)
225
+
226
+ It's recommended to use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
227
+
228
+ Example Docker parameters:
229
+
230
+ ```shell
231
+ --model-id TheBloke/Llama-2-7B-ft-instruct-es-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
232
+ ```
233
+
234
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
235
+
236
+ ```shell
237
+ pip3 install huggingface-hub
238
+ ```
239
+
240
+ ```python
241
+ from huggingface_hub import InferenceClient
242
+
243
+ endpoint_url = "https://your-endpoint-url-here"
244
+
245
+ prompt = "Tell me about AI"
246
+ prompt_template=f'''A continuación hay una instrucción que describe una tarea. Escriba una respuesta que complete adecuadamente la solicitud.
247
+ ### Instrucción:
248
+ {prompt}
249
+
250
+ ### Respuesta:
251
+ '''
252
+
253
+ client = InferenceClient(endpoint_url)
254
+ response = client.text_generation(prompt,
255
+ max_new_tokens=128,
256
+ do_sample=True,
257
+ temperature=0.7,
258
+ top_p=0.95,
259
+ top_k=40,
260
+ repetition_penalty=1.1)
261
+
262
+ print(f"Model output: {response}")
263
+ ```
264
+ <!-- README_GPTQ.md-use-from-tgi end -->
265
+ <!-- README_GPTQ.md-use-from-python start -->
266
+ ## Python code example: inference from this GPTQ model
267
+
268
+ ### Install the necessary packages
269
+
270
+ Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
271
+
272
+ ```shell
273
+ pip3 install --upgrade transformers optimum
274
+ # If using PyTorch 2.1 + CUDA 12.x:
275
+ pip3 install --upgrade auto-gptq
276
+ # or, if using PyTorch 2.1 + CUDA 11.x:
277
+ pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
278
+ ```
279
+
280
+ If you are using PyTorch 2.0, you will need to install AutoGPTQ from source. Likewise if you have problems with the pre-built wheels, you should try building from source:
281
+
282
+ ```shell
283
+ pip3 uninstall -y auto-gptq
284
+ git clone https://github.com/PanQiWei/AutoGPTQ
285
+ cd AutoGPTQ
286
+ git checkout v0.5.1
287
+ pip3 install .
288
+ ```
289
+
290
+ ### Example Python code
291
+
292
+ ```python
293
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
294
+
295
+ model_name_or_path = "TheBloke/Llama-2-7B-ft-instruct-es-GPTQ"
296
+ # To use a different branch, change revision
297
+ # For example: revision="gptq-4bit-32g-actorder_True"
298
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
299
+ device_map="auto",
300
+ trust_remote_code=False,
301
+ revision="main")
302
+
303
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
304
+
305
+ prompt = "Write a story about llamas"
306
+ system_message = "You are a story writing assistant"
307
+ prompt_template=f'''A continuación hay una instrucción que describe una tarea. Escriba una respuesta que complete adecuadamente la solicitud.
308
+ ### Instrucción:
309
+ {prompt}
310
+
311
+ ### Respuesta:
312
+ '''
313
+
314
+ print("\n\n*** Generate:")
315
+
316
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
317
+ output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
318
+ print(tokenizer.decode(output[0]))
319
+
320
+ # Inference can also be done using transformers' pipeline
321
+
322
+ print("*** Pipeline:")
323
+ pipe = pipeline(
324
+ "text-generation",
325
+ model=model,
326
+ tokenizer=tokenizer,
327
+ max_new_tokens=512,
328
+ do_sample=True,
329
+ temperature=0.7,
330
+ top_p=0.95,
331
+ top_k=40,
332
+ repetition_penalty=1.1
333
+ )
334
+
335
+ print(pipe(prompt_template)[0]['generated_text'])
336
+ ```
337
+ <!-- README_GPTQ.md-use-from-python end -->
338
+
339
+ <!-- README_GPTQ.md-compatibility start -->
340
+ ## Compatibility
341
+
342
+ The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
343
+
344
+ [ExLlama](https://github.com/turboderp/exllama) is compatible with Llama architecture models (including Mistral, Yi, DeepSeek, SOLAR, etc) in 4-bit. Please see the Provided Files table above for per-file compatibility.
345
+
346
+ For a list of clients/servers, please see "Known compatible clients / servers", above.
347
+ <!-- README_GPTQ.md-compatibility end -->
348
+
349
+ <!-- footer start -->
350
+ <!-- 200823 -->
351
+ ## Discord
352
+
353
+ For further support, and discussions on these models and AI in general, join us at:
354
+
355
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
356
+
357
+ ## Thanks, and how to contribute
358
+
359
+ Thanks to the [chirper.ai](https://chirper.ai) team!
360
+
361
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
362
+
363
+ 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.
364
+
365
+ 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.
366
+
367
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
368
+
369
+ * Patreon: https://patreon.com/TheBlokeAI
370
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
371
+
372
+ **Special thanks to**: Aemon Algiz.
373
+
374
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
375
+
376
+
377
+ Thank you to all my generous patrons and donaters!
378
+
379
+ And thank you again to a16z for their generous grant.
380
+
381
+ <!-- footer end -->
382
+
383
+ # Original model card: CliBrAIn's Llama 2 7B FT Instruct ES
384
+
385
+
386
+ # Llama-2-7B-ft-instruct-es
387
+
388
+ [Llama 2 (7B)](https://huggingface.co/meta-llama/Llama-2-7b) fine-tuned on [Clibrain](https://huggingface.co/clibrain)'s Spanish instructions dataset.
389
+
390
+
391
+ ## Model Details
392
+
393
+ Llama 2 is a collection of pre-trained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B pre-trained model. Links to other models can be found in the index at the bottom.
394
+
395
+
396
+ ## Example of Usage
397
+
398
+ ```py
399
+ import torch
400
+ from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
401
+
402
+ model_id = "clibrain/Llama-2-7b-ft-instruct-es"
403
+
404
+ model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True).to("cuda")
405
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
406
+
407
+ def create_instruction(instruction, input_data=None, context=None):
408
+ sections = {
409
+ "Instrucción": instruction,
410
+ "Entrada": input_data,
411
+ "Contexto": context,
412
+ }
413
+
414
+ system_prompt = "A continuación hay una instrucción que describe una tarea, junto con una entrada que proporciona más contexto. Escriba una respuesta que complete adecuadamente la solicitud.\n\n"
415
+ prompt = system_prompt
416
+
417
+ for title, content in sections.items():
418
+ if content is not None:
419
+ prompt += f"### {title}:\n{content}\n\n"
420
+
421
+ prompt += "### Respuesta:\n"
422
+
423
+ return prompt
424
+
425
+
426
+ def generate(
427
+ instruction,
428
+ input=None,
429
+ context=None,
430
+ max_new_tokens=128,
431
+ temperature=0.1,
432
+ top_p=0.75,
433
+ top_k=40,
434
+ num_beams=4,
435
+ **kwargs
436
+ ):
437
+
438
+ prompt = create_instruction(instruction, input, context)
439
+ print(prompt.replace("### Respuesta:\n", ""))
440
+ inputs = tokenizer(prompt, return_tensors="pt")
441
+ input_ids = inputs["input_ids"].to("cuda")
442
+ attention_mask = inputs["attention_mask"].to("cuda")
443
+ generation_config = GenerationConfig(
444
+ temperature=temperature,
445
+ top_p=top_p,
446
+ top_k=top_k,
447
+ num_beams=num_beams,
448
+ **kwargs,
449
+ )
450
+ with torch.no_grad():
451
+ generation_output = model.generate(
452
+ input_ids=input_ids,
453
+ attention_mask=attention_mask,
454
+ generation_config=generation_config,
455
+ return_dict_in_generate=True,
456
+ output_scores=True,
457
+ max_new_tokens=max_new_tokens,
458
+ early_stopping=True
459
+ )
460
+ s = generation_output.sequences[0]
461
+ output = tokenizer.decode(s)
462
+ return output.split("### Respuesta:")[1].lstrip("\n")
463
+
464
+ instruction = "Dame una lista de lugares a visitar en España."
465
+ print(generate(instruction))
466
+ ```
467
+ ## Example of Usage with `pipelines`
468
+
469
+ ```py
470
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
471
+
472
+ model_id = "clibrain/Llama-2-7b-ft-instruct-es"
473
+
474
+ model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True).to("cuda")
475
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
476
+
477
+ pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200, device=0)
478
+
479
+ prompt = """
480
+ A continuación hay una instrucción que describe una tarea. Escriba una respuesta que complete adecuadamente la solicitud.
481
+ ### Instrucción:
482
+ Dame una lista de 5 lugares a visitar en España.
483
+
484
+ ### Respuesta:
485
+ """
486
+
487
+ result = pipe(prompt)
488
+ print(result[0]['generated_text'])
489
+ ```