Giter Club home page Giter Club logo

finetune-quantize-llms's Introduction

How to fine-tune and quantize an LLM with Google Colab easily?

MIT License Open In Colab (vi)

Introduction

This repository contains materials for the CSE Summer School Hackathon 2024, aimed at guiding high school students on how to fine-tune and quantize large language models (LLMs) with Google Colab in the simplest way possible. It minimizes the need for coding and requires only minor adjustments to pre-designed functions.

Key information:

  • Fine-tuning the model with LLaMA Factory.
  • Quantizing the model with Unsloth.
  • The model being fine-tuned in the notebook is GemSUra 2B.
  • The type of fine-tuning fixed in the notebook is LoRA using SFT with sample data from HCMUT_FAQ. Students are guided on how to create their own data based on the competition theme.
  • The quantization method in the notebook is 8-bit, enabling students to deploy the model on personal computers using Ollama.

Notebook usage guide

Install required packages

!pip install --upgrade -r requirements.txt -q

from module import *

Log in to Hugging Face

hf("HF_TOKEN")

Load dataset

hcmut_dataset = load_dataset("IAmSkyDra/HCMUT_FAQ", split="train", streaming=False)

identity_dataset = load_dataset("IAmSkyDra/HCMUT_FAQ", split="validation", streaming=False)

Train the model

train([identity_dataset, hcmut_dataset], num_train_epochs, continue_training)

Evaluate the fine-tuned model

test()

Merge LoRA adapters with the model and upload to Hugging Face

merge_and_push("IAmSkyDra/GemSUra-edu")

Model inference

inference("IAmSkyDra/GemSUra-edu")

chat(max_new_tokens, history)

Quantize the model and upload to Hugging Face

quantize_and_push("IAmSkyDra/GemSUra-edu-quantized")

Detailed explanations of each function and their arguments, as well as other information, are provided in the notebook.

Conclusion

By the end of this notebook, students will have a fine-tuned model tailored with custom data based on the pre-trained GemSUra 2B model, along with its quantized version.

finetune-quantize-llms's People

Contributors

iamskydra avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.