使用模板在 Sagemaker 中部署 huggingface 零样本分类 returns 错误,缺少位置参数 'candidate_labels'
Deploying huggingface zero-shot classification in Sagemaker using template returns error, missing positional argument 'candidate_labels'
我正在使用从 huggingface 生成的代码,任务:Zero-Shot Classification
,配置:AWS
和 运行在 Sagemaker 的 jupyterlab 中使用它
from sagemaker.huggingface import HuggingFaceModel
import sagemaker
role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
'HF_MODEL_ID':'facebook/bart-large-mnli',
'HF_TASK':'zero-shot-classification'
}
# 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(
initial_instance_count=1, # number of instances
instance_type='ml.m5.xlarge' # ec2 instance type
)
predictor.predict({
'inputs': "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"
})
返回以下错误:
ModelError: An error occurred (ModelError) when calling the
InvokeEndpoint operation: Received client error (400) from primary
with message "{ "code": 400, "type": "InternalServerException",
"message": "call() missing 1 required positional argument:
\u0027candidate_labels\u0027" } ". See ...
in account **** for more information.
我试过 运行以不同的方式设置它们,例如这样,
predictor.predict({
'inputs': "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
'candidate_labels': ['science', 'life']
})
但还是不行。我应该怎么运行呢?
零样本分类模型的请求正文架构在此 link 中定义。
{
"inputs": "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
"parameters": {
"candidate_labels": [
"refund",
"legal",
"faq"
]
}
}
我正在使用从 huggingface 生成的代码,任务:Zero-Shot Classification
,配置:AWS
和 运行在 Sagemaker 的 jupyterlab 中使用它
from sagemaker.huggingface import HuggingFaceModel
import sagemaker
role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
'HF_MODEL_ID':'facebook/bart-large-mnli',
'HF_TASK':'zero-shot-classification'
}
# 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(
initial_instance_count=1, # number of instances
instance_type='ml.m5.xlarge' # ec2 instance type
)
predictor.predict({
'inputs': "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"
})
返回以下错误:
ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{ "code": 400, "type": "InternalServerException",
"message": "call() missing 1 required positional argument: \u0027candidate_labels\u0027" } ". See ... in account **** for more information.
我试过 运行以不同的方式设置它们,例如这样,
predictor.predict({
'inputs': "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
'candidate_labels': ['science', 'life']
})
但还是不行。我应该怎么运行呢?
零样本分类模型的请求正文架构在此 link 中定义。
{
"inputs": "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
"parameters": {
"candidate_labels": [
"refund",
"legal",
"faq"
]
}
}