YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
med-llm-es: Spanish Medical Triage LLM
End-to-end pipeline to build a fine-tuned Spanish medical triage model for offline/edge deployment.
β οΈ MEDICAL DISCLAIMER - IMPORTANT
THIS PROJECT IS FOR EDUCATIONAL AND RESEARCH PURPOSES ONLY.
- β This is NOT a medical device
- β This does NOT provide medical advice
- β Do NOT use for actual patient triage
- β The model may produce incorrect, incomplete, or harmful outputs
Required Actions:
- Always recommend professional medical consultation
- In real emergencies, call emergency services (112 in Europe, 911 in US)
- This model should only be used for learning about LLM fine-tuning
- Researchers: validate thoroughly before any downstream applications
- Deployers: assume full liability for any use cases
Project Status
| Phase | Status | Details |
|---|---|---|
| Data Preparation | β Complete | 5000+ Spanish medical prompts |
| Continued Pre-Training (CPT) | β Complete | Medical domain adaptation |
| Supervised Fine-Tuning (SFT) | β Complete | Triage instruction tuning |
| Knowledge Distillation | β Complete | MiniMax-M2.5 teacher outputs |
| GRPO Training | β Complete | Reward-based optimization |
| DPO Training | β Complete | Preference alignment |
| GGUF Quantization | β Complete | Multiple quantization levels |
What This Project Provides
Working Models
| Model File | Size | Use Case |
|---|---|---|
| med-llm-es-triage-balanced-Q5_K_M.gguf | ~800MB | Recommended - Best quality/size balance |
| med-llm-es-triage-balanced-Q4_K_M.gguf | ~700MB | Mobile devices |
| med-llm-es-triage-balanced-Q2_K.gguf | ~460MB | Low-resource devices |
Training Datasets (Available)
- Distilled data: 5000+ examples from MiniMax-M2.5
- Preference data: 10K+ DPO training pairs
- Balanced data: Enhanced training sets
Technical Achievements
- Full RLHF pipeline (CPT β SFT β GRPO β DPO)
- Offline-capable quantized models
- Spanish medical language specialization
- Manchester Triage System (MTS) implementation
Use Cases (Educational)
This project demonstrates how to:
- Build domain-specific LLMs - Medical Spanish fine-tuning
- Implement knowledge distillation - Using powerful teacher models
- Apply RLHF techniques - GRPO and DPO for alignment
- Optimize for edge deployment - GGUF quantization
- Create safety-aligned models - Medical disclaimers and urgency levels
Pipeline
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Data Prep β 2. CPT β 3. SFT β 4. Distill β
β OpenMed + MTS Spanish Med Triage SFT MiniMax-M2.5 β
β β
β 5. GRPO β 6. DPO β 7. Quantize β 8. Deploy β
β Rewards Preference GGUF Q5 Offline App β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Directory Structure
med-llm-es/
βββ configs/
β βββ config.py # Configuration settings
βββ data/
β βββ raw/ # Downloaded OpenMed datasets
β βββ translated/ # Spanish translations
β βββ triage/ # Generated triage prompts
β βββ distilled/ # Teacher-generated data (~10MB)
β βββ preference/ # DPO preference pairs (~10MB)
βββ models/
β βββ cpt-spanish-medical-v1/ # CPT model
β βββ sft-spanish-triage-v1/ # SFT model
β βββ grpo-spanish-triage-v1/ # GRPO model
β βββ dpo-spanish-triage-v1/ # DPO model
β βββ gguf/ # Quantized models (~2GB total)
βββ scripts/
β βββ 01_download_opendmed.py # Download datasets
β βββ 02_translate_to_spanish.py # Translate to Spanish
β βββ 03_generate_triage_data.py # Create triage prompts
β βββ 04_cpt_spanish_medical.py # Continued Pre-Training
β βββ 05_sft_triage.py # Supervised Fine-Tuning
β βββ 06_distillation_generate.py # Knowledge Distillation
β βββ 07_create_preference_data.py # Create DPO dataset
β βββ 08_grpo_triage.py # GRPO training
β βββ 09_dpo_triage.py # DPO training
β βββ 10_quantize_gguf.py # Quantization
β βββ 11_monitor_grpo.py # Passive GRPO run monitor
βββ checkpoints/ # Training checkpoints
βββ reports/ # Documentation
βββ DEPLOYMENT_GUIDES.md # Edge deployment instructions
βββ README.md
Quick Start
Prerequisites
- Google Colab Pro (for A100 GPU access) or local GPU (16GB+ VRAM)
- MiniMax API Key (for distillation)
- Google Drive (for storage)
Execution Order
Data Preparation
python scripts/01_download_opendmed.py python scripts/02_translate_to_spanish.py python scripts/03_generate_triage_data.pyTraining (on Colab)
python scripts/04_cpt_spanish_medical.py # CPT python scripts/05_sft_triage.py # SFT python scripts/06_distillation_generate.py # Distillation python scripts/07_create_preference_data.py # Preference data python scripts/08_grpo_triage.py # GRPO python scripts/09_dpo_triage.py # DPOQuantization
python scripts/10_quantize_gguf.py
Triage System
Uses Manchester Triage System (MTS):
| Level | Color | Meaning | Response Time |
|---|---|---|---|
| ROJO | Red | Emergency | Immediate |
| NARANJA | Orange | Very Urgent | 10 min |
| AMARILLO | Yellow | Urgent | 60 min |
| VERDE | Green | Less Urgent | 120 min |
| AZUL | Blue | Non-urgent | 240 min |
Configuration
Edit configs/config.py:
BASE_MODEL = "LiquidAI/LFM2.5-1.2B-Base"
TEACHER_MODEL = "MiniMaxAI/MiniMax-M2.5"
MINIMAX_API_KEY = "your-api-key-here"
# Paths (use your drive)
DATA_DIR = "E:/med-llm-es/data"
MODELS_DIR = "E:/med-llm-es/models"
Deployment
See DEPLOYMENT_GUIDES.md for:
- Android (Termux)
- iOS (MLX)
- Desktop
- Raspberry Pi
Cost Estimate
| Item | Cost |
|---|---|
| Colab Pro (80 hours) | ~$100-150 |
| MiniMax API (distillation) | ~$50-100 |
| Total | ~$150-250 |
Limitations & Risks
- Model may hallucinate - Incorrect medical information
- Limited training data - Not comprehensive medical coverage
- No clinical validation - Never tested in real settings
- Language bias - Trained on specific Spanish variants
- Quantization losses - Accuracy trade-offs from compression
License
This project is for educational/research purposes only.
- Base models: LFM2.5 (Liquid AI), MiniMax-M2.5 (MiniMax)
- Training: Apache 2.0 / TRL
Acknowledgments
- Downloads last month
- 39
Hardware compatibility
Log In to add your hardware
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support