RLHF를 위한 생성 텍스트 분류하기
이제 생성된 리뷰를 범주화해 보려고 합니다. 출력을 평가하는 한 가지 방법은 분류기 lvwerra/distilbert-imdb를 사용해 생성된 리뷰의 긍정성을 측정하는 것입니다. 이 분류기는 Hugging Face 파이프라인으로도 생성해 사용할 수 있어요.
transformers에서 pipeline 라이브러리가 미리 임포트되어 있습니다. lvwerra/distilbert-imdb 모델은 model로, 토크나이저는 tokenizer로 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Reinforcement Learning from Human Feedback (RLHF)
연습 안내
pipeline함수를 사용해 해당 모델로 감성 분석 파이프라인을 만드세요.- 제공된 리뷰의 감성을 분류하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a sentiment analysis pipeline
sentiment_analyzer = pipeline(____, model=____, tokenizer=____)
review_text = "Surprisingly, the film is a very good one"
# Classify the sentiment of the review
sentiment = sentiment_analyzer(____)
print(f"Sentiment Analysis Result: {sentiment}")