Views
No views yet
| Metric | Value |
|---|---|
| ROC AUC | 97.59% |
| Training Loss | 0.116 |
| Validation Loss | 0.214 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model and tokenizer
5model_name = "fatihburakkaragoz/quora-cross-encoder"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForSequenceClassification.from_pretrained(model_name)
8
9# Example usage
10question1 = "How do I learn Python programming?"
11question2 = "What's the best way to learn Python?"
12
13# Tokenize and predict
14inputs = tokenizer(question1, question2,
15 truncation=True, padding=True,
16 max_length=128, return_tensors="pt")
17
18with torch.no_grad():
19 outputs = model(**inputs)
20 logits = outputs.logits
21 probability = torch.softmax(logits, dim=-1)[0, 1].item()
22
23print(f"Duplicate probability: {probability:.3f}")1import joblib
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3import torch
4
5# Load model, tokenizer, and calibrator
6model_name = "fatihburakkaragoz/quora-cross-encoder"
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForSequenceClassification.from_pretrained(model_name)
9
10# Note: Download the calibrator separately from the model repository
11calibrator = joblib.load("deberta_cal.pkl")
12
13def predict_duplicate(question1, question2):
14 # Get raw prediction
15 inputs = tokenizer(question1, question2, truncation=True,
16 padding=True, max_length=128, return_tensors="pt")
17
18 with torch.no_grad():
19 logits = model(**inputs).logits
20 raw_prob = torch.sigmoid(logits[0, 1]).item()
21
22 # Apply calibration for better confidence estimates
23 calibrated_prob = calibrator.predict_proba([[raw_prob]])[0, 1]
24 return calibrated_prob
25
26# Example
27prob = predict_duplicate("How to cook pasta?", "What's the best pasta recipe?")
28print(f"Calibrated duplicate probability: {prob:.3f}")| Epoch | Training Loss | Validation Loss | ROC AUC |
|---|---|---|---|
| 1 | 0.219 | 0.211 | 0.972 |
| 2 | 0.171 | 0.198 | 0.976 |
| 3 | 0.116 | 0.214 | 0.976 |
deberta_cal.pkl (included in repository)1@misc{deberta-v3-quora-question-pairs,
2 title={DeBERTa-v3 for Quora Question Pairs Duplicate Detection},
3 author={Fatih Burak Karagöz},
4 year={2025},
5 url={https://huggingface.co/fatihburakkaragoz/quora-cross-encoder}
6}