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.
1pip install torch==2.0.0+cu117 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117
2pip install transformers==4.31.0
3pip install accelerate
4pip install auto-gptq # for gptq
5pip install sentencepiece
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3base_model = 'llama-2-7b'
4comp_method = 'magnitude_unstructured'
5comp_degree = 0.2
6model_path = f'vita-group/{base_model}_{comp_method}'
7model = AutoModelForCausalLM.from_pretrained(
8 model_path,
9 revision=f's{comp_degree}',
10 torch_dtype=torch.float16,
11 low_cpu_mem_usage=True,
12 device_map="auto"
13 )
14tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-2-7b-hf')
15input_ids = tokenizer('Hello! I am a VITA-compressed-LLM chatbot!', return_tensors='pt').input_ids.cuda()
16outputs = model.generate(input_ids, max_new_tokens=128)
17print(tokenizer.decode(outputs[0]))
1from transformers import AutoTokenizer
2from auto_gptq import AutoGPTQForCausalLM
3model_path = 'vita-group/llama-2-7b_wanda_2_4_gptq_4bit_128g'
4tokenizer_path = 'meta-llama/Llama-2-7b-hf'
5model = AutoGPTQForCausalLM.from_quantized(
6 model_path,
7 # inject_fused_attention=False, # or
8 disable_exllama=True,
9 device_map='auto',
10 )
11tokenizer = AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True)
12input_ids = tokenizer('Hello! I am a VITA-compressed-LLM chatbot!', return_tensors='pt').input_ids.to('cuda')
13outputs = model.generate(input_ids=input_ids, max_length=128)
14tokenizer.decode(outputs[0])
1from transformers import AutoTokenizer
2from auto_gptq import AutoGPTQForCausalLM
3# model_path = 'vita-group/llama-2-7b_wanda_2_4_gptq_4bit_128g'
4# tokenizer_path = 'meta-llama/Llama-2-7b-hf'
5model_path = 'vita-group/vicuna-7b-v1.3_gptq'
6tokenizer_path = 'lmsys/vicuna-7b-v1.3'
7model = AutoGPTQForCausalLM.from_quantized(
8 model_path,
9 # inject_fused_attention=False, # or
10 disable_exllama=True,
11 device_map='auto',
12 revision='2bit_128g',
13 )
14from transformers import AutoTokenizer
15tokenizer = AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True)
16input_ids = tokenizer('Hello! I am a VITA-compressed-LLM chatbot!', return_tensors='pt').input_ids.to('cuda')
17outputs = model.generate(input_ids=input_ids, max_length=128)
18tokenizer.decode(outputs[0])