Commit Graph

15 Commits

Author SHA1 Message Date
cb7575a229 feat: Update model and training parameters
In `models.py`:
- Change temporal attention mask to be strictly causal (`<` instead of `<=`).
- Add self-attention for the first token in a sequence to prevent NaNs.

In `train.py`:
- Update hyperparameters:
  - `block_length`: 24 -> 48
  - `n_embd`: 256 -> 120
  - `n_layer`: 8 -> 12
  - `n_head`: 8 -> 12
2025-10-16 18:50:15 +08:00
e2495f43b0 revert 6e0713048a
revert update attn mask
2025-10-16 18:37:55 +08:00
6e0713048a update attn mask 2025-10-16 18:29:48 +08:00
eec406d79f update ignored events. 2025-10-16 17:10:01 +08:00
e3e533c9ec update 2025-10-16 16:58:30 +08:00
b5172392cb update dpp 2025-10-16 16:46:33 +08:00
6b0b86d9d0 add Multi_GPU support. 2025-10-16 16:28:52 +08:00
c7296381b8 Revert "feat: adapt train.py to multi-GPU environment"
This reverts commit b7aad7a774.
2025-10-16 16:23:38 +08:00
2b20299e36 Revert "fix: average loss for multi-GPU training"
This reverts commit 85502561ee.
2025-10-16 16:23:35 +08:00
85502561ee fix: average loss for multi-GPU training 2025-10-16 16:21:51 +08:00
b7aad7a774 feat: adapt train.py to multi-GPU environment 2025-10-16 16:16:15 +08:00
4181ead03a Refactor: Improve attention mechanism and early stopping
- Refactor the self-attention mechanism in `models.py` to use `nn.MultiheadAttention` for better performance and clarity.
- Disable early stopping check during warmup epochs in `train.py` to improve training stability.
2025-10-16 15:57:27 +08:00
8a757a8b1d feat: Add training and validation data via Git LFS 2025-10-16 14:24:56 +08:00
589d4d0bd2 feat: Implement time-aware GPT-2 for patient event prediction
This commit introduces a complete framework for training a temporal GPT-2 model on sequential patient event data.

Key components include:

- `models.py`:
  - `TimeAwareGPT2`: A custom GPT-2 model that incorporates temporal information through a time-based causal attention mask and a sinusoidal age encoding for positional information.
  - `AgeSinusoidalEncoding`: A module for creating time-based positional embeddings.
  - `CombinedLoss`: A two-part loss function combining cross-entropy for event prediction and a survival loss for event timing.

- `utils.py`:
  - `PatientEventDataset`: A PyTorch Dataset class to process, batch, and load patient event sequences, including imputation of "no event" gaps and padding/truncation.

- `train.py`:
  - A comprehensive training script that initializes the model, data loaders, and loss function.
  - Implements a training loop with a cosine annealing learning rate scheduler, validation, and early stopping based on validation loss.

- `prepare_data.py`:
  - Script for preprocessing raw UK Biobank data into a format suitable for the model.

- `GEMINI.md`:
  - Project documentation outlining the structure, coding style, and framework.
2025-10-16 14:21:36 +08:00
1d4731ae42 Initial commit 2025-10-15 13:54:52 +08:00