LoRAfrica: Scaling LLM Fine Tuning for African History
# **LoRAfrica: Scaling LLM Fine Tuning for African History**
## **Aim**
Fine tune Phi-4-mini-instruct model using LoRA on the consolidated African History Dataset
## **Objectives**
- Fine tune model using LoRA
- Fine tune model using LoRA with Deep Speed stage-2
- Fine tune model using LoRA with Axolotl
- Fine tune model using LoRA with Deep Speed stage-2 via Axolotl
- Compare metrics of baseline model with fine-tuned models
## **How the Project Goes**
- Create your accounts on Weights and Biases, Huggingface and Runpod.
- Create your access tokens on Weights and Biases & Huggingface (you will need read and write token previlages on Huggingface)
- An A40 pod instance created on Runpod. Refer to this video to learn on to create a Pod instance
- Once instance is created, clone project into runpod workspace environment using `git clone
github.com` or just drag and drop each file/folder
Once all files and folders are in the environment, the requirements file must be installed by running `pip install -r requirements.txt`
### **Data**
- Using Google Colab, the dataset was created and pushed to Huggingface; check `data` folder for the notebook.
### **Baseline**
- Using Google Colab, the baseline bert score and benchmark (tinyMMLU & tinyTruthfulQA) were recorded and pushed to Weights & Biases; check `baseline` folder
### **Fine tuning and benchmarking without Axolotl**
Once `requirements.txt` is installed, navigate to the project `lora` folder.
- `lora_fine_tuning.ipynb` is the fine tuning file for lora
- `lora_benchmark.ipynb` is the lora benchmark file
- `deep_speed_2_lora.py` is the lora fine tuning file using deep speed with the config `ds_config_2.json`. To run this file use `accelerate launch deep_speed_2_lora.py`
- `eval_deep_speed_2_lora.py` is the deep speed lora evaluation file. To run this file use `python eval_deep_speed_2_lora.py`
- `deep_speed2_lora_benchmark.ipynb` is the deep speed lora benchmark file
### **Fine tuning …