- Build Docker container
docker build --tag sentence-encoder-lambda .
- Run container
docker run -p 9000:8080 sentence-encoder-lambda:latest
- Make a cURL request
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"text":["are you open?"]}'
The endpoint returns a 512 dimension dense vector, which can be used when implementing e.g. a similarity search
{"vector":"[-0.01935427635908127, ....]"}
Resources
- Tensorflow Hub - Universal Sentence Encoder
- Lambda Function Handlers - Python
- Testing Locally - Lambda Containers