Using the fine-tuned model
The model has been fine-tuned. Now you ready to use on some new data and generate some classifications. Let's see how well your fine-tuned model does at tagging new interactions as either low or high risk for churn.
Your fine-tuned model
and the tokenizer
have been loaded for you.
Este exercício faz parte do curso
Introduction to LLMs in Python
Instruções de exercício
- Tokenize the new data.
- Pass the tokenized inputs into the fine-tuned model, disabling gradients.
- Extract the new predictions.
Exercício interativo prático
Experimente este exercício preenchendo este código de exemplo.
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}")