scientific-skills/Evidence Insights/low-resource-ai-researcher/SKILL.md
Train high-performance medical LLMs on consumer GPUs using parameter-efficient fine-tuning
npx skillsauth add aipoch/medical-research-skills low-resource-ai-researcherInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ID: 215
Category: AI/ML Research
Language: Python
Framework: PyTorch + PEFT (LoRA/QLoRA) + Transformers
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.
# 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
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
)
| 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:
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"
# Basic training
python scripts/main.py \
--model_name_or_path meta-llama/Llama-2-7b-hf \
--dataset medical_qa \
--output_dir ./output \
--use_qlora \
--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
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
)
| 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 |
| 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 |
| 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% |
# Enable gradient checkpointing
trainer.train(gradient_checkpointing=True)
# Reduce sequence length
trainer.train(max_seq_length=1024)
# Use DeepSpeed ZeRO-3 for large models
# Enable Flash Attention
trainer.train(use_flash_attention=True)
# Use bf16 on Ampere GPUs
trainer.train(bf16=True)
This skill follows the license of the underlying models used. Medical applications require compliance with HIPAA/GDPR regulations.
| 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 |
# Python dependencies
pip install -r requirements.txt
tools
Generates complete conventional oncology bulk-transcriptome biomarker and hub-gene research designs from a user-provided cancer type and study direction. Always use this skill whenever a user wants to design, plan, or build a tumor bioinformatics study centered on differential expression, prognostic filtering or risk modeling, PPI-based hub-gene prioritization, diagnostic/prognostic evaluation, clinical association, immune infiltration context, methylation context, and optional tissue or cell validation. Covers five study patterns (signature-first prognostic workflow, hub-gene-first biomarker workflow, hybrid signature-to-hub workflow, immune-context biomarker workflow, translational validation workflow) and always outputs four workload configs (Lite / Standard / Advanced / Publication+) with recommended primary plan, step-by-step workflow, figure plan, validation strategy, minimal executable version, publication upgrade path...
development
Generates complete conventional non-oncology bioinformatics research designs from a user-provided disease context, process-related gene family or biological theme, and validation direction. Use when a study centers on multi-dataset bulk transcriptome integration, DEG analysis, process-gene intersection, enrichment analysis, GSEA, PPI hub-gene prioritization, TF/miRNA regulatory networks, ROC-based biomarker evaluation, and immune infiltration analysis. Covers five study patterns (process-DEG discovery, enrichment/GSEA interpretation, hub-gene prioritization, regulatory-network and immune interpretation, multi-layer public validation) and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.
tools
Plans confounder control, variable adjustment logic, and bias mitigation strategies at the protocol stage for clinical, epidemiologic, translational, observational, and biomarker studies. Always use this skill when a user needs to identify major confounders, decide which variables should or should not be adjusted for, compare matching/stratification/weighting approaches, anticipate selection or measurement bias, or pressure-test a study design before execution. Focus on bias sensing, causal structure awareness, variable-role classification, and critical design review rather than generic statistical advice.
testing
Generates complete comparative network-toxicology research designs from a user-provided exposure pair, shared toxic phenotype, and validation direction. Use when a study centers on two related exposures under one outcome and needs target collection, shared-vs-specific target decomposition, enrichment, PPI hub prioritization, docking, optional transcriptomic cross-checks, and conservative mechanistic synthesis. Covers five study patterns and always outputs Lite / Standard / Advanced / Publication+ with a recommended primary plan, stepwise workflow, figure plan, validation hierarchy, minimal executable version, publication upgrade path, and strictly verified literature retrieval.