prempranavreddy commited on
Commit
3cac895
·
verified ·
1 Parent(s): 786376c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -65,6 +65,30 @@ demo = gr.ChatInterface(
65
  ],
66
  )
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  if __name__ == "__main__":
70
  demo.launch()
 
65
  ],
66
  )
67
 
68
+ api_token = os.getenv("HUGGINGFACEHUB_API_TOKEN")
69
+
70
+ if not api_token:
71
+ raise ValueError("❌ ERROR: Hugging Face API token is not set. Please set it as an environment variable.")
72
+
73
+ # Define model names
74
+ base_model_name = "mistralai/Mistral-7B-Instruct-v0.3"
75
+ peft_model_name = "prempranavreddy/MP1"
76
+
77
+ # Load base model with authentication
78
+ base_model = AutoModelForCausalLM.from_pretrained(
79
+ base_model_name,
80
+ torch_dtype=torch.float16,
81
+ device_map="auto",
82
+ use_auth_token=api_token # ✅ Correct
83
+ )
84
+
85
+
86
+ # Load fine-tuned model
87
+ model = PeftModel.from_pretrained(base_model, peft_model_name, token=api_token)
88
+
89
+ # Load tokenizer
90
+ tokenizer = AutoTokenizer.from_pretrained(base_model_name, token=api_token)
91
+
92
 
93
  if __name__ == "__main__":
94
  demo.launch()