Suparious commited on
Commit
ae182b9
·
1 Parent(s): ef2709d

Provide usage example

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md CHANGED
@@ -37,6 +37,52 @@ This repo contains AWQ model files for [cognitivecomputations's Samantha 7B v1.1
37
 
38
  These files were quantised using hardware kindly provided by [SolidRusT Networks](https://solidrust.net/).
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  ### About AWQ
41
 
42
  AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.
 
37
 
38
  These files were quantised using hardware kindly provided by [SolidRusT Networks](https://solidrust.net/).
39
 
40
+ ## How to use
41
+
42
+ ### Install the necessary packages
43
+
44
+ ```bash
45
+ pip install --upgrade autoawq autoawq-kernels
46
+ ```
47
+
48
+ ### Example Python code
49
+
50
+ ```bash
51
+ from awq import AutoAWQForCausalLM
52
+ from transformers import AutoTokenizer, TextStreamer
53
+
54
+ quant_path = "/srv/home/shaun/repos/samantha-1.1-westlake-7b-laser-AWQ"
55
+
56
+ # Load model
57
+ model = AutoAWQForCausalLM.from_quantized(quant_path,
58
+ fuse_layers=True)
59
+ tokenizer = AutoTokenizer.from_pretrained(quant_path,
60
+ trust_remote_code=True)
61
+ streamer = TextStreamer(tokenizer,
62
+ skip_prompt=True,
63
+ skip_special_tokens=True)
64
+
65
+ # Convert prompt to tokens
66
+ prompt_template = """\
67
+ <|system|>
68
+ </s>
69
+ <|user|>
70
+ {prompt}</s>
71
+ <|assistant|>"""
72
+
73
+ prompt = "You're standing on the surface of the Earth. "\
74
+ "You walk one mile south, one mile west and one mile north. "\
75
+ "You end up exactly where you started. Where are you?"
76
+
77
+ tokens = tokenizer(prompt_template.format(prompt=prompt),
78
+ return_tensors='pt').input_ids.cuda()
79
+
80
+ # Generate output
81
+ generation_output = model.generate(tokens,
82
+ streamer=streamer,
83
+ max_new_tokens=512)
84
+ ```
85
+
86
  ### About AWQ
87
 
88
  AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.