Hi,
I am using HF for zero shot classification for doc classification. I successfully implemented code with native HF library. After working code I deploy the model using SM, but I am not able to find anywhere how to pass the custom labels to the predict method?
Using HF library:
classifier = pipeline("zero-shot-classification")
a = classifier(
"Sample Vaccination Record Card Mary Major M Last Name First Name MI 1/6/58 012345abcd67 blah blah blah….",
candidate_labels=["Medical Card", "ID card", "Passport" ,"education", "politics", "business"],
)
I got the prediction score for each candidate label. So all good until here
Now I deployed the model using our SM:
hub_v1 = {
'HF_MODEL_ID':'cross-encoder/nli-distilroberta-base',
'HF_TASK':'text-classification'
}
huggingface_model_v1 = HuggingFaceModel(
transformers_version='4.17.0',
pytorch_version='1.10.2',
py_version='py38',
env=hub_v1,
role=role,
)
serverless_config_v1 = ServerlessInferenceConfig(
memory_size_in_mb=4096, max_concurrency=10,
)
predictor_v1 = huggingface_model_v1.deploy(
serverless_inference_config=serverless_config_v1
)
I called the endpoint like this
predictor_v1.predict({
'inputs': "Sample Vaccination Record Card Mary Major M Last Name First Name MI 1/6/58 012345abcd67 blah blah blah…",
'candidate_labels' : ['WILL', 'ID', 'P60', 'OTHER']
})
i get output like this:
[{'label': 'ENTAILMENT', 'score': 0.5859580636024475}]
I need the prediction score for the input string per each of the four categories.
Any idea? Am i missing something here? Appreciate your help