Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -82,76 +82,52 @@ def translate_text(
|
|
82 |
|
83 |
description = """<p align="center">Enter Japanese text to translate it into Simplified Chinese.</p>"""
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
with gr.Row():
|
96 |
-
with gr.Column():
|
97 |
-
input_textbox = gr.Textbox(
|
98 |
-
lines=10,
|
99 |
-
placeholder="請輸入日文",
|
100 |
-
label="Input Japanese Text"
|
101 |
-
)
|
102 |
-
translate_button = gr.Button("翻譯")
|
103 |
-
|
104 |
-
with gr.Column():
|
105 |
-
output_textbox = gr.Textbox(
|
106 |
-
lines=10,
|
107 |
-
label="Translated Chinese Text",
|
108 |
-
interactive=False
|
109 |
-
)
|
110 |
-
copy_button = gr.Button("複製結果")
|
111 |
-
|
112 |
-
translate_button.click(
|
113 |
-
fn=translate_text,
|
114 |
-
inputs=[
|
115 |
-
input_textbox,
|
116 |
-
gr.Dropdown([
|
117 |
'sakura-14b-qwen2beta-v0.9.2-q6k.gguf'
|
118 |
],
|
119 |
value="sakura-14b-qwen2beta-v0.9.2-q6k.gguf",
|
120 |
label="Model"
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
)
|
155 |
|
156 |
if __name__ == "__main__":
|
157 |
demo.launch()
|
|
|
82 |
|
83 |
description = """<p align="center">Enter Japanese text to translate it into Simplified Chinese.</p>"""
|
84 |
|
85 |
+
demo = gr.Interface(
|
86 |
+
fn=translate_text,
|
87 |
+
inputs=[
|
88 |
+
gr.Textbox(
|
89 |
+
lines=2,
|
90 |
+
placeholder="請輸入日文",
|
91 |
+
label="Input Japanese Text"
|
92 |
+
),
|
93 |
+
gr.Dropdown([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
'sakura-14b-qwen2beta-v0.9.2-q6k.gguf'
|
95 |
],
|
96 |
value="sakura-14b-qwen2beta-v0.9.2-q6k.gguf",
|
97 |
label="Model"
|
98 |
+
),
|
99 |
+
gr.Textbox(value="你是一个轻小说翻译模型,可以流畅通顺地以日本轻小说的风格将日文翻译成简体中文,并联系上下文正确使用人称代词,不擅自添加原文中没有的代词。", label="System message"),
|
100 |
+
gr.Slider(minimum=1, maximum=4096, value=512, step=1, label="Max tokens"),
|
101 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.1, step=0.1, label="Temperature"),
|
102 |
+
gr.Slider(
|
103 |
+
minimum=0.1,
|
104 |
+
maximum=1.0,
|
105 |
+
value=0.3,
|
106 |
+
step=0.05,
|
107 |
+
label="Top-p",
|
108 |
+
),
|
109 |
+
gr.Slider(
|
110 |
+
minimum=0,
|
111 |
+
maximum=100,
|
112 |
+
value=1,
|
113 |
+
step=1,
|
114 |
+
label="Top-k",
|
115 |
+
),
|
116 |
+
gr.Slider(
|
117 |
+
minimum=0.0,
|
118 |
+
maximum=2.0,
|
119 |
+
value=1.0,
|
120 |
+
step=0.1,
|
121 |
+
label="Repetition penalty",
|
122 |
+
),
|
123 |
+
],
|
124 |
+
outputs=gr.Textbox(
|
125 |
+
lines=2,
|
126 |
+
label="Translated Chinese Text"
|
127 |
+
),
|
128 |
+
title="Japanese to Chinese Translator",
|
129 |
+
description=description
|
130 |
+
)
|
|
|
131 |
|
132 |
if __name__ == "__main__":
|
133 |
demo.launch()
|