'How to return all labels and scores in SageMaker Inference?
I am using the HuggingFacePredictor from sagemaker.huggingface to inference some text and I would like to get all label scores.
Is there any way of getting, as response from the endpoint:
{
"labels": ["help", "Greeting", "Farewell"] ,
"score": [0.81, 0.1, 0.09],
}
(or similar)
Instead of:
{
"label": "help",
"score": 0.81,
}
Here is some example code:
import boto3
from sagemaker.huggingface import HuggingFacePredictor
from sagemaker.session import Session
sagemaker_session = Session(boto_session=boto3.session.Session())
predictor = HuggingFacePredictor(
endpoint_name=project, sagemaker_session=sagemaker_session
)
prediciton = predictor.predict({"inputs": text})[0]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
