diabolic6045 commited on
Commit
19bfff9
·
verified ·
1 Parent(s): 46c144d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +141 -141
README.md CHANGED
@@ -1,142 +1,142 @@
1
- ---
2
- base_model: meta-llama/Llama-3.2-1B
3
- library_name: peft
4
- tags:
5
- - code
6
- - llm
7
- - Evolution_Learning_Network
8
- - qlora
9
- - llama
10
- ---
11
-
12
- # Evolution Learning Network (ELN) with QLoRA and Genetic Algorithms For LLM
13
-
14
- ## Overview
15
-
16
- This project implements an **Evolution Learning Network (ELN)** to fine-tune transformer-based models like LLaMA using a combination of **Quantized Low-Rank Adaptation (QLoRA)** and **Genetic Algorithms (GA)**. The primary objective is to evolve a population of models across multiple generations to optimize for performance (fitness) and specialization, while maintaining diversity.
17
-
18
- ### Key Features
19
- - Efficient model fine-tuning using **QLoRA**.
20
- - Evolutionary strategies, including **random mutations** and fitness-based selection.
21
- - Hardware-efficient training with **4-bit quantization**.
22
- - Comprehensive experiment tracking with **WandB**.
23
- - Diversity maintenance through **LoRA weight fingerprinting**.
24
-
25
- ---
26
-
27
- ## Model Details
28
-
29
- ### Base Model
30
- - **Name**: [meta-llama/Llama-3.2-1B](https://huggingface.co/meta-llama/Llama-3.2-1B) (can be replaced with any Hugging Face model).
31
- - **Architecture**: Transformer-based causal language model.
32
-
33
- ### Quantization Configuration
34
- - **Quantization Type**: 4-bit using `bitsandbytes` (`bnb_4bit`).
35
- - **Parameters**:
36
- - Compute Type: `torch.float16`
37
- - Quantization Type: `"nf4"` (Nonlinear quantization).
38
- - Double Quantization: Enabled.
39
- - Nested Quantization: Enabled.
40
-
41
- ### LoRA (Low-Rank Adaptation)
42
- - **Dimensions (r)**: 8
43
- - **Alpha (Scaling)**: 16
44
- - **Target Modules**: Query and Value projections (`q_proj`, `v_proj`).
45
- - **Dropout**: 0.05
46
- - **Task Type**: Causal Language Modeling (`CAUSAL_LM`).
47
-
48
- ### Training Strategy
49
- - **Optimizer**: `paged_adamw_8bit` for memory-efficient updates.
50
- - **Precision**: Mixed precision (`fp16`) for faster training.
51
-
52
- ---
53
-
54
- ## Hyperparameters
55
-
56
- ### General Parameters
57
- - **Generations**: 10
58
- - **Population Size**: 4
59
- - **Dataset Size**: 2000 samples per split (adjustable for larger datasets).
60
-
61
- ### Training
62
- - **Batch Size**: 8
63
- - **Gradient Accumulation**: 16 steps.
64
- - **Learning Rate**: `2e-4`
65
- - **Epochs per Model**: 2
66
-
67
- ### Mutations
68
- - **Mutation Rate**: 10% (probability per parameter).
69
- - **Mutation Scale**: Noise added with a standard deviation of 0.02.
70
-
71
- ---
72
-
73
- ## Dataset Details
74
-
75
- ### Source
76
- - **Name**: WikiText ([wikitext-2-raw-v1](https://huggingface.co/datasets/Salesforce/wikitext/viewer/wikitext-2-raw-v1) for larger datasets).
77
- - **Splits**:
78
- - `train` → Model training.
79
- - `validation` → General task evaluation.
80
- - `test` → Specific task evaluation.
81
-
82
- ### Tokenization
83
- - **Tokenizer**: Hugging Face `AutoTokenizer`.
84
- - **Max Token Length**: 128 tokens.
85
- - **Padding**: Fixed to `"max_length"`.
86
-
87
- ---
88
-
89
- ## Results
90
-
91
- ### Summary
92
- - **Total Generations**: 10
93
- - **Best Fitness Achieved**: 0.4772
94
- - **Final Population Diversity**: 0.0011
95
-
96
- ### Evolution History (Highlights)
97
- | Generation | Best Fitness | Avg Fitness | Diversity | Best Specialization |
98
- |------------|--------------|-------------|-----------|---------------------|
99
- | 1 | 0.4096 | 0.4023 | 0.00097 | 0.9967 |
100
- | 5 | 0.4727 | 0.4722 | 0.00099 | 0.9968 |
101
- | 10 | 0.4772 | 0.4768 | 0.00106 | 0.9972 |
102
-
103
- ---
104
-
105
- ## Hardware & Framework
106
-
107
- ### Hardware
108
- - Multi-GPU support with `torch.nn.parallel.DistributedDataParallel` or `Accelerator`.
109
- - Logs GPU/CPU usage with `psutil` and `torch.cuda`.
110
-
111
- ### Frameworks & Libraries
112
- - **Transformers**: Hugging Face model and tokenizer handling.
113
- - **Datasets**: Data loading and processing.
114
- - **WandB**: Experiment tracking and visualization.
115
- - **BitsAndBytes**: 4-bit quantization.
116
- - **PEFT**: LoRA-based fine-tuning.
117
-
118
- ---
119
-
120
- ## Future Work
121
- - Explore larger population sizes and more generations for enhanced diversity.
122
- - Experiment with other datasets to generalize findings.
123
- - Integrate additional mutation strategies for broader exploration.
124
-
125
- ---
126
-
127
- ## Citation
128
- Remaining
129
-
130
- ---
131
- > Code to run locally
132
-
133
- ```python
134
- from peft import PeftModel
135
- from transformers import AutoModelForCausalLM
136
-
137
- base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
138
- model = PeftModel.from_pretrained(base_model, "diabolic6045/ELN-llama-1B-adapter")
139
- ```
140
- ### Framework versions
141
-
142
  - PEFT 0.14.0
 
1
+ ---
2
+ base_model: meta-llama/Llama-3.2-1B
3
+ library_name: peft
4
+ tags:
5
+ - code
6
+ - llm
7
+ - Evolution_Learning_Network
8
+ - qlora
9
+ - llama
10
+ ---
11
+
12
+ # Evolution Learning Network (ELN) with QLoRA and Genetic Algorithms For LLM
13
+
14
+ ## Overview
15
+
16
+ This project implements an **Evolution Learning Network (ELN)** to fine-tune transformer-based models like LLaMA using a combination of **Quantized Low-Rank Adaptation (QLoRA)** and **Genetic Algorithms (GA)**. The primary objective is to evolve a population of models across multiple generations to optimize for performance (fitness) and specialization, while maintaining diversity.
17
+
18
+ ### Key Features
19
+ - Efficient model fine-tuning using **QLoRA**.
20
+ - Evolutionary strategies, including **random mutations** and fitness-based selection.
21
+ - Hardware-efficient training with **4-bit quantization**.
22
+ - Comprehensive experiment tracking with **WandB**.
23
+ - Diversity maintenance through **LoRA weight fingerprinting**.
24
+
25
+ ---
26
+
27
+ ## Model Details
28
+
29
+ ### Base Model
30
+ - **Name**: [meta-llama/Llama-3.2-1B](https://huggingface.co/meta-llama/Llama-3.2-1B) (can be replaced with any Hugging Face model).
31
+ - **Architecture**: Transformer-based causal language model.
32
+
33
+ ### Quantization Configuration
34
+ - **Quantization Type**: 4-bit using `bitsandbytes` (`bnb_4bit`).
35
+ - **Parameters**:
36
+ - Compute Type: `torch.float16`
37
+ - Quantization Type: `"nf4"` (Nonlinear quantization).
38
+ - Double Quantization: Enabled.
39
+ - Nested Quantization: Enabled.
40
+
41
+ ### LoRA (Low-Rank Adaptation)
42
+ - **Dimensions (r)**: 8
43
+ - **Alpha (Scaling)**: 16
44
+ - **Target Modules**: Query and Value projections (`q_proj`, `v_proj`).
45
+ - **Dropout**: 0.05
46
+ - **Task Type**: Causal Language Modeling (`CAUSAL_LM`).
47
+
48
+ ### Training Strategy
49
+ - **Optimizer**: `paged_adamw_8bit` for memory-efficient updates.
50
+ - **Precision**: Mixed precision (`fp16`) for faster training.
51
+
52
+ ---
53
+
54
+ ## Hyperparameters
55
+
56
+ ### General Parameters
57
+ - **Generations**: 10
58
+ - **Population Size**: 4
59
+ - **Dataset Size**: 2000 samples per split (adjustable for larger datasets).
60
+
61
+ ### Training
62
+ - **Batch Size**: 8
63
+ - **Gradient Accumulation**: 16 steps.
64
+ - **Learning Rate**: `2e-4`
65
+ - **Epochs per Model**: 2
66
+
67
+ ### Mutations
68
+ - **Mutation Rate**: 10% (probability per parameter).
69
+ - **Mutation Scale**: Noise added with a standard deviation of 0.02.
70
+
71
+ ---
72
+
73
+ ## Dataset Details
74
+
75
+ ### Source
76
+ - **Name**: WikiText ([wikitext-2-raw-v1](https://huggingface.co/datasets/Salesforce/wikitext/viewer/wikitext-2-raw-v1) for larger datasets).
77
+ - **Splits**:
78
+ - `train` → Model training.
79
+ - `validation` → General task evaluation.
80
+ - `test` → Specific task evaluation.
81
+
82
+ ### Tokenization
83
+ - **Tokenizer**: Hugging Face `AutoTokenizer`.
84
+ - **Max Token Length**: 128 tokens.
85
+ - **Padding**: Fixed to `"max_length"`.
86
+
87
+ ---
88
+
89
+ ## Results
90
+
91
+ ### Summary
92
+ - **Total Generations**: 10
93
+ - **Best Fitness Achieved**: 0.4772
94
+ - **Final Population Diversity**: 0.0011
95
+
96
+ ### Evolution History (Highlights)
97
+ | Generation | Best Fitness | Avg Fitness | Diversity | Best Specialization |
98
+ |------------|--------------|-------------|-----------|---------------------|
99
+ | 1 | 0.4096 | 0.4023 | 0.00097 | 0.9967 |
100
+ | 5 | 0.4727 | 0.4722 | 0.00099 | 0.9968 |
101
+ | 10 | 0.4772 | 0.4768 | 0.00106 | 0.9972 |
102
+
103
+ ---
104
+
105
+ ## Hardware & Framework
106
+
107
+ ### Hardware
108
+ - Multi-GPU support with `torch.nn.parallel.DistributedDataParallel` or `Accelerator`.
109
+ - Logs GPU/CPU usage with `psutil` and `torch.cuda`.
110
+
111
+ ### Frameworks & Libraries
112
+ - **Transformers**: Hugging Face model and tokenizer handling.
113
+ - **Datasets**: Data loading and processing.
114
+ - **WandB**: Experiment tracking and visualization.
115
+ - **BitsAndBytes**: 4-bit quantization.
116
+ - **PEFT**: LoRA-based fine-tuning.
117
+
118
+ ---
119
+
120
+ ## Future Work
121
+ - Explore larger population sizes and more generations for enhanced diversity.
122
+ - Experiment with other datasets to generalize findings.
123
+ - Integrate additional mutation strategies for broader exploration.
124
+
125
+ ---
126
+
127
+ ## Citation
128
+ Remaining
129
+
130
+ ---
131
+ > Code to run locally
132
+
133
+ ```python
134
+ from peft import PeftModel
135
+ from transformers import AutoModelForCausalLM
136
+
137
+ base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B")
138
+ model = PeftModel.from_pretrained(base_model, "diabolic6045/ELN-AOC-CAIN")
139
+ ```
140
+ ### Framework versions
141
+
142
  - PEFT 0.14.0