Skip to content

Add GPU Support for GLiNERRecognizer and Validator Module for PII Detection #13

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thisaltennakoon
Copy link

This pull request introduces GPU support for the GLiNERRecognizer class and updates the validator module to allow GPU usage for PII detection. The changes include adding a use_gpu parameter, determining the device for model inference, and ensuring the model is loaded and executed on the appropriate device.

GPU Support for GLiNERRecognizer:

  • Added a use_gpu parameter to the GLiNERRecognizer constructor to enable or disable GPU usage. The _get_device method determines whether to use a GPU or CPU based on availability and the use_gpu flag. (validator/gliner_recognizer.py, [1] [2]
  • Updated the load method to move the model to the appropriate device and set it to evaluation mode if GPU is used. (validator/gliner_recognizer.py, validator/gliner_recognizer.pyR24-R44)
  • Modified the analyze method to ensure the model is on the correct device and to disable gradients during inference for efficiency. (validator/gliner_recognizer.py, validator/gliner_recognizer.pyR24-R44)

Integration with validator Module:

  • Added a use_gpu parameter to the Validator class constructor and passed it to the GLiNERRecognizer instance when use_local is enabled. (validator/main.py, [1] [2] [3]

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.

1 participant