Skip to content

High Level Design

Sudhanshu Shukla edited this page Nov 23, 2026 · 2 revisions

High-Level Design (HLD)

Healthcare text acquisition and audit, tokenizer, random-initialized pretraining, full-parameter medical SFT, checkpoints, and evaluation.

This diagram is rendered directly by GitHub Wiki Mermaid, not as a link to a raw .mmd file. It describes the implemented training pipeline and architecture; it is not clinical validation.

flowchart TB
    HFS[("HF: common-pile/pubmed_filtered<br/>biomedical research text")]
    HFM[("HF: FreedomIntelligence/<br/>medical-o1-reasoning-SFT")]

    subgraph PREP["Stage 0 · Data and tokenizer preparation"]
      AUDIT["Dataset provenance, licensing<br/>and clinical-text screening"]
      BPE["Train healthcare BPE tokenizer<br/>and validate vocabulary IDs"]
      TOK[("Healthcare tokenizer JSON")]
      AUDIT --> BPE --> TOK
    end

    subgraph PRETRAIN["Stage 1 · Healthcare-only pretraining"]
      PACK["Stream, partition and pack<br/>128-token training sequences"]
      INIT["Initialize native Mixtral-style MoE<br/>with random model weights"]
      CE["Causal next-token CE<br/>plus MoE balancing loss"]
      ADAM["AdamW updates all parameters<br/>5,000 optimizer steps"]
      CK1[("Pretraining checkpoint: last.pt")]
      PACK --> CE
      INIT --> CE
      CE --> ADAM --> CK1
    end

    subgraph SFT["Stage 2 · Full-parameter medical SFT"]
      FORMAT["Question/Response parsing<br/>and deterministic data partition"]
      MASK["Prompt-to-answer formatting<br/>completion-only loss masks"]
      LOAD["Initialize with Stage 1 weights<br/>and a fresh AdamW optimizer"]
      UPDATE["Update all model parameters<br/>2,000 optimizer steps"]
      CK2[("Medical SFT checkpoint: last.pt")]
      FORMAT --> MASK --> UPDATE
      LOAD --> UPDATE --> CK2
    end

    subgraph VERIFY["Validation and responsible evaluation"]
      METRICS["Held-out CE and perplexity<br/>training and checkpoint metrics"]
      REVIEW["Independent medical quality,<br/>privacy and safety review required"]
      METRICS --> REVIEW
    end

    HFS --> AUDIT
    AUDIT --> PACK
    TOK --> PACK
    TOK --> MASK
    CK1 --> LOAD
    HFM --> FORMAT
    CK1 --> METRICS
    CK2 --> METRICS

    classDef source fill:#e6f2ff,stroke:#5583b2,color:#173b61
    classDef checkpoint fill:#ebf8ec,stroke:#4d9869,color:#235d39
    classDef caution fill:#fff1dd,stroke:#bc8241,color:#75451b
    class HFS,HFM source
    class TOK,CK1,CK2 checkpoint
    class REVIEW caution
Loading

Interactive architecture site · Source repository · Architecture · Home

Clone this wiki locally