aws / aws/sagemaker-huggingface-inference-toolkit

SageMaker endpoint can't load huggingface tokenizer

Open
#31 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
270
Forks
60
PR merge metrics
No merged PRs in 30d

Description

I used Amazon SageMaker to train a HuggingFace model. At the end of the training script provided to the estimator, I saved the model into the correct path (`SM_MODEL_DIR`):
```
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--model-dir", type=str, default=os.environ["SM_MODEL_DIR"])
...
trainer.model.save_pretrained(args.model_dir)
```
After the model was trained, I deployed it using the `deploy` method of the HuggingFace estimator. Once the endpoint was successfully created, I tried inference with the returned predictor:
```
response = self.predictor.predict(
{"inputs": "I want to know where is my order"}
)
```
And I received the following client error:
```
{'code': 400, 'type': 'InternalServerException', 'message': "Can't load tokenizer for '/.sagemaker/mms/models/model'. Make sure that:\n\n- '/.sagemaker/mms/models/model' is a correct model identifier listed on 'https://huggingface.co/models'\n\n- or '/.sagemaker/mms/models/model' is the correct path to a directory containing relevant tokenizer files\n\n"}
```

The problem seems to be on the path that the endpoint uses to load the model on the `from_pretrained` method.

Any idea of why the tokenizer cannot be loaded?

Contributor guide

Open the contributing guide

Research direction

Start with the provided training script's SM_MODEL_DIR save_pretrained call and the endpoint's from_pretrained path shown in the error; compare that path with the files produced by deployment. Reproduce the deploy/predict flow and determine what change is needed so the endpoint can load the tokenizer, then verify inference no longer returns the 400 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, huggingface, python
Domain
api, cloud, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.