Update app.py
Browse files
app.py
CHANGED
@@ -16,10 +16,13 @@ bnb_config = BitsAndBytesConfig(
|
|
16 |
)
|
17 |
|
18 |
# Load models and tokenizer efficiently
|
19 |
-
config = PeftConfig.from_pretrained(
|
20 |
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
21 |
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config)
|
22 |
|
|
|
|
|
|
|
23 |
def greet(text):
|
24 |
with torch.no_grad(): # Disable gradient calculation for inference
|
25 |
batch = tokenizer(f'"{text}" ->:', return_tensors='pt') # Move tensors to device
|
|
|
16 |
)
|
17 |
|
18 |
# Load models and tokenizer efficiently
|
19 |
+
config = PeftConfig.from_pretrained(model_id)
|
20 |
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
21 |
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, quantization_config=bnb_config)
|
22 |
|
23 |
+
# Load the Lora model
|
24 |
+
model = PeftModel.from_pretrained(model, model_id)
|
25 |
+
|
26 |
def greet(text):
|
27 |
with torch.no_grad(): # Disable gradient calculation for inference
|
28 |
batch = tokenizer(f'"{text}" ->:', return_tensors='pt') # Move tensors to device
|