> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Add system packages

> Deploy a model with both Python and system dependencies.

> [card] [View example on GitHub](https://github.com/basetenlabs/truss-examples/tree/main/10-using-system-packages)

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:

```yaml config.yaml theme={"system"}
system_packages:
  - tesseract-ocr
```

For this example, we use the [LayoutLM Document QA](https://huggingface.co/impira/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.

```python model/model.py theme={"system"}
from transformers import pipeline


class Model:
    def __init__(self, **kwargs) -> None:
        self._model = None

    def load(self):
        self._model = pipeline(
            "document-question-answering",
            model="impira/layoutlm-document-qa",
        )

    def predict(self, model_input):
        return self._model(model_input["url"], model_input["prompt"])
```

# Set up the config.yaml file

The main items that need to be configured in `config.yaml` are the `requirements`
and `system_packages` sections.

> [!NOTE]
>
> Pin exact versions for your Python dependencies so a new release can't
> introduce a breaking change between deploys.

```yaml config.yaml theme={"system"}
environment_variables: {}
external_package_dirs: []
model_metadata:
  example_model_input:
    {
      "url": "https://templates.invoicehome.com/invoice-template-us-neat-750px.png",
      "prompt": "What is the invoice number?",
    }
model_name: LayoutLM Document QA
python_version: py311
requirements:
  - Pillow==12.3.0
  - pytesseract==0.3.13
  - torch==2.14.0
  - transformers==5.17.0
resources:
  cpu: "4"
  memory: 16Gi
  use_gpu: false
  accelerator: null
secrets: []
system_packages:
  - tesseract-ocr
```

# Deploy the model

Install the Baseten CLI and sign in:

**Install the Baseten CLI**

> [tab] macOS or Linux
>
> ```bash Terminal theme={"system"}
> brew tap basetenlabs/baseten
> brew trust --formula basetenlabs/baseten/baseten
> brew install baseten
> ```

> [tab] Windows
>
> Download and extract the Windows archive for the latest Baseten CLI release:
>
> ```powershell Terminal theme={"system"}
> $release = Invoke-RestMethod https://api.github.com/repos/basetenlabs/baseten-cli/releases/latest
> $asset = $release.assets | Where-Object { $_.name -like "*_windows_amd64.zip" }
> Invoke-WebRequest $asset.browser_download_url -OutFile baseten.zip
> Expand-Archive -Force baseten.zip .
> ```
>
> Move `baseten.exe` to a directory on your `PATH`.

For other platforms or a specific version, see the [Baseten CLI install reference](https://docs.baseten.co/reference/cli/baseten/overview.md#install).

**Sign in**

```sh theme={"system"}
baseten auth login
```

From the directory that contains `config.yaml`, deploy the model:

```sh theme={"system"}
baseten model push
```

The output's `Model:` line shows your model ID. Once the deployment is active, call the model, replacing `YOUR_MODEL_ID` with that ID:

```sh theme={"system"}
baseten model predict --model-id YOUR_MODEL_ID --data '{"url": "https://templates.invoicehome.com/invoice-template-us-neat-750px.png", "prompt": "What is the invoice number?"}'
```
