Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-8693t24ed: Add workaround for older DeID models in newer MedCAT #397

Merged
merged 3 commits into from
Feb 12, 2024

Conversation

mart-r
Copy link
Collaborator

@mart-r mart-r commented Feb 8, 2024

In medcat==1.9.3 there was a change to the transformers dependency range (from transformers>=4.19.2,<4.22.0 to transformers>=4.34.0). That change also removed the comment that the pin was for the DeID model to work.

I've looked into the issue and believe I've got a workaround for it.
The newer versions of transformers (starting rom 4.22.0) expect the tokenizer to have a specific attribute (_in_target_context_manager). However, as we load it off disk, the attribute doesn't exist since the saved version is older.
The change reference:
huggingface/transformers#18325

So what this PR does is add the missing attribute to the tokenizer.
I've tested locally with the DeID model and after this change, it worked just fine.

PS:
This isn't really easy to test automatically. The only way we could do that would be to include (or potentially download during test time) an older DeID model. But I don't want to clutter the repo with that.

@tomolopolis
Copy link
Member

@mart-r
Copy link
Collaborator Author

mart-r commented Feb 8, 2024

PS:
GHA failure due to #396

Copy link
Member

@tomolopolis tomolopolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mart-r mart-r merged commit e8658c4 into master Feb 12, 2024
5 checks passed
@mart-r mart-r deleted the CU-8693t24ed-fix-transformers-NER branch March 1, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants