Text Generation
PEFT
Arabic
Ali-C137 commited on
Commit
7971f19
โ€ข
1 Parent(s): 642bd31

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +87 -0
  2. adapter_config.json +19 -0
  3. adapter_model.bin +3 -0
README.md CHANGED
@@ -1,3 +1,90 @@
1
  ---
 
2
  license: apache-2.0
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ library_name: peft
3
  license: apache-2.0
4
+ datasets:
5
+ - Yasbok/Alpaca_arabic_instruct
6
+ language:
7
+ - ar
8
+ pipeline_tag: text-generation
9
  ---
10
+
11
+ # ๐Ÿš€ Falcon-7b-QLoRA-alpaca-arabic
12
+ This repo contains a low-rank adapter for Falcon-7b fit on the Stanford Alpaca dataset Arabic version [Yasbok/Alpaca_arabic_instruct](https://huggingface.co/datasets/Yasbok/Alpaca_arabic_instruct).
13
+
14
+ ## Model Summary
15
+
16
+ - **Model Type:** Causal decoder-only
17
+ - **Language(s):** Arabic
18
+ - **Base Model:** [Falcon-7B](https://huggingface.co/tiiuae/falcon-7b) (License: [Apache 2.0](https://huggingface.co/tiiuae/falcon-7b#license))
19
+ - **Dataset:** [Yasbok/Alpaca_arabic_instruct](https://huggingface.co/datasets/Yasbok/Alpaca_arabic_instruct)
20
+ - **License(s):** Apache 2.0 inherited from "Base Model"
21
+
22
+ ## Model Details
23
+
24
+ The model was fine-tuned in 8-bit precision using ๐Ÿค— `peft` adapters, `transformers`, and `bitsandbytes`. Training relied on a method called QLoRA introduced in this [paper](https://arxiv.org/abs/2305.14314). The run took approximately 3 hours and was executed on a workstation with a single A100-SXM NVIDIA GPU with 37 GB of available memory.
25
+
26
+ ### Model Date
27
+
28
+ June 10, 2023
29
+
30
+ ### Recommendations
31
+
32
+ We recommend users of this model to develop guardrails and to take appropriate precautions for any production use.
33
+
34
+ ## How to Get Started with the Model
35
+
36
+ ### Setup
37
+ ```python
38
+ # Install packages
39
+ !pip install -q -U bitsandbytes loralib einops
40
+ !pip install -q -U git+https://github.com/huggingface/transformers.git
41
+ !pip install -q -U git+https://github.com/huggingface/peft.git
42
+ !pip install -q -U git+https://github.com/huggingface/accelerate.git
43
+ ```
44
+
45
+ ### GPU Inference in 8-bit
46
+
47
+ This requires a GPU with at least 12 GB of memory.
48
+
49
+ ### First, Load the Model
50
+
51
+ ```python
52
+ import torch
53
+ from peft import PeftModel, PeftConfig
54
+ from transformers import AutoModelForCausalLM, AutoTokenizer
55
+
56
+ # load the model
57
+ peft_model_id = "Ali-C137/falcon-7b-chat-alpaca-arabic"
58
+ config = PeftConfig.from_pretrained(peft_model_id)
59
+
60
+ model = AutoModelForCausalLM.from_pretrained(
61
+ config.base_model_name_or_path,
62
+ return_dict=True,
63
+ device_map={"":0},
64
+ trust_remote_code=True,
65
+ load_in_8bit=True,
66
+ )
67
+
68
+ tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
69
+ tokenizer.pad_token = tokenizer.eos_token
70
+
71
+ model = PeftModel.from_pretrained(model, peft_model_id)
72
+ ```
73
+
74
+ ### CUDA Info
75
+
76
+ - CUDA Version: 12.0
77
+ - Hardware: 1 A100-SXM
78
+ - Max Memory: {0: "37GB"}
79
+ - Device Map: {"": 0}
80
+
81
+ ### Package Versions Employed
82
+
83
+ - `torch`: 2.0.1+cu118
84
+ - `transformers`: 4.30.0.dev0
85
+ - `peft`: 0.4.0.dev0
86
+ - `accelerate`: 0.19.0
87
+ - `bitsandbytes`: 0.39.0
88
+ - `einops`: 0.6.1
89
+
90
+ ### This work is highly inspired from Daniel Furman's work, so Thanks a lot Daniel
adapter_config.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "base_model_name_or_path": "tiiuae/falcon-7b",
3
+ "bias": "none",
4
+ "fan_in_fan_out": false,
5
+ "inference_mode": true,
6
+ "init_lora_weights": true,
7
+ "layers_pattern": null,
8
+ "layers_to_transform": null,
9
+ "lora_alpha": 32,
10
+ "lora_dropout": 0.05,
11
+ "modules_to_save": null,
12
+ "peft_type": "LORA",
13
+ "r": 16,
14
+ "revision": null,
15
+ "target_modules": [
16
+ "query_key_value"
17
+ ],
18
+ "task_type": "CAUSAL_LM"
19
+ }
adapter_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7dd95ec2bb08a5141047c4da11c868bbb96d871e36d4c619392a808f646a6cd
3
+ size 18898161