Skip to main content

View example on GitHub

In this example, we build a Truss with a model that requires specific system packages. To add system packages to your model serving environment, open config.yaml and update the system_packages key with a list of apt-installable Debian packages:
config.yaml
For this example, we use the LayoutLM Document QA model, a multimodal model that answers questions about provided invoice documents. This model requires a system package, tesseract-ocr, which needs to be included in the model serving environment.

Set up the model.py

For this model, we use the HuggingFace transformers library, and the document-question-answering task.
model/model.py

Set up the config.yaml file

The main items that need to be configured in config.yaml are the requirements and system_packages sections.
Pin exact versions for your Python dependencies so a new release can’t introduce a breaking change between deploys.
config.yaml

Deploy the model

From the Truss directory, deploy the model with:
You can then invoke the model with: