Skip to content

Implementing QLoRA and best-model checkpointing (2 issues) #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dcrey7
Copy link
Contributor

@dcrey7 dcrey7 commented Jul 10, 2025

🚀 Key Feature 1: QLoRA for Efficient Fine-Tuning

  • 4-bit Quantization: The training script now loads the base model in 4-bit precision using the bitsandbytes library.
  • Low-Rank Adaptation (LoRA): A PEFT adapter is applied to the quantized model. This freezes the 4-billion base parameters and trains only a tiny fraction of new parameters (~0.47%).
  • Benefit: This dramatically reduces the VRAM requirement from >16GB to ~5-6GB, making it possible to fine-tune this model on a wide range of consumer and prosumer GPUs.

💾 Key Feature 2: Best-Model Checkpointing

  • Validation Loop: The script now runs a validation loop at the end of each epoch to calculate the validation loss.
  • Save on Improvement: A checkpoint of the trained LoRA adapter is saved to disk only when the validation loss is lower than the previous best.
  • Benefit: This ensures that the final saved artifact is the best-performing version of the model from the entire training run, not just the last one.

📈 Other Improvements:

  • Robust Data Loading: The get_dataloaders function has been improved with more robust error handling.
  • Cleaned .gitignore: The wandb/ directory has been added to .gitignore to prevent local log files from being committed.
  • Enhanced Code Comments: The code in config.py and train.py has been commented to make it easier for future users to switch between test runs and full training sessions.

was able to run it on google colab - https://colab.research.google.com/drive/1H4cLS-HotsaS_40Bfo_7d_fZVwqBcrLW#scrollTo=yiE6lvpvdmio, i was able to get save the final lora adapters in the output file with best models, will hape to add your own hugging face token here

These changes make the project significantly more practical and user-friendly, especially for those without access to high-end industrial hardware. looking forward to my first commit , feedback is really appreaciated will try my best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant