This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| README.md | |
| *.pyc | |
| *.pyo | |
| *.pyd | |
| __pycache__ | |
| .pytest_cache | |
| serverless.yaml | |
| get_model.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM public.ecr.aws/lambda/python:3.8 | |
| # Copy function code and models into our /var/task | |
| COPY ./ ${LAMBDA_TASK_ROOT}/ | |
| # install our dependencies | |
| RUN python3 -m pip install -r requirements.txt --target ${LAMBDA_TASK_ROOT} | |
| # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | |
| CMD [ "handler.handler" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp38-cp38-linux_x86_64.whl | |
| transformers==3.4.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import torch | |
| from transformers import AutoModelForQuestionAnswering, AutoTokenizer, AutoConfig | |
| def encode(tokenizer, question, context): | |
| """encodes the question and context with a given tokenizer""" | |
| encoded = tokenizer.encode_plus(question, context) | |
| return encoded["input_ids"], encoded["attention_mask"] | |
| def decode(tokenizer, token): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| python3 get_model.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import AutoModelForQuestionAnswering, AutoTokenizer | |
| def get_model(model): | |
| """Loads model from Hugginface model hub""" | |
| try: | |
| model = AutoModelForQuestionAnswering.from_pretrained(model,use_cdn=True) | |
| model.save_pretrained('./model') | |
| except Exception as e: | |
| raise(e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mkdir model & pip3 install torch==1.5.0 transformers==3.4.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| serverless create --template aws-python3 --path serverless-multilingual |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "context": "We introduce a new language representation model called BERT, which stands for idirectional Encoder Representations from Transformers. Unlike recent language epresentation models (Peters et al., 2018a; Radford et al., 2018), BERT is designed to pretrain deep bidirectional representations from unlabeled text by jointly conditioning on both left and right context in all layers. As a result, the pre-trained BERT model can be finetuned with just one additional output layer to create state-of-the-art models for a wide range of tasks, such as question answering and language inference, without substantial taskspecific architecture modifications. BERT is conceptually simple and empirically powerful. It obtains new state-of-the-art results on eleven natural language processing tasks, including pushing the GLUE score to 80.5% (7.7% point absolute improvement), MultiNLI accuracy to 86.7% (4.6% absolute improvement), SQuAD v1.1 question answering Test F1 to 93.2 (1.5 point absolute improvement) and SQuAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| serverless deploy |