andrijdavid commited on
Commit
3cd6ee7
1 Parent(s): 065f1c9

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +261 -0
README.md ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ ---
4
+ language:
5
+ - fr
6
+ - en
7
+ license: apache-2.0
8
+ library_name: transformers
9
+ tags:
10
+ - llama3
11
+ - french
12
+ - llama-3-8B
13
+ - GGUF
14
+ datasets:
15
+ - jpacifico/French-Alpaca-dataset-Instruct-110K
16
+ quantized_by: andrijdavid
17
+ ---
18
+ # French-Alpaca-Llama3-8B-Instruct-v1.0-GGUF
19
+ - Original model: [French-Alpaca-Llama3-8B-Instruct-v1.0](https://huggingface.co/jpacifico/French-Alpaca-Llama3-8B-Instruct-v1.0)
20
+
21
+ <!-- description start -->
22
+ ## Description
23
+
24
+ This repo contains GGUF format model files for [French-Alpaca-Llama3-8B-Instruct-v1.0](https://huggingface.co/jpacifico/French-Alpaca-Llama3-8B-Instruct-v1.0).
25
+
26
+ <!-- description end -->
27
+ <!-- README_GGUF.md-about-gguf start -->
28
+ ### About GGUF
29
+ 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.
30
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
31
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). This is the source project for GGUF, providing both a Command Line Interface (CLI) and a server option.
32
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), Known as the most widely used web UI, this project boasts numerous features and powerful extensions, and supports GPU acceleration.
33
+ * [Ollama](https://github.com/jmorganca/ollama) Ollama is a lightweight and extensible framework designed for building and running language models locally. It features a simple API for creating, managing, and executing models, along with a library of pre-built models for use in various applications​
34
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), A comprehensive web UI offering GPU acceleration across all platforms and architectures, particularly renowned for storytelling.
35
+ * [GPT4All](https://gpt4all.io), This is a free and open source GUI that runs locally, supporting Windows, Linux, and macOS with full GPU acceleration.
36
+ * [LM Studio](https://lmstudio.ai/) An intuitive and powerful local GUI for Windows and macOS (Silicon), featuring GPU acceleration.
37
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui). A notable web UI with a variety of unique features, including a comprehensive model library for easy model selection.
38
+ * [Faraday.dev](https://faraday.dev/), An attractive, user-friendly character-based chat GUI for Windows and macOS (both Silicon and Intel), also offering GPU acceleration.
39
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), A Python library equipped with GPU acceleration, LangChain support, and an OpenAI-compatible API server.
40
+ * [candle](https://github.com/huggingface/candle), A Rust-based ML framework focusing on performance, including GPU support, and designed for ease of use.
41
+ * [ctransformers](https://github.com/marella/ctransformers), A Python library featuring GPU acceleration, LangChain support, and an OpenAI-compatible AI server.
42
+ * [localGPT](https://github.com/PromtEngineer/localGPT) An open-source initiative enabling private conversations with documents.
43
+ <!-- README_GGUF.md-about-gguf end -->
44
+
45
+ <!-- compatibility_gguf start -->
46
+ ## Explanation of quantisation methods
47
+ <details>
48
+ <summary>Click to see details</summary>
49
+ The new methods available are:
50
+
51
+ * 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)
52
+ * 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.
53
+ * 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.
54
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
55
+ * 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.
56
+ </details>
57
+ <!-- compatibility_gguf end -->
58
+
59
+ <!-- README_GGUF.md-how-to-download start -->
60
+ ## How to download GGUF files
61
+
62
+ **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 folder.
63
+
64
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
65
+
66
+ * LM Studio
67
+ * LoLLMS Web UI
68
+ * Faraday.dev
69
+
70
+ ### In `text-generation-webui`
71
+
72
+ Under Download Model, you can enter the model repo: LiteLLMs/French-Alpaca-Llama3-8B-Instruct-v1.0-GGUF and below it, a specific filename to download, such as: Q4_0/Q4_0-00001-of-00009.gguf.
73
+
74
+ Then click Download.
75
+
76
+ ### On the command line, including multiple files at once
77
+
78
+ I recommend using the `huggingface-hub` Python library:
79
+
80
+ ```shell
81
+ pip3 install huggingface-hub
82
+ ```
83
+
84
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
85
+
86
+ ```shell
87
+ huggingface-cli download LiteLLMs/French-Alpaca-Llama3-8B-Instruct-v1.0-GGUF Q4_0/Q4_0-00001-of-00009.gguf --local-dir . --local-dir-use-symlinks False
88
+ ```
89
+
90
+ <details>
91
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
92
+
93
+ You can also download multiple files at once with a pattern:
94
+
95
+ ```shell
96
+ huggingface-cli download LiteLLMs/French-Alpaca-Llama3-8B-Instruct-v1.0-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
97
+ ```
98
+
99
+ 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).
100
+
101
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
102
+
103
+ ```shell
104
+ pip3 install huggingface_hub[hf_transfer]
105
+ ```
106
+
107
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
108
+
109
+ ```shell
110
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download LiteLLMs/French-Alpaca-Llama3-8B-Instruct-v1.0-GGUF Q4_0/Q4_0-00001-of-00009.gguf --local-dir . --local-dir-use-symlinks False
111
+ ```
112
+
113
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
114
+ </details>
115
+ <!-- README_GGUF.md-how-to-download end -->
116
+ <!-- README_GGUF.md-how-to-run start -->
117
+ ## Example `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 Q4_0/Q4_0-00001-of-00009.gguf --color -c 8192 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<PROMPT>"
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 8192` 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
+ ## How to run 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%E2%80%90%20Model%20Tab.md#llamacpp).
136
+
137
+ ## How to run 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
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
163
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
164
+ pip install llama-cpp-python
165
+ ```
166
+
167
+ #### Simple llama-cpp-python example code
168
+
169
+ ```python
170
+ from llama_cpp import Llama
171
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
172
+ llm = Llama(
173
+ model_path="./Q4_0/Q4_0-00001-of-00009.gguf", # Download the model file first
174
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
175
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
176
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
177
+ )
178
+ # Simple inference example
179
+ output = llm(
180
+ "<PROMPT>", # Prompt
181
+ max_tokens=512, # Generate up to 512 tokens
182
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
183
+ echo=True # Whether to echo the prompt
184
+ )
185
+ # Chat Completion API
186
+ llm = Llama(model_path="./Q4_0/Q4_0-00001-of-00009.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
187
+ llm.create_chat_completion(
188
+ messages = [
189
+ {"role": "system", "content": "You are a story writing assistant."},
190
+ {
191
+ "role": "user",
192
+ "content": "Write a story about llamas."
193
+ }
194
+ ]
195
+ )
196
+ ```
197
+
198
+ ## How to use with LangChain
199
+
200
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
201
+
202
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
203
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
204
+
205
+ <!-- README_GGUF.md-how-to-run end -->
206
+
207
+ <!-- footer end -->
208
+
209
+ <!-- original-model-card start -->
210
+ # Original model card: French-Alpaca-Llama3-8B-Instruct-v1.0
211
+
212
+
213
+ ## Model Card for Model ID
214
+
215
+ French-Alpaca based on Llama3-8B-Instruct
216
+
217
+ ![image/jpeg](https://github.com/jpacifico/French-Alpaca/blob/main/Assets/French-Alpaca_500px.png?raw=true)
218
+
219
+ ### Model Description
220
+
221
+ fine-tuned from the original French-Alpaca-dataset entirely generated with OpenAI GPT-3.5-turbo.
222
+ French-Alpaca is a general model and can itself be finetuned to be specialized for specific use cases.
223
+
224
+ The fine-tuning method is inspired from https://crfm.stanford.edu/2023/03/13/alpaca.html
225
+
226
+ Quantized Q4_K_M GGUF 4bits version available : jpacifico/french-alpaca-llama3-8B-Q4-GGUF
227
+
228
+ ### Usage
229
+
230
+ ```python
231
+
232
+ model_id = "jpacifico/French-Alpaca-Llama3-8B-Instruct-v1.0"
233
+ model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map={"":0})
234
+ tokenizer = AutoTokenizer.from_pretrained(model_id, add_eos_token=True, padding_side='left')
235
+ streamer = TextStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
236
+
237
+ def stream_frenchalpaca(user_prompt):
238
+ runtimeFlag = "cuda:0"
239
+ system_prompt = 'Tu trouveras ci-dessous une instruction qui décrit une tâche. Rédige une réponse qui complète de manière appropriée la demande.\n\n'
240
+ B_INST, E_INST = "### Instruction:\n", "### Response:\n"
241
+ prompt = f"{system_prompt}{B_INST}{user_prompt.strip()}\n\n{E_INST}"
242
+ inputs = tokenizer([prompt], return_tensors="pt").to(runtimeFlag)
243
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
244
+ _ = model.generate(**inputs, streamer=streamer, max_new_tokens=500)
245
+
246
+ stream_frenchalpaca("your prompt here")
247
+ ```
248
+ Colab notebook available on my Github :
249
+ https://github.com/jpacifico/French-Alpaca/blob/main/French_Alpaca_Llama3_inference_test_colab.ipynb
250
+
251
+ ### Limitations
252
+
253
+ The French-Alpaca model is a quick demonstration that a base 8B model can be easily fine-tuned to specialize in a particular language.
254
+ It does not have any moderation mechanisms.
255
+
256
+ - **Developed by:** Jonathan Pacifico, 2024
257
+ - **Model type:** LLM
258
+ - **Language(s) (NLP):** French
259
+ - **License:** MIT
260
+
261
+ <!-- original-model-card end -->