Views
No views yet
1from sentence_transformers.cross_encoder import CrossEncoder
2
3
4class CROSSENCODER:
5 def __init__(self, model_name, sim_threshold=0.5):
6 self.model = CrossEncoder(model_name)
7 self.sim_threshold = sim_threshold
8
9 def __call__(self, premise: str, hypothesis: str) -> bool:
10 scores = self.model.predict([[premise, hypothesis]])
11 return float(scores[0]) > self.sim_threshold # Here depends on num_labels during training