luiscgp commited on
Commit
3b7ac08
1 Parent(s): 34f813d
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -114,6 +114,24 @@ class EntailmentChecker(BaseComponent):
114
  }
115
 
116
  return entailment_checker_result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  def get_entailment_dict(self, probs):
119
  return {k.lower(): v for k, v in zip(self.labels, probs)}
 
114
  }
115
 
116
  return entailment_checker_result
117
+
118
+ def run_batch(self, queries: List[str], documents: List[Document]):
119
+ entailment_checker_result_batch = []
120
+ entailment_info_batch = self.get_entailment_batch(premise_batch=documents, hypothesis_batch=queries)
121
+ for doc, entailment_info in zip(documents, entailment_info_batch):
122
+ doc.meta["entailment_info"] = entailment_info
123
+ aggregate_entailment_info = {
124
+ "contradiction": round(entailment_info["contradiction"] / doc.score),
125
+ "neutral": round(entailment_info["neutral"] / doc.score),
126
+ "entailment": round(entailment_info["entailment"] / doc.score),
127
+ }
128
+ entailment_checker_result_batch.append(
129
+ {
130
+ "documents": [doc],
131
+ "aggregate_entailment_info": aggregate_entailment_info,
132
+ }
133
+ )
134
+ return entailment_checker_result_batch, "output_1"
135
 
136
  def get_entailment_dict(self, probs):
137
  return {k.lower(): v for k, v in zip(self.labels, probs)}