Views
No views yet
1from awq import AutoAWQForCausalLM
2from transformers import AutoTokenizer, TextStreamer
3
4
5quant_path = "Moses25/Llama-3-8B-chat-32K-AWQ"
6
7# Load model
8model = AutoAWQForCausalLM.from_quantized(quant_path, fuse_layers=True)
9tokenizer = AutoTokenizer.from_pretrained(quant_path, trust_remote_code=True)
10streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
11
12prompt = "You're standing on the surface of the Earth. "\
13 "You walk one mile south, one mile west and one mile north. "\
14 "You end up exactly where you started. Where are you?"
15
16chat = [
17 {"role": "system", "content": "You are a concise assistant that helps answer questions."},
18 {"role": "user", "content": prompt},
19]
20
21terminators = [
22 tokenizer.eos_token_id,
23 tokenizer.convert_tokens_to_ids("<|eot_id|>")
24]
25
26tokens = tokenizer.apply_chat_template(
27 chat,
28 return_tensors="pt"
29).cuda()
30
31# Generate output
32generation_output = model.generate(
33 tokens,
34 streamer=streamer,
35 max_new_tokens=2048,
36 eos_token_id=terminators
37)