RecallTrace

Causal Inference via Adversarial Self-Play

An RL agent that doesn't just detect contamination โ€” it infers the hidden causal intervention behind it. Trained via adversarial self-play where an adversary learns to hide better as the investigator reasons better.

0.95+ F1 Score
3.1 Nodes/Episode
<2s CPU Training
200 Episodes
GPU Inference Status
Engine T4 GPU
Base Model Qwen2.5-0.5B-Instruct
LoRA Adapter RecallTrace (r=16)
Precision 4-bit (bitsandbytes)
โœ… System Online & Ready

Supply-Chain Graph

Ready
Unvisited
Visited
Quarantined
Safe
Hidden contamination

Controls

200
10

Belief State

Step 0
Run simulation to see belief state

Episode Stats

F1 Score โ€”
Quarantined โ€”
Steps โ€”
Intervention โ€”

๐Ÿค– Live LLM Agent Demo

Checking GPU...

Watch the fine-tuned Qwen2.5-0.5B model investigate a supply-chain contamination in real-time. The model was trained via SFT on 3,500 expert demonstrations using Unsloth + TRL.

Adaptive Heuristic Agent (200 episodes, ~4s on CPU)

Click "Run Heuristic Training" to generate plots

Task Runner

Run the deterministic baseline on OpenEnv tasks

Scoreboard

Current score โ€”
Steps taken โ€”
Status Ready
Average (all tasks) โ€”
Run all tasks to compare performance.

Episode Log

Reward Curve

Run a task to see rewards.

Final Outcome

Scoring highlights appear here.
Run a task to populate the trajectory.

RecallTrace Architecture & Environment Flow

The RecallTrace Hugging Face Space operates as a Python-based Gradio application hosting an OpenEnv-compliant causal inference benchmark. At its core, the system runs a two-agent adversarial self-play loop. In this environment, an Investigator must identify and isolate a hidden contamination event within a procedurally generated, partially observable supply graph. An opposing Adversary intelligently places these interventions to maximize the Investigator's failure rate. The environment enforces an ungameable, composable reward function that computes a final score based on Recall (catching unsafe nodes), Precision (sparing safe nodes), Belief Calibration (making confident decisions), and Efficiency (using fewer steps).

The Adaptive Heuristic Search

The Heuristic Investigator serves as an interpretable, fast-adapting baseline. Instead of neural networks, this agent uses dynamic, rule-based heuristics governed by learnable thresholds (e.g., quarantine confidence limits and "trust" in ambiguous lab results). After every episode, the agent calculates its F1 score (the harmonic mean of its precision and recall accuracy). If the F1 score dips, the agent adjusts its internal thresholds using an Exponential Moving Average (EMA). This allows the heuristic search to continuously tune its exploration and exploitation strategies dynamically, finding optimal paths through the causal graph with a very low computational footprint.

The PyTorch RL Agent

The PyTorch RL Investigator is powered by a Deep Reinforcement Learning policy network. Because the environment's observation space is variable (graphs change size, inventory fluctuates), the architecture utilizes a StateEncoder to map the raw observation dictionaries into a fixed 112-dimensional feature tensor. This tensor is fed into a Multi-Layer Perceptron (MLP) equipped with three distinct output heads: an Action Head (to select one of the 7 tools), a Node Head (to target a specific node), and a Value Head (to predict the baseline reward). The model is trained using the REINFORCE algorithm. To ensure stable learning, the Value Head serves as a learned baseline to reduce variance, while an underlying entropy regularization coefficient forces the model to maintain exploration, preventing it from collapsing into trivial behaviors like quarantining every node immediately.

Adaptive Curriculum

Adversarial Co-Evolution & Plot Generation

As the Investigator improves, the training environment shifts with it. The Adversary samples harder scenarios, then backs away from cells the Investigator has already mastered.

Attack Sampler 18-cell score table

Cross-references intervention type, graph region, and density bucket.

Exploration Temperature Softmax

Samples attacks probabilistically so the adversary keeps trying fresh patterns.

Adaptation Rule High F1 penalizes the cell

Expertly solved scenarios become less likely, pushing the curriculum forward.

01 Investigator learns

F1 improves as the policy identifies hidden interventions more precisely.

02 Adversary reweights

Successful cells are penalized and unexplored regions gain sampling pressure.

03 Telemetry buffers

Matplotlib continuously records accuracy, loss, reward, and adversary success.

RL F1 Curve

Tracks the agent's expanding accuracy across episodes.

RL Training Curve

Compares REINFORCE policy loss against reward.

Co-Evolution Curve

Shows the arms race: adversary success dips as Investigator capability rises.

Theme & Architecture

Theme 3.1

World Modeling

Belief state tracking with P(contaminated) per node. Agent maintains probabilistic world model and reasons under uncertainty.

Architecture

Dual-Agent Causal Inference

Investigator and Adversary modules share the same environment loop, reward function, telemetry buffer, and PyTorch policy architecture.