Get startedGet started for free

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.

This exercise is part of the course

Introduction to LLMs in Python

View Course

Exercise instructions

  • Tokenize the new data.
  • Pass the tokenized inputs into the fine-tuned model, disabling gradients.
  • Extract the new predictions.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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}")
Edit and Run Code