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:

  1. Build domain-specific LLMs - Medical Spanish fine-tuning
  2. Implement knowledge distillation - Using powerful teacher models
  3. Apply RLHF techniques - GRPO and DPO for alignment
  4. Optimize for edge deployment - GGUF quantization
  5. 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

  1. Google Colab Pro (for A100 GPU access) or local GPU (16GB+ VRAM)
  2. MiniMax API Key (for distillation)
  3. Google Drive (for storage)

Execution Order

  1. Data Preparation

    python scripts/01_download_opendmed.py
    python scripts/02_translate_to_spanish.py
    python scripts/03_generate_triage_data.py
    
  2. Training (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           # DPO
    
  3. Quantization

    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

  1. Model may hallucinate - Incorrect medical information
  2. Limited training data - Not comprehensive medical coverage
  3. No clinical validation - Never tested in real settings
  4. Language bias - Trained on specific Spanish variants
  5. 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
GGUF
Model size
1B params
Architecture
lfm2
Hardware compatibility
Log In to add your hardware

2-bit

4-bit

5-bit

Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using apol/med-llm-triage-es 1