Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,13 @@ model = AutoModelForSeq2SeqLM.from_pretrained(".", local_files_only=True)
|
|
6 |
pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
7 |
|
8 |
def predict(task, prompt, context="", auto_cot=False):
|
9 |
-
|
10 |
if context:
|
11 |
-
|
12 |
if auto_cot:
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
return result
|
17 |
|
18 |
demo = gr.Interface(
|
19 |
fn=predict,
|
|
|
6 |
pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
|
7 |
|
8 |
def predict(task, prompt, context="", auto_cot=False):
|
9 |
+
full_prompt = f"[TASK: {task.upper()}] {prompt}"
|
10 |
if context:
|
11 |
+
full_prompt += f" Context: {context}"
|
12 |
if auto_cot:
|
13 |
+
full_prompt += "\nLet's think step by step."
|
14 |
+
output = pipe(full_prompt, max_new_tokens=128)[0]["generated_text"]
|
15 |
+
return output
|
|
|
16 |
|
17 |
demo = gr.Interface(
|
18 |
fn=predict,
|