Trainer 설정하기
이 모델은 복잡한 표현을 더 쉽고 이해하기 쉬운 문장으로 바꿔 번역의 가독성을 높입니다. 예를 들어, "The inclement weather conditions precipitated the postponement of the outdoor event"라는 문장을 "The bad weather caused the outdoor event to be delayed."로 단순화할 수 있습니다. 언어 번역 서비스 훈련을 준비하기 위해 Trainer를 구성해 보세요! trainer.train()을 호출하므로 실행하는 데 다소 시간이 걸릴 수 있습니다.
다음 데이터가 미리 불러와져 있습니다:
model: Transformer 모델dataset: 문장 바꿔쓰기(paraphrase) 데이터셋인 MRPC 데이터셋compute_metrics: 정확도와 F1 점수를 반환하는 함수- 이전 연습 문제에서
training_args를 정의했습니다
이 연습은 강의의 일부입니다
PyTorch로 AI 모델 효율적으로 학습시키기
연습 안내
model을Trainer()클래스에 전달하세요.- 훈련 인수를
Trainer()클래스에 입력하세요. - 메트릭을 계산하는 함수를
Trainer()클래스에 전달하세요. trainer가 선택한 장치를 출력하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
trainer = Trainer(
# Pass in the model
model=____,
# Input the training arguments
args=____,
train_dataset=dataset["train"],
eval_dataset=dataset["validation"],
# Pass in a function to compute metrics
compute_metrics=____,
)
trainer.train()
# Print the device that the trainer chooses
print(trainer.args.____)