Views
No views yet
Stable Beluga 7B is a Llama2 7B model finetuned on an Orca style Dataset.8.0 or higher.nvcr.io/nvidia/pytorch:23.06-py3 image is runtime v12.1 but otherwise the same as the configuration above and has also been verified to work.1git clone https://github.com/mit-han-lab/llm-awq \
2&& cd llm-awq \
3&& git checkout f084f40bd996f3cf3a0633c1ad7d9d476c318aaa \
4&& pip install -e . \
5&& cd awq/kernels \
6&& python setup.py install1import time
2import torch
3from awq.quantize.quantizer import real_quantize_model_weight
4from transformers import AutoModelForCausalLM, AutoConfig, AutoTokenizer, TextStreamer
5from accelerate import init_empty_weights, load_checkpoint_and_dispatch
6from huggingface_hub import snapshot_download
7
8model_name = "abhinavkulkarni/stabilityai-StableBeluga-7B-w4-g128-awq"
9
10# Config
11config = AutoConfig.from_pretrained(model_name, trust_remote_code=True)
12
13# Tokenizer
14try:
15 tokenizer = AutoTokenizer.from_pretrained(config.tokenizer_name, trust_remote_code=True)
16except:
17 tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False, trust_remote_code=True)
18streamer = TextStreamer(tokenizer, skip_special_tokens=True)
19
20# Model
21w_bit = 4
22q_config = {
23 "zero_point": True,
24 "q_group_size": 128,
25}
26
27load_quant = snapshot_download(model_name)
28
29with init_empty_weights():
30 model = AutoModelForCausalLM.from_config(config=config,
31 torch_dtype=torch.float16, trust_remote_code=True)
32
33real_quantize_model_weight(model, w_bit=w_bit, q_config=q_config, init_only=True)
34model.tie_weights()
35
36model = load_checkpoint_and_dispatch(model, load_quant, device_map="balanced")
37
38# Inference
39prompt = f'''What is the difference between nuclear fusion and fission?
40###Response:'''
41
42input_ids = tokenizer(prompt, return_tensors='pt').input_ids.cuda()
43output = model.generate(
44 inputs=input_ids,
45 temperature=0.7,
46 max_new_tokens=512,
47 top_p=0.15,
48 top_k=0,
49 repetition_penalty=1.1,
50 eos_token_id=tokenizer.eos_token_id,
51 streamer=streamer)| Task | Version | Metric | Value | Stderr | |
|---|---|---|---|---|---|
| wikitext | 1 | word_perplexity | 9.5097 | ||
| byte_perplexity | 1.5238 | ||||
| bits_per_byte | 0.6077 |
| Task | Version | Metric | Value | Stderr | |
|---|---|---|---|---|---|
| wikitext | 1 | word_perplexity | 9.7783 | ||
| byte_perplexity | 1.5317 | ||||
| bits_per_byte | 0.6152 |
1@misc{touvron2023llama,
2 title={Llama 2: Open Foundation and Fine-Tuned Chat Models},
3 author={Hugo Touvron and Louis Martin and Kevin Stone and Peter Albert and Amjad Almahairi and Yasmine Babaei and Nikolay Bashlykov and Soumya Batra and Prajjwal Bhargava and Shruti Bhosale and Dan Bikel and Lukas Blecher and Cristian Canton Ferrer and Moya Chen and Guillem Cucurull and David Esiobu and Jude Fernandes and Jeremy Fu and Wenyin Fu and Brian Fuller and Cynthia Gao and Vedanuj Goswami and Naman Goyal and Anthony Hartshorn and Saghar Hosseini and Rui Hou and Hakan Inan and Marcin Kardas and Viktor Kerkez and Madian Khabsa and Isabel Kloumann and Artem Korenev and Punit Singh Koura and Marie-Anne Lachaux and Thibaut Lavril and Jenya Lee and Diana Liskovich and Yinghai Lu and Yuning Mao and Xavier Martinet and Todor Mihaylov and Pushkar Mishra and Igor Molybog and Yixin Nie and Andrew Poulton and Jeremy Reizenstein and Rashi Rungta and Kalyan Saladi and Alan Schelten and Ruan Silva and Eric Michael Smith and Ranjan Subramanian and Xiaoqing Ellen Tan and Binh Tang and Ross Taylor and Adina Williams and Jian Xiang Kuan and Puxin Xu and Zheng Yan and Iliyan Zarov and Yuchen Zhang and Angela Fan and Melanie Kambadur and Sharan Narang and Aurelien Rodriguez and Robert Stojnic and Sergey Edunov and Thomas Scialom},
4 year={2023},
5 eprint={2307.09288},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}1@misc{mukherjee2023orca,
2 title={Orca: Progressive Learning from Complex Explanation Traces of GPT-4},
3 author={Subhabrata Mukherjee and Arindam Mitra and Ganesh Jawahar and Sahaj Agarwal and Hamid Palangi and Ahmed Awadallah},
4 year={2023},
5 eprint={2306.02707},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}@article{lin2023awq,
title={AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration},
author={Lin, Ji and Tang, Jiaming and Tang, Haotian and Yang, Shang and Dang, Xingyu and Han, Song},
journal={arXiv},
year={2023}
}