项目介绍

Reason-Wang/flan-alpaca-lora 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,目前获得 50 个 Star、7 次 Fork。

仓库全名
Reason-Wang/flan-alpaca-lora
Star 数
50
Fork 数
7
未关闭 Issue
3

README 摘要

🍮🦙🤏Flan-Alpaca-LoRA: Instruction Tuning from Humans and Machines with Low-Rank Adaptation This repo trains google/flan-t5 on alpaca dataset with low-rank adaptation training method. It reduces the GPU memory needed and speeds the training. Jun 17, 2023: add a notebook. You can try flan-alpaca-lora with now. May 3, 2023: train flan-t5-xl using alpaca-gpt4 dataset. Apr 13, 2023: train flan-t5-xl using GPTeacher…

完整内容见 GitHub 原始 README 或本页 。

常见问题

flan-alpaca-lora 用什么语言开发?

主要使用 Python 编写,目前有 50 个 Star。

如何获取 flan-alpaca-lora 的源码?

可以直接克隆仓库:git clone https://github.com/Reason-Wang/flan-alpaca-lora.git;安装与运行步骤见仓库 README。

flan-alpaca-lora 最近还在维护吗?

仓库最近一次更新为 2023年6月17日,当前有 3 个未关闭 Issue;Star 数为 50,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

This repository contains the code to train flan t5 with alpaca instructions and low rank adaptation.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
114
价值分
36
活跃状态
活跃

语言占比

Jupyter Notebook
Python

贡献者

README

🍮🦙🤏Flan-Alpaca-LoRA: Instruction Tuning from Humans and Machines with Low-Rank Adaptation

This repo trains google/flan-t5 on alpaca dataset with low-rank adaptation training method. It reduces the GPU memory needed and speeds the training.

Jun 17, 2023: add a notebook. You can try flan-alpaca-lora with Open In Colab now.

May 3, 2023: train flan-t5-xl using alpaca-gpt4 dataset.

Apr 13, 2023: train flan-t5-xl using GPTeacher dataset (Instruct and Roleplay), which seems to perform well.

Apr 5, 2023: train flan-t5-xxl using 8bit quantization. The model can be fitted into a single 3090 GPU. All of the models can be found in huggingface.

model adapter_params data GPU time
flan-alpaca-lora-base 0.9M alpaca cleaned 3090 20mins
flan-alpaca-lora-large 2.4M alpaca cleaned 3090 50mins
flan-alpaca-lora-xl 4.7M alpaca cleaned 3090 2.5hrs
flan-alpaca-lora-xxl 9.4M alpaca cleaned 3090 10hrs
flan-gpteacher-lora-xl 4.7M GPTeacher 3090 80mins
flan-alpaca-gpt4-lora-xl 4.7M alpaca-gpt4 3090 3.25hrs
Dependencies
torch == 1.13.1
transformers == 4.29.1
peft == 0.3.0
bitsandbytes==0.38.1
accelerate==0.19.0

Newest version of these packages should work fine.

Training

The following command finetune Flan-T5-base with only 20 mins on a single 3090 GPU

python train.py \
    --model_name_or_path google/flan-t5-base \
    --data_path ./alpaca_data_cleaned.json \
    --bf16 True \
    --output_dir ./ckpts/ \
    --num_train_epochs 3 \
    --per_device_train_batch_size 8 \
    --gradient_accumulation_steps 8 \
    --evaluation_strategy "no" \
    --save_strategy "no" \
    --learning_rate 5e-4 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 50 \
    --tf32 True

Example usage:

import transformers
from peft import PeftModel

# Where peft_model_id should be the saving directory or huggingface model id
model_name = "google/flan-t5-large"; peft_model_id = "reasonwang/flan-alpaca-lora-large"
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
base_model = transformers.AutoModelForSeq2SeqLM.from_pretrained(model_name)
peft_model = PeftModel.from_pretrained(base_model, peft_model_id)

# Input an instruction or any other questions.
inputs = tokenizer("List a few tips to get good scores in math.", return_tensors="pt")
outputs = peft_model.generate(**inputs, max_length=128, do_sample=True)
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))

评论

暂无评论