How to use from
Docker Model Runner
docker model run hf.co/drdeveloper88/WorldDisasterLM-8B
Quick Links

WorldDisasterLM-8B

Open-source AI foundation model for global disaster intelligence, emergency response, and humanitarian aid — supporting 11 languages including Nepali.

Python 3.11+ License HuggingFace Tests


How to Use

# pip install transformers accelerate bitsandbytes peft
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
import torch

model_id = "drdeveloper88/WorldDisasterLM-8B"

# Load with 4-bit NF4 quantization (requires ~6 GB VRAM)
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
)

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    quantization_config=bnb_config,
    device_map="auto",
)

# Ask a disaster question in any of the 11 supported languages
messages = [
    {
        "role": "user",
        "content": "What immediate steps should I take during a major earthquake? I am in Kathmandu, Nepal."
    }
]

input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
).to(model.device)

gen_tokens = model.generate(
    input_ids,
    max_new_tokens=512,
    do_sample=True,
    temperature=0.7,
    top_p=0.9,
    repetition_penalty=1.1,
)

response = tokenizer.decode(gen_tokens[0][input_ids.shape[-1]:], skip_special_tokens=True)
print(response)

Multilingual example (Nepali)

messages = [{"role": "user", "content": "भूकम्पको बेला के गर्ने? म काठमाडौंमा छु।"}]
# (What to do during an earthquake? I am in Kathmandu.)

CLI inference

python inference.py --prompt "What to do during a flood?" --language English --region Nepal
python inference.py --prompt "भूकम्पको बेला के गर्ने?" --language Nepali --region Nepal

Note: Model weights (.safetensors) are generated after training completes.
Run python train.py on a GPU (A100/V100 recommended) to produce the weights, then push via scripts/push_to_hub.py.


What is WorldDisasterLM-8B?

WorldDisasterLM-8B is a production-grade, domain-specialized large language model fine-tuned on top of meta-llama/Llama-3.1-8B-Instruct using QLoRA (4-bit NF4 quantization, LoRA r=16). It is purpose-built to assist:

  • 🌍 Emergency responders — real-time disaster action guidance
  • 🏥 Humanitarian aid workers — resource allocation and triage support
  • 🏛️ Government agencies — risk assessment and crisis intelligence
  • 🌐 Global communities — multilingual disaster preparedness in 11 languages

Training data is collected live from six free public APIs: ReliefWeb, USGS Earthquake, GDACS, NOAA Weather, OpenFEMA, and WHO — with automated QA amplification generating 8 instruction variants per disaster record.


Key Features

Feature Detail
Base model meta-llama/Llama-3.1-8B-Instruct
Fine-tuning QLoRA — 4-bit NF4, LoRA r=16, all attn+MLP projectors
Languages 11: English, Nepali (नेपाली), Spanish, French, Arabic, Hindi, Telugu, Chinese, Japanese, Korean, Portuguese
Data sources ReliefWeb, USGS, GDACS, NOAA, OpenFEMA, WHO
Dataset size 88+ live records → 711+ instruction samples per run
API FastAPI REST + Server-Sent Events streaming
Frontend React 18 + Vite disaster analytics dashboard
Export GGUF (llama.cpp) + ONNX formats
HuggingFace Auto-push via scripts/push_to_hub.py

Supported Languages

Language Code Script
English en Latin
Nepali ne Devanagari (नेपाली)
Spanish es Latin
French fr Latin
Arabic ar Arabic
Hindi hi Devanagari
Telugu te Telugu
Chinese zh Hanzi
Japanese ja Kanji/Hiragana
Korean ko Hangul
Portuguese pt Latin

Quick Start

1. Clone and install

git clone https://huggingface.co/drdeveloper88/WorldDisasterLM-8B worlddisasterllm
cd worlddisasterllm
python -m venv .venv

# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate

pip install -r requirements.txt

Windows note: If your path has spaces, always set:

$env:PYTHONPATH = "C:\path\to\worlddisasterllm"

2. Configure environment

cp .env.example .env
# Add HF_TOKEN for HuggingFace publishing (optional)

3. Run the API backend

uvicorn backend.app.main:app --reload --port 8000

API available at: http://localhost:8000
Interactive docs: http://localhost:8000/docs

4. Run the React dashboard

cd frontend
npm install
npm run dev

Dashboard at: http://localhost:5173

5. Run the Gradio demo

python app.py

Demo at: http://localhost:7860

6. Run CLI inference

# English
python inference.py --prompt "What to do during a flood?" --language English --region Nepal

# Nepali
python inference.py --prompt "भूकम्पको बेला के गर्ने?" --language Nepali --region Nepal

Training Pipeline

Step 1 — Collect live data

python scripts/collect_data.py
# Collects from: ReliefWeb, USGS, GDACS, NOAA, OpenFEMA, WHO
# Output: data/processed/instruction_dataset.jsonl

Step 2 — Fine-tune with QLoRA

python train.py --output checkpoints/worlddisasterlm-8b-qlora
# Requires GPU (A100/V100 recommended)
# Uses: 4-bit NF4 quantization + LoRA r=16 + SFTTrainer

Step 3 — Evaluate

python evaluate.py

Step 4 — Push to HuggingFace

export HF_TOKEN=hf_xxxx   # or $env:HF_TOKEN on Windows
python scripts/push_to_hub.py \
    --adapter checkpoints/worlddisasterlm-8b-qlora \
    --base-model meta-llama/Llama-3.1-8B-Instruct \
    --repo-id YourUsername/WorldDisasterLM-8B

Step 5 — Export to GGUF (for llama.cpp / Ollama)

python scripts/export_gguf.py \
    --model-path checkpoints/worlddisasterlm-8b-qlora \
    --output-path artifacts/worlddisasterlm-8b.gguf

API Reference

Health check

GET /health
→ { "status": "ok", "model": "WorldDisasterLM-8B" }

Disaster chat

POST /v1/chat
{
  "messages": [{"role": "user", "content": "What to do during earthquake?"}],
  "language": "Nepali",
  "region": "Nepal"
}
→ { "answer": "[WorldDisasterLM-8B | नेपाली | Nepal] ...", "confidence": 0.74, ... }

Streaming chat

POST /v1/chat/stream    (Server-Sent Events)

Risk scoring

POST /v1/risk/score
{ "region": "South Asia", "hazard_type": "flood", "vulnerability_index": 0.74, "exposure_index": 0.81 }
→ { "risk_score": ..., "risk_level": "High", "recommendation": "..." }

Incident classification

POST /v1/incidents/classify
{ "text": "Magnitude 7.1 earthquake near coastal city. Hospitals overloaded." }
→ { "incident_type": "earthquake", "severity": "critical", ... }

Repository Structure

worlddisasterlm/
├── backend/                   FastAPI backend
│   └── app/
│       ├── main.py            API entrypoint
│       ├── services/
│       │   ├── inference_service.py   Core response generation (multilingual)
│       │   └── risk_engine.py         Risk scoring engine
│       ├── guardrails/
│       │   └── safety.py      Prompt safety filters
│       └── models/schemas.py  Pydantic v2 request/response models
├── worlddisasterlm/           Core ML package
│   ├── config.py              SUPPORTED_LANGUAGES, PipelineConfig
│   ├── data/
│   │   ├── collectors/        6 live API data collectors
│   │   ├── etl.py             Extract-Transform-Load pipeline
│   │   ├── qa_generator.py    8-variant QA amplification
│   │   ├── scenario_builder.py  Multilingual disaster scenarios
│   │   └── processors.py      JSONL dataset builder
│   ├── training/
│   │   ├── train_qlora.py     Production QLoRA training (SFTTrainer)
│   │   └── chat_format.py     Llama 3.1 chat template
│   ├── evaluation/
│   │   ├── metrics.py         Task + safety metrics
│   │   └── multilingual_eval.py  11-language coverage scoring
│   └── optimization/
│       ├── export_gguf.py     GGUF export (llama.cpp)
│       └── export_onnx.py     ONNX export
├── frontend/                  React 18 + Vite dashboard
│   └── src/App.jsx            Language selector, chat, analytics, monitoring
├── scripts/
│   ├── collect_data.py        Live data collection orchestrator
│   ├── push_to_hub.py         HuggingFace Hub publisher
│   ├── export_gguf.py         GGUF CLI wrapper
│   └── export_onnx.py         ONNX CLI wrapper
├── tests/
│   ├── test_api.py            FastAPI integration tests (incl. Nepali)
│   ├── test_dataset_builder.py  ETL + Nepali language tests
│   └── test_risk_engine.py    Risk scoring tests
├── inference.py               CLI inference entrypoint
├── train.py                   Training entrypoint
├── evaluate.py                Evaluation entrypoint
├── app.py                     Gradio demo
├── dataset_builder.py         Dataset build entrypoint
├── Dockerfile                 API container
├── docker-compose.yml         Full stack (API + frontend + MLflow)
└── pyproject.toml             Project metadata + pytest config

Running Tests

# Windows
$env:PYTHONPATH = "C:\path\to\worlddisasterllm"
python -m pytest tests/ -v

# macOS/Linux
PYTHONPATH=. pytest tests/ -v

Expected output: 9 passed — including Nepali language tests.


Safety and Responsible AI

  • Prompt-level guardrails block unsafe instructions
  • Output confidence scoring with human-review flags
  • Emergency disclaimers on all life-safety guidance
  • Hallucination heuristics with citation anchoring
  • Human-in-the-loop escalation for critical incidents

HuggingFace Publishing

The model is published as WorldDisasterLM-8B on HuggingFace Hub with:

  • Merged LoRA adapters (production-ready weights)
  • Model card with 11-language tags (en, ne, es, fr, ar, hi, te, zh, ja, ko, pt)
  • GGUF variant for llama.cpp / Ollama compatibility

License

Base model: Llama 3 Community License (Meta).
This fine-tuning code and dataset pipeline: Apache 2.0.


Acknowledgements

Downloads last month
54
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for drdeveloper88/WorldDisasterLM-8B

Adapter
(2499)
this model