SDKs overview

Hugging Face provides Software Development Kits (SDKs) and libraries designed to facilitate interaction with its ecosystem, encompassing the Hugging Face Hub, the Inference API, and various machine learning tools. These SDKs aim to abstract away complexities in tasks such as loading pre-trained models, fine-tuning, performing inference, and managing datasets. The primary official SDK is written in Python, reflecting its prevalence in machine learning and data science communities. This Python SDK integrates core functionalities for natural language processing (NLP), computer vision, and audio tasks, supporting a wide range of architectures and pre-trained models.

The SDKs are generally structured to support different levels of abstraction. For instance, the transformers library provides high-level APIs for common tasks like text classification or tokenization, while also allowing lower-level access to model configurations and layers for advanced users. Developers can use these tools to build applications that leverage state-of-the-art machine learning models without needing to implement complex algorithms from scratch. The open-source nature of many Hugging Face components means that the community also contributes a variety of libraries and tools that extend the platform's capabilities or offer integrations with other programming languages and frameworks.

Official SDKs by language

Hugging Face's official SDK ecosystem is primarily centered around Python, providing robust tooling for interacting with its platform and models. While Python is the flagship language, there are also utilities and client libraries that support interaction with certain aspects of the Hugging Face ecosystem, particularly for the Inference API.

Python

The main SDK for Hugging Face is implemented in Python, offering comprehensive access to the Hugging Face Hub, over 60,000 pre-trained models, and 10,000 datasets as of 2026. Key Python libraries include:

  • transformers: This library provides APIs and implementations of popular transformer models (e.g., BERT, GPT, T5) across various modalities like text, vision, and audio. It supports model loading, fine-tuning, and inference, and integrates with deep learning frameworks such as PyTorch, TensorFlow, and JAX. The transformers library is noted for its unified API across different model architectures and its focus on interoperability between frameworks. More details are available in the Hugging Face Transformers documentation.
  • datasets: This library simplifies the process of loading, processing, and sharing datasets for machine learning. It supports large datasets and provides tools for efficient data management, including caching and streaming capabilities. The datasets library is optimized for handling diverse data formats and sizes, crucial for modern machine learning workflows, as outlined in the Hugging Face Datasets documentation.
  • accelerate: Designed to make training and evaluating PyTorch models at scale easier, accelerate handles complexities like distributed training, mixed precision, and multi-GPU setups with minimal code changes.
  • diffusers: Focused on generative AI, this library provides pre-trained diffusion models for generating images, audio, and other media, along with tools for fine-tuning and deploying these models.
  • huggingface_hub: This client library provides tools to interact programmatically with the Hugging Face Hub, enabling developers to upload and download models, datasets, and other files, as well as manage repositories.
  • evaluate: A library for easily comparing and evaluating machine learning models, offering a wide range of metrics and evaluation strategies.

The following table summarizes the primary official SDKs maintained by Hugging Face:

Language Package Name Install Command Maturity
Python transformers pip install transformers Stable, actively maintained
Python datasets pip install datasets Stable, actively maintained
Python accelerate pip install accelerate Stable, actively maintained
Python diffusers pip install diffusers Stable, actively maintained
Python huggingface_hub pip install huggingface_hub Stable, actively maintained
Python evaluate pip install evaluate Stable, actively maintained

Installation

To begin using the Hugging Face Python SDKs, you typically install them using pip, the standard package installer for Python. It is recommended to use a virtual environment to manage dependencies and avoid conflicts with other projects.

Prerequisites

  • Python 3.8 or newer.
  • pip (usually included with Python installations).
  • An integrated development environment (IDE) like VS Code or PyCharm, or a text editor and terminal.

Basic Installation Steps

  1. Create a virtual environment (recommended):

    python -m venv huggingface-env
    source huggingface-env/bin/activate  # On macOS/Linux
    huggingface-env\Scripts\activate.bat # On Windows
    
  2. Install the core transformers library:

    pip install transformers
    
  3. Install deep learning framework dependencies (choose one or more based on your needs):

    • PyTorch: For PyTorch users, install as specified in the PyTorch installation guide.
    • TensorFlow: For TensorFlow users, install as specified in the TensorFlow installation guide.

    Example for PyTorch:

    pip install torch
    

    Example for TensorFlow:

    pip install tensorflow
    
  4. Install other Hugging Face libraries as needed:

    pip install datasets accelerate diffusers huggingface_hub evaluate
    

Quickstart example

The following Python quickstart demonstrates how to use the transformers library to perform text classification using a pre-trained model. This example uses a pipeline, which is a high-level API designed for common inference tasks.

from transformers import pipeline

# 1. Initialize a text classification pipeline with a pre-trained sentiment analysis model.
#    The 'sentiment-analysis' task will automatically load a suitable model and tokenizer.
classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")

# 2. Define the text inputs for classification.
texts = [
    "I love using Hugging Face's libraries! They are incredibly powerful.",
    "The documentation could be a bit clearer on some advanced topics.",
    "This is an amazing day, filled with joy and productivity.",
    "I am so frustrated with this error, it's preventing any progress."
]

# 3. Process the texts using the classifier.
results = classifier(texts)

# 4. Print the classification results.
print("Sentiment Analysis Results:")
for i, result in enumerate(results):
    print(f"  Text: '{texts[i][:50]}...'")
    print(f"  Label: {result['label']}, Score: {result['score']:.4f}")
    print("---------------------------------------------------")

# Example of using a different pipeline for zero-shot classification
# Zero-shot classification allows classifying text without specific training data for the labels.
print("\nZero-Shot Classification Example:")
zero_shot_classifier = pipeline("zero-shot-classification")

sequence_to_classify = "One of the best movies I've seen in a while, highly recommend it."
candidate_labels = ["positive", "negative", "neutral"]

zero_shot_results = zero_shot_classifier(
    sequence_to_classify,
    candidate_labels,
    multi_label=False
)

print(f"  Text: '{zero_shot_results['sequence']}'")
print(f"  Labels: {zero_shot_results['labels']}")
print(f"  Scores: {[f'{score:.4f}' for score in zero_shot_results['scores']]}")

This example first initializes a sentiment analysis pipeline, which abstracts away the complexities of loading a model and tokenizer, preprocessing text, and performing inference. It then processes a list of sentences to determine their sentiment. The second part demonstrates zero-shot classification, where a model classifies text into user-defined categories without prior task-specific training. These pipelines simplify common machine learning tasks, making advanced models accessible with minimal code.

Community libraries

Given Hugging Face's open-source ethos and strong community involvement, numerous third-party and community-contributed libraries extend the platform's functionality or provide integrations for different programming languages and frameworks. While not officially maintained by Hugging Face, these libraries can be valuable for developers working in diverse environments.

Some examples of community-driven efforts include:

  • Rust bindings: Projects like huggingface-rust aim to provide Rust interfaces for interacting with Hugging Face models, enabling high-performance, memory-safe machine learning applications. While not as comprehensive as the official Python SDK, these efforts facilitate model deployment in Rust ecosystems.
  • JavaScript/TypeScript libraries: For web and Node.js environments, community libraries sometimes emerge to offer client-side interaction with the Hugging Face Inference API or to utilize ONNX-exported models directly in the browser. Libraries like @xenova/transformers.js (an independent project) compile Hugging Face models to ONNX and run them in JavaScript, as detailed in its GitHub repository.
  • Go client libraries: Some developers create Go client libraries to interact with the Hugging Face Inference API, useful for backend services written in Go that need to leverage pre-trained models. These are typically smaller, focused clients rather than full SDKs.
  • Integrations with other ML frameworks: Community members often build bridges between Hugging Face models and other machine learning ecosystems not directly supported by the core SDKs, such as specific reinforcement learning frameworks or specialized data science platforms.

Developers interested in community libraries are encouraged to explore the Hugging Face forums, GitHub, and other community channels for the latest contributions and active projects. When using community-maintained libraries, it is important to verify their stability, maintenance status, and adherence to security best practices.