Hrushi02 commited on
Commit
aae460b
·
verified ·
1 Parent(s): 28e426c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -66,31 +66,29 @@ if __name__ == "__main__":
66
  demo.launch()
67
 
68
  import os
69
-
70
- api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
71
  from transformers import AutoModelForCausalLM, AutoTokenizer
72
  from peft import PeftModel
73
  import torch
74
 
75
- # Load the Hugging Face API token securely
76
  api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
77
 
78
- if api_token is None:
79
- raise ValueError("HUGGINGFACEHUB_API_TOKEN is not set. Please set it in your environment variables.")
80
 
81
  # Define model names
82
  base_model_name = "unsloth/qwen2.5-math-7b-bnb-4bit"
83
  peft_model_name = "Hrushi02/Root_Math"
84
 
85
- # Load base model securely
86
  base_model = AutoModelForCausalLM.from_pretrained(
87
  base_model_name,
88
  torch_dtype=torch.float16,
89
  device_map="auto",
90
- token=api_token
91
  )
92
 
93
- # Load PEFT fine-tuned model
94
  model = PeftModel.from_pretrained(base_model, peft_model_name, token=api_token)
95
 
96
  # Load tokenizer
@@ -98,3 +96,4 @@ tokenizer = AutoTokenizer.from_pretrained(base_model_name, token=api_token)
98
 
99
 
100
 
 
 
66
  demo.launch()
67
 
68
  import os
 
 
69
  from transformers import AutoModelForCausalLM, AutoTokenizer
70
  from peft import PeftModel
71
  import torch
72
 
73
+ # Load Hugging Face API token securely
74
  api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
75
 
76
+ if not api_token:
77
+ raise ValueError(" ERROR: Hugging Face API token is not set. Please set it as an environment variable.")
78
 
79
  # Define model names
80
  base_model_name = "unsloth/qwen2.5-math-7b-bnb-4bit"
81
  peft_model_name = "Hrushi02/Root_Math"
82
 
83
+ # Load base model with authentication
84
  base_model = AutoModelForCausalLM.from_pretrained(
85
  base_model_name,
86
  torch_dtype=torch.float16,
87
  device_map="auto",
88
+ token=api_token # ✅ Pass token here
89
  )
90
 
91
+ # Load fine-tuned model
92
  model = PeftModel.from_pretrained(base_model, peft_model_name, token=api_token)
93
 
94
  # Load tokenizer
 
96
 
97
 
98
 
99
+