Created
October 19, 2021 15:20
-
-
Save philschmid/f6572c211d4b827ab3eac099e1f4f31b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sagemaker.huggingface import HuggingFaceModel | |
| import sagemaker | |
| role = sagemaker.get_execution_role() | |
| hub = { 'HF_MODEL_ID':'bigscience/T0_3B','HF_TASK':'text2text-generation'} | |
| # create Hugging Face Model Class | |
| huggingface_model = HuggingFaceModel( | |
| transformers_version='4.6.1', | |
| pytorch_version='1.7.1', | |
| py_version='py36', | |
| env=hub, | |
| role=role, | |
| ) | |
| # deploy model to SageMaker Inference | |
| predictor = huggingface_model.deploy(1,'ml.g4dn.2xlarge') | |
| # run inference | |
| predictor.predict({ | |
| 'inputs': "Is this review positive or negative? Review: Best cast iron skillet you will every buy." | |
| }) | |
| # [{'generated_text': 'Positive'}] | |
| predictor.predict({ | |
| 'inputs': "A is the son's of B's uncle. What is the family relationship between A and B?" | |
| }) | |
| # [{'generated_text': "B is A's cousin."}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment