低资源 AI 研究员:医疗 LLM 微调 - Openclaw Skills
作者:互联网
2026-04-12
什么是 低资源 AI 研究员?
Low-Resource AI Researcher 是一个旨在使医疗 AI 开发民主化的综合框架。它利用包括 LoRA 和 QLoRA 在内的参数高效微调 (PEFT) 技术,能够在 RTX 3090 或 4090 等消费级 GPU 上训练复杂的医疗模型。作为 Openclaw Skills 的核心组件,该工具简化了医疗领域适配的复杂性,为临床笔记、诊断和医疗问答提供了预配置的工作流程。
该技能在通用 LLM 和专业医疗应用之间架起了一座桥梁。通过 bitsandbytes 利用 4-bit 和 8-bit 量化,研究人员可以处理大型模型(高达 70B 参数),而无需庞大的数据中心基础设施。它无缝集成到 Openclaw Skills 生态系统中,为医疗 NLP 研究和开发提供标准化的方法。
下载入口:https://github.com/openclaw/skills/tree/main/skills/aipoch-ai/low-resource-ai-researcher
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install low-resource-ai-researcher
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 low-resource-ai-researcher。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
低资源 AI 研究员 应用场景
- 使用 PubMedQA 或 MedQA 数据集对 LLaMA 3 或 Mistral 等基础模型进行微调,以用于医疗问答。
- 适配大语言模型以处理和总结来自 MIMIC-III 数据库的去隐私临床笔记。
- 使用单块消费级 GPU 或单个 A100 实例等低资源硬件训练专业的诊断助手。
- 为医疗保健专用对话代理进行医疗指令微调和直接偏好优化 (DPO)。
- 在训练器配置中选择基础模型并定义医疗任务(例如 medical_qa 或 clinical_note)。
- 初始化 MedicalPEFTTrainer,它会使用适当的 LoRA 或 QLoRA 参数设置模型。
- 加载目标医疗数据集并应用领域特定的预处理和分词。
- 使用优化后的硬件配置文件执行训练过程,该文件管理 GPU 显存和量化设置。
- 针对医疗基准评估模型,以确保准确性和临床相关性。
- 将训练好的适配器权重与基础模型合并,用于最终部署和推理。
低资源 AI 研究员 配置指南
要开始使用此技能,请安装核心 AI 和医疗 NLP 依赖项:
# 安装核心训练依赖项
pip install torch transformers datasets accelerate peft bitsandbytes
# 安装优化和医疗工具
pip install flash-attn --no-build-isolation
pip install scispacy scikit-learn wandb
然后,您可以在 Python 环境中初始化训练器,或使用提供的 CLI 脚本进行自动化训练运行。
低资源 AI 研究员 数据架构与分类体系
该技能使用以下结构组织训练数据和模型元数据:
| 数据组件 | 描述 | 支持的格式 |
|---|---|---|
| 基础模型 | 用于适配的基础 LLM | LLaMA, Mistral, Qwen, Yi |
| 训练数据 | 医疗指令/问答对 | JSON, CSV, HuggingFace Datasets |
| 硬件配置文件 | GPU 显存管理配置 | YAML, Python Dict |
| 模型适配器 | 保存的 LoRA/QLoRA 权重 | Safetensors, Bin |
| 基准测试 | 医疗数据集上的性能指标 | CSV, JSON |
name: low-resource-ai-researcher
description: Train high-performance medical LLMs on consumer GPUs using parameter-efficient
fine-tuning
version: 1.0.0
category: Research
tags: []
author: AIPOCH
license: MIT
status: Draft
risk_level: Medium
skill_type: Tool/Script
owner: AIPOCH
reviewer: ''
last_updated: '2026-02-06'
Skill: Low-Resource AI Researcher
ID: 215
Category: AI/ML Research
Language: Python
Framework: PyTorch + PEFT (LoRA/QLoRA) + Transformers
Overview
Based on Parameter-Efficient Fine-Tuning (PEFT) technology, trains high-performance medical domain large language models on consumer-grade GPUs or single A100. Supports advanced fine-tuning methods such as LoRA, QLoRA, optimized for medical text understanding and generation tasks.
Features
- ?? Parameter-Efficient Fine-Tuning: LoRA, QLoRA, DoRA support
- ?? Medical Domain Optimized: Pre-configured for medical QA, diagnosis, clinical notes
- ?? Low-Resource Ready: Optimized for consumer GPUs (RTX 3090/4090) and single A100
- ?? Quantization: 4-bit/8-bit quantization with bitsandbytes
- ?? Multi-Task: Supports SFT, DPO, and medical instruction tuning
- ?? Medical Datasets: Built-in support for PubMedQA, MedQA, MIMIC-III
Installation
# Core dependencies
pip install torch transformers datasets accelerate peft bitsandbytes
# Optional for training optimization
pip install flash-attn --no-build-isolation
pip install wandb tensorboard
# Medical NLP utilities
pip install scispacy scikit-learn
Quick Start
from skills.low_resource_ai_researcher.scripts.main import MedicalPEFTTrainer
# Initialize trainer
trainer = MedicalPEFTTrainer(
model_name="meta-llama/Llama-2-7b-hf",
task="medical_qa"
)
# Train with LoRA
trainer.train(
output_dir="./medical_lora_model",
num_epochs=3,
batch_size=4,
use_qlora=True # 4-bit quantization
)
Configuration
Hardware Profiles
| Profile | GPU Memory | Quantization | Max Model Size | Batch Size |
|---|---|---|---|---|
| consumer-24g | 24GB (RTX 3090/4090) | QLoRA 4-bit | 70B | 1-2 |
| a100-40g | 40GB (A100) | LoRA 8-bit | 70B | 4-8 |
| a100-80g | 80GB (A100) | LoRA 16-bit | 70B | 8-16 |
| multi-gpu | 2x A100 | LoRA 16-bit | 70B+ | 16+ |
LoRA Config
lora:
r: 64 # LoRA rank
lora_alpha: 128 # Scaling factor
target_modules: # Modules to apply LoRA
- q_proj
- v_proj
- k_proj
- o_proj
- gate_proj
- up_proj
- down_proj
lora_dropout: 0.05
bias: "none"
task_type: "CAUSAL_LM"
CLI Usage
# Basic training
python scripts/main.py r
--model_name_or_path meta-llama/Llama-2-7b-hf r
--dataset medical_qa r
--output_dir ./output r
--use_qlora r
--per_device_train_batch_size 4
# With custom config
python scripts/main.py --config configs/medical_qlora.yaml
# Resume training
python scripts/main.py --resume_from_checkpoint ./output/checkpoint-1000
API Reference
MedicalPEFTTrainer
trainer = MedicalPEFTTrainer(
model_name: str, # Base model name/path
task: str, # Task type: medical_qa, diagnosis, clinical_note
lora_r: int = 64, # LoRA rank
lora_alpha: int = 128, # LoRA alpha
use_qlora: bool = False, # Use 4-bit quantization
target_modules: List[str] = None,
device_map: str = "auto",
trust_remote_code: bool = True
)
Methods
| Method | Description |
|---|---|
train() |
Start fine-tuning with configured parameters |
evaluate() |
Evaluate on medical benchmark datasets |
merge_and_save() |
Merge LoRA weights and save full model |
load_model() |
Load a trained model for inference |
generate() |
Generate medical text/responses |
Supported Models
- LLaMA 2/3 (7B, 13B, 70B)
- Mistral (7B, 8x7B)
- Yi (6B, 34B)
- Qwen (7B, 14B, 72B)
- Baichuan (7B, 13B)
- ChatGLM (6B)
Medical Datasets
| Dataset | Description | Size |
|---|---|---|
| PubMedQA | Biomedical QA | 1k QA pairs |
| MedQA | USMLE-style questions | 61k |
| MedMCQA | Medical entrance exam QA | 194k |
| MIMIC-III | Clinical notes | De-identified |
| CMeEE | Chinese medical NER | 15k |
| Huatuo-26M | Chinese medical corpus | 26M samples |
Performance Benchmarks
| Model | Method | GPU | Training Time | MedQA Acc |
|---|---|---|---|---|
| LLaMA-2-7B | LoRA | A100-40G | 2h | 58.2% |
| LLaMA-2-7B | QLoRA | RTX 4090 | 3h | 57.8% |
| LLaMA-2-13B | QLoRA | A100-40G | 4h | 62.5% |
| Mistral-7B | LoRA | A100-40G | 2.5h | 61.3% |
Best Practices
- Gradient Accumulation: Use for effective larger batch sizes
- Learning Rate: Start with 2e-4 for LoRA, 1e-4 for full fine-tuning
- Warmup Steps: 100 steps for medical domain adaptation
- Max Length: 2048-4096 for clinical notes, 512-1024 for QA
- Data Quality: Filter out low-quality medical data carefully
Troubleshooting
Out of Memory
# Enable gradient checkpointing
trainer.train(gradient_checkpointing=True)
# Reduce sequence length
trainer.train(max_seq_length=1024)
# Use DeepSpeed ZeRO-3 for large models
Slow Training
# Enable Flash Attention
trainer.train(use_flash_attention=True)
# Use bf16 on Ampere GPUs
trainer.train(bf16=True)
License
This skill follows the license of the underlying models used. Medical applications require compliance with HIPAA/GDPR regulations.
References
- Hu et al. (2021) - LoRA: Low-Rank Adaptation of Large Language Models
- Dettmers et al. (2023) - QLoRA: Efficient Finetuning of Quantized LLMs
- Singhal et al. (2023) - Large Language Models Encode Clinical Knowledge
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|---|---|
| Code Execution | Python/R scripts executed locally | Medium |
| Network Access | No external API calls | Low |
| File System Access | Read input files, write output files | Medium |
| Instruction Tampering | Standard prompt guidelines | Low |
| Data Exposure | Output files saved to workspace | Low |
Security Checklist
- No hardcoded credentials or API keys
- No unauthorized file system access (../)
- Output does not expose sensitive information
- Prompt injection protections in place
- Input file paths validated (no ../ traversal)
- Output directory restricted to workspace
- Script execution in sandboxed environment
- Error messages sanitized (no stack traces exposed)
- Dependencies audited
Prerequisites
# Python dependencies
pip install -r requirements.txt
Evaluation Criteria
Success Metrics
- Successfully executes main functionality
- Output meets quality standards
- Handles edge cases gracefully
- Performance is acceptable
Test Cases
- Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
Heimdall:针对 Openclaw Skills 的 AI 驱动安全扫描器
solo-humanize: AI 文本拟人化与模式消除器 - Openclaw Skills
CodeDNA:BNB Chain 上的自主 AI 生命进化 - Openclaw Skills
EvoMap Lite 客户端:自动化 AI 智能体集群协作 - Openclaw Skills
Skill Guard:Openclaw Skills 的高级安全扫描器
Arayun 173 蓝丝黛尔石执行官:AI 执法技能 - Openclaw Skills
乐享:腾讯知识库 API 集成 - Openclaw Skills
Auto Logger:持久化记忆与活动追踪 - Openclaw Skills
小红书 AI 内容创作与自动发布 - Openclaw Skills
Google 搜索:AI 驱动的网络智能 - Openclaw Skills
AI精选
