Text Generation
Transformers
PyTorch
Safetensors
Chinese
bloom
PULSE
llm
conversational
text-generation-inference
Instructions to use OpenMEDLab/PULSE-7bv5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMEDLab/PULSE-7bv5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OpenMEDLab/PULSE-7bv5") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OpenMEDLab/PULSE-7bv5") model = AutoModelForCausalLM.from_pretrained("OpenMEDLab/PULSE-7bv5") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenMEDLab/PULSE-7bv5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenMEDLab/PULSE-7bv5" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenMEDLab/PULSE-7bv5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OpenMEDLab/PULSE-7bv5
- SGLang
How to use OpenMEDLab/PULSE-7bv5 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "OpenMEDLab/PULSE-7bv5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenMEDLab/PULSE-7bv5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "OpenMEDLab/PULSE-7bv5" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenMEDLab/PULSE-7bv5", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OpenMEDLab/PULSE-7bv5 with Docker Model Runner:
docker model run hf.co/OpenMEDLab/PULSE-7bv5
PULSE
目录
开源模型
模型介绍
- 大规模训练:PULSE模型在Bloom 7B模型的基础上, 使用约4,000,000个医学领域和通用领域的SFT数据进行进一步微调。
- 全面的医学自然语言处理任务:PULSE支持医学领域的各种自然语 言处理任务,包括健康教育、医师考试问题、报告解读、医疗记录结构化 以及模拟诊断和治疗。
局限性
由于模型参数量较小和自回归生成范式,尽管模型提供了有关疾病诊断和治疗的推理结果,但这些结果不能代替线下职业医生的建议和治疗方案。所有回答仅供参考,不应作为诊断或治疗的依据。我们强烈建议用户在需要诊断或治疗疾病时,寻求专业医生的帮助和建议。
Elo评测
| model_name | model_size | ALL | MedQA_Mainland | PromptCBLUE | webMedQA |
|---|---|---|---|---|---|
| GPT4 | 220B*8(?) | 1195 | 1087 | 1134 | 1107 |
| ChatGPT | 175B(?) | 1123 | 1053 | 1089 | 1067 |
| PULSE_7b with prompt | 7B | 1074 | 1019 | 1047 | 1060 |
| PULSE_14b | 14B | 1055 | 1001 | 1037 | 1056 |
| PULSE_7b | 7B | 1054 | 1028 | 1037 | 1030 |
| BianQue | 6B | 926 | 939 | 920 | 1011 |
| QiZhenGPT | 13B | 918 | 949 | 935 | 974 |
| Med-ChatGLM | 6B | 864 | 988 | 921 | 859 |
| BenTsao | 7B | 846 | 966 | 913 | 859 |
| DoctorGLM | 6B | 812 | 935 | 891 | 856 |
推理
硬件要求
下表提供了一个batch size=1时本地部署PULSE进行推理所需的显存大小。
| 量化等级 | 加载模型 |
|---|---|
| FP16 | 14GB |
下载安装
- 下载本仓库内容至本地/远程服务器
git clone https://github.com/openmedlab/PULSE
cd PULSE
- 创建conda环境安装依赖
conda env create -f llm.yml
conda activate llm
其中torch和transformers版本不建议低于推荐版本。
使用示例
网页Demo
Gradio
python web_demo_gradio.py
命令行Demo
您可以运行仓库中的cli_demo.py来启动一个简单的命令行Demo:
python cli_demo.py
致谢
- 上海人工智能实验室
- 上海交通大学-清源研究院
- 华东理工大学-自然语言处理与大数据挖掘实验室
开源协议
本项目所含代码采用Apache 2.0协议,模型权重采用GNU AGPL 3.0协议。如使用本项目所含模型及其修改版本提供服务产生误导性或有害性言论,造成不良影响,由服务提供方负责,与本项目无关。
- Downloads last month
- 33
docker model run hf.co/OpenMEDLab/PULSE-7bv5