cehrbert 1.4.2__tar.gz → 1.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cehrbert-1.4.2 → cehrbert-1.4.4}/PKG-INFO +84 -29
- {cehrbert-1.4.2 → cehrbert-1.4.4}/README.md +82 -27
- {cehrbert-1.4.2 → cehrbert-1.4.4}/pyproject.toml +1 -1
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_configs/hf_cehrbert_finetuning_runner_config.yaml +3 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_configs/hf_cehrbert_pretrain_runner_config.yaml +4 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_configs/hf_cehrbert_pretrain_runner_meds_config.yaml +4 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/hf_dataset.py +6 -4
- cehrbert-1.4.4/src/cehrbert/data_generators/hf_data_generator/hf_dataset_collator.py +396 -0
- cehrbert-1.4.4/src/cehrbert/data_generators/hf_data_generator/sample_packing_sampler.py +138 -0
- cehrbert-1.4.4/src/cehrbert/linear_prob/compute_cehrbert_features.py +307 -0
- cehrbert-1.4.4/src/cehrbert/linear_prob/train_with_cehrbert_features.py +87 -0
- cehrbert-1.4.4/src/cehrbert/models/hf_models/config.py +66 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/hf_models/hf_cehrbert.py +130 -37
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/runners/hf_cehrbert_finetune_runner.py +149 -189
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/runners/hf_cehrbert_pretrain_runner.py +155 -80
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/runners/hf_runner_argument_dataclass.py +25 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/runners/runner_util.py +5 -5
- cehrbert-1.4.4/src/cehrbert/runners/sample_packing_trainer.py +158 -0
- cehrbert-1.4.4/src/cehrbert/scripts/create_cehrbert_pretraining_data.sh +103 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert.egg-info/PKG-INFO +84 -29
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert.egg-info/SOURCES.txt +7 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert.egg-info/requires.txt +1 -1
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/integration_tests/runners/hf_cehrbert_pretrain_runner_meds_test.py +6 -0
- cehrbert-1.4.4/tests/integration_tests/runners/hf_cehrbert_pretrain_runner_sample_packing_test.py +99 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/integration_tests/runners/hf_cehrbert_pretrain_runner_streaming_test.py +6 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/integration_tests/runners/hf_cehrbert_pretrain_runner_test.py +10 -0
- cehrbert-1.4.4/tests/unit_tests/utils/__init__.py +0 -0
- cehrbert-1.4.2/src/cehrbert/data_generators/hf_data_generator/hf_dataset_collator.py +0 -231
- cehrbert-1.4.2/src/cehrbert/models/hf_models/config.py +0 -230
- {cehrbert-1.4.2 → cehrbert-1.4.4}/.github/workflows/python-build.yml +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/.github/workflows/tests.yml +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/.gitignore +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/.pre-commit-config.yaml +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/LICENSE +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/db_properties.ini +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/deepspeed_configs/zero1.json +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/deepspeed_configs/zero2.json +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/deepspeed_configs/zero3.json +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/full_grid_search_config.ini +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/images/cehr_bert_architecture.png +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/images/tokenization_att_generation.png +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/.done +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/code/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/code/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/code/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/doses_per_24_hrs/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/doses_per_24_hrs/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/drg_mortality/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/drg_mortality/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/drg_severity/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/drg_severity/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/emar_id/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/emar_id/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/emar_id/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/emar_seq/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/emar_seq/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/frequency/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/frequency/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/frequency/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/hadm_id/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/hadm_id/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/icustay_id/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/icustay_id/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/insurance/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/insurance/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/insurance/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/language/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/language/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/language/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/link_order_id/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/link_order_id/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/marital_status/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/marital_status/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/marital_status/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/meds_reader.length +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/meds_reader.null_map/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/meds_reader.null_map/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/meds_reader.properties +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/meds_reader.version +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/metadata/.shards.json +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/metadata/codes.parquet +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/metadata/dataset.json +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/metadata/subject_splits.parquet +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/numeric_value/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/numeric_value/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/order_id/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/order_id/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/ordercategorydescription/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/ordercategorydescription/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/ordercategorydescription/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/poe_id/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/poe_id/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/poe_id/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/priority/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/priority/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/priority/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/race/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/race/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/race/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/route/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/route/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/route/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/statusdescription/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/statusdescription/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/statusdescription/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/subject_id +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/text_value/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/text_value/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/text_value/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/time/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/time/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/unit/data +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/unit/dictionary +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/MIMIC-IV-meds/meds_reader/unit/zdict +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/finetune/full/fake_data.parquet +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/finetune/test/fake_data.parquet +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/finetune/train/fake_data.parquet +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/sample_data/pretrain/patient_sequence.parquet +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/setup.cfg +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/simple_grid_search_config.ini +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/config/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/config/grid_search_config.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/config/output_names.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/data_classes.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/data_generator_base.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/graph_sample_method.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/cache_util.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/hf_dataset_mapping.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/meds_to_cehrbert_conversion_rules/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/meds_to_cehrbert_conversion_rules/meds_to_cehrbert_base.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/meds_to_cehrbert_conversion_rules/meds_to_cehrbert_micmic4.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/meds_to_cehrbert_conversion_rules/meds_to_cehrbert_omop.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/meds_utils.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/patient_block.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/learning_objective.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/tokenizer.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/evaluation.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/evaluation_parameters.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/evaluation_parse_args.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/model_evaluators/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/model_evaluators/bert_model_evaluators.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/model_evaluators/frequency_model_evaluators.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/model_evaluators/hierarchical_bert_evaluators.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/model_evaluators/model_evaluators.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/model_evaluators/sequence_model_evaluators.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/evaluations/transfer_learning_evaluation.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/keras_transformer/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/keras_transformer/bert.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/keras_transformer/extras.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/keras_transformer/position.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/med_extension → cehrbert-1.4.4/src/cehrbert/linear_prob}/__init__.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/models → cehrbert-1.4.4/src/cehrbert/med_extension}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/med_extension/schema_extension.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/models/hf_models → cehrbert-1.4.4/src/cehrbert/models}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/bert_models.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/bert_models_visit_prediction.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/evaluation_models.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/models/layers → cehrbert-1.4.4/src/cehrbert/models/hf_models}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/hf_models/hf_modeling_outputs.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/hf_models/tokenization_hf_cehrbert.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/hf_models/tokenization_utils.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/hierachical_bert_model_v2.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/hierachical_phenotype_model_new.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/runners → cehrbert-1.4.4/src/cehrbert/models/layers}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/layers/custom_layers.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/layers/hierarchical_custom_layers.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/loss_schedulers.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/models/parse_args.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/tools → cehrbert-1.4.4/src/cehrbert/runners}/__init__.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/trainers → cehrbert-1.4.4/src/cehrbert/tools}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/tools/download_omop_tables.py +0 -0
- {cehrbert-1.4.2/src/cehrbert/utils → cehrbert-1.4.4/src/cehrbert/trainers}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/trainers/model_trainer.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/trainers/train_cehr_bert.py +0 -0
- {cehrbert-1.4.2/tests → cehrbert-1.4.4/src/cehrbert/utils}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/utils/checkpoint_utils.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/utils/logging_utils.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/utils/model_utils.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/utils/stat_utils.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert.egg-info/dependency_links.txt +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert.egg-info/entry_points.txt +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert.egg-info/top_level.txt +0 -0
- {cehrbert-1.4.2/tests/integration_tests → cehrbert-1.4.4/tests}/__init__.py +0 -0
- {cehrbert-1.4.2/tests/integration_tests/runners → cehrbert-1.4.4/tests/integration_tests}/__init__.py +0 -0
- {cehrbert-1.4.2/tests/integration_tests/trainers → cehrbert-1.4.4/tests/integration_tests/runners}/__init__.py +0 -0
- {cehrbert-1.4.2/tests/unit_tests → cehrbert-1.4.4/tests/integration_tests/trainers}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/integration_tests/trainers/train_cehr_bert_test.py +0 -0
- {cehrbert-1.4.2/tests/unit_tests/data_generators → cehrbert-1.4.4/tests/unit_tests}/__init__.py +0 -0
- {cehrbert-1.4.2/tests/unit_tests/data_generators/hf_data_generator → cehrbert-1.4.4/tests/unit_tests/data_generators}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/bert_masked_language_modeling_learning_objective_test.py +0 -0
- {cehrbert-1.4.2/tests/unit_tests/models → cehrbert-1.4.4/tests/unit_tests/data_generators/hf_data_generator}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/hf_dataset_mapping_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/hf_generate_start_end_index_mapping_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/hf_masked_language_modeling_mapping_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/hf_med_to_cehrbert_mapping_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/hf_sort_patient_sequence_dataset_mapping_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/meds_utils_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/omop_meds_generate_demographics_and_patient_blocks_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/hf_data_generator/patient_block_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/data_generators/visit_prediction_learning_objective_test.py +0 -0
- {cehrbert-1.4.2/tests/unit_tests/models/hf_models → cehrbert-1.4.4/tests/unit_tests/models}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/models/concept_value_decoder_layer_test.py +0 -0
- {cehrbert-1.4.2/tests/unit_tests/utils → cehrbert-1.4.4/tests/unit_tests/models/hf_models}/__init__.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/models/hf_models/hf_cehrbert_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/models/hf_models/numeric_concept_statistics_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/models/hf_models/tokenization_hf_cehrbert_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/utils/truncated_offline_statistics_test.py +0 -0
- {cehrbert-1.4.2 → cehrbert-1.4.4}/tests/unit_tests/utils/truncated_online_statistics_test.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cehrbert
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.4
|
|
4
4
|
Summary: CEHR-BERT: Incorporating temporal information from structured EHR data to improve prediction tasks
|
|
5
5
|
Author-email: Chao Pang <chaopang229@gmail.com>, Xinzhuo Jiang <xj2193@cumc.columbia.edu>, Krishna Kalluri <kk3326@cumc.columbia.edu>, Nishanth Parameshwar Pavinkurve <np2689@cumc.columbia.edu>, Karthik Natarajan <kn2174@cumc.columbia.edu>
|
|
6
6
|
License: MIT License
|
|
@@ -39,7 +39,7 @@ Requires-Dist: tensorflow-datasets==4.5.2
|
|
|
39
39
|
Requires-Dist: tqdm>=4.66.1
|
|
40
40
|
Requires-Dist: torch==2.4.0
|
|
41
41
|
Requires-Dist: tokenizers>=0.19.0
|
|
42
|
-
Requires-Dist: transformers
|
|
42
|
+
Requires-Dist: transformers<=4.45.0,>=4.41.0
|
|
43
43
|
Requires-Dist: accelerate>=0.31.0
|
|
44
44
|
Requires-Dist: Werkzeug==3.0.1
|
|
45
45
|
Requires-Dist: wandb>=0.17.8
|
|
@@ -57,6 +57,13 @@ Dynamic: license-file
|
|
|
57
57
|
|
|
58
58
|
# CEHR-BERT
|
|
59
59
|
|
|
60
|
+
[](https://pypi.org/project/cehrbert/)
|
|
61
|
+

|
|
62
|
+
[](https://github.com/cumc-dbmi/cehrbert/actions/workflows/tests.yml)
|
|
63
|
+
[](https://github.com/cumc-dbmi/cehrbert/blob/main/LICENSE)
|
|
64
|
+
[](https://github.com/cumc-dbmi/cehrbert/graphs/contributors)
|
|
65
|
+
|
|
66
|
+
|
|
60
67
|
CEHR-BERT is a large language model developed for the structured EHR data, the work has been published
|
|
61
68
|
at https://proceedings.mlr.press/v158/pang21a.html. CEHR-BERT currently only supports the structured EHR data in the
|
|
62
69
|
OMOP format, which is a common data model used to support observational studies and managed by the Observational Health
|
|
@@ -112,15 +119,15 @@ Build the project
|
|
|
112
119
|
pip install -e .[dev]
|
|
113
120
|
```
|
|
114
121
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
## OMOP vs. MEDS Format Considerations
|
|
123
|
+
CEHR-BERT can be trained using either the OMOP or MEDS data formats; however, models trained on one format are not compatible with those trained on the other.
|
|
124
|
+
This incompatibility arises because CEHR-BERT uses different concept identifiers depending on the format: standard concept IDs (e.g., SNOMED for conditions) in OMOP,
|
|
125
|
+
and source concept IDs (e.g., ICD-9/10) in MEDS. The mappings between these terminologies are many-to-many, making direct alignment between formats unreliable.
|
|
126
|
+
It is therefore crucial to use a consistent data format across pretraining, fine-tuning, and downstream tasks such as linear probing.
|
|
119
127
|
|
|
120
128
|
## Instructions for Use with [MEDS](https://github.com/Medical-Event-Data-Standard/meds)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
Step 1. Convert MEDS to the [meds_reader](https://github.com/som-shahlab/meds_reader) database
|
|
130
|
+
---------------------------
|
|
124
131
|
If you don't have the MEDS dataset, you could convert the OMOP dataset to the MEDS
|
|
125
132
|
using [meds_etl](https://github.com/Medical-Event-Data-Standard/meds_etl).
|
|
126
133
|
We have prepared a synthea dataset with 1M patients for you to test, you could download it
|
|
@@ -180,22 +187,41 @@ Convert MEDS to the meds_reader database to get the patient level data
|
|
|
180
187
|
meds_reader_convert synthea_meds synthea_meds_reader --num_threads 4
|
|
181
188
|
```
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
Step 2. Pretrain CEHR-BERT using the meds_reader database
|
|
191
|
+
---------------------------
|
|
184
192
|
```console
|
|
185
193
|
mkdir test_dataset_prepared;
|
|
186
194
|
mkdir test_synthea_results;
|
|
187
|
-
python -m cehrbert.runners.hf_cehrbert_pretrain_runner
|
|
195
|
+
python -m cehrbert.runners.hf_cehrbert_pretrain_runner \
|
|
196
|
+
sample_configs/hf_cehrbert_pretrain_runner_meds_config.yaml
|
|
188
197
|
```
|
|
189
198
|
|
|
190
199
|
## Instructions for Use with OMOP
|
|
191
200
|
|
|
192
|
-
|
|
193
|
-
|
|
201
|
+
Step 1. Download OMOP tables as parquet files
|
|
202
|
+
---------------------------
|
|
194
203
|
We created a spark app to download OMOP tables from SQL Server as parquet files. You need adjust the properties
|
|
195
|
-
in `db_properties.ini` to match with your database setup.
|
|
196
|
-
|
|
204
|
+
in `db_properties.ini` to match with your database setup. Download [jtds-1.3.1.jar](https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds/1.3.1) into the spark jars folder in the python environment.
|
|
197
205
|
```console
|
|
198
|
-
|
|
206
|
+
cp jtds-1.3.1.jar .venv/lib/python3.10/site-packages/pyspark/jars/
|
|
207
|
+
```
|
|
208
|
+
We use spark as the data processing engine to generate the pretraining data.
|
|
209
|
+
For that, we need to set up the relevant SPARK environment variables.
|
|
210
|
+
```bash
|
|
211
|
+
# the omop derived tables need to be built using pyspark
|
|
212
|
+
export SPARK_WORKER_INSTANCES="1"
|
|
213
|
+
export SPARK_WORKER_CORES="16"
|
|
214
|
+
export SPARK_EXECUTOR_CORES="2"
|
|
215
|
+
export SPARK_DRIVER_MEMORY="12g"
|
|
216
|
+
export SPARK_EXECUTOR_MEMORY="12g"
|
|
217
|
+
```
|
|
218
|
+
Download the OMOP tables as parquet files
|
|
219
|
+
```console
|
|
220
|
+
python -u -m cehrbert.tools.download_omop_tables -c db_properties.ini \
|
|
221
|
+
-tc person visit_occurrence condition_occurrence procedure_occurrence \
|
|
222
|
+
drug_exposure measurement observation_period \
|
|
223
|
+
concept concept_relationship concept_ancestor \
|
|
224
|
+
-o ~/Documents/omop_test/
|
|
199
225
|
```
|
|
200
226
|
|
|
201
227
|
We have prepared a synthea dataset with 1M patients for you to test, you could download it
|
|
@@ -205,8 +231,8 @@ at [omop_synthea.tar.gz](https://drive.google.com/file/d/1k7-cZACaDNw8A1JRI37mfM
|
|
|
205
231
|
tar -xvf omop_synthea.tar ~/Document/omop_test/
|
|
206
232
|
```
|
|
207
233
|
|
|
208
|
-
|
|
209
|
-
|
|
234
|
+
Step 2. Generate training data for CEHR-BERT using cehrbert_data
|
|
235
|
+
---------------------------
|
|
210
236
|
We order the patient events in chronological order and put all data points in a sequence. We insert artificial tokens
|
|
211
237
|
VS (visit start) and VE (visit end) to the start and the end of the visit. In addition, we insert artificial time
|
|
212
238
|
tokens (ATT) between visits to indicate the time interval between visits. This approach allows us to apply BERT to
|
|
@@ -214,35 +240,64 @@ structured EHR as-is.
|
|
|
214
240
|
The sequence can be seen conceptually as [VS] [V1] [VE] [ATT] [VS] [V2] [VE], where [V1] and [V2] represent a list of
|
|
215
241
|
concepts associated with those visits.
|
|
216
242
|
|
|
217
|
-
|
|
218
|
-
|
|
243
|
+
Set up the pyspark environment variables if you haven't done so.
|
|
244
|
+
```bash
|
|
245
|
+
# the omop derived tables need to be built using pyspark
|
|
246
|
+
export SPARK_WORKER_INSTANCES="1"
|
|
247
|
+
export SPARK_WORKER_CORES="16"
|
|
248
|
+
export SPARK_EXECUTOR_CORES="2"
|
|
249
|
+
export SPARK_DRIVER_MEMORY="12g"
|
|
250
|
+
export SPARK_EXECUTOR_MEMORY="12g"
|
|
251
|
+
```
|
|
252
|
+
Generate the pretraining data using the following command
|
|
253
|
+
```bash
|
|
254
|
+
sh src/cehrbert/scripts/create_cehrbert_pretraining_data.sh \
|
|
255
|
+
--input_folder $OMOP_DIR \
|
|
256
|
+
--output_folde $CEHR_BERT_DATA_DIR \
|
|
257
|
+
--start_date "1985-01-01"
|
|
219
258
|
```
|
|
220
259
|
|
|
221
|
-
|
|
260
|
+
Step 3. Pre-train CEHR-BERT
|
|
261
|
+
---------------------------
|
|
222
262
|
If you don't have your own OMOP instance, we have provided a sample of patient sequence data generated using Synthea
|
|
223
263
|
at `sample/patient_sequence` in the repo. CEHR-BERT expects the data folder to be named as `patient_sequence`
|
|
224
264
|
|
|
225
265
|
```console
|
|
226
266
|
mkdir test_dataset_prepared;
|
|
227
267
|
mkdir test_results;
|
|
228
|
-
python -m cehrbert.runners.hf_cehrbert_pretrain_runner
|
|
268
|
+
python -m cehrbert.runners.hf_cehrbert_pretrain_runner \
|
|
269
|
+
sample_configs/hf_cehrbert_pretrain_runner_config.yaml
|
|
229
270
|
```
|
|
230
271
|
|
|
231
272
|
If your dataset is large, you could add ```--use_dask``` in the command above
|
|
232
273
|
|
|
233
|
-
|
|
274
|
+
Step 4. Generate hf readmission prediction task
|
|
275
|
+
---------------------------
|
|
234
276
|
If you don't have your own OMOP instance, we have provided a sample of patient sequence data generated using Synthea
|
|
235
|
-
at `sample/hf_readmissioon` in the repo
|
|
236
|
-
|
|
277
|
+
at `sample/hf_readmissioon` in the repo. Set up the pyspark environment variables if you haven't done so.
|
|
278
|
+
```bash
|
|
279
|
+
# the omop derived tables need to be built using pyspark
|
|
280
|
+
export SPARK_WORKER_INSTANCES="1"
|
|
281
|
+
export SPARK_WORKER_CORES="16"
|
|
282
|
+
export SPARK_EXECUTOR_CORES="2"
|
|
283
|
+
export SPARK_DRIVER_MEMORY="12g"
|
|
284
|
+
export SPARK_EXECUTOR_MEMORY="12g"
|
|
285
|
+
```
|
|
286
|
+
Generate the HF readmission prediction task
|
|
237
287
|
```console
|
|
238
|
-
|
|
288
|
+
python -u -m cehrbert_data.prediction_cohorts.hf_readmission \
|
|
289
|
+
-c hf_readmission -i ~/Documents/omop_test/ -o ~/Documents/omop_test/cehr-bert \
|
|
290
|
+
-dl 1985-01-01 -du 2020-12-31 \
|
|
291
|
+
-l 18 -u 100 -ow 360 -ps 0 -pw 30 \
|
|
292
|
+
--is_new_patient_representation
|
|
239
293
|
```
|
|
240
294
|
|
|
241
|
-
|
|
242
|
-
|
|
295
|
+
Step 5. Fine-tune CEHR-BERT
|
|
296
|
+
---------------------------
|
|
243
297
|
```console
|
|
244
298
|
mkdir test_finetune_results;
|
|
245
|
-
python -m cehrbert.runners.hf_cehrbert_finetune_runner
|
|
299
|
+
python -m cehrbert.runners.hf_cehrbert_finetune_runner \
|
|
300
|
+
sample_configs/hf_cehrbert_finetuning_runner_config.yaml
|
|
246
301
|
```
|
|
247
302
|
|
|
248
303
|
## Contact us
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# CEHR-BERT
|
|
2
2
|
|
|
3
|
+
[](https://pypi.org/project/cehrbert/)
|
|
4
|
+

|
|
5
|
+
[](https://github.com/cumc-dbmi/cehrbert/actions/workflows/tests.yml)
|
|
6
|
+
[](https://github.com/cumc-dbmi/cehrbert/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/cumc-dbmi/cehrbert/graphs/contributors)
|
|
8
|
+
|
|
9
|
+
|
|
3
10
|
CEHR-BERT is a large language model developed for the structured EHR data, the work has been published
|
|
4
11
|
at https://proceedings.mlr.press/v158/pang21a.html. CEHR-BERT currently only supports the structured EHR data in the
|
|
5
12
|
OMOP format, which is a common data model used to support observational studies and managed by the Observational Health
|
|
@@ -55,15 +62,15 @@ Build the project
|
|
|
55
62
|
pip install -e .[dev]
|
|
56
63
|
```
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
## OMOP vs. MEDS Format Considerations
|
|
66
|
+
CEHR-BERT can be trained using either the OMOP or MEDS data formats; however, models trained on one format are not compatible with those trained on the other.
|
|
67
|
+
This incompatibility arises because CEHR-BERT uses different concept identifiers depending on the format: standard concept IDs (e.g., SNOMED for conditions) in OMOP,
|
|
68
|
+
and source concept IDs (e.g., ICD-9/10) in MEDS. The mappings between these terminologies are many-to-many, making direct alignment between formats unreliable.
|
|
69
|
+
It is therefore crucial to use a consistent data format across pretraining, fine-tuning, and downstream tasks such as linear probing.
|
|
62
70
|
|
|
63
71
|
## Instructions for Use with [MEDS](https://github.com/Medical-Event-Data-Standard/meds)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
Step 1. Convert MEDS to the [meds_reader](https://github.com/som-shahlab/meds_reader) database
|
|
73
|
+
---------------------------
|
|
67
74
|
If you don't have the MEDS dataset, you could convert the OMOP dataset to the MEDS
|
|
68
75
|
using [meds_etl](https://github.com/Medical-Event-Data-Standard/meds_etl).
|
|
69
76
|
We have prepared a synthea dataset with 1M patients for you to test, you could download it
|
|
@@ -123,22 +130,41 @@ Convert MEDS to the meds_reader database to get the patient level data
|
|
|
123
130
|
meds_reader_convert synthea_meds synthea_meds_reader --num_threads 4
|
|
124
131
|
```
|
|
125
132
|
|
|
126
|
-
|
|
133
|
+
Step 2. Pretrain CEHR-BERT using the meds_reader database
|
|
134
|
+
---------------------------
|
|
127
135
|
```console
|
|
128
136
|
mkdir test_dataset_prepared;
|
|
129
137
|
mkdir test_synthea_results;
|
|
130
|
-
python -m cehrbert.runners.hf_cehrbert_pretrain_runner
|
|
138
|
+
python -m cehrbert.runners.hf_cehrbert_pretrain_runner \
|
|
139
|
+
sample_configs/hf_cehrbert_pretrain_runner_meds_config.yaml
|
|
131
140
|
```
|
|
132
141
|
|
|
133
142
|
## Instructions for Use with OMOP
|
|
134
143
|
|
|
135
|
-
|
|
136
|
-
|
|
144
|
+
Step 1. Download OMOP tables as parquet files
|
|
145
|
+
---------------------------
|
|
137
146
|
We created a spark app to download OMOP tables from SQL Server as parquet files. You need adjust the properties
|
|
138
|
-
in `db_properties.ini` to match with your database setup.
|
|
139
|
-
|
|
147
|
+
in `db_properties.ini` to match with your database setup. Download [jtds-1.3.1.jar](https://mvnrepository.com/artifact/net.sourceforge.jtds/jtds/1.3.1) into the spark jars folder in the python environment.
|
|
140
148
|
```console
|
|
141
|
-
|
|
149
|
+
cp jtds-1.3.1.jar .venv/lib/python3.10/site-packages/pyspark/jars/
|
|
150
|
+
```
|
|
151
|
+
We use spark as the data processing engine to generate the pretraining data.
|
|
152
|
+
For that, we need to set up the relevant SPARK environment variables.
|
|
153
|
+
```bash
|
|
154
|
+
# the omop derived tables need to be built using pyspark
|
|
155
|
+
export SPARK_WORKER_INSTANCES="1"
|
|
156
|
+
export SPARK_WORKER_CORES="16"
|
|
157
|
+
export SPARK_EXECUTOR_CORES="2"
|
|
158
|
+
export SPARK_DRIVER_MEMORY="12g"
|
|
159
|
+
export SPARK_EXECUTOR_MEMORY="12g"
|
|
160
|
+
```
|
|
161
|
+
Download the OMOP tables as parquet files
|
|
162
|
+
```console
|
|
163
|
+
python -u -m cehrbert.tools.download_omop_tables -c db_properties.ini \
|
|
164
|
+
-tc person visit_occurrence condition_occurrence procedure_occurrence \
|
|
165
|
+
drug_exposure measurement observation_period \
|
|
166
|
+
concept concept_relationship concept_ancestor \
|
|
167
|
+
-o ~/Documents/omop_test/
|
|
142
168
|
```
|
|
143
169
|
|
|
144
170
|
We have prepared a synthea dataset with 1M patients for you to test, you could download it
|
|
@@ -148,8 +174,8 @@ at [omop_synthea.tar.gz](https://drive.google.com/file/d/1k7-cZACaDNw8A1JRI37mfM
|
|
|
148
174
|
tar -xvf omop_synthea.tar ~/Document/omop_test/
|
|
149
175
|
```
|
|
150
176
|
|
|
151
|
-
|
|
152
|
-
|
|
177
|
+
Step 2. Generate training data for CEHR-BERT using cehrbert_data
|
|
178
|
+
---------------------------
|
|
153
179
|
We order the patient events in chronological order and put all data points in a sequence. We insert artificial tokens
|
|
154
180
|
VS (visit start) and VE (visit end) to the start and the end of the visit. In addition, we insert artificial time
|
|
155
181
|
tokens (ATT) between visits to indicate the time interval between visits. This approach allows us to apply BERT to
|
|
@@ -157,35 +183,64 @@ structured EHR as-is.
|
|
|
157
183
|
The sequence can be seen conceptually as [VS] [V1] [VE] [ATT] [VS] [V2] [VE], where [V1] and [V2] represent a list of
|
|
158
184
|
concepts associated with those visits.
|
|
159
185
|
|
|
160
|
-
|
|
161
|
-
|
|
186
|
+
Set up the pyspark environment variables if you haven't done so.
|
|
187
|
+
```bash
|
|
188
|
+
# the omop derived tables need to be built using pyspark
|
|
189
|
+
export SPARK_WORKER_INSTANCES="1"
|
|
190
|
+
export SPARK_WORKER_CORES="16"
|
|
191
|
+
export SPARK_EXECUTOR_CORES="2"
|
|
192
|
+
export SPARK_DRIVER_MEMORY="12g"
|
|
193
|
+
export SPARK_EXECUTOR_MEMORY="12g"
|
|
194
|
+
```
|
|
195
|
+
Generate the pretraining data using the following command
|
|
196
|
+
```bash
|
|
197
|
+
sh src/cehrbert/scripts/create_cehrbert_pretraining_data.sh \
|
|
198
|
+
--input_folder $OMOP_DIR \
|
|
199
|
+
--output_folde $CEHR_BERT_DATA_DIR \
|
|
200
|
+
--start_date "1985-01-01"
|
|
162
201
|
```
|
|
163
202
|
|
|
164
|
-
|
|
203
|
+
Step 3. Pre-train CEHR-BERT
|
|
204
|
+
---------------------------
|
|
165
205
|
If you don't have your own OMOP instance, we have provided a sample of patient sequence data generated using Synthea
|
|
166
206
|
at `sample/patient_sequence` in the repo. CEHR-BERT expects the data folder to be named as `patient_sequence`
|
|
167
207
|
|
|
168
208
|
```console
|
|
169
209
|
mkdir test_dataset_prepared;
|
|
170
210
|
mkdir test_results;
|
|
171
|
-
python -m cehrbert.runners.hf_cehrbert_pretrain_runner
|
|
211
|
+
python -m cehrbert.runners.hf_cehrbert_pretrain_runner \
|
|
212
|
+
sample_configs/hf_cehrbert_pretrain_runner_config.yaml
|
|
172
213
|
```
|
|
173
214
|
|
|
174
215
|
If your dataset is large, you could add ```--use_dask``` in the command above
|
|
175
216
|
|
|
176
|
-
|
|
217
|
+
Step 4. Generate hf readmission prediction task
|
|
218
|
+
---------------------------
|
|
177
219
|
If you don't have your own OMOP instance, we have provided a sample of patient sequence data generated using Synthea
|
|
178
|
-
at `sample/hf_readmissioon` in the repo
|
|
179
|
-
|
|
220
|
+
at `sample/hf_readmissioon` in the repo. Set up the pyspark environment variables if you haven't done so.
|
|
221
|
+
```bash
|
|
222
|
+
# the omop derived tables need to be built using pyspark
|
|
223
|
+
export SPARK_WORKER_INSTANCES="1"
|
|
224
|
+
export SPARK_WORKER_CORES="16"
|
|
225
|
+
export SPARK_EXECUTOR_CORES="2"
|
|
226
|
+
export SPARK_DRIVER_MEMORY="12g"
|
|
227
|
+
export SPARK_EXECUTOR_MEMORY="12g"
|
|
228
|
+
```
|
|
229
|
+
Generate the HF readmission prediction task
|
|
180
230
|
```console
|
|
181
|
-
|
|
231
|
+
python -u -m cehrbert_data.prediction_cohorts.hf_readmission \
|
|
232
|
+
-c hf_readmission -i ~/Documents/omop_test/ -o ~/Documents/omop_test/cehr-bert \
|
|
233
|
+
-dl 1985-01-01 -du 2020-12-31 \
|
|
234
|
+
-l 18 -u 100 -ow 360 -ps 0 -pw 30 \
|
|
235
|
+
--is_new_patient_representation
|
|
182
236
|
```
|
|
183
237
|
|
|
184
|
-
|
|
185
|
-
|
|
238
|
+
Step 5. Fine-tune CEHR-BERT
|
|
239
|
+
---------------------------
|
|
186
240
|
```console
|
|
187
241
|
mkdir test_finetune_results;
|
|
188
|
-
python -m cehrbert.runners.hf_cehrbert_finetune_runner
|
|
242
|
+
python -m cehrbert.runners.hf_cehrbert_finetune_runner \
|
|
243
|
+
sample_configs/hf_cehrbert_finetuning_runner_config.yaml
|
|
189
244
|
```
|
|
190
245
|
|
|
191
246
|
## Contact us
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
# Please point this to your model folder
|
|
1
2
|
model_name_or_path: "test_results"
|
|
3
|
+
# Please point this to your model folder
|
|
2
4
|
tokenizer_name_or_path: "test_results"
|
|
3
5
|
|
|
4
6
|
data_folder: "sample_data/finetune/full"
|
|
@@ -32,6 +34,7 @@ max_position_embeddings: 512
|
|
|
32
34
|
dataloader_num_workers: 4
|
|
33
35
|
dataloader_prefetch_factor: 2
|
|
34
36
|
|
|
37
|
+
# Please point this to your finetuned model folder
|
|
35
38
|
output_dir: "test_finetune_results"
|
|
36
39
|
evaluation_strategy: "epoch"
|
|
37
40
|
save_strategy: "epoch"
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
# Please point this to your output model folder
|
|
1
2
|
model_name_or_path: "test_results"
|
|
3
|
+
# Please point this to your output model folder
|
|
2
4
|
tokenizer_name_or_path: "test_results"
|
|
3
5
|
|
|
4
6
|
data_folder: "sample_data/pretrain"
|
|
@@ -32,7 +34,9 @@ max_position_embeddings: 512
|
|
|
32
34
|
dataloader_num_workers: 4
|
|
33
35
|
dataloader_prefetch_factor: 4
|
|
34
36
|
|
|
37
|
+
# Please point this to your output model folder
|
|
35
38
|
output_dir: "test_results"
|
|
39
|
+
|
|
36
40
|
evaluation_strategy: "epoch"
|
|
37
41
|
save_strategy: "epoch"
|
|
38
42
|
learning_rate: 0.00005
|
{cehrbert-1.4.2 → cehrbert-1.4.4}/sample_configs/hf_cehrbert_pretrain_runner_meds_config.yaml
RENAMED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
# Please point this to your model folder
|
|
1
2
|
model_name_or_path: "test_synthea_results"
|
|
3
|
+
# Please point this to your model folder
|
|
2
4
|
tokenizer_name_or_path: "test_synthea_results"
|
|
3
5
|
|
|
6
|
+
# Please point this to the MEDS_READER because the MEDS data is used as the input
|
|
4
7
|
data_folder: "synthea_meds_reader"
|
|
5
8
|
dataset_prepared_path: "test_dataset_prepared"
|
|
6
9
|
validation_split_percentage: 0.05
|
|
@@ -32,6 +35,7 @@ max_position_embeddings: 512
|
|
|
32
35
|
dataloader_num_workers: 4
|
|
33
36
|
dataloader_prefetch_factor: 4
|
|
34
37
|
|
|
38
|
+
# Please point this to your model folder
|
|
35
39
|
output_dir: "test_synthea_results"
|
|
36
40
|
evaluation_strategy: "epoch"
|
|
37
41
|
save_strategy: "epoch"
|
{cehrbert-1.4.2 → cehrbert-1.4.4}/src/cehrbert/data_generators/hf_data_generator/hf_dataset.py
RENAMED
|
@@ -48,7 +48,7 @@ def create_cehrbert_pretraining_dataset(
|
|
|
48
48
|
mapping_functions = [HFTokenizationMapping(concept_tokenizer, True)]
|
|
49
49
|
else:
|
|
50
50
|
mapping_functions = [
|
|
51
|
-
SortPatientSequenceMapping(),
|
|
51
|
+
# SortPatientSequenceMapping(),
|
|
52
52
|
HFTokenizationMapping(concept_tokenizer, True),
|
|
53
53
|
]
|
|
54
54
|
|
|
@@ -91,7 +91,7 @@ def create_cehrbert_finetuning_dataset(
|
|
|
91
91
|
else:
|
|
92
92
|
mapping_functions = [
|
|
93
93
|
HFFineTuningMapping(),
|
|
94
|
-
SortPatientSequenceMapping(),
|
|
94
|
+
# SortPatientSequenceMapping(),
|
|
95
95
|
HFTokenizationMapping(concept_tokenizer, False),
|
|
96
96
|
]
|
|
97
97
|
|
|
@@ -166,6 +166,8 @@ def apply_cehrbert_dataset_mapping(
|
|
|
166
166
|
)
|
|
167
167
|
if mapping_function.remove_columns():
|
|
168
168
|
dataset = dataset.remove_columns(mapping_function.remove_columns())
|
|
169
|
-
|
|
170
|
-
cache_file_collector
|
|
169
|
+
|
|
170
|
+
if cache_file_collector:
|
|
171
|
+
cache_file_collector.add_cache_files(dataset)
|
|
172
|
+
|
|
171
173
|
return dataset
|