Update app.py
Browse files
app.py
CHANGED
@@ -68,7 +68,7 @@ def generate_prompt(instruction, input=None):
|
|
68 |
else:
|
69 |
return PROMPT_DICT["prompt_no_input"].format(instruction=instruction)
|
70 |
|
71 |
-
|
72 |
def getIds(inputs):
|
73 |
return inputs["input_ids"].cuda()
|
74 |
|
@@ -83,7 +83,8 @@ def generator(input_ids, generation_config, max_new_tokens):
|
|
83 |
max_new_tokens=max_new_tokens,
|
84 |
)
|
85 |
return generation_output
|
86 |
-
|
|
|
87 |
def respond(
|
88 |
message,
|
89 |
history: list[tuple[str, str]],
|
@@ -94,7 +95,7 @@ def respond(
|
|
94 |
):
|
95 |
ins_f = generate_prompt(message,None)
|
96 |
inputs = tokenizer(ins_f, return_tensors="pt")
|
97 |
-
input_ids =
|
98 |
max_new_tokens = 512
|
99 |
generation_config = GenerationConfig(
|
100 |
temperature=0.1,
|
@@ -155,4 +156,4 @@ demo = gr.ChatInterface(
|
|
155 |
)
|
156 |
if __name__ == "__main__":
|
157 |
model.eval()
|
158 |
-
demo.launch(
|
|
|
68 |
else:
|
69 |
return PROMPT_DICT["prompt_no_input"].format(instruction=instruction)
|
70 |
|
71 |
+
|
72 |
def getIds(inputs):
|
73 |
return inputs["input_ids"].cuda()
|
74 |
|
|
|
83 |
max_new_tokens=max_new_tokens,
|
84 |
)
|
85 |
return generation_output
|
86 |
+
|
87 |
+
@spaces.GPU
|
88 |
def respond(
|
89 |
message,
|
90 |
history: list[tuple[str, str]],
|
|
|
95 |
):
|
96 |
ins_f = generate_prompt(message,None)
|
97 |
inputs = tokenizer(ins_f, return_tensors="pt")
|
98 |
+
input_ids = inputs["input_ids"].cuda()
|
99 |
max_new_tokens = 512
|
100 |
generation_config = GenerationConfig(
|
101 |
temperature=0.1,
|
|
|
156 |
)
|
157 |
if __name__ == "__main__":
|
158 |
model.eval()
|
159 |
+
demo.launch()
|