Code Monkey home page Code Monkey logo

llm-tuning's Introduction

This package is to provide a codebase to easily fine-tune some open-source LLMs and reproduce the results.

So far, the codebase supports

For detailed instruction, please refer to the Notion site: LLM Fine-tuning


A Simple Example

Here is a simple example of using the package for fine-tuning or prediction on the SST2 dataset. You can also find this demo code in demo.py.

import fire

from lora import Llama_Lora


def main(
    task: str = "eval",
	base_model: str = "meta-llama/Llama-2-7b-hf",
):
    m = Llama_Lora(
        base_model=base_model,
    )
    if task == "train":
        m.train(
            train_file = "data/sst2/train.json",
            val_file = "data/sst2/val.json",
            output_dir = "./ckp_sst_llama2_lora",
            train_batch_size = 32,
            num_epochs = 1,
        )
    elif task == "eval":
        m.predict(
            input_file = "data/sst2/val.json",
            max_new_tokens = 32,
            verbose = True,
        )
    else:
        raise ValueError(f"Unrecognized task: {task}")


if __name__ == "__main__":
    fire.Fire(main)

For prediction, please use

python demo.py

For fine-tuning, please use

python demo.py --task train

Contributors

In addition, this package has been tested by many members from the UVA ILP group via their research projects.

This project was inspired by the Alpaca-LoRA project, from which we learned a lot!

llm-tuning's People

Contributors

jiyfeng avatar uvanlp avatar

Stargazers

Shreyas Jaiswal avatar Tongxuan Tian avatar Seongkook avatar Chang Lou avatar

Watchers

 avatar Kostas Georgiou avatar  avatar

Forkers

vivian2ski

llm-tuning's Issues

cannot import name 'prepare_model_for_int8_training' from 'peft'

prepare_model_for_int8_training is deprecated in the new version peft. I think we should change the code to be
self.model = prepare_model_for_kbit_training(self.model) on line 128, in llm_lora.py, and also change the import statement to be
from peft import ( LoraConfig, PeftModel, get_peft_model, get_peft_model_state_dict, prepare_model_for_kbit_training, set_peft_model_state_dict )

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.