Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ def load_model_org():
|
|
| 20 |
return model, tokenizer
|
| 21 |
|
| 22 |
|
| 23 |
-
def
|
| 24 |
# Load base model first
|
| 25 |
base_model = AutoModelForCausalLM.from_pretrained(
|
| 26 |
"unsloth/mistral-7b-v0.3", # Use your base model name
|
|
@@ -44,6 +44,26 @@ def load_model():
|
|
| 44 |
|
| 45 |
return model, tokenizer
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
# Initialize model and tokenizer
|
|
@@ -86,7 +106,7 @@ def generate_response(prompt, max_length=512, temperature=0.7, top_p=0.95):
|
|
| 86 |
|
| 87 |
# Create the Gradio interface
|
| 88 |
def main():
|
| 89 |
-
with gr.Blocks(title="
|
| 90 |
gr.Markdown("""
|
| 91 |
# SBX Certification Query Helper
|
| 92 |
Ask questions about SBX certifications and get detailed answers!
|
|
|
|
| 20 |
return model, tokenizer
|
| 21 |
|
| 22 |
|
| 23 |
+
def load_model_gpu():
|
| 24 |
# Load base model first
|
| 25 |
base_model = AutoModelForCausalLM.from_pretrained(
|
| 26 |
"unsloth/mistral-7b-v0.3", # Use your base model name
|
|
|
|
| 44 |
|
| 45 |
return model, tokenizer
|
| 46 |
|
| 47 |
+
def load_model():
|
| 48 |
+
# Load in pure CPU mode without quantization
|
| 49 |
+
config = PeftConfig.from_pretrained("satishpednekar/sbx-qhelper-mistral-loraWeights")
|
| 50 |
+
|
| 51 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 52 |
+
config.base_model_name_or_path,
|
| 53 |
+
torch_dtype=torch.float32, # Use float32 for CPU
|
| 54 |
+
device_map=None, # Force CPU
|
| 55 |
+
trust_remote_code=True,
|
| 56 |
+
load_in_4bit=False # Remove quantization
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
model = PeftModel.from_pretrained(model, "satishpednekar/sbx-qhelper-mistral-loraWeights")
|
| 60 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
| 61 |
+
|
| 62 |
+
# Explicitly move to CPU
|
| 63 |
+
model = model.to("cpu")
|
| 64 |
+
|
| 65 |
+
return model, tokenizer
|
| 66 |
+
|
| 67 |
|
| 68 |
|
| 69 |
# Initialize model and tokenizer
|
|
|
|
| 106 |
|
| 107 |
# Create the Gradio interface
|
| 108 |
def main():
|
| 109 |
+
with gr.Blocks(title="SBX Certification Query Helper") as demo:
|
| 110 |
gr.Markdown("""
|
| 111 |
# SBX Certification Query Helper
|
| 112 |
Ask questions about SBX certifications and get detailed answers!
|