Deep Learning Spring 2025: Finetuning with LoRA Parameter. Efficient Finetuning of LLMs with Low-Rank Adaption (LoRA) for News Data
This project explores Low-Rank Adaptation (LoRA) for parameter-efficient fine-tuning of large language models using Hugging Face's transformers and peft libraries. The notebook provides a complete pipeline for adapting a base model (such as GPT or LLaMA) using minimal additional parameters while preserving efficiency and performance.
- Understand and apply the LoRA technique for efficient fine-tuning
- Leverage Hugging Face's
peftandtransformerslibraries - Load a pre-trained language model and apply LoRA adaptation
- Train on a sample dataset
- Save and test the adapted model
├── Final_LoRaFits_Project_2.ipynb # Main notebook with code and explanation
├── Final_submission.csv # csv file with output on test dataet submitted to kaggle
├── README.md # Project description (this file)
Install the following Python libraries:
pip install transformers datasets peft accelerate
How to Run
-
Clone this repository or download the .ipynb file.
-
Install the dependencies listed above.
-
Open the notebook in Jupyter Notebook or JupyterLab:
jupyter notebook Final_LoRaFits_Project_2.ipynb
- Follow each cell sequentially to:
• Load the base model
• Apply LoRA
• Prepare dataset
• Train the model
• Evaluate results
===== MODEL CONFIGURATION SUMMARY ===== Model architecture: RoBERTa with LoRA adapter
LoRA rank (r): 16
LoRA alpha: 32
Target modules: {'query', 'value', 'key'}
Total trainable parameters: 884,736
Validation accuracy: 0.9376
Test accuracy: 0.9404