Skip to main content

Easily deploy HuggingFace Transformers on a website

Project description

🚀 Deploy Transformers 🤗

Deploy a SOTA model for text-generation in just three lines of code 💻



Pytorch and Transformers are obviously needed.

pip install deploy-transformers

For deployment, file structure needs to be like this:

├── static
│   ├── script.js
│   ├── style.css
├── templates
│   ├── 404.html
│   ├── index.html

You can either clone this repository to have original files or use the function website.create_structure() or create yourself the structure.

website.create_structure() will automatically create templates/, static/ and all the files that are in it (.html, .js, .css).


Check the examples/ folder.

# 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')

You can change homepage filename, templates/ and static/ names in website.deploy() but it's better to keep them as default.

# 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

## Thanks


  • Do the same but for other tasks like sentiment analysis, or Q&A.
  • Add Flask option?

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deploy-transformers-0.1.tar.gz (12.0 kB view hashes)

Uploaded source

Built Distribution

deploy_transformers-0.1-py3-none-any.whl (15.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page