Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,25 +15,25 @@ model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)
|
|
15 |
|
16 |
|
17 |
def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
|
18 |
-
|
19 |
|
20 |
-
### Instruction:
|
21 |
-
{}
|
22 |
-
|
23 |
-
### Input:
|
24 |
-
{}
|
25 |
-
|
26 |
-
### Response:
|
27 |
-
{}"""
|
28 |
|
29 |
inputs = tokenizer(
|
30 |
-
[
|
31 |
alpaca_prompt.format(
|
32 |
"You are an AI assistant. Please ensure that the answers conclude with an end-of-sequence (EOS) token.", # instruction
|
33 |
user_text, # input goes here
|
34 |
"", # output - leave this blank for generation!
|
35 |
)
|
36 |
-
], return_tensors = "pt",return_dict=True)
|
37 |
|
38 |
# Start generation on a separate thread, so that we don't block the UI. The text is pulled from the streamer
|
39 |
# in the main thread. Adds timeout to the streamer to handle exceptions in the generation thread.
|
|
|
15 |
|
16 |
|
17 |
def run_generation(user_text, top_p, temperature, top_k, max_new_tokens):
|
18 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
19 |
|
20 |
+
### Instruction:
|
21 |
+
{}
|
22 |
+
|
23 |
+
### Input:
|
24 |
+
{}
|
25 |
+
|
26 |
+
### Response:
|
27 |
+
{}"""
|
28 |
|
29 |
inputs = tokenizer(
|
30 |
+
[
|
31 |
alpaca_prompt.format(
|
32 |
"You are an AI assistant. Please ensure that the answers conclude with an end-of-sequence (EOS) token.", # instruction
|
33 |
user_text, # input goes here
|
34 |
"", # output - leave this blank for generation!
|
35 |
)
|
36 |
+
], return_tensors = "pt",return_dict=True)
|
37 |
|
38 |
# Start generation on a separate thread, so that we don't block the UI. The text is pulled from the streamer
|
39 |
# in the main thread. Adds timeout to the streamer to handle exceptions in the generation thread.
|