파인튜닝한 모델 사용하기
모델을 이미 파인튜닝했어요. 이제 새로운 데이터에 적용해 분류를 생성해 볼 차례입니다. 파인튜닝한 모델이 새로운 상호작용을 이탈 위험(낮음/높음)으로 얼마나 잘 태깅하는지 확인해 보세요.
파인튜닝된 model과 tokenizer는 이미 로드되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 배우는 LLM 입문
연습 안내
- 새로운 데이터를 토크나이즈하세요.
- 그래디언트를 비활성화한 상태로, 토크나이즈한 입력을 파인튜닝된 모델에 전달하세요.
- 새로운 예측을 추출하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
input_text = ["I'd just like to say, I love the product! Thank you!"]
# Tokenize the new data
inputs = ____(____, return_tensors="pt", padding=True, truncation=True)
# Pass the tokenized inputs through the model
with ____:
outputs = ____
# Extract the new predictions
predicted_labels = ____.____(outputs.logits, dim=1).tolist()
label_map = {0: "Low risk", 1: "High risk"}
for i, predicted_label in enumerate(predicted_labels):
churn_label = label_map[predicted_label]
print(f"\n Input Text {i + 1}: {input_text[i]}")
print(f"Predicted Label: {predicted_label}")