opensi·si

Inference is the process of using a trained model to make predictions on new data. Because this process can be compute-intensive, running on a dedicated or external service can…

Inference Client

Inference is the process of using a trained model to make predictions on new data. Because this process can be compute-intensive, running on a dedicated or external service can be an interesting option. The huggingface_hub library provides a unified interface to run inference across multiple services for models hosted on the Hugging Face Hub:

  1. Inference Providers: a streamlined, unified access to hundreds of machine learning models, powered by our serverless inference partners. This new approach builds on our previous Serverless Inference API, offering more models, improved performance, and greater reliability thanks to world-class providers. Refer to the documentation for a list of supported providers.
  2. Inference Endpoints: a product to easily deploy models to production. Inference is run by Hugging Face in a dedicated, fully managed infrastructure on a cloud provider of your choice.
  3. Local endpoints: you can also run inference with local inference servers like llama.cpp, Ollama, vLLM, LiteLLM, or Text Generation Inference (TGI) by connecting the client to these local endpoints.

These services can be called with the InferenceClient object. Please refer to this guide for more information on how to use it.

Inference Client

[[autodoc]] InferenceClient

Async Inference Client

An async version of the client is also provided, based on asyncio and httpx2.

[[autodoc]] AsyncInferenceClient

InferenceTimeoutError

[[autodoc]] InferenceTimeoutError

Source and license

Source: Hub Python Library documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.