Text Generation
Transformers
Safetensors
Chinese
English
baichuan
feature-extraction
custom_code
medical
healthcare
prostate-cancer
lifestyle-management
patient-education
domain-specific
supervised-fine-tuning
lora
bilingual
conversational
text-generation-inference
Instructions to use RomilY/PCaPLMM_SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RomilY/PCaPLMM_SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RomilY/PCaPLMM_SFT", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("RomilY/PCaPLMM_SFT", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RomilY/PCaPLMM_SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RomilY/PCaPLMM_SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RomilY/PCaPLMM_SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RomilY/PCaPLMM_SFT
- SGLang
How to use RomilY/PCaPLMM_SFT 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 "RomilY/PCaPLMM_SFT" \ --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": "RomilY/PCaPLMM_SFT", "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 "RomilY/PCaPLMM_SFT" \ --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": "RomilY/PCaPLMM_SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RomilY/PCaPLMM_SFT with Docker Model Runner:
docker model run hf.co/RomilY/PCaPLMM_SFT
Upload folder using huggingface_hub
Browse files- README.md +98 -1
- model-00001-of-00004.safetensors +3 -0
- model-00002-of-00004.safetensors +3 -0
- model-00003-of-00004.safetensors +3 -0
- model-00004-of-00004.safetensors +3 -0
- tokenizer.model +3 -0
README.md
CHANGED
|
@@ -1 +1,98 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- zh
|
| 5 |
+
- en
|
| 6 |
+
tasks:
|
| 7 |
+
- text-generation
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# PCaPLMM_SFT: A Prostate Cancer Patient Lifestyle Management Model via Supervised Fine-Tuning
|
| 12 |
+
|
| 13 |
+
## 📄 项目简介
|
| 14 |
+
|
| 15 |
+
PCaPLMM_SFT 是一个基于 Baichuan2-7B-chat 应用 LoRA 微调经 LLaMA-Factory 架构训练而成的中英文医学对话生成模型。它面向前列腺癌患者的生活方式管理需求,展现了职业医学知识和人文关怀的组合性交互特征。
|
| 16 |
+
|
| 17 |
+
## 🤖 基础模型信息
|
| 18 |
+
|
| 19 |
+
- 基础模型:Baichuan2-7B-Chat
|
| 20 |
+
- 微调方式:LoRA (rank=8, 使用 bf16)
|
| 21 |
+
- 训练架构:LLaMA-Factory (v0.7.0)
|
| 22 |
+
- 训练数据:基于系统纳入的2211篇文献构建了面向前列腺癌生活方式场景的训练数据集,包括营养管理、体力活动、体重管控、药物从实性、心理支持等场景
|
| 23 |
+
表2.MedLIFE-Pca-Train数据集的数据构成
|
| 24 |
+
|数据集名称 |类型数据量 | 描述 |
|
| 25 |
+
|预训练数据集 |文本数据 |2211 篇文献 包含 1516 篇原创性研究文章和695篇与前列腺癌生活方式相关的综述,用于领域继续预训练 |
|
| 26 |
+
|单轮对话数据集 |医疗对话 |42,670 组 基于知识库生成的单轮患者问答,覆盖饮食营养、体力活动、体重管理、心理支持、药物依从等主题 |
|
| 27 |
+
|多轮对话数据集 |多轮医疗对话| 3,008 组 结合上下文语境扩展生成的连续问答数据,模拟患者在生活方式管理过程中的多轮互动情境 |
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
> 注:根据随机抽样100条问答对进行人工评分
|
| 35 |
+
|
| 36 |
+
## 📚 训练数据生成流程
|
| 37 |
+
|
| 38 |
+
将已生成的问题和区域化知识片段进行 prompt 拼接,通过模型生成给出答案。生成进程中模型被指示优先引用专业术语和指南意见,并清晰标明知识来源,以确保答案的医学准确性、可解释性和上下文连谱性。
|
| 39 |
+
|
| 40 |
+
所有问答对通过统一 JSON 格式保存,用于作为相同类型的盈得导入,保证格式统一、组织程度高、可重复性强。
|
| 41 |
+
|
| 42 |
+
同时,为了保障训练数据的质量与安全,引入人工评估机制对部分样本进行检查,并通过关键术语迁渡和格式校验规则删除存在医学误差、逻辑矛盾或语言异常的问答对。
|
| 43 |
+
|
| 44 |
+
## 📂 文件结构
|
| 45 |
+
|
| 46 |
+
```
|
| 47 |
+
├── adapter_model.bin # LoRA 微调权重
|
| 48 |
+
├── config.json # 模型配置文件
|
| 49 |
+
├── tokenizer_config.json # 分词器配置
|
| 50 |
+
├── special_tokens_map.json # 特殊符号映射
|
| 51 |
+
├── README.md # 详细说明
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
## 🔧 使用示例
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 58 |
+
|
| 59 |
+
model = AutoModelForCausalLM.from_pretrained("your-username/PCaPLMM_SFT")
|
| 60 |
+
tokenizer = AutoTokenizer.from_pretrained("your-username/PCaPLMM_SFT")
|
| 61 |
+
|
| 62 |
+
prompt = "前列腺癌患者是否可以运动?"
|
| 63 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 64 |
+
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 65 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## 🚫 使用限制
|
| 69 |
+
|
| 70 |
+
- 本模型仅用于科研与教学相关场景,不应用于实际医疗诊断或倡导
|
| 71 |
+
- 如需商业化使用,请联系项目负责人
|
| 72 |
+
|
| 73 |
+
## 📧 联系方式
|
| 74 |
+
|
| 75 |
+
- 项目负责人:[Fangyuan Jiang\_theromily@gmail.com]
|
| 76 |
+
- 所属单位:南通大学医学院
|
| 77 |
+
|
| 78 |
+
## 🌟 致谢
|
| 79 |
+
|
| 80 |
+
- [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory)
|
| 81 |
+
- [Baichuan2-7B-Chat](https://huggingface.co/baichuan-inc/Baichuan2-7B-Chat)
|
| 82 |
+
|
| 83 |
+
## 协议
|
| 84 |
+
|
| 85 |
+
社区使用 Baichuan 2 模型需要遵循 [Apache 2.0](https://github.com/baichuan-inc/Baichuan2/blob/main/LICENSE) 和[《Baichuan 2 模型社区许可协议》](https://huggingface.co/baichuan-inc/Baichuan2-7B-Base/resolve/main/Baichuan%202%E6%A8%A1%E5%9E%8B%E7%A4%BE%E5%8C%BA%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.pdf)。Baichuan 2 模型支持商业用途,如果您计划将 Baichuan 2 模型或其衍生品用于商业目的,请您确认您的主体符合以下情况:
|
| 86 |
+
1. 您或您的关联方的服务或产品的日均用户活跃量(DAU)低于100万。
|
| 87 |
+
2. 您或您的关联方不是软件服务提供商、云服务提供商。
|
| 88 |
+
3. 您或您的关联方不存在将授予您的商用许可,未经百川许可二次授权给其他第三方的可能。
|
| 89 |
+
|
| 90 |
+
在符合以上条件的前提下,您需要通过以下联系邮箱 opensource@baichuan-inc.com ,提交《Baichuan 2 模型社区许可协议》要求的申请材料。审核通过后,百川将特此授予您一个非排他性、全球性、不可转让、不可再许可、可撤销的商用版权许可。
|
| 91 |
+
|
| 92 |
+
The community usage of Baichuan 2 model requires adherence to [Apache 2.0](https://github.com/baichuan-inc/Baichuan2/blob/main/LICENSE) and [Community License for Baichuan2 Model](https://huggingface.co/baichuan-inc/Baichuan2-7B-Base/resolve/main/Baichuan%202%E6%A8%A1%E5%9E%8B%E7%A4%BE%E5%8C%BA%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.pdf). The Baichuan 2 model supports commercial use. If you plan to use the Baichuan 2 model or its derivatives for commercial purposes, please ensure that your entity meets the following conditions:
|
| 93 |
+
|
| 94 |
+
1. The Daily Active Users (DAU) of your or your affiliate's service or product is less than 1 million.
|
| 95 |
+
2. Neither you nor your affiliates are software service providers or cloud service providers.
|
| 96 |
+
3. There is no possibility for you or your affiliates to grant the commercial license given to you, to reauthorize it to other third parties without Baichuan's permission.
|
| 97 |
+
|
| 98 |
+
Upon meeting the above conditions, you need to submit the application materials required by the Baichuan 2 Model Community License Agreement via the following contact email: opensource@baichuan-inc.com. Once approved, Baichuan will hereby grant you a non-exclusive, global, non-transferable, non-sublicensable, revocable commercial copyright license.
|
model-00001-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05ea820ce25efe213ccdc418d3d03cf321d4186d7f7c23c32f17b6477cedf32e
|
| 3 |
+
size 4987182800
|
model-00002-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:31d301738f8342bb5a093094de2e43159bcf93376c0015ae009b8e2e88c7f1f7
|
| 3 |
+
size 4947404688
|
model-00003-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0cf6e40f4c3066896e519f38ed2b98399c2d58425d005ffae122d6b66ff9cb57
|
| 3 |
+
size 4047683632
|
model-00004-of-00004.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f5fb54adaafd83f71008d96741393725d92a63b9443c860bc6484930c21fa33
|
| 3 |
+
size 1029701760
|
tokenizer.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79452955be6b419a65984273a9f08af86042e1c2a75ee3ba989cbf620a133cc2
|
| 3 |
+
size 2001107
|