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。