Spaces:
Build error
Build error
Update app.py
Browse files5 unmodified lines678910111213141516171819205 unmodified lines# Use GPU if availabledevice = "cuda" if torch.cuda.is_available() else "cpu"# Base model and adapter pathsbase_model_name = "microsoft/phi-2" # Pull from HF Hub directlyadapter_path = "Shriti09/Microsoft-Phi-QLora" # Update with your Hugging Face repo pathprint("🔧 Loading base model...")base_model = AutoModelForCausalLM.from_pretrained(base_model_name,device_map="auto",torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32)print("🔧 Loading LoRA adapter...")5 unmodified lines67891011121314151617181920212223242526272829303132333435363738395 unmodified lines# Use GPU if availabledevice = "cuda" if torch.cuda.is_available() else "cpu"# Base model and adapter pathsbase_model_name = "microsoft/phi-2" # Pull from HF Hub directlyimport torchfrom transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModelimport gradio as grimport os# Use GPU if availabledevice = "cuda" if torch.cuda.is_available() else "cpu"# Base model and adapter pathsbase_model_name = "microsoft/phi-2" # Pull from HF Hub directlyadapter_path = "Shriti09/Microsoft-Phi-QLora" # Update with your Hugging Face repo path# Create an offload directory to store the model partsoffload_dir = "./offload" # Replace with your desired path# Ensure the offload directory existsos.makedirs(offload_dir, exist_ok=True)print("🔧 Loading base model...")base_model = AutoModelForCausalLM.from_pretrained(base_model_name,device_map="auto",torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,offload_dir=offload_dir # Set offload directory here)print("🔧 Loading LoRA adapter...")
app.py+20-1