Omid-sar commited on
Commit
ed25397
·
1 Parent(s): 7987642
Files changed (1) hide show
  1. README.md +66 -0
README.md CHANGED
@@ -33,3 +33,69 @@ The following `bitsandbytes` quantization config was used during training:
33
  - PEFT 0.5.0
34
 
35
  - PEFT 0.5.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  - PEFT 0.5.0
34
 
35
  - PEFT 0.5.0
36
+
37
+ - # Fine-Tuning Llama2-7b (Ludwig) for Code Generation
38
+
39
+ ## Goal
40
+
41
+ The goal of this project is to fine-tune the Llama2-7b language model for code generation using the QLORA method. The model will take natural language as input, and should return code as output. We're first going to iterate on a base Llama-2-7b model with prompting, and finally instruction-fine-tune the model.
42
+
43
+ As an example, if we prompt the model with this instruction:
44
+
45
+ ```
46
+ Instruction: Create an array of length 5 which contains all even numbers between 1 and 10.
47
+ ```
48
+
49
+ We want the model to produce exactly this response:
50
+
51
+ ```
52
+ Response: array = [2, 4, 6, 8, 10]
53
+ ```
54
+
55
+ ## QLORA Method for Fine-Tuning
56
+
57
+ The QLORA method for fine-tuning large language models (LLMs) is a parameter-efficient approach that uses 4-bit quantization to reduce the memory and computational requirements of fine-tuning. QLORA is implemented in the PEFT library, which is built on top of the Hugging Face Transformers library.
58
+
59
+ ## Ludwig Data Format
60
+
61
+ Ludwig requires data to be in a specific format. The main components of the data format are:
62
+
63
+ - `input_features`: Defines the input features of the model. Each feature must have a `name` and `type`.
64
+ - `output_features`: Defines the output features of the model. Similar to input features, each output feature must have a `name` and `type`.
65
+
66
+ Here is an example of a simple Ludwig config:
67
+
68
+ ```yaml
69
+ input_features:
70
+ - name: instruction
71
+ type: text
72
+ output_features:
73
+ - name: output
74
+ type: text
75
+ ```
76
+
77
+ This config tells Ludwig to use the column called `instruction` in the dataset as an input feature and the `output` column as an output feature.
78
+
79
+ ## Prerequisites
80
+
81
+ - Python 3.x
82
+ - Ludwig
83
+ - GPU (recommended for faster training)
84
+
85
+ ## Setup and Installation
86
+
87
+ 1. Clone the repository:
88
+ ```sh
89
+ git clone https://github.com/omid-sar/Llama2-7B-Fine-Tuning--Google-Colab-.git
90
+ ```
91
+ 2. Open the notebook `Fine_Tuning_Llama2_7b(_Ludwig).ipynb` in Google Colab or a local Jupyter environment.
92
+ 3. Install the required libraries:
93
+ ```sh
94
+ pip install ludwig
95
+ ```
96
+ 4. Follow the instructions in the notebook to download any additional datasets or models.
97
+
98
+ ## Usage
99
+
100
+ 1. Run the cells in the notebook sequentially, following the instructions and comments provided.
101
+ 2. Modify the model configuration, training parameters, or input data as needed to suit your use case.