PaddlePaddle Integration with Hugging Face Hub

Hugging Face and PaddlePaddle have collaborated to integrate the PaddlePaddle deep learning platform into the Hugging Face Hub. This partnership aims to democratize AI by making PaddlePaddle's pre-trained models across text, image, audio, video, and multi-modalities available to the global open-source community.

PaddlePaddle Platform Overview

Originally open-sourced by Baidu in 2016, PaddlePaddle is a deep learning platform designed for scalable implementation. As of Q4 2022, the platform is used by over 5.35 million developers and 200,000 enterprises, holding the top market share for deep learning platforms in China.

The ecosystem includes several specialized open-source repositories:

  • Paddle: The core Deep Learning Framework.
  • Model Libraries: Specialized libraries for different modalities, including PaddleOCR, PaddleDetection, PaddleNLP, and PaddleSpeech.
  • PaddleSlim: A tool for model compression.
  • FastDeploy: A framework for model deployment.

Hub Integration and Model Discovery

Integration begins with PaddleNLP, with other libraries following. Users can discover PaddlePaddle models on the Hugging Face Hub by using the specific "PaddlePaddle" library tag.

At the time of announcement, over 75 PaddlePaddle models are available on the Hub, including:

  • UIE: A multi-task Information Extraction model series.
  • ERNIE 3.0: A state-of-the-art Chinese language model series.
  • Ernie-Layout: A document pre-training model that incorporates layout knowledge enhancement.

Additionally, the PaddlePaddle organization on the Hub provides access to Spaces for interactive tools such as Ernie-ViLG (text-to-image), UIE-X (cross-modal Information Extraction), and PaddleOCR (multilingual OCR toolkit).

Inference and Interactive Capabilities

PaddlePaddle models on the Hub support the Hugging Face Inference API, allowing users to interact with models via HTTP requests using cURL, Python's requests library, or other network request methods. For models that support a specific task, an interactive widget is provided directly in the browser for immediate testing.

Model Usage and Sharing

Users can load specific models using the "Use in paddlenlp" button on the Hub, which provides a code snippet for implementation.

For sharing models, PaddleNLP currently supports pushing models to the Hub via the save_to_hf_hub method. Example implementation:

from paddlenlp.transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("PaddlePaddle/ernie-3.0-base-zh", from_hf_hub=True)
model = AutoModelForMaskedLM.from_pretrained("PaddlePaddle/ernie-3.0-base-zh", from_hf_hub=True)

tokenizer.save_to_hf_hub(repo_id="<my_org_name>/<my_repo_name>")
model.save_to_hf_hub(repo_id="<my_org_name>/<my_repo_name>")

Sources