transformers 라이브러리
설치
!pip install transformers
간단히 써보기
from transformers import pipeline
classifier = pipeline('sentiment-analysis')
classifier('I am glad to hear that you finally made it.')
[{'label': 'POSITIVE', 'score': 0.9998080134391785}]
classifier('I am sorry that you hate it.')
[{'label': 'NEGATIVE', 'score': 0.9981151223182678}]
한국어에 학습된 모형을 사용해보기
classifier = pipeline('sentiment-analysis', model='monologg/koelectra-small-finetuned-nsmc')
classifier('이 영화 진짜 재밌다')
[{'label': 'positive', 'score': 0.9803304076194763}]
classifier('이야기가 말이 안된다')
[{'label': 'negative', 'score': 0.8447015881538391}]