RichardLu commited on
Commit
021be98
·
verified ·
1 Parent(s): df0ebdd

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +8 -9
handler.py CHANGED
@@ -39,21 +39,20 @@ alpaca_prompt = (
39
  )
40
 
41
  def initialize():
42
- """
43
- This function loads the finetuned unsloth model and tokenizer.
44
- Adjust the 'model_name' to point to your model repository.
45
- """
46
  global model, tokenizer
47
- # Set your finetuned model repository name here
48
- model_name = "RichardLu/Mistral7b_AE_res" # e.g., "unsloth/mistral-7b-instruct-v0.3-bnb-4bit-finetuned"
 
 
 
 
49
  model, tokenizer = FastLanguageModel.from_pretrained(
50
  model_name=model_name,
51
  max_seq_length=2048,
52
- load_in_4bit=True # Change if necessary
 
53
  )
54
- # Set the model in inference mode
55
  FastLanguageModel.for_inference(model)
56
- model.eval()
57
 
58
  def preprocess(request):
59
  """
 
39
  )
40
 
41
  def initialize():
 
 
 
 
42
  global model, tokenizer
43
+ model_name = "RichardLu/Mistral7b_AE_res"
44
+
45
+ # Read the environment variable
46
+ hf_auth_token = os.environ.get("HF_AUTH_TOKEN", None)
47
+
48
+ # Pass the token if it exists
49
  model, tokenizer = FastLanguageModel.from_pretrained(
50
  model_name=model_name,
51
  max_seq_length=2048,
52
+ load_in_4bit=True,
53
+ use_auth_token=hf_auth_token # <--- Use your token here
54
  )
 
55
  FastLanguageModel.for_inference(model)
 
56
 
57
  def preprocess(request):
58
  """