Abhishek-CS221006 commited on
Commit
28cd431
·
verified ·
1 Parent(s): d063a68

Update env.py

Browse files
Files changed (1) hide show
  1. env.py +18 -10
env.py CHANGED
@@ -179,7 +179,10 @@ class ClinicalTrialEnvironment(
179
  for field_name, expected in truth.extracted_fields.items()
180
  if _normalize(self._state.extracted_fields.get(field_name)) == _normalize(expected)
181
  )
182
- components.append(field_hits / len(truth.extracted_fields))
 
 
 
183
 
184
  if self._current_scenario.hidden_exclusions:
185
  exclusion_hits = sum(
@@ -187,7 +190,10 @@ class ClinicalTrialEnvironment(
187
  for exclusion in self._current_scenario.hidden_exclusions
188
  if exclusion in self._state.identified_deviations
189
  )
190
- components.append(exclusion_hits / len(self._current_scenario.hidden_exclusions))
 
 
 
191
 
192
  if truth.ranking:
193
  ranking = self._submitted_ranking
@@ -203,15 +209,17 @@ class ClinicalTrialEnvironment(
203
  if ranking.index(higher) < ranking.index(lower):
204
  pairwise_hits += 1
205
  pairwise_score = pairwise_hits / max(total_pairs, 1)
206
- components.append((0.6 * positional_hits) + (0.4 * pairwise_score))
207
  else:
208
- components.append(0.0)
 
 
 
209
 
210
- components.append(
211
- 1.0
212
- if _normalize(self._state.final_decision) == _normalize(truth.final_decision)
213
- else 0.0
214
- )
215
 
216
  if not components:
217
  return MIN_STRICT_SCORE
@@ -336,4 +344,4 @@ class ClinicalTrialEnvironment(
336
  class ClinicalTrialEnv(ClinicalTrialEnvironment):
337
  """Compatibility alias for manifest entry points expecting env:ClinicalTrialEnv."""
338
 
339
- pass
 
179
  for field_name, expected in truth.extracted_fields.items()
180
  if _normalize(self._state.extracted_fields.get(field_name)) == _normalize(expected)
181
  )
182
+ score = field_hits / len(truth.extracted_fields)
183
+ # Clamp component to ensure it never hits exact 0.0 or 1.0
184
+ score = min(max(score, MIN_STRICT_SCORE), MAX_STRICT_SCORE)
185
+ components.append(score)
186
 
187
  if self._current_scenario.hidden_exclusions:
188
  exclusion_hits = sum(
 
190
  for exclusion in self._current_scenario.hidden_exclusions
191
  if exclusion in self._state.identified_deviations
192
  )
193
+ score = exclusion_hits / len(self._current_scenario.hidden_exclusions)
194
+ # Clamp component to ensure it never hits exact 0.0 or 1.0
195
+ score = min(max(score, MIN_STRICT_SCORE), MAX_STRICT_SCORE)
196
+ components.append(score)
197
 
198
  if truth.ranking:
199
  ranking = self._submitted_ranking
 
209
  if ranking.index(higher) < ranking.index(lower):
210
  pairwise_hits += 1
211
  pairwise_score = pairwise_hits / max(total_pairs, 1)
212
+ score = (0.6 * positional_hits) + (0.4 * pairwise_score)
213
  else:
214
+ score = MIN_STRICT_SCORE # Penalize missing/incorrect ranking
215
+ # Clamp component to ensure it never hits exact 0.0 or 1.0
216
+ score = min(max(score, MIN_STRICT_SCORE), MAX_STRICT_SCORE)
217
+ components.append(score)
218
 
219
+ # Final decision correctness
220
+ final_match = _normalize(self._state.final_decision) == _normalize(truth.final_decision)
221
+ score = MAX_STRICT_SCORE if final_match else MIN_STRICT_SCORE # Already clamped
222
+ components.append(score)
 
223
 
224
  if not components:
225
  return MIN_STRICT_SCORE
 
344
  class ClinicalTrialEnv(ClinicalTrialEnvironment):
345
  """Compatibility alias for manifest entry points expecting env:ClinicalTrialEnv."""
346
 
347
+ pass