LukasHug commited on
Commit
bff577f
·
1 Parent(s): bf1b494

test last rule only

Browse files
VerifiableRewardsForScalableLogicalReasoning.py CHANGED
@@ -123,7 +123,7 @@ def _evaluate_with_prolog(prediction, validation_program, eval_config, timeout=5
123
  # Extract configuration
124
  positive_pred = eval_config.get("positive_predicate", "eastbound")
125
  negative_pred = eval_config.get("negative_predicate", "westbound")
126
- allow_multiple_rules = eval_config.get("allow_multiple_rules", True)
127
 
128
  # extract predicate from rule_to_evaluate
129
  rule_to_evaluate = extract_ilp_from_text_v2(prediction, positive_pred, allow_multiple_rules)
@@ -253,8 +253,8 @@ def extract_ilp_from_text_v2(text, target_predicate=None, allow_multiple_rules=F
253
  rule_pattern = re.compile(rf'({target_predicate}\([^()]*\)\s*:-.*?\.)')
254
  rules = list(rule_pattern.findall(text))
255
  if len(rules) > 1 and not allow_multiple_rules:
256
- logger.warning(f"Found multiple rules in text, but allow_multiple_rules is set to False. Using only the first match.")
257
- rules = rules[:1]
258
  # Remove rules that are also captured as facts
259
  p_code = ''
260
  for rule in rules:
 
123
  # Extract configuration
124
  positive_pred = eval_config.get("positive_predicate", "eastbound")
125
  negative_pred = eval_config.get("negative_predicate", "westbound")
126
+ allow_multiple_rules = eval_config.get("allow_multiple_rules", False)
127
 
128
  # extract predicate from rule_to_evaluate
129
  rule_to_evaluate = extract_ilp_from_text_v2(prediction, positive_pred, allow_multiple_rules)
 
253
  rule_pattern = re.compile(rf'({target_predicate}\([^()]*\)\s*:-.*?\.)')
254
  rules = list(rule_pattern.findall(text))
255
  if len(rules) > 1 and not allow_multiple_rules:
256
+ logger.warning(f"Found multiple rules in text, but allow_multiple_rules is set to False. Using only the last match.")
257
+ rules = rules[-1:]
258
  # Remove rules that are also captured as facts
259
  p_code = ''
260
  for rule in rules: