deploy transformers
1.0.0
仅在三行代码中部署SOTA模型以进行文本生成
显然需要Pytorch和变压器。
pip install deploy-transformers对于部署,文件结构必须这样:
├── static
│ ├── script.js
│ ├── style.css
├── templates
│ ├── 404.html
│ ├── index.html
|
└── your_file.py您可以克隆此存储库以拥有原始文件或使用function website.create_structure()或创建自己的结构。
website.create_structure()将自动创建模板/ ,静态/以及其中的所有文件(.html,.js,.css)。
检查示例/文件夹。
# Deployment
from deploy_transformers import Website
website = Website ( model_type = "gpt2" , model_name = "distilgpt2" )
# website.create_folder(homepage_file="index.html", template_folder='templates', static_folder='static')
website . deploy ()您可以在website.deploy()中的主页文件名,模板/和静态/名称,但是最好将它们保留为默认值。
# Only text generation
from deploy_transformers import ListModels , Model
# ListModels() to show available models
model = Model ( "gpt2" , "distilgpt2" , seed = 42 , verbose = False )
model . generate ( length = 20 , prompt = "The quick brown fox jumps over the lazy dog" )
# If no prompt, input will be ask until exit还有一个Dockerfile。