Skip to content

2025 MedCAT v2 models missing MetaCAT; adding from v1 works but saved model cannot be re-loaded #228

@LeJudith

Description

@LeJudith

Hi!

The pretrained 2025 MedCAT v2 SNOMED models (e.g., SNOMED 2025 trained on MIMIC-IV) do not include a MetaCAT negation component, whereas the older SNOMED-Int v1 models do.

To add negation detection to the 2025 model, I converted the v1 SNOMED-Int model into a v2 model using the migration tutorial and transferred its MetaCAT addon into the 2025 v2 model:

cat_snomed_int_v2 = CAT.load_model_pack("./mc_modelpack_snomed_int_16_mar_2022_25be3857ba34bdd5v2_85293d2448666153")
mc = cat_snomed_int_v2.get_addons()[0]

cat_2025.add_addon(mc)

This approach works, but it requires loading two models every time. To avoid that, I tried saving the 2025 model after adding the MetaCAT component. However, loading the updated model back in fails:

File "/home/user/venvs/prism/lib/python3.10/site-packages/medcat/cat.py", line 816, in CAT.load_model_pack
    cat = deserialise(
        model_pack_path,
        model_load_path=model_pack_path,
        ignore_folders_prefix={
            AddonComponent.NAME_PREFIX,
            AbstractCoreComponent.NAME_PREFIX,
            TOKENIZER_PREFIX,
            COMPONENTS_FOLDER,
            "."
        },
        config_dict=config_dict,
        addon_config_dict=addon_config_dict,
    )

File "/home/user/venvs/prism/lib/python3.10/site-packages/medcat/utils/serialisation.py", line 79, in deserialise
    with open(file_path) as f:
        contents = f.read()

FileNotFoundError: [Errno 2] No such file or directory:
    "/data/.../v2_Snomed2025_MIMIC_IV_meta_status/.serialised_by"

Questions:

  • Is there an issue with adding the MetaCAT component taken from the older (v1 → v2 converted) model to a newer model that I’m not aware of?
  • Related to this, is the error expected or a potential a bug in the v2 model-pack save/load process for addons?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions