Skip to main content

HuggingFace runtime for MLServer

Project description

HuggingFace runtime for MLServer

This package provides a MLServer runtime compatible with HuggingFace Transformers.

Usage

You can install the runtime, alongside mlserver, as:

pip install mlserver mlserver-huggingface

For further information on how to use MLServer with HuggingFace, you can check out this worked out example.

Content Types

The HuggingFace runtime will always decode the input request using its own built-in codec. Therefore, content type annotations at the request level will be ignored. Not that this doesn't include input-level content type annotations, which will be respected as usual.

Settings

The HuggingFace runtime exposes a couple extra parameters which can be used to customise how the runtime behaves. These settings can be added under the parameters.extra section of your model-settings.json file, e.g.

---
emphasize-lines: 5-8
---
{
  "name": "qa",
  "implementation": "mlserver_huggingface.HuggingFaceRuntime",
  "parameters": {
    "extra": {
      "task": "question-answering",
      "optimum_model": true
    }
  }
}
These settings can also be injected through environment variables prefixed with `MLSERVER_MODEL_HUGGINGFACE_`, e.g.

```bash
MLSERVER_MODEL_HUGGINGFACE_TASK="question-answering"
MLSERVER_MODEL_HUGGINGFACE_OPTIMUM_MODEL=true
```

Loading models

Local models

It is possible to load a local model into a HuggingFace pipeline by specifying the model artefact folder path in parameters.uri in model-settings.json.

HuggingFace models

Models in the HuggingFace hub can be loaded by specifying their name in parameters.extra.pretrained_model in model-settings.json.

If `parameters.extra.pretrained_model` is specified, it takes precedence over `parameters.uri`.

Reference

You can find the full reference of the accepted extra settings for the HuggingFace runtime below:

.. autopydantic_settings:: mlserver_huggingface.settings.HuggingFaceSettings

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

mlserver_huggingface-1.4.0rc3.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlserver_huggingface-1.4.0rc3-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file mlserver_huggingface-1.4.0rc3.tar.gz.

File metadata

  • Download URL: mlserver_huggingface-1.4.0rc3.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure

File hashes

Hashes for mlserver_huggingface-1.4.0rc3.tar.gz
Algorithm Hash digest
SHA256 61d24e7b0e9b1b26a672bf3945284efc7ff59b2cd7deac88dc12c8f10749feb4
MD5 b07b23bb3ae357aefa8371375fef935d
BLAKE2b-256 156469dddddf3190fdf4b7e03514d97e600dd2e0688599bc1af00e249c51d356

See more details on using hashes here.

File details

Details for the file mlserver_huggingface-1.4.0rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for mlserver_huggingface-1.4.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 25d3522faaae5f8c1c355859966c0f758d208f8568a064b016ca347e9aa3eff5
MD5 478582bdf7c369d91c5a34013f98d8c2
BLAKE2b-256 0a1dbbc6dc7ebaee60a1a388a33c484c6db352466ec0a15044f2a4ed1736e0ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page