The bot: https://botsin.space/web/accounts/89547
This is a fun project created to get my hands on and try out AWS - namely Lambda function. It uses textgenrnn
library to generate new superhero names and dataset of superheroes link. It was trained on google colab with 10 epochs (just arbitraty number I chose, honestly).
I've had some trouble using the AWS Lambda environment - especially running the handler function. I found this article link on how to deploy it using Docker.
I had trouble with running library libffi-d7...
from cffi
package that the Mastodon.py wrapper uses. What (I think) helped was putting the precompiled library to the root folder of the .zip file.
Another problem I encountered was putting the model in the Lambda function. Since textgenrnn uses keras and tensorflow. TF package is very large and Lambda restriction for the function code is 250 mb unzipped when uploaded through s3. So the first workaround was to generate n (in our case 10k) examples and just randomly choose 5 of them, instead of generating them everytime the Lambda function is run.
Another useful links for AWS Lambda and Python
- AWS Lambda Deployment Package - official docs
- Hassle-Free Python Lambda Deployment
- Precompiled lambda packages
- Zappa serverless python
- Hosting platforms for bots
- Serverless dl/ml in production
- Serving TF predictions with Lambda and Python
I can an improvement in actually generating the output when the function is run - that would mean, I think, to build tensorflow and other big libraries that are being used from source. Or maybe developing simple REST api (maybe using Flask?) on EC2 and calling it from the Lambda function.