Giter Club home page Giter Club logo

llama3_finetuning's Introduction

LLama3 Finetuning

The purpose of this repository is to understand the finetuning process of Llama-3 Large Language Model

How to read this repository?

.
├── LICENSE
├── README.md
├── config.py
├── dataset.py
├── inference.py
├── llama_model.py
├── peft_model.py
├── prompts.py
├── requirements.txt
├── train.py

Install PyPi Libraries

pip install -r requirements.txt

Dataset

About Dataset

Download Dataset

from datasets import load_dataset
dataset = load_dataset("yahma/alpaca-cleaned")

Refer dataset.py for converting the training dataset into the Alpaca format for fine-tuning.

Alpaca Example

"instruction": "Calculate the area of the following shape in square centimeters.",
"input": "rectangle of size 4 cm x 5 cm",
"output": ""
"instruction": "Create a graphic or logo that visually represents the word \"courage\".",
"input": "",
"output": "<No Output>"

Model Finetuning

Llama3_Finetuning_Architecture

🔍 Quantize the Llama3 8B large Language Model to 16-bit model. This technique reduces the memory and computation requirements of the Neural Network layer by representing the weights and activations in only 4 bits. Refer quantization_utils.py

🧠 Identify the Layers that require weight updates and freeze the rest during fine-tuning. Managing the layers this way will allow the crucial layers to adapt to the new domain-specific data, while preserving the rest of the parameters of the pre-trained model.

The layer names can be identified by printing the Architecture of the model

Inferencing

Llama3_Inferencing

🔍 Extract the Adapter from the Fine-tuned Quantized model. This Adapter encapsulates the refined parameters tailored to the domain-sepcific data.

🧩 Integrate the Adapter with the original Pre-Trained Llama-3 Large Language Model. This fusion enables the Language Model with the domain knowledge acquired during the fine-tuning process.

💬 User provides the prompt to the Langauage Model for interaction

🚀 The Language Model generates the response for the provided Prompt.

llama3_finetuning's People

Contributors

bala1802 avatar

Watchers

 avatar Kostas Georgiou 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.