github-actions[bot] commited on
Commit
2ff8798
·
1 Parent(s): d02622b

Auto-sync from demo at Wed Oct 29 12:31:26 UTC 2025

Browse files
graphgen/utils/calculate_confidence.py CHANGED
@@ -61,8 +61,8 @@ def _normalize_yes_no(tokens: List[Token]) -> Dict[str, float]:
61
  {"yes": 0.8, "no": 0.2}
62
  Among them, "yes" and "yeah" are synonyms for "yes",
63
  while "no" and "nope" are synonyms for "no".
64
- If neither "yes" nor "no" synonyms are present, it returns:
65
- {"yes": 0.5, "no": 0.5}
66
  """
67
  yes_syno = {
68
  # English yes synonyms
@@ -126,17 +126,23 @@ def _normalize_yes_no(tokens: List[Token]) -> Dict[str, float]:
126
 
127
  yes_prob = 0.0
128
  no_prob = 0.0
 
129
  for tok in tokens:
130
  t = tok.text.lower().strip()
131
  if t in yes_syno:
132
  yes_prob += tok.prob
133
  elif t in no_syno:
134
  no_prob += tok.prob
 
 
 
 
135
 
136
- total = yes_prob + no_prob
137
- if total == 0:
138
- return {"yes": 0.5, "no": 0.5}
139
- return {"yes": yes_prob / total, "no": no_prob / total}
 
140
 
141
 
142
  def yes_no_loss_entropy(
 
61
  {"yes": 0.8, "no": 0.2}
62
  Among them, "yes" and "yeah" are synonyms for "yes",
63
  while "no" and "nope" are synonyms for "no".
64
+ If no "yes" or "no" synonyms are present, it will be judged as uncertain.
65
+ An uncertain result will also be considered as opposite to the ground truth.
66
  """
67
  yes_syno = {
68
  # English yes synonyms
 
126
 
127
  yes_prob = 0.0
128
  no_prob = 0.0
129
+ uncertain_prob = 0.0
130
  for tok in tokens:
131
  t = tok.text.lower().strip()
132
  if t in yes_syno:
133
  yes_prob += tok.prob
134
  elif t in no_syno:
135
  no_prob += tok.prob
136
+ else:
137
+ uncertain_prob += tok.prob
138
+
139
+ total = yes_prob + no_prob + uncertain_prob
140
 
141
+ return {
142
+ "yes": yes_prob / total,
143
+ "no": no_prob / total,
144
+ "uncertain": uncertain_prob / total,
145
+ }
146
 
147
 
148
  def yes_no_loss_entropy(