Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ model = PeftModel.from_pretrained(model, model_id)
|
|
24 |
|
25 |
def greet(text):
|
26 |
with torch.no_grad(): # Disable gradient calculation for inference
|
27 |
-
batch = tokenizer(f'### Input:\n{text}\n\n### Answer
|
28 |
with torch.cuda.amp.autocast(): # Enable mixed-precision if available
|
29 |
output_tokens = model.generate(**batch, max_new_tokens=25)
|
30 |
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
|
|
24 |
|
25 |
def greet(text):
|
26 |
with torch.no_grad(): # Disable gradient calculation for inference
|
27 |
+
batch = tokenizer(f'### Input:\n{text}\n\n### Answer:', return_tensors='pt') # Move tensors to device
|
28 |
with torch.cuda.amp.autocast(): # Enable mixed-precision if available
|
29 |
output_tokens = model.generate(**batch, max_new_tokens=25)
|
30 |
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|