• Stars
    star
    286
  • Rank 143,959 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Finetune ALL LLMs with ALL Adapeters on ALL Platforms!

SuperAdapters

Finetune ALL LLMs with ALL Adapeters on ALL Platforms!

Support

Model LoRA QLoRA AdaLoRA Prefix Tuning P-Tuning Prompt Tuning
Bloom
LLaMA
LLaMA2
ChatGLM ☑️ ☑️ ☑️
ChatGLM2 ☑️ ☑️ ☑️
Qwen
Baichuan

You can Finetune LLM on

  • Windows
  • Linux
  • Mac M1/2

You can Handle train / test Data with

  • Terminal
  • File
  • DataBase

You can Do various Task

  • CausalLM (default)
  • SequenceClassification

P.S. Unfortunately, SuperAdapters do not support qlora on Mac, please use lora/adalora instead.

Requirement

CentOS:

yum install -y xz-devel

Ubuntu:

apt-get install -y liblzma-dev

MacOS:

brew install xz

P.S. Maybe you should recompile the python with xz

CPPFLAGS="-I$(brew --prefix xz)/include" pyenv install 3.10.0

If you want to use gpu on Mac, Please read How to use GPU on Mac

pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
pip install -r requirements.txt

LLMs

Model Download Link
Bloom https://huggingface.co/bigscience/bloom-560m
LLaMA https://huggingface.co/openlm-research/open_llama_3b_600bt_preview
LLaMA2 https://huggingface.co/meta-llama/Llama-2-13b-hf
Vicuna https://huggingface.co/lmsys/vicuna-7b-delta-v1.1
ChatGLM https://huggingface.co/THUDM/chatglm-6b
ChatGLM2 https://huggingface.co/THUDM/chatglm2-6b
Qwen https://huggingface.co/Qwen/Qwen-7B-Chat

Finetune Data Format

Here is an example

Usage

ChatGLM with lora

python finetune.py --model_type chatglm --data "data/train/" --model_path "LLMs/chatglm/chatglm-6b/" --adapter "lora" --output_dir "output/chatglm"
python inference.py --model_type chatglm --instruction "Who are you?" --model_path "LLMs/chatglm/chatglm-6b/" --adapter_weights "output/chatglm" --max_new_tokens 32

LLaMa with lora

python finetune.py --model_type llama --data "data/train/" --model_path "LLMs/open-llama/open-llama-3b/" --adapter "lora" --output_dir "output/llama"
python inference.py --model_type llama --instruction "Who are you?" --model_path "LLMs/open-llama/open-llama-3b" --adapter_weights "output/llama" --max_new_tokens 32

Bloom with lora

python finetune.py --model_type bloom --data "data/train/" --model_path "LLMs/bloom/bloomz-560m" --adapter "lora" --output_dir "output/bloom"
python inference.py --model_type bloom --instruction "Who are you?" --model_path "LLMs/bloom/bloomz-560m" --adapter_weights "output/bloom" --max_new_tokens 32

Qwen with lora

python finetune.py --model_type qwen --data "data/train/" --model_path "LLMs/Qwen/Qwen-7b-chat" --adapter "lora" --output_dir "output/Qwen"
python inference.py --model_type qwen --instruction "Who are you?" --model_path "LLMs/Qwen/Qwen-7b-chat" --adapter_weights "output/Qwen" --max_new_tokens 32

Baichuan with lora

python finetune.py --model_type baichuan --data "data/train/" --model_path "LLMs/baichuan/baichuan-7b" --adapter "lora" --output_dir "output/baichuan"
python inference.py --model_type baichuan --instruction "Who are you?" --model_path "LLMs/baichuan/baichuan-7b" --adapter_weights "output/baichuan" --max_new_tokens 32

Use Classify Mode

You need to specify task_type('classify') and labels

python finetune.py --model_type llama --data "data/train/alpaca_tiny_classify.json" --model_path "LLMs/open-llama/open-llama-3b" --adapter "lora" --output_dir "output/llama" --task_type classify --labels '["0", "1"]' --disable_wandb
python inference.py --model_type llama --data "data/train/alpaca_tiny_classify.json" --model_path "LLMs/open-llama/open-llama-3b" --adapter_weights "output/llama" --task_type classify --labels '["0", "1"]' --disable_wandb

Use DataBase

  1. You need to install a MySQL, and put the db config into the system env.

Eg.

export LLM_DB_HOST='127.0.0.1'
export LLM_DB_PORT=3306
export LLM_DB_USERNAME='YOURUSERNAME'
export LLM_DB_PASSWORD='YOURPASSWORD'
export LLM_DB_NAME='YOURDBNAME'
  1. create the necessary tables

Here is the sql files

source xxxx.sql
  • db_iteration: [train/test] The record's set name.
  • db_type: [test] The record is whether "train" or "test".
  • db_test_iteration: [test] The record's test set name.
  1. finetune (use chatglm for example)
python finetune.py --model_type chatglm --fromdb --db_iteration xxxxxx --model_path "LLMs/chatglm/chatglm-6b/" --adapter "lora" --output_dir "output/chatglm" --disable_wandb
  1. eval
python inference.py --model_type chatglm --fromdb --db_iteration xxxxxx --db_type 'test' --db_test_iteration yyyyyyy --model_path "LLMs/chatglm/chatglm-6b/" --adapter_weights "output/chatglm" --max_new_tokens 6

Params

Finetune

usage: finetune.py [-h] [--data DATA] [--model_type {llama,llama2,chatglm,chatglm2,bloom,qwen,baichuan}] [--task_type {seq2seq,classify}] [--labels LABELS] [--model_path MODEL_PATH]
                   [--output_dir OUTPUT_DIR] [--disable_wandb] [--adapter {lora,qlora,adalora,prompt,p_tuning,prefix}] [--lora_r LORA_R] [--lora_alpha LORA_ALPHA] [--lora_dropout LORA_DROPOUT]
                   [--lora_target_modules LORA_TARGET_MODULES [LORA_TARGET_MODULES ...]] [--adalora_init_r ADALORA_INIT_R] [--adalora_tinit ADALORA_TINIT] [--adalora_tfinal ADALORA_TFINAL]
                   [--adalora_delta_t ADALORA_DELTA_T] [--num_virtual_tokens NUM_VIRTUAL_TOKENS] [--mapping_hidden_dim MAPPING_HIDDEN_DIM] [--epochs EPOCHS] [--learning_rate LEARNING_RATE]
                   [--cutoff_len CUTOFF_LEN] [--val_set_size VAL_SET_SIZE] [--group_by_length] [--logging_steps LOGGING_STEPS] [--load_8bit] [--add_eos_token]
                   [--resume_from_checkpoint [RESUME_FROM_CHECKPOINT]] [--per_gpu_train_batch_size PER_GPU_TRAIN_BATCH_SIZE] [--gradient_accumulation_steps GRADIENT_ACCUMULATION_STEPS] [--fromdb]
                   [--db_iteration DB_ITERATION]

Finetune for all.

optional arguments:
  -h, --help            show this help message and exit
  --data DATA           the data used for instructing tuning
  --model_type {llama,llama2,chatglm,chatglm2,bloom,qwen,baichuan}
  --task_type {seq2seq,classify}
  --labels LABELS       Labels to classify, only used when task_type is classify
  --model_path MODEL_PATH
  --output_dir OUTPUT_DIR
                        The DIR to save the model
  --disable_wandb       Disable report to wandb
  --adapter {lora,qlora,adalora,prompt,p_tuning,prefix}
  --lora_r LORA_R
  --lora_alpha LORA_ALPHA
  --lora_dropout LORA_DROPOUT
  --lora_target_modules LORA_TARGET_MODULES [LORA_TARGET_MODULES ...]
                        the module to be injected, e.g. q_proj/v_proj/k_proj/o_proj for llama, query_key_value for bloom&GLM
  --adalora_init_r ADALORA_INIT_R
  --adalora_tinit ADALORA_TINIT
                        number of warmup steps for AdaLoRA wherein no pruning is performed
  --adalora_tfinal ADALORA_TFINAL
                        fix the resulting budget distribution and fine-tune the model for tfinal steps when using AdaLoRA
  --adalora_delta_t ADALORA_DELTA_T
                        interval of steps for AdaLoRA to update rank
  --num_virtual_tokens NUM_VIRTUAL_TOKENS
  --mapping_hidden_dim MAPPING_HIDDEN_DIM
  --epochs EPOCHS
  --learning_rate LEARNING_RATE
  --cutoff_len CUTOFF_LEN
  --val_set_size VAL_SET_SIZE
  --group_by_length
  --logging_steps LOGGING_STEPS
  --load_8bit
  --add_eos_token
  --resume_from_checkpoint [RESUME_FROM_CHECKPOINT]
                        resume from the specified or the latest checkpoint, e.g. `--resume_from_checkpoint [path]` or `--resume_from_checkpoint`
  --per_gpu_train_batch_size PER_GPU_TRAIN_BATCH_SIZE
                        Batch size per GPU/CPU for training.
  --gradient_accumulation_steps GRADIENT_ACCUMULATION_STEPS
  --fromdb
  --db_iteration DB_ITERATION
                        The record's set name.

Generate

usage: inference.py [-h] [--debug] [--instruction INSTRUCTION] [--input INPUT] [--data DATA] [--model_type {llama,llama2,chatglm,chatglm2,bloom,qwen,baichuan}] [--task_type {seq2seq,classify}]
                    [--labels LABELS] [--model_path MODEL_PATH] [--adapter_weights ADAPTER_WEIGHTS] [--load_8bit] [--temperature TEMPERATURE] [--top_p TOP_P] [--top_k TOP_K]
                    [--max_new_tokens MAX_NEW_TOKENS] [--fromdb] [--db_type DB_TYPE] [--db_iteration DB_ITERATION] [--db_test_iteration DB_TEST_ITERATION]

Inference for all.

optional arguments:
  -h, --help            show this help message and exit
  --debug               Debug Mode to output detail info
  --instruction INSTRUCTION
  --input INPUT
  --data DATA           The DIR of test data
  --model_type {llama,llama2,chatglm,chatglm2,bloom,qwen,baichuan}
  --task_type {seq2seq,classify}
  --labels LABELS       Labels to classify, only used when task_type is classify
  --model_path MODEL_PATH
  --adapter_weights ADAPTER_WEIGHTS
                        The DIR of adapter weights
  --load_8bit
  --temperature TEMPERATURE
                        temperature higher, LLM is more creative
  --top_p TOP_P
  --top_k TOP_K
  --max_new_tokens MAX_NEW_TOKENS
  --fromdb
  --db_type DB_TYPE     The record is whether 'train' or 'test'.
  --db_iteration DB_ITERATION
                        The record's set name.
  --db_test_iteration DB_TEST_ITERATION
                        The record's test set name.

Label Web

Classify

python web/label.py

Chat

python web/label.py --type chat

Reference

More Repositories

1

vulbase

各大漏洞文库合集
HTML
727
star
2

reapoc

OpenSource Poc && Vulnerable-Target Storage Box.
PHP
666
star
3

JNDI-Injection-Exploit-Plus

80+ Gadgets(30 More than ysoserial). JNDI-Injection-Exploit-Plus is a tool for generating workable JNDI links and provide background services by starting RMI server,LDAP server and HTTP server.
Java
663
star
4

hostscan

自动化Host碰撞工具,帮助红队快速扩展网络边界,获取更多目标点
Go
539
star
5

awesome-gpt-security

A curated list of awesome security tools, experimental case or other interesting things with LLM or GPT.
514
star
6

py2sec

🐍 py2sec is a Cross-Platform, Fast and Flexible tool to change the .py to .so(Linux and Mac) or .pyd(Win).
Python
482
star
7

HackChrome

⛄ Get the User:Password from Chrome(include version < 80 and version > 80)
Go
333
star
8

pocsploit

a lightweight, flexible and novel open source poc verification framework
Python
234
star
9

py2so

🐍 py2so is tool to change the .py to .so, you can use it to hide the source code of py [Deprecated]. Please navigate to Py2sec
Python
141
star
10

spring-cloud-function-SpEL-RCE

spring-cloud-function SpEL RCE, Vultarget & Poc
Java
133
star
11

YarnRpcRCE

79
star
12

colorsys-go

🎃 colorsys-go is a go package(or lib) for everyone to transform one color system to another. The transformation is among RGB, YIQ, HLS and HSV.
Go
78
star
13

InformationGather

SRC Assets Information Gather Website(SRC资产信息聚合网站)
Vue
61
star
14

netuser

Add or Delete User via windows api,it can be used when .net is inaccessible.
C++
38
star
15

MosaicImage

自动获取用户指定类别图片,并制作马赛克图片
Go
31
star
16

PocCollect

Poc Collected for study and develop
HTML
31
star
17

CVE-2022-40146_Exploit_Jar

Java
30
star
18

Shyvana

A full vul scanner which contains many aspects (adding)
Go
28
star
19

ICS-Protocal-Detect-Nmap-Script

Some nmap scripts to detetct the infomations of the different ICS Here are 16 main ics protocal scan-scripts include Modbus, S7 and so on.
Lua
28
star
20

gitAutoStar

配合GitStar编写的自动Star工具,稳定快速,跨平台
Go
21
star
21

simHtml

Compare html similarity using structural and style metrics
Go
20
star
22

log4shell_1.x

log4j 1.x RCE Poc -- CVE-2021-4104
Java
20
star
23

Log4j_CVE-2021-45046

Log4j 2.15.0 Privilege Escalation -- CVE-2021-45046
Java
20
star
24

Log4j_dos_CVE-2021-45105

Log4j_dos_CVE-2021-45105
Java
13
star
25

nginx_vultarget

Python
12
star
26

gitAutoStar-py

最新版gitStar自动点赞,使用selenium
Python
11
star
27

HaveIReg

HaveIReg用于查找出特定用户在哪些网站注册过
Python
8
star
28

Interview

面试题整理分享(持续更新ing)
Batchfile
8
star
29

cckuailong.github.io

Writing 1000 Words a Day Changed My Life
HTML
7
star
30

Small_Functions

Some interesting code fragments to please
HTML
6
star
31

awesome-ml-for-cybersecurity-books

PDF books for awesome-ml-for-cybersecurity-books
6
star
32

CS-Fun-500-Questions

计算机科学中有趣的500问
Batchfile
5
star
33

DgaDetect

Use Keras or TFLearn to detetct DGA via LSTM, AMSGrad and NAdam
Python
5
star
34

WebsiteApp

We provide a tiny Anddroid App which collects many website for whoerver wants to get the main information of news in a short time
Java
5
star
35

log4j_RCE_CVE-2021-44832

Java
4
star
36

BGPStream_Operate_Plugin

I write two shell scripts to help people create or delete the bgpcorsaro's plugin with only one shell command.
C
4
star
37

KerGaNs

Various GANs with Keras (With diginmon generator as example)
Python
4
star
38

CVE-2021-2471

Java
3
star
39

Learning

好文章收集整理
3
star
40

Colorsys.jl

🌈 Colorsys.jl is a Julia package(or lib) for everyone to transform one color system to another. The transformation is among RGB, YIQ, HLS and HSV.
Julia
3
star
41

vultarget_web

Python
3
star
42

pget

pget is a go package for people to add parallel download func into there project. (Adapt from the go download client [https://github.com/Code-Hex/pget])
Go
3
star
43

clonehub

clone all images(with all tags) on dockerhub to your own dockerhub repo
Shell
2
star
44

Spark-Scala-Handle

Scala
2
star
45

Test-JNDI-Injection-Exploit-Plus

Examples for JNDI-Injection-Exploit-Plus
Java
2
star
46

DLMovies

提供查询下载电影的网站,爬取各大电影网站
Go
2
star
47

apereo-cas-docker

apereo cas docker-compose (can customize cas version)
Dockerfile
2
star
48

Dga.jl

Dga.jl can make you customize one or many DGAs. The included DGAs are [Banjori,Corebot,Cryptolocker,Dircrypt,Kraken,Lockyv2,Pykspa,Qakbot Ramdo,Ramnit,Simda]
Julia
2
star
49

Leetcode-go

Leetcode write in Golang.
Go
1
star
50

gunicorn_request_smuggling

gunicorn 20.0.4 request smuggling
Python
1
star
51

Spiders

随便写的爬虫
Python
1
star
52

Paper_torrent

Academic papers to download, the data is more than 10 TB
1
star