Hub documentation

Hugging Face에서 PaddleNLP 사용

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

paddlenlp-banner

Hugging Face에서 PaddleNLP 사용

PaddlePaddle 프레임워크를 활용하는 PaddleNLP는 훌륭한 사전 학습 모델 조를 갖춘, 사용하기 쉽고 강력한 NLP 라이브러리로, 연구부터 산업용 애플리케이션까지 다양한 NLP 작업을 지원합니다.

Hub에서 PaddleNLP 탐색

모델 페이지 왼쪽에서 필터링하여 PaddleNLP 모델을 찾을 수 있습니다.

Hub의 모든 모델에는 다음 기능이 제공됩니다:

  1. 검색 가능성을 높이는 간략한 설명과 메타데이터 태그가 포함된 자동 생성된 모델 카드
  2. 모델을 브라우저에서 직접 실험해 볼 수 있는 인터랙티브 위젯입니다.
  1. 추론 요청을 수행할 수 있는 Inference Providers 위젯입니다.
  1. Spaces에서 모델을 Gradio 앱으로 쉽게 배포하세요.

설치

시작하려면 PaddlePaddle Quick Start를 따라 원하는 OS, Package Manager, Compute Platform에 PaddlePaddle Framework를 설치할 수 있습니다.

paddlenlp는 pip을 통해 한 줄로 빠르게 설치할 수 있습니다:

pip install -U paddlenlp

기존 모델 사용

transformer 모델과 마찬가지로, paddlenlp 라이브러리는 from_hf_hub=True를 설정하여 Hugging Face Hub에서 모델을 로드하는 간단한 한 줄 코드를 제공합니다! 사용 목적에 따라 Taskflow 함수를 사용한 고수준 API를 사용하거나, 더 세밀한 제어가 필요하면 AutoModel과 AutoTokenizer를 사용할 수 있습니다.

# Taskflow provides a simple end-to-end capability and a more optimized experience for inference
from paddlenlp.transformers import Taskflow
taskflow = Taskflow("fill-mask", task_path="PaddlePaddle/ernie-1.0-base-zh", from_hf_hub=True)

# If you want more control, you will need to define the tokenizer and model.
from paddlenlp.transformers import AutoTokenizer, AutoModelForMaskedLM
tokenizer = AutoTokenizer.from_pretrained("PaddlePaddle/ernie-1.0-base-zh", from_hf_hub=True)
model = AutoModelForMaskedLM.from_pretrained("PaddlePaddle/ernie-1.0-base-zh", from_hf_hub=True)

특정 모델을 로드하는 방법을 확인하려면 Use in paddlenlp를 클릭하면 로드할 수 있는 작동하는 스니펫이 제공됩니다!

모델 공유

모든 Model 및 Tokenizer 클래스에서 save_to_hf_hub 메서드를 사용하여 PaddleNLP 모델을 공유할 수 있습니다.

from paddlenlp.transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("PaddlePaddle/ernie-1.0-base-zh", from_hf_hub=True)
model = AutoModelForMaskedLM.from_pretrained("PaddlePaddle/ernie-1.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>")

추가 리소스

Update on GitHub