Views
No views yet
pip install autoawq1from awq import AutoAWQForCausalLM
2from transformers import AutoTokenizer, TextStreamer
3
4quant_path = "casperhansen/vicuna-7b-v1.5-awq"
5quant_file = "awq_model_w4_g128.pt"
6
7# Load model
8model = AutoAWQForCausalLM.from_quantized(quant_path, quant_file, fuse_layers=True)
9tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True)
10streamer = TextStreamer(tokenizer, skip_special_tokens=True)
11
12# Convert prompt to tokens
13prompt_template = """\
14A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
15
16USER: {prompt}
17ASSISTANT:"""
18
19tokens = tokenizer(
20 prompt_template.format(prompt="How are you today?"),
21 return_tensors='pt'
22).input_ids.cuda()
23
24# Generate output
25generation_output = model.generate(
26 tokens,
27 streamer=streamer,
28 max_new_tokens=512
29)