CoolFace
Modelpublic

compressed-llm/llama-2-13b-sparsegpt-semistruct

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes19downloads
Model Card

Compressed LLM Model Zone

The models are prepared by Visual Informatics Group @ University of Texas at Austin (VITA-group). Credits to Ajay Jaiswal, Zhenyu Zhang, Zhangheng Li, Lu Yin, Shiwei Liu and Junyuan Hong.

License: MIT License

Setup environment

shell
pip install torch==2.0.0+cu117 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117
pip install transformers==4.31.0
pip install accelerate
pip install auto-gptq  # for gptq
pip install sentencepiece

How to use pruned models

python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model = 'llama-2-7b'
comp_method = 'magnitude_unstructured'
comp_degree = 0.2
model_path = f'vita-group/{base_model}_{comp_method}'
model = AutoModelForCausalLM.from_pretrained(
        model_path, 
        revision=f's{comp_degree}',
        torch_dtype=torch.float16, 
        low_cpu_mem_usage=True, 
        device_map="auto"
    )
tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-2-7b-hf')
input_ids = tokenizer('Hello! I am a VITA-compressed-LLM chatbot!', return_tensors='pt').input_ids.cuda()
outputs = model.generate(input_ids, max_new_tokens=128)
print(tokenizer.decode(outputs[0]))

How to use wanda+gptq models

python
from transformers import AutoTokenizer
from auto_gptq import AutoGPTQForCausalLM
model_path = 'vita-group/llama-2-7b_wanda_2_4_gptq_4bit_128g'
tokenizer_path = 'meta-llama/Llama-2-7b-hf'
model = AutoGPTQForCausalLM.from_quantized(
        model_path,
        # inject_fused_attention=False, # or 
        disable_exllama=True,
        device_map='auto',
    )
tokenizer = AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True)
input_ids = tokenizer('Hello! I am a VITA-compressed-LLM chatbot!', return_tensors='pt').input_ids.to('cuda')
outputs = model.generate(input_ids=input_ids, max_length=128)
tokenizer.decode(outputs[0])

How to use gptq models

python
from transformers import AutoTokenizer
from auto_gptq import AutoGPTQForCausalLM
# model_path = 'vita-group/llama-2-7b_wanda_2_4_gptq_4bit_128g'
# tokenizer_path = 'meta-llama/Llama-2-7b-hf'
model_path = 'vita-group/vicuna-7b-v1.3_gptq'
tokenizer_path = 'lmsys/vicuna-7b-v1.3'
model = AutoGPTQForCausalLM.from_quantized(
        model_path,
        # inject_fused_attention=False, # or 
        disable_exllama=True,
        device_map='auto',
        revision='2bit_128g',
    )
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True)
input_ids = tokenizer('Hello! I am a VITA-compressed-LLM chatbot!', return_tensors='pt').input_ids.to('cuda')
outputs = model.generate(input_ids=input_ids, max_length=128)
tokenizer.decode(outputs[0])
Base ModelModel SizeCompression MethodCompression Degree
0Llama-27bmagnitude_unstructureds0.1
1Llama-27bmagnitude_unstructureds0.2
2Llama-27bmagnitude_unstructureds0.3
3Llama-27bmagnitude_unstructureds0.5
4Llama-27bmagnitude_unstructureds0.6
5Llama-27bsparsegpt_unstructureds0.1
6Llama-27bsparsegpt_unstructureds0.2
7Llama-27bsparsegpt_unstructureds0.3
8Llama-27bsparsegpt_unstructureds0.5
9Llama-27bsparsegpt_unstructureds0.6
10Llama-27bwanda_gptq4bit_128g
11Llama-27bwanda_unstructureds0.1
12Llama-27bwanda_unstructureds0.2
13Llama-27bwanda_unstructureds0.3
14Llama-27bwanda_unstructureds0.5
15Llama-27bwanda_unstructureds0.6
16vicuna-v1.313bgptq10bit_128g
17vicuna-v1.313bgptq12bit_128g
18vicuna-v1.313bgptq14bit_128g
19vicuna-v1.313bgptq2bit_128g
20vicuna-v1.313bgptq3bit_128g
21vicuna-v1.313bgptq4bit_128g
22vicuna-v1.313bgptq6bit_128g
23vicuna-v1.313bgptq8bit_128g
24vicuna-v1.37bgptq10bit_128g
25vicuna-v1.37bgptq12bit_128g
26vicuna-v1.37bgptq14bit_128g
27vicuna-v1.37bgptq2bit_128g
28vicuna-v1.37bgptq3bit_128g
29vicuna-v1.37bgptq4bit_128g
30vicuna-v1.37bgptq6bit_128g
31vicuna-v1.37bgptq8bit_128g