Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,11 @@ import torch
|
|
6 |
# Load the model and config when the script starts
|
7 |
config = PeftConfig.from_pretrained("phearion/bigbrain-v0.0.1")
|
8 |
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
|
9 |
-
model = PeftModel.from_pretrained(model,
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# Load the tokenizer
|
12 |
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
|
@@ -18,7 +22,7 @@ def greet(text):
|
|
18 |
|
19 |
# Use torch.no_grad to disable gradient calculation
|
20 |
with torch.no_grad():
|
21 |
-
output_tokens =
|
22 |
|
23 |
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
24 |
|
|
|
6 |
# Load the model and config when the script starts
|
7 |
config = PeftConfig.from_pretrained("phearion/bigbrain-v0.0.1")
|
8 |
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
|
9 |
+
model = PeftModel.from_pretrained(model,
|
10 |
+
"phearion/bigbrain-v0.0.1")
|
11 |
+
|
12 |
+
# Convert the model to TorchScript
|
13 |
+
scripted_model = torch.jit.script(model)
|
14 |
|
15 |
# Load the tokenizer
|
16 |
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
|
|
|
22 |
|
23 |
# Use torch.no_grad to disable gradient calculation
|
24 |
with torch.no_grad():
|
25 |
+
output_tokens = scripted_model.generate(**batch, max_new_tokens=20)
|
26 |
|
27 |
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
28 |
|