Skip to content

Regression in loading models in release 3.8.12 #13942

@mart-r

Description

@mart-r

How to reproduce the behaviour

I don't know how far this goes exactly, but I've got an en_core_web_md v3.1.0 model saved on disk, and I have this script for loading it:

import spacy
print("spacy==", spacy.__version__)
spacy_path = "en_core_web_md/"
print("Loading Spacy Model")
nlp = spacy.load(spacy_path)
print("NLP:", nlp.meta['name'], "@", nlp.meta['version'])

In spacy==3.8.7 I get:

 % python .temp/2026_03_23_spacy_model_load/load_model.py
spacy== 3.8.7
Loading Spacy Model
/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/util.py:922: UserWarning: [W095] Model 'en_core_web_md' (3.1.0) was trained with spaCy v3.1.0 and may not be 100% compatible with the current version (3.8.7). If you see errors or degraded performance, download a newer compatible model or retrain your custom model with the current spaCy version. For more details and available updates, run: python -m spacy validate
  warnings.warn(warn_msg)
NLP: core_web_md @ 3.1.0

And same in 3.8.11:

 % python .temp/2026_03_23_spacy_model_load/load_model.py
spacy== 3.8.11
Loading Spacy Model
/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/util.py:969: UserWarning: [W095] Model 'en_core_web_md' (3.1.0) was trained with spaCy v3.1.0 and may not be 100% compatible with the current version (3.8.11). If you see errors or degraded performance, download a newer compatible model or retrain your custom model with the current spaCy version. For more details and available updates, run: python -m spacy validate
  warnings.warn(warn_msg)
NLP: core_web_md @ 3.1.0

Yet in spacy==3.8.12 I get:

% python .temp/2026_03_23_spacy_model_load/load_model.py
spacy== 3.8.12
Loading Spacy Model
/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/util.py:969: UserWarning: [W095] Model 'en_core_web_md' (3.1.0) was trained with spaCy v3.1.0 and may not be 100% compatible with the current version (3.8.12). If you see errors or degraded performance, download a newer compatible model or retrain your custom model with the current spaCy version. For more details and available updates, run: python -m spacy validate
  warnings.warn(warn_msg)
Traceback (most recent call last):
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/load_model.py", line 5, in <module>
    nlp = spacy.load(spacy_path)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/__init__.py", line 52, in load
    return util.load_model(
           ^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/util.py", line 526, in load_model
    return load_model_from_path(Path(name), **kwargs)  # type: ignore[arg-type]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/util.py", line 598, in load_model_from_path
    nlp = load_model_from_config(
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/util.py", line 646, in load_model_from_config
    nlp = lang_cls.from_config(
          ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/spacy/language.py", line 1832, in from_config
    resolved_nlp = registry.resolve(
                   ^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/confection/__init__.py", line 760, in resolve
    resolved, _ = cls._make(
                  ^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/confection/__init__.py", line 809, in _make
    filled, _, resolved = cls._fill(
                          ^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/confection/__init__.py", line 937, in _fill
    result = schema.parse_obj(validation)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/pydantic/main.py", line 1370, in parse_obj
    return cls.model_validate(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/pydantic/main.py", line 716, in model_validate
    return cls.__pydantic_validator__.validate_python(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.temp/2026_03_23_spacy_model_load/.venv/lib/python3.12/site-packages/pydantic/_internal/_mock_val_ser.py", line 100, in __getattr__
    raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: `ConfigSchemaNlp` is not fully defined; you should define `Language`, then call `ConfigSchemaNlp.model_rebuild()`.

For further information visit https://errors.pydantic.dev/2.12/u/class-not-fully-defined

Your Environment

  • Operating System: MacOS and ubuntu (on CI)
  • Python Version Used: 3.12
  • spaCy Version Used: 3.8.12 (the problematic)
  • Environment Information: The OLD en_core_web_md model.

PS:
I understand that you guys are probably unable to indefinitely support loading old models. But a regression like this in a patch version seems out of place to me.

PPS:
If I've made some mistake on my end, do point it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions