Five-class response sufficiency classifier using DeBERTa-v3 as a cross-encoder.
Takes (objective, response) pairs as separate inputs with direct cross-attention
between the two texts.
Only 3 misclassifications out of 374 test samples.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model = AutoModelForSequenceClassification.from_pretrained("KingTechnician/osmosis-crossencoder-joint")
5tokenizer = AutoTokenizer.from_pretrained("KingTechnician/osmosis-crossencoder-joint")
6
7labels = ["ADDR_DIRECT", "ADDR_PARTIAL", "NOADDR_ON", "NOADDR_TANGENTIAL", "NOADDR_OFF"]
8
9objective = "What causes rain?"
10response = "Rain forms when water vapor in the atmosphere condenses into droplets."
11
12inputs = tokenizer(objective, response, return_tensors="pt", truncation=True, max_length=512)
13with torch.no_grad():
14 logits = model(**inputs).logits
15 prediction = logits.argmax(dim=-1).item()
16
17print(f"Prediction: {labels[prediction]}")
18# Output: Prediction: ADDR_DIRECT