Spaces:
Runtime error
Runtime error
[update]edit main
Browse files
Users/__init__.py
ADDED
File without changes
|
Users/tianx/PycharmProjects/__init__.py
ADDED
File without changes
|
Users/tianx/PycharmProjects/qwen_7b_chinese_modern_poetry/__init__.py
ADDED
File without changes
|
Users/tianx/PycharmProjects/qwen_7b_chinese_modern_poetry/trained_models/__init__.py
ADDED
File without changes
|
Users/tianx/__init__.py
ADDED
File without changes
|
main.py
CHANGED
@@ -36,10 +36,10 @@ def get_args():
|
|
36 |
description = """
|
37 |
## Qwen-7B
|
38 |
|
39 |
-
基于 [Qwen-7B](https://huggingface.co/qgyd2021/Qwen-7B) 模型, 在 [chinese_modern_poetry](https://huggingface.co/datasets/Iess/chinese_modern_poetry) 的 prompt
|
40 |
|
41 |
可用于生成现代诗. 如下:
|
42 |
-
|
43 |
"""
|
44 |
|
45 |
|
@@ -64,7 +64,7 @@ def main():
|
|
64 |
args.pretrained_model_name_or_path,
|
65 |
trust_remote_code=True,
|
66 |
low_cpu_mem_usage=True,
|
67 |
-
torch_dtype=torch.
|
68 |
device_map="auto",
|
69 |
offload_folder="./offload",
|
70 |
offload_state_dict=True,
|
@@ -88,30 +88,31 @@ def main():
|
|
88 |
outputs = outputs.tolist()[0][len(input_ids[0]):]
|
89 |
response = tokenizer.decode(outputs)
|
90 |
response = response.strip().replace(tokenizer.eos_token, "").strip()
|
91 |
-
return response
|
92 |
|
93 |
-
|
94 |
-
max_new_tokens: int = 200,
|
95 |
-
top_p: float = 0.85,
|
96 |
-
temperature: float = 0.35,
|
97 |
-
repetition_penalty: float = 1.2
|
98 |
-
):
|
99 |
-
return
|
100 |
|
101 |
with gr.Blocks() as blocks:
|
102 |
gr.Markdown(value=description)
|
103 |
|
104 |
-
chatbot = gr.Chatbot([], elem_id="chatbot"
|
105 |
with gr.Row():
|
106 |
with gr.Column(scale=4):
|
107 |
-
|
108 |
with gr.Column(scale=1):
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
blocks.queue().launch()
|
117 |
|
|
|
36 |
description = """
|
37 |
## Qwen-7B
|
38 |
|
39 |
+
基于 [Qwen-7B](https://huggingface.co/qgyd2021/Qwen-7B) 模型, 在 [chinese_modern_poetry](https://huggingface.co/datasets/Iess/chinese_modern_poetry) 的 prompt 数据集上训练了 2 个 epoch.
|
40 |
|
41 |
可用于生成现代诗. 如下:
|
42 |
+
使用下列意象写一首现代诗:智慧,刀刃.
|
43 |
"""
|
44 |
|
45 |
|
|
|
64 |
args.pretrained_model_name_or_path,
|
65 |
trust_remote_code=True,
|
66 |
low_cpu_mem_usage=True,
|
67 |
+
torch_dtype=torch.bfloat16,
|
68 |
device_map="auto",
|
69 |
offload_folder="./offload",
|
70 |
offload_state_dict=True,
|
|
|
88 |
outputs = outputs.tolist()[0][len(input_ids[0]):]
|
89 |
response = tokenizer.decode(outputs)
|
90 |
response = response.strip().replace(tokenizer.eos_token, "").strip()
|
|
|
91 |
|
92 |
+
return [(text, response)]
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
with gr.Blocks() as blocks:
|
95 |
gr.Markdown(value=description)
|
96 |
|
97 |
+
chatbot = gr.Chatbot([], elem_id="chatbot", height=400)
|
98 |
with gr.Row():
|
99 |
with gr.Column(scale=4):
|
100 |
+
text_box = gr.Textbox(show_label=False, placeholder="Enter text and press enter", container=False)
|
101 |
with gr.Column(scale=1):
|
102 |
+
submit_button = gr.Button("💬Submit")
|
103 |
+
with gr.Column(scale=1):
|
104 |
+
clear_button = gr.Button("🗑️Clear", variant="secondary")
|
105 |
+
|
106 |
+
gr.Examples(examples, text_box)
|
107 |
+
|
108 |
+
text_box.submit(fn, [text_box], [chatbot])
|
109 |
+
submit_button.click(fn, [text_box], [chatbot])
|
110 |
+
clear_button.click(
|
111 |
+
fn=lambda: ("", ""),
|
112 |
+
outputs=[text_box, chatbot],
|
113 |
+
queue=False,
|
114 |
+
api_name=False,
|
115 |
+
)
|
116 |
|
117 |
blocks.queue().launch()
|
118 |
|