Views
No views yet
1import torch
2from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
4# Load model and tokenizer
5device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
6
7model_name = "agentlans/deberta-v3-xsmall-zyda-2-quality"
8model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=1).to(device)
9tokenizer = AutoTokenizer.from_pretrained(model_name)
10
11# Function to perform inference
12def predict_score(text):
13 inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True).to(device)
14 with torch.no_grad():
15 logits = model(**inputs).logits
16 return logits.item()
17
18# Example usage
19input_text = "This product is excellent and works perfectly!"
20predicted_score = predict_score(input_text)
21print(f"Predicted score: {predicted_score}")| Text | Quality Score |
|---|---|
| Discover the secret to eternal youth with our revolutionary skincare product! | -1.74 |
| Act now! Limited time offer on miracle weight loss pills! | -1.50 |
| Congratulations! You've won a $1,000 gift card! Click here to claim your prize! | -0.86 |
| Get rich quick with our foolproof investment strategy - no experience needed! | -0.77 |
| Your computer is infected! Click here for a free scan and fix your issues now! | -0.29 |
| Unlock the secrets of the universe with our exclusive online astronomy course! | 0.14 |
| Earn money from home by participating in online surveys - sign up today! | 0.23 |
| The Eiffel Tower can be 15 cm taller during the summer due to thermal expansion. | 0.75 |
| Did you know? The average person spends 6 years of their life dreaming. | 1.60 |
| Did you know that honey never spoils? Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still edible. | 2.27 |
| Training Loss | Epoch | Step | Validation Loss | MSE |
|---|---|---|---|---|
| 0.3506 | 1.0 | 12649 | 0.3512 | 0.3512 |
| 0.2800 | 2.0 | 25298 | 0.3187 | 0.3187 |
| 0.2398 | 3.0 | 37947 | 0.3165 | 0.3165 |