itsanurag commited on
Commit
4a23544
β€’
1 Parent(s): 27345bd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, pipeline
2
+ from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
3
+ import torch
4
+
5
+ model_id = "MaziyarPanahi/Smaug-72B-v0.1-GPTQ"
6
+
7
+ quantize_config = BaseQuantizeConfig(
8
+ bits=4,
9
+ group_size=128,
10
+ desc_act=False
11
+ )
12
+
13
+ model = AutoGPTQForCausalLM.from_quantized(
14
+ model_id,
15
+ use_safetensors=True,
16
+ device="cuda:0",
17
+ quantize_config=quantize_config)
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
20
+
21
+ pipe = pipeline(
22
+ "text-generation",
23
+ model=model,
24
+ tokenizer=tokenizer,
25
+ max_new_tokens=512,
26
+ temperature=0.7,
27
+ top_p=0.95,
28
+ repetition_penalty=1.1
29
+ )
30
+
31
+ outputs = pipe("What is a large language model?")
32
+ print(outputs[0]["generated_text"])