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. Note 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.6.1.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

mlserver_huggingface-1.6.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file mlserver_huggingface-1.6.1.tar.gz.

File metadata

  • Download URL: mlserver_huggingface-1.6.1.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-1025-azure

File hashes

Hashes for mlserver_huggingface-1.6.1.tar.gz
Algorithm Hash digest
SHA256 52e61a6edce8286ae90e65c62ee9fdb40da3f2ef29e16c9f4a10b7a925cf56e0
MD5 27afc4b689d0d9f263e84d2ff0e38f8f
BLAKE2b-256 5748c03b0599dff5fc7ada86cc8c461cfc3fd855031b617a3f9b928334c90067

See more details on using hashes here.

File details

Details for the file mlserver_huggingface-1.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mlserver_huggingface-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b3cf325515a53dc5e35ecf17ee1a16341f2bc1b2875f8360b199a49e1a0468a
MD5 e0feaa9c2cee426bf08f43b4745cf53e
BLAKE2b-256 d3f6d755c23e9489fc483079df9bf1ed80c9cf84d262f424a19d4b9bc50551af

See more details on using hashes here.

Supported by

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