보상 초기화하기
여러분은 온라인 서점을 위한 개인화 추천을 제공하는 생성 모델의 배포 막바지 단계에 있습니다. 이 모델을 사람 선호도에 맞추려면, 수집한 선호 데이터로 보상 모델을 학습해야 해요. 첫 단계는 모델과 구성 매개변수를 초기화하는 일입니다.
AutoTokenizer와 AutoModelForSequenceClassification은 transformers에서 미리 로드되어 있고, RewardConfig는 trl에서 미리 로드되어 있습니다.
이 연습은 강의의 일부입니다
Reinforcement Learning from Human Feedback (RLHF)
연습 안내
- Hugging Face의
AutoModelForSequenceClassification을 사용해 시퀀스 분류 작업용 GPT-1 모델"openai-gpt"를 로드하세요. "output_dir"를 출력 디렉터리로 사용해 보상 구성을 초기화하고, 토큰 최대 길이를60으로 설정하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Load the pre-trained GPT-1 model for text classification
model = ____
tokenizer = AutoTokenizer.from_pretrained("openai-gpt")
# Initialize the reward configuration and set max_length
config = ____(output_dir=____, max_length=____)