--- license: other base_model: unsloth/Qwen2.5-3B-Instruct-bnb-4bit tags: - clinical - medical - healthcare - qlora - unsloth - chatml - rapha language: - en --- # Rapha — Clinical AI Physician Assistant Rapha conducts structured, empathetic clinical interviews across five stages (greeting, OPQRST symptom exploration, medical history, red-flag screening, escalation report) and hands a structured report to a physician. **Rapha never diagnoses.** - **Base model:** `unsloth/Qwen2.5-3B-Instruct-bnb-4bit` - **Method:** QLoRA (Unsloth) → curriculum SFT → DPO - **Chat template:** ChatML - **Context window:** 8,192 tokens (training) / 4,096 (Ollama default) - **LoRA config:** r=32, alpha=32, target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj - **Trained:** 2026-07-22 ## Training architecture (v2.3) Single-trainer curriculum SFT: three phases concatenated into one ordered dataset with a single cosine LR schedule. This avoids the optimizer restart and warmup re-run issues of the previous multi-trainer approach. | Phase | Data | Purpose | |---|---|---| | 1 | Stage1 + Stage4 + Adversarial | Interview boundaries + robustness | | 2 | Stage2 + Stage3 | Clinical content (OPQRST + history) | | 3 | Full mix + FullArc | Complete session flows (Stage1→5) | ## Repo contents | Path | Contents | |---|---| | `/` (root) | LoRA adapter (PEFT) — small, load on top of the base model | | `merged/` | Full merged fp16 weights — standalone, no base model needed | | `gguf/` | Quantised GGUF files (Q4_K_M, Q5_K_M, Q8_0) for Ollama / llama.cpp / LM Studio | | `datasets/` | Raw JSONL training/validation/DPO datasets used for this run | ## Training data **Total training records: ~159,766** | Dataset | Records | File | |---|---|---| | Stage 1 — Greetings | 25,000 | `stage1_greetings.jsonl` | | Stage 2 — OPQRST | 40,344 | `stage2_opqrst.jsonl` | | Stage 3 — History | 40,000 | `stage3_history.jsonl` | | Stage 4 — Red Flags | 14,422 | `stage4_red_flags.jsonl` | | Adversarial | 10,000 | `adversarial.jsonl` | | Full-Arc Conversations | 30,000 | `full_arc_conversations.jsonl` | | Validation | 1,100 | `val_sharegpt.jsonl` | | DPO Preference Pairs | 3,000 | `preference_pairs.jsonl` | Stage 1 greetings, Stage 2 OPQRST symptom exploration, Stage 3 medical history, Stage 4 red-flag screening, and a multi-turn adversarial set (self-diagnosis, symptom denial, medication refusal, minimised red flags, prompt injection — a portion include a patient pushback turn to test boundary-holding). Followed by DPO preference alignment on the pairs above. ### Red-flag terms screened for `worst headache`, `can't feel my legs`, `arm feels heavy and chest`, `can't breathe`, `loss of consciousness`, `sudden vision`, `neck stiff`, `light hurts`, `confused`, `won't stop bleeding`, `bilateral leg weakness`, `bladder dysfunction`, `tachypnoea`, `thunderclap`, `cauda equina`, `qsofa`, `meningitis` ## Eval metrics (last training run) | Metric | Value | |---|---| | _(no eval metrics captured)_ | — | ## Usage — Ollama (GGUF) ```bash ollama create rapha -f Modelfile.q4_k_m ollama run rapha ``` ## Usage — Transformers (LoRA adapter) ```python from unsloth import FastLanguageModel model, tokenizer = FastLanguageModel.from_pretrained( model_name="Phora68/rapha", max_seq_length=8192, load_in_4bit=True, ) FastLanguageModel.for_inference(model) ``` ## Safety Rapha is an information-gathering and triage-support tool. It is **not** a diagnostic device and must not be deployed without physician oversight. Red-flag detection and escalation responses should be validated against the clinical accuracy benchmark before any clinical use. --- *Generated automatically by `train_rapha_llm.py` v2.3.*