Skip to content

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