satishpednekar commited on
Commit
e9d28c8
·
verified ·
1 Parent(s): e6c701d

mistral load

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForCausalLM
3
  import torch
4
- from unsloth import FastLanguageModel
5
 
6
  # Model and tokenizer initialization
7
  MODEL_NAME = "satishpednekar/sbxcertqueryhelper"
@@ -21,32 +21,31 @@ def load_model_org():
21
 
22
 
23
  def load_model():
24
- model, tokenizer = FastLanguageModel.from_pretrained(
25
- model_name="satishpednekar/sbxcertqueryhelper", # Use the path where you saved the model
26
- max_seq_length=4096, # Use the same as during training
27
- dtype=torch.float16,
28
- load_in_4bit=False,
29
- token="ff"
 
 
 
 
 
 
 
 
30
  )
31
 
32
- # Configure PEFT settings exactly as during training
33
- model = FastLanguageModel.get_peft_model(
34
- model,
35
- r=16,
36
- target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
37
- "gate_proj", "up_proj", "down_proj"],
38
- lora_alpha=16,
39
- lora_dropout=0,
40
- bias="none",
41
- use_gradient_checkpointing="unsloth",
42
- random_state=3407,
43
- use_rslora=False,
44
- loftq_config=None
45
  )
46
 
47
  return model, tokenizer
48
 
49
 
 
50
  # Initialize model and tokenizer
51
  print("Loading model...")
52
  model, tokenizer = load_model()
@@ -89,15 +88,15 @@ def generate_response(prompt, max_length=512, temperature=0.7, top_p=0.95):
89
  def main():
90
  with gr.Blocks(title="Salesforce Certification Query Helper") as demo:
91
  gr.Markdown("""
92
- # Salesforce Certification Query Helper
93
- Ask questions about Salesforce certifications and get detailed answers!
94
  """)
95
 
96
  with gr.Row():
97
  with gr.Column():
98
  input_text = gr.Textbox(
99
  label="Your Question",
100
- placeholder="Enter your question about Salesforce certifications...",
101
  lines=3
102
  )
103
 
 
1
  import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForCausalLM
3
  import torch
4
+ from peft import PeftModel, PeftConfig
5
 
6
  # Model and tokenizer initialization
7
  MODEL_NAME = "satishpednekar/sbxcertqueryhelper"
 
21
 
22
 
23
  def load_model():
24
+ # Load base model first
25
+ base_model = AutoModelForCausalLM.from_pretrained(
26
+ "unsloth/mistral-7b-v0.3", # Use your base model name
27
+ torch_dtype=torch.float16,
28
+ device_map="auto",
29
+ trust_remote_code=True
30
+ )
31
+
32
+ # Load the PEFT adapter weights
33
+ model = PeftModel.from_pretrained(
34
+ base_model,
35
+ "satishpednekar/sbx-qhelper-mistral-loraWeights", # Path to your trained LoRA weights
36
+ torch_dtype=torch.float16,
37
+ device_map="auto"
38
  )
39
 
40
+ tokenizer = AutoTokenizer.from_pretrained(
41
+ "unsloth/mistral-7b-v0.3", # Use your base model name
42
+ trust_remote_code=True
 
 
 
 
 
 
 
 
 
 
43
  )
44
 
45
  return model, tokenizer
46
 
47
 
48
+
49
  # Initialize model and tokenizer
50
  print("Loading model...")
51
  model, tokenizer = load_model()
 
88
  def main():
89
  with gr.Blocks(title="Salesforce Certification Query Helper") as demo:
90
  gr.Markdown("""
91
+ # SBX Certification Query Helper
92
+ Ask questions about SBX certifications and get detailed answers!
93
  """)
94
 
95
  with gr.Row():
96
  with gr.Column():
97
  input_text = gr.Textbox(
98
  label="Your Question",
99
+ placeholder="Enter your question about SBX certifications...",
100
  lines=3
101
  )
102