This example illustrates how to use a BlazingText text classification training with SageMaker, and serving with AWS Lambda.
For both supervised (text classification) and unsupervised (Word2Vec) modes, the binaries (*.bin) produced by BlazingText can be cross-consumed by fastText and vice versa. You can use binaries produced by BlazingText by fastText. Likewise, you can host the model binaries created with fastText using BlazingText.
This project contains source code and supporting files for a serverless application that you can deploy with the notebook. It includes the following files and folders.
- blazingtext-text-classification-train-in-sagemaker-deploy-with-lambda.ipynb - Notebook to run training with SageMaker, and deploy the Lambda function.
- container - The container directory has all the components you need to package the sample Lambda function.
- events - Invocation events that you can use to invoke the function.
You'll be running the BlazingText text classification training with SageMaker, and serving with AWS Lambda notebook to train a TensorFlow classification model on the MNIST dataset.
You can run this notebook in SageMaker Notebook instance
Note: this notebook will not run on SageMaker Studio since you are building a Docker Image.
This notebooks is identical to the original BlazingText text classification notebook, except the fact that you'll deploy the model in Lambda function.
- In the Lambda Console, select Configure test events from the Test events dropdown.
- For Event Name, enter InferenceTestEvent.
- Copy the event JSON from here and paste in the dialog box.
- Choose Create.
After saving, you see InferenceTestEvent in the Test list. Now choose Test.
You see the Lambda function inference result, log output, and duration: