DW-ReCo commited on
Commit
03eeab0
1 Parent(s): aa4e156

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -3
handler.py CHANGED
@@ -1,5 +1,7 @@
1
  from typing import Dict, List, Any
2
- from transformers import AutoTokenizer, AutoModelForCausalLM
 
 
3
 
4
 
5
  alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
@@ -17,9 +19,9 @@ alpaca_prompt = """Below is an instruction that describes a task, paired with an
17
  class EndpointHandler:
18
  def __init__(self, path=""):
19
  # load model and processor from path
20
- self.model = AutoModelForCausalLM.from_pretrained(path, device_map="auto")
21
- self.tokenizer = AutoTokenizer.from_pretrained(path)
22
 
 
 
23
  with open(f"{path}/zero_shot_cot_prompt.txt", 'r') as file:
24
  self.instruction_prompt = file.read()
25
 
 
1
  from typing import Dict, List, Any
2
+ from transformers import AutoTokenizer
3
+ from peft import PeftModel, PeftConfig
4
+ from transformers import AutoModelForCausalLM, BitsAndBytesConfig
5
 
6
 
7
  alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
 
19
  class EndpointHandler:
20
  def __init__(self, path=""):
21
  # load model and processor from path
 
 
22
 
23
+ self.model = AutoModelForCausalLM.from_pretrained(path, load_in_4bit=True)
24
+ self.tokenizer = AutoTokenizer.from_pretrained(path)
25
  with open(f"{path}/zero_shot_cot_prompt.txt", 'r') as file:
26
  self.instruction_prompt = file.read()
27