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
-
Currently in
schemas.py
pydantic imports are done the following wayThis makes sure that
spacy
supports both v1 and v2 of pydantic. The downside is that onlyv1
models are used which means you can't extend any of the models inv2
models. It also means that performance will be worse.I have a use case where I need to wrap
TokenPattern
in a pydantic v2 model which isn't possible. Instead I have to redo all the models inschemas.py
as 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.py
andschemas/pydantic_v2.py
.I guess it's also worth considering dropping
v1
support. Let me know what you think, thanks.Beta Was this translation helpful? Give feedback.
All reactions