kizzay
kizzay

Reputation: 21

How can I deploy a model that i trained on amazon sagemaker locally?

I trained a model using aws blazingtext algorithm on amazon sagemaker and I was able to deploy an endpoint using sagemaker. However, in my circumstance this is not cost-efficient and I would like to run it locally. I have found the documentation on this to be confusing.

What I have is the trained model saved as a "model.tar.gz" file that I have downloaded from my s3 bucket. I have read online that you can deploy models using tensorflow and docker images, but I simply want to deploy the model I have created using sagemaker using my local machine. Essentially what I want to do is :

predictor = sagemaker.deploy(initial_instance_count=1, instance_type='local_cpu')

I expect to be able to use the predict function to make inference calls and return responses with the prediction results. I am looking for which libraries to use, and the associated code to accomplish this task. Thank you.

Upvotes: 2

Views: 924

Answers (1)

Olivier Cruchant
Olivier Cruchant

Reputation: 4037

SageMaker BlazingText comes in 2 flavors:

  1. a supervised version, that learns to classify variable-length token sequences and
  2. an unsupervised version, that learns token embeddings.

According to the documentation, for both versions, the binaries produced by the model can be consumed by fastText. From fasttext python binding documentation it seems that the following command will work for both situations:

import fasttext

# bin file is found in the model.tar.gz produced by Sagemaker
model = fasttext.load_model('model_filename.bin')

# inference for unsupervised version
model['king']

# inference for supervised version
model.predict('Which baking dish is best to bake a banana bread ?')

Gensim seems to have similar ability to read fastText artifacts but I found the API a little less clear and it seems to be available only for the unsupervised case (word embeddings)

Upvotes: 4

Related Questions