param-bharat commited on
Commit
a43245b
·
verified ·
1 Parent(s): 59a4873

Upload NLIScorer

Browse files
Files changed (1) hide show
  1. pipeline.py +27 -31
pipeline.py CHANGED
@@ -331,31 +331,31 @@ TASK_CLASSES = {
331
  }
332
 
333
  TASK_THRESHOLDS = {
334
- "Detection/Hallucination/Factual Consistency": 0.5895,
335
- "Detection/Prompt Injection": 0.4147,
336
- "Detection/Source Code": 0.4001,
337
- "Detection/Toxicity/Disability": 0.5547,
338
- "Detection/Toxicity/Gender": 0.4007,
339
- "Detection/Toxicity/Identity Hate": 0.5502,
340
- "Detection/Toxicity/Insult": 0.4913,
341
- "Detection/Toxicity/Obscene": 0.448,
342
- "Detection/Toxicity/Race": 0.5983,
343
- "Detection/Toxicity/Religion": 0.4594,
344
- "Detection/Toxicity/Toxic": 0.5034,
345
- "Detection/Toxicity/Violence": 0.4031,
346
- "Quality/Context/Document Relevance": 0.5809,
347
- "Quality/Context/Document Utilization": 0.4005,
348
- "Quality/Context/Sentence Relevance": 0.6003,
349
- "Quality/Context/Sentence Utilization": 0.5417,
350
- "Quality/Response/Adherence": 0.59,
351
- "Quality/Response/Attribution": 0.5304,
352
- "Quality/Response/Coherence": 0.6891,
353
- "Quality/Response/Complexity": 0.7235,
354
- "Quality/Response/Correctness": 0.6535,
355
- "Quality/Response/Helpfulness": 0.4445,
356
- "Quality/Response/Instruction Following": 0.5323,
357
- "Quality/Response/Relevance": 0.4011,
358
- "Quality/Response/Verbosity": 0.4243,
359
  }
360
 
361
 
@@ -381,12 +381,8 @@ class NLIScorer(Pipeline):
381
  return outputs
382
 
383
  def postprocess(self, model_outputs, task_type=None, threshold=None):
384
- if threshold is not None:
385
- threshold = threshold
386
- elif task_type is not None:
387
- threshold = TASK_THRESHOLDS[task_type]
388
- else:
389
- threshold = 0.5
390
  pos_scores = model_outputs["logits"].softmax(-1)[0][1]
391
  best_class = int(pos_scores > threshold)
392
  if best_class == 1:
 
331
  }
332
 
333
  TASK_THRESHOLDS = {
334
+ "Detection/Hallucination/Factual Consistency": 0.5,
335
+ "Detection/Prompt Injection": 0.5001,
336
+ "Detection/Source Code": 0.5039,
337
+ "Detection/Toxicity/Disability": 0.5111,
338
+ "Detection/Toxicity/Gender": 0.5003,
339
+ "Detection/Toxicity/Identity Hate": 0.5035,
340
+ "Detection/Toxicity/Insult": 0.5187,
341
+ "Detection/Toxicity/Obscene": 0.5034,
342
+ "Detection/Toxicity/Race": 0.5081,
343
+ "Detection/Toxicity/Religion": 0.5058,
344
+ "Detection/Toxicity/Toxic": 0.5005,
345
+ "Detection/Toxicity/Violence": 0.5001,
346
+ "Quality/Context/Document Relevance": 0.5016,
347
+ "Quality/Context/Document Utilization": 0.5014,
348
+ "Quality/Context/Sentence Relevance": 0.5002,
349
+ "Quality/Context/Sentence Utilization": 0.5039,
350
+ "Quality/Response/Adherence": 0.5107,
351
+ "Quality/Response/Attribution": 0.5053,
352
+ "Quality/Response/Coherence": 0.6103,
353
+ "Quality/Response/Complexity": 0.5603,
354
+ "Quality/Response/Correctness": 0.501,
355
+ "Quality/Response/Helpfulness": 0.5018,
356
+ "Quality/Response/Instruction Following": 0.5001,
357
+ "Quality/Response/Relevance": 0.5012,
358
+ "Quality/Response/Verbosity": 0.5408,
359
  }
360
 
361
 
 
381
  return outputs
382
 
383
  def postprocess(self, model_outputs, task_type=None, threshold=None):
384
+ if threshold is None:
385
+ threshold = TASK_THRESHOLDS.get(task_type, 0.5)
 
 
 
 
386
  pos_scores = model_outputs["logits"].softmax(-1)[0][1]
387
  best_class = int(pos_scores > threshold)
388
  if best_class == 1: