Use pydantic v2 models instead of v1 models in spacy/schemas.py
#13553
NixBiks
started this conversation in
New Features & Project Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently in
schemas.pypydantic imports are done the following wayThis makes sure that
spacysupports both v1 and v2 of pydantic. The downside is that onlyv1models are used which means you can't extend any of the models inv2models. It also means that performance will be worse.I have a use case where I need to wrap
TokenPatternin a pydantic v2 model which isn't possible. Instead I have to redo all the models inschemas.pyas v2 models but maybe you want that change as a PR instead? I realise it might not be straightforward to use v2 models when possible and v1 models otherwise but I think it's worth it - even just for the improved performance. I imagine a solution will involveschemas/__init__.py,schemas/pydantic_v1.pyandschemas/pydantic_v2.py.I guess it's also worth considering dropping
v1support. Let me know what you think, thanks.Beta Was this translation helpful? Give feedback.
All reactions