본문 바로가기

AI

hugging face zero-shot text classification

반응형

hugging face에서 제공하는 transformers pipeline을 통해 model을 zeroshot으로 사용가능.

from transformers import pipeline
classifier = pipeline("zero-shot-classification",
                      model="facebook/bart-large-mnli")

 

model에 hugging face에 올려져있는 다양한 모델을 대입하여 사용가능하다.

 

https://huggingface.co/

 

Hugging Face – The AI community building the future.

The AI community building the future. Build, train and deploy state of the art models powered by the reference open source in natural language processing.

huggingface.co

 

  • facebook/bart-large-mnli
  • bert-base-uncased
  • joeddav/bart-large-mnli-yahoo-answers

 

  • classifier에 labels , sentence 외에 multi_class option 가능
  • 만약 classifier가 하나의 라벨을 찾는 것이 아니라 여러개의 라벨을 추출하는 경우에는 multi_class = True로 지정.
  • 각 클래스의 score를 독립적으로 계산한다.
반응형