Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,8 @@ import random
|
|
| 5 |
generator = pipeline('text-generation', model='jslin09/bloom-560m-finetuned-fraud')
|
| 6 |
|
| 7 |
def generate(text):
|
| 8 |
-
|
| 9 |
-
set_seed(
|
| 10 |
result = generator(text,
|
| 11 |
max_length=500,
|
| 12 |
num_return_sequences=1,
|
|
@@ -22,14 +22,19 @@ examples = [
|
|
| 22 |
["王大明意圖為自己不法所有,基於竊盜之犯意,"]
|
| 23 |
]
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|
| 35 |
-
demo.launch()
|
|
|
|
| 5 |
generator = pipeline('text-generation', model='jslin09/bloom-560m-finetuned-fraud')
|
| 6 |
|
| 7 |
def generate(text):
|
| 8 |
+
rnd_seed = random.randint(10, 500)
|
| 9 |
+
set_seed(rnd_seed)
|
| 10 |
result = generator(text,
|
| 11 |
max_length=500,
|
| 12 |
num_return_sequences=1,
|
|
|
|
| 22 |
["王大明意圖為自己不法所有,基於竊盜之犯意,"]
|
| 23 |
]
|
| 24 |
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown(
|
| 27 |
+
"""
|
| 28 |
+
# <p style="text-align: center;">Legal Document Drafting</p>
|
| 29 |
+
""")
|
| 30 |
+
with gr.Row():
|
| 31 |
+
with gr.Column():
|
| 32 |
+
prompt = gr.components.Textbox(lines=5, label="輸入提示文字", placeholder=examples[0])
|
| 33 |
+
btn = gr.Button("生成草稿")
|
| 34 |
+
gr.Examples(examples, inputs=[prompt])
|
| 35 |
+
with gr.Column():
|
| 36 |
+
result = gr.components.Textbox(label="生成的草稿")
|
| 37 |
+
btn.click(generate, inputs=[prompt], outputs=[result])
|
| 38 |
|
| 39 |
if __name__ == "__main__":
|
| 40 |
+
demo.launch() # 在遠端啟動時,需要 share=True 。
|