Skip to content

Towards Unified Sequence Representation IV: Add RNN_V2 for SequenceProcessorV2 fields - #1353

Draft
Logiquo wants to merge 3 commits into
feat/seq-v2-3from
feat/seq-v2-4
Draft

Logiquo wants to merge 3 commits into
feat/seq-v2-3from
feat/seq-v2-4

Conversation

@Logiquo

@Logiquo Logiquo commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fourth PR in the stack toward a unified sequence representation, on top of #1352. It adds RNN_V2, the first model that consumes SequenceProcessorV2 fields and per-step labels.

Changes

  • Each sequence_v2 field is embedded by SequenceEmbeddingModel and encoded bottom-up, level by level. A set level mean-pools each group; a sequence or series level runs an RNN over each group and keeps the last output. A group without records is skipped and summarized as zeros.
  • Static tensor fields are used directly or through a projection. The field summaries and statics are concatenated, and a linear layer predicts the label. Other processors are rejected; sequences, sets and tokens are expressed with sequence_v2.
  • hidden_dim, rnn_type, num_layers, dropout, bidirectional and time_feature take one value, or a {field: value} dict. time_feature adds the time since the previous record of the group on timed levels.
  • Per-step labels: one prediction per label record, from each field's top-level state after its last record at or before the label's time. A prediction never sees later records. Fields need a series top level, and bidirectional RNNs are rejected.
  • RNN and MultimodalRNN now point to RNN_V2 for per-step labels.
  • The per-step tests from Towards Unified Sequence Representation II: Move YAIB tasks and per-step labels to SequenceProcessorV2 #1347 also run with RNN_V2, and the YAIB tasks are tested end to end with it.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Test Coverage

Total: 75.14% (21431 / 28522 lines)

Modified file Coverage Lines
pyhealth/models/__init__.py 100.00% 54 / 54
pyhealth/models/base_model.py 94.33% 133 / 141
pyhealth/models/rnn.py 93.77% 346 / 369
pyhealth/processors/timeseries_processor.py 88.35% 91 / 103
pyhealth/tasks/yaib_mimic4.py 93.06% 523 / 562

Workflow run · fb711f5

Unified_RNN embeds each sequence_v2 field with SequenceEmbeddingModel and
encodes it bottom-up, level by level: a set level mean-pools each group,
a sequence or series level runs an RNN over each group and keeps the last
output. A group without records is skipped and summarized as zeros.
Static tensor fields are used directly or through a projection; the
summaries and statics are concatenated and a linear layer predicts the
label.

- Per-field settings (hidden_dim, rnn_type, num_layers, dropout,
  bidirectional, time_feature) take one value or a {field: value} dict.
- time_feature adds the time since the previous record of the group on
  timed levels.
- Per-step labels: one prediction per label record, from each field's
  top-level state after its last record at or before the label's time,
  so a prediction never sees later records. Fields need a series top
  level and the RNNs must be causal.
- RNN and MultimodalRNN now point to Unified_RNN for per-step labels.
@Logiquo Logiquo changed the title Towards Unified Sequence Representation IV: Add Unified_RNN for SequenceProcessorV2 fields Towards Unified Sequence Representation IV: Add RNN_V2 for SequenceProcessorV2 fields Nov 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant