gunjanjoshi commited on
Commit
c3f1f3a
·
1 Parent(s): 0973b84

Added accelerate

Browse files
Files changed (1) hide show
  1. app.py +1 -10
app.py CHANGED
@@ -1,24 +1,15 @@
1
  import torch
2
- from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3
  from peft import PeftConfig, PeftModel
4
  import gradio as gr
5
 
6
  # Loading PEFT model
7
  PEFT_MODEL = "gunjanjoshi/llama2-7b-sharded-bf16-finetuned-mental-health-conversational"
8
 
9
- # Modify BitsAndBytesConfig for CPU
10
- bnb_config = BitsAndBytesConfig(
11
- load_in_4bit=True,
12
- bnb_4bit_quant_type="pf4",
13
- bnb_4bit_use_double_quant=True,
14
- bnb_4bit_compute_dtype=torch.float16,
15
- )
16
-
17
  config = PeftConfig.from_pretrained(PEFT_MODEL)
18
  peft_base_model = AutoModelForCausalLM.from_pretrained(
19
  config.base_model_name_or_path,
20
  return_dict=True,
21
- quantization_config=bnb_config,
22
  device_map="cpu", # Ensure this is set to CPU
23
  trust_remote_code=True,
24
  )
 
1
  import torch
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
  from peft import PeftConfig, PeftModel
4
  import gradio as gr
5
 
6
  # Loading PEFT model
7
  PEFT_MODEL = "gunjanjoshi/llama2-7b-sharded-bf16-finetuned-mental-health-conversational"
8
 
 
 
 
 
 
 
 
 
9
  config = PeftConfig.from_pretrained(PEFT_MODEL)
10
  peft_base_model = AutoModelForCausalLM.from_pretrained(
11
  config.base_model_name_or_path,
12
  return_dict=True,
 
13
  device_map="cpu", # Ensure this is set to CPU
14
  trust_remote_code=True,
15
  )