Search code examples
amazon-web-servicesaws-lambdanlpspacyserverless-framework

How to download "en_core_web_sm" model at runtime in spacy?


I am working on writing a lambda function which depends on Spacy's "en_core_web_sm" model. Due to limitation of AWS Lambda, I need to find a mechanism which allows me to download the model at runtime (I can afford to increase the lambda timeout).

Note: I can't use EFS at the moment due to some requirement restriction.


Solution

  • You can do this.

    from spacy.cli import download
    
    download("en_core_web_sm")
    

    See the source.