feat: controller.py
Browse files
tensegrity/broca/controller.py
CHANGED
|
@@ -395,6 +395,27 @@ class CognitiveController:
|
|
| 395 |
n = len(self.belief_state.hypotheses) or self.agent.n_states
|
| 396 |
features = np.zeros(n)
|
| 397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
# Map entities and relations to hypothesis dimensions using the
|
| 399 |
# known hypothesis labels. The LLM parser (or template fallback)
|
| 400 |
# extracts entities that may match hypothesis names.
|
|
|
|
| 395 |
n = len(self.belief_state.hypotheses) or self.agent.n_states
|
| 396 |
features = np.zeros(n)
|
| 397 |
|
| 398 |
+
# Detect binary yes/no tasks. For these tasks, the template parser's
|
| 399 |
+
# keyword-based polarity detection is systematically wrong because
|
| 400 |
+
# passages about questions almost always contain negation words
|
| 401 |
+
# ("not", "doesn't") that have nothing to do with the answer.
|
| 402 |
+
# When we detect a binary yes/no task, we suppress the template
|
| 403 |
+
# parser's relation-based evidence entirely and let SBERT carry
|
| 404 |
+
# the signal. This fixes the BoolQ -12% regression.
|
| 405 |
+
active_labels = [
|
| 406 |
+
h.description.lower() for h in self.belief_state.hypotheses
|
| 407 |
+
if not h.description.startswith("_empty_")
|
| 408 |
+
]
|
| 409 |
+
is_binary_yesno = (
|
| 410 |
+
len(active_labels) == 2
|
| 411 |
+
and any(l in ("yes", "no", "true", "false") for l in active_labels)
|
| 412 |
+
)
|
| 413 |
+
if is_binary_yesno:
|
| 414 |
+
# For binary yes/no: return zero vector (no template-parser evidence).
|
| 415 |
+
# SBERT sentence similarity in the canonical pipeline will provide
|
| 416 |
+
# the actual signal. The template parser does more harm than good here.
|
| 417 |
+
return features
|
| 418 |
+
|
| 419 |
# Map entities and relations to hypothesis dimensions using the
|
| 420 |
# known hypothesis labels. The LLM parser (or template fallback)
|
| 421 |
# extracts entities that may match hypothesis names.
|