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

Token Object Contracts for policy-based usage of Hugging Face Models #57

Open
wants to merge 5 commits into
base: cf_policy_for_hf_endpoints
Choose a base branch
from

Conversation

prakashngit
Copy link
Contributor

This PR provides a PoC for tokenization and policy-based access of (possibly private) models hosted on Hugging Face, and made available for inferencing via Serverless Inference API. The PoC in spirit is similar to what is demonstrated via the inference contract family, where we provided PDO contracts/guardians for policy-based access control of ML models hosted via OpenVINO model server.

Please see hfmodels-contract/README.md for problem statement, solution overview, and details on how to test the PoC.

…. Change enables other use cases to re-use the exchange op_initialize method, while passing in use-case specific initiazation arguments via kwargs

Signed-off-by: Prakash Narayana Moorthy <[email protected]>
…s. The token object implements the policy for accessing HF hosted models. The token object code inherits several base methods from the exchange contract token object, and only implements asset-use specific methods. In addition, the token object initialization method is used to store asset (HF model) specifc details, so of which are secrets, and others used to provide meta data regarding the asset for a prospective token user

Signed-off-by: Prakash Narayana Moorthy <[email protected]>
…s. The Guardian frontend is largely similar to the guardian

used as part of the OpenVINO inference contract use-case. The operations folder implements the capability_handler_map unique to
the Hugging Face use case. The use_hfmodel module implemented within the operations package enables  the guardian server to process
inferencing capabilities that invoke REST API calls to the Hugging Face hosted models. Parameters required for the API call
are passed as part of the capability package. The module implements support for JSON and binary payloads. The module is model agnostic,
and does not implement any model specific pre or post processing steps.

The large overlap among the remaining modules of the HF and OpenVINO guardians calls for a future PR that refactors the modules to permit
reuse. Currently, simply expecting the HF use case to reuse the OpenVINO guardian frontend python packages is challenging, since OpenVINO
guardian demands intallation of dependencies such an tensoflow, opencv, numpy etc, none of which are required for the HF usecase.
In a secure deployment, the guardian is ideally deployed with a TEEs, and hence it's best to have a SW footprint that is minimal.

Signed-off-by: Prakash Narayana Moorthy <[email protected]>
…rdian plugin is largely same as the guardian plugin for the

openvino inference use case. A future PR that permits refactoring, and reuse of modules among the HF and OpenVINO use cases
needs to be explored.

2. installation related files such as setup.py, MANIFEST, etc.

3. test script that needs to be manually invoked to test the HF use case. To run the test script, the user must create an HF account,
and obtain an HF authentication token, and set HF_AUTH_TOKEN environment variable to the token value. Due to this external depdency,
test is currently not integrated as part of the 'make test' automatic test suite. The test is done using the gpt2 opensource model
available on Hugging Face.

Signed-off-by: Prakash Narayana Moorthy <[email protected]>
Copy link

mergify bot commented Jul 16, 2024

⚠️ The sha of the head commit of this PR conflicts with #55. Mergify cannot evaluate rules on this PR. ⚠️

@prakashngit prakashngit added the good first issue Good for newcomers label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant