CLMBRTaskHead.__init__() got an unexpected keyword argument '_name_or_path'
Hello,
I'm trying to run CLMBR-T on a GPU-enabled Nero instance and can't get the demo code to work. I've entered it exactly as on the model card and am getting the following error:
TypeError Traceback (most recent call last)
Cell In[6], line 2
1 # Load model
----> 2 model = femr.models.transformer.FEMRModel.from_pretrained(model_name)
4 # Run model
5 with torch.no_grad():
File /opt/conda/envs/ehrshot_env/lib/python3.10/site-packages/transformers/modeling_utils.py:3236, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)
3233 config = cls._check_and_enable_flash_attn_2(config, torch_dtype=torch_dtype, device_map=device_map)
3235 with ContextManagers(init_contexts):
-> 3236 model = cls(config, *model_args, **model_kwargs)
3238 # make sure we use the model's config since the init call might have copied it
3239 config = model.config
File /opt/conda/envs/ehrshot_env/lib/python3.10/site-packages/femr/models/transformer.py:234, in FEMRModel.init(self, config, **kwargs)
232 self.transformer = FEMRTransformer(self.config.transformer_config)
233 if self.config.task_config is not None:
--> 234 self.task_model = self.config.task_config.create_task_head(self.config.transformer_config.hidden_size)
File /opt/conda/envs/ehrshot_env/lib/python3.10/site-packages/femr/models/transformer.py:193, in FEMRTaskConfig.create_task_head(self, hidden_size)
191 def create_task_head(self, hidden_size: int):
192 if self.task_type == "clmbr":
--> 193 return CLMBRTaskHead(hidden_size, **self.kwargs)
194 elif self.task_type == "labeled_patients":
195 return LabeledPatientTaskHead(hidden_size, **self.kwargs)
TypeError: CLMBRTaskHead.init() got an unexpected keyword argument '_name_or_path'
Could you let me know how to fix this please? Thanks.
Thanks for the note!
This should be fixed in this commit: https://github.com/som-shahlab/femr/commit/746cb8eead3ffe0cd94445df0a9c7ddadb7a37f9
(it's a one line fix to basically just add **kwargs
to the __init__
of CLMBRTaskHead
.
This should be merged within the next update of FEMR, and will update you once that is merged!
This is now fixed, with the README updated to point to the newer version of FEMR.