Update app.py
Browse files
app.py
CHANGED
@@ -4,12 +4,12 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
4 |
import torch
|
5 |
|
6 |
# Load the model and config when the script starts
|
7 |
-
config = PeftConfig.from_pretrained("
|
8 |
-
model = AutoModelForCausalLM.from_pretrained("
|
9 |
-
model = PeftModel.from_pretrained(model, "
|
10 |
|
11 |
# Load the tokenizer
|
12 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
13 |
|
14 |
|
15 |
def greet(text):
|
@@ -17,9 +17,10 @@ def greet(text):
|
|
17 |
|
18 |
# Use torch.no_grad to disable gradient calculation
|
19 |
with torch.no_grad():
|
20 |
-
output_tokens = model.generate(**batch, do_sample=True, max_new_tokens=
|
21 |
|
22 |
-
return tokenizer.decode
|
|
|
23 |
|
24 |
|
25 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
4 |
import torch
|
5 |
|
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, "Phearion/bigbrain-v0.0.1")
|
10 |
|
11 |
# Load the tokenizer
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")
|
13 |
|
14 |
|
15 |
def greet(text):
|
|
|
17 |
|
18 |
# Use torch.no_grad to disable gradient calculation
|
19 |
with torch.no_grad():
|
20 |
+
output_tokens = model.generate(**batch, do_sample=True, max_new_tokens=20)
|
21 |
|
22 |
+
return tokenizer.decode
|
23 |
+
(output_tokens[0], skip_special_tokens=True)
|
24 |
|
25 |
|
26 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|