Skip to content

Causal Reasoning

advanced

Measure causal strength, infer direction, perform do-calculus interventions, and counterfactual analysis.

Causal strength

POST/v1/memory/causal/strength

Measure causal strength between two patterns in both directions.

pattern_aarray[number] | null

First pattern embedding.

pattern_barray[number] | null

Second pattern embedding.

text_astring | null

First pattern as text (auto-embedded).

text_bstring | null

Second pattern as text (auto-embedded).

200Response
{
  "strength_a_to_b": 0.78,
  "strength_b_to_a": 0.12,
  "direction": "a_to_b",
  "observations_a_to_b": 15,
  "observations_b_to_a": 3,
  "confounded": false
}
Tip

Provide either embeddings (pattern_a/pattern_b) or text (text_a/text_b). Text is auto-embedded server-side.


Causal direction

POST/v1/memory/causal/direction

Infer causal direction between two patterns with confounding detection.

pattern_aarray[number] | null

First pattern embedding.

pattern_barray[number] | null

Second pattern embedding.

text_astring | null

First pattern as text (auto-embedded).

text_bstring | null

Second pattern as text (auto-embedded).

200Response
{
  "direction": "a_causes_b",
  "confidence": 0.87,
  "confounded": false,
  "details": {
    "displacement_consistency": 0.92
  }
}

Intervene (do-calculus)

POST/v1/memory/causal/intervene

do-calculus: predict effects of intervening on a pattern (Pearl Level 2).

cause_keyarray[number] | null

Cause pattern embedding.

cause_valuearray[number] | null

Intervention value for the cause.

textstring | null

Cause pattern as text (auto-embedded, used as both key and value).

200Response
{
  "predicted_effects": [
    {
      "effect_key": [
        0.23,
        -0.45,
        "..."
      ],
      "predicted_value": [
        0.67,
        0.12,
        "..."
      ],
      "causal_strength": 0.78
    }
  ]
}

Counterfactual

POST/v1/memory/causal/counterfactual

Pearl Level 3: "If cause had been different, what would effect have been?"

cause_keyarray[number] | null

Cause pattern embedding.

effect_keyarray[number] | null

Effect pattern embedding.

counterfactual_cause_valuearray[number] | null

Alternative cause value.

text_causestring | null

Cause pattern as text.

text_effectstring | null

Effect pattern as text.

text_counterfactualstring | null

Counterfactual cause as text.

200Response
{
  "counterfactual_effect": [
    0.34,
    -0.12,
    0.78,
    "..."
  ],
  "computable": true
}
Tip

If the causal relationship is too weak or unknown, computable returns false and counterfactual_effect is null.


Causal neighbors

POST/v1/memory/causal/neighbors

Get causal parents and/or children of a pattern.

pattern_keyarray[number] | null

Pattern embedding.

textstring | null

Pattern as text (auto-embedded).

directionstringDefault: both

Filter: parents, children, or both.

min_strengthnumberDefault: 0.3

Minimum causal strength to include (0.0–1.0).

200Response
{
  "parents": [
    {
      "key": [
        0.12,
        -0.34,
        "..."
      ],
      "strength": 0.82
    }
  ],
  "children": [
    {
      "key": [
        0.56,
        0.78,
        "..."
      ],
      "strength": 0.65
    },
    {
      "key": [
        0.23,
        -0.45,
        "..."
      ],
      "strength": 0.41
    }
  ]
}

Next steps