Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files
pulse_model_deployment/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# PULSE 疾病问答系统
|
| 3 |
+
|
| 4 |
+
## 介绍
|
| 5 |
+
这是一个基于PULSE模型的疾病问答系统,用户可以输入症状描述,系统将生成对应的疾病回答。
|
| 6 |
+
|
| 7 |
+
## 如何使用
|
| 8 |
+
1. 通过Gradio界面与模型进行交互。
|
| 9 |
+
2. 在输入框中输入症状描述,点击“提交”按钮即可获取模型的回答。
|
| 10 |
+
|
pulse_model_deployment/app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 4 |
+
|
| 5 |
+
# 加载模型
|
| 6 |
+
model_name = "OpenMEDLab/PULSE-7bv5"
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 9 |
+
|
| 10 |
+
# 定义Gradio接口
|
| 11 |
+
def predict(symptoms):
|
| 12 |
+
inputs = tokenizer(symptoms, return_tensors="pt")
|
| 13 |
+
outputs = model.generate(**inputs, max_length=200)
|
| 14 |
+
result_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 15 |
+
return result_text
|
| 16 |
+
|
| 17 |
+
# 创建Gradio界面
|
| 18 |
+
iface = gr.Interface(fn=predict, inputs="text", outputs="text", title="PULSE 疾病问答系统", description="输入症状描述获取模型的回答")
|
| 19 |
+
iface.launch()
|
| 20 |
+
|
pulse_model_deployment/requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
gradio
|
| 3 |
+
transformers
|
| 4 |
+
torch
|
| 5 |
+
|