- Newest
- Most votes
- Most comments
Hello,
I understand that you tried to query the Sagemaker endpoint but received the below error:
Error:
ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{
"code": 400,
"type": "InternalServerException",
"message": "model_fn() takes 1 positional argument but 2 were given"
}
Here, I would like to mention that I tried to replicate the scenario at my end using the documentation you provided; however, I was successfully able to query the endpoint at my end without facing any error.
Further, I deep dived into this issue, and I could find that this issue can be mitigated by adding the argument “context=None” to the model_fn() and predict_fn() as follows:
def model_fn(model_dir,context=None):
def predict_fn(data, model_and_tokenizer,context=None):
I would request that you please try this at your end and let us know how it goes for you.
If you have any difficulty or if you still run into issues, please reach out to AWS Support [1] (Sagemaker) along with your issue or use case in detail, and we would be happy to assist you further.
References:
[1] Creating support cases and case management: https://docs.aws.amazon.com/awssupport/latest/user/case-management.html#creating-a-support-casehttps://docs.aws.amazon.com/awssupport/latest/user/case-management.html#creating-a-support-case
Relevant content
- asked 4 years ago
- asked 2 years ago
- asked 4 years ago

Hi Shubham, Thank you for your help. I'll try from my side.
Lei