Spaces:
Running
on
Zero
Running
on
Zero
qinghuazhou
commited on
Commit
·
1f370f1
1
Parent(s):
9b292d2
updated demo
Browse files
app.py
CHANGED
@@ -28,12 +28,12 @@ def load_editor(model_name='gpt2-xl'):
|
|
28 |
)
|
29 |
return editor
|
30 |
|
31 |
-
|
32 |
def return_generate(prompt):
|
33 |
text = editor.generate(prompt, prune_bos=True)
|
34 |
return format_generation_with_edit(text, prompt)
|
35 |
|
36 |
-
|
37 |
def return_generate_with_edit(prompt, truth, edit_mode='in-place', context=None):
|
38 |
editor.edit_mode = edit_mode
|
39 |
if context == '':
|
@@ -80,7 +80,7 @@ def return_trigger_context():
|
|
80 |
print(editor.find_context())
|
81 |
return editor.find_context()
|
82 |
|
83 |
-
|
84 |
def return_generate_with_attack(prompt):
|
85 |
text = editor.generate_with_edit(prompt, stop_at_eos=True, prune_bos=True)
|
86 |
return format_generation_with_edit(text, prompt)
|
|
|
28 |
)
|
29 |
return editor
|
30 |
|
31 |
+
@spaces.GPU
|
32 |
def return_generate(prompt):
|
33 |
text = editor.generate(prompt, prune_bos=True)
|
34 |
return format_generation_with_edit(text, prompt)
|
35 |
|
36 |
+
@spaces.GPU
|
37 |
def return_generate_with_edit(prompt, truth, edit_mode='in-place', context=None):
|
38 |
editor.edit_mode = edit_mode
|
39 |
if context == '':
|
|
|
80 |
print(editor.find_context())
|
81 |
return editor.find_context()
|
82 |
|
83 |
+
@spaces.GPU
|
84 |
def return_generate_with_attack(prompt):
|
85 |
text = editor.generate_with_edit(prompt, stop_at_eos=True, prune_bos=True)
|
86 |
return format_generation_with_edit(text, prompt)
|