KARNA
v2 Architecture
A neuroscience-inspired, contrarian trading engine. KARNA (Knowledge-Acquiring Reinforcement Network with Attention) utilizes Cross-Modal Knowledge Distillation to achieve high-frequency performance on non-stationary market data.
01. Knowledge Distillation
The Oracle & Zero Framework
High-quality sentiment and institutional flow data are too latent and expensive for sub-100ms execution. We solved this via Teacher-Student Distillation.
- The Teacher (Oracle)Trained on multimodal inputs: Price, Volume, Order Flow, and Macro Sentiment.
- The Student (Zero)Learns to mimic Oracle's policy using ONLY OHLCV data. Sentiment is effectively "baked" into the weights.
Loss_Total = L_PPO + λ * L_KL(Policy_Zero || Policy_Oracle)Input: [Price, Vol] → (Policy_Zero) → [Buy, Sell, Hold]Neuro-Reinforcement Learning
We implemented a Dopamine Reward Prediction Error (RPE) system. Instead of flat P&L rewards, the model is rewarded based on its ability to "surprise" the expectation baseline.
This prevents the model from becoming complacent during easy markets and forces it to discover local alpha during sideways regimes.
System Intelligence Layer
Shannon Entropy Gating
Information theory filter that detects 'Price Chaos'. Automatically halts execution during high-entropy non-predictable regimes to preserve capital.
Mixture of Experts (MoE)
Three specialized neural sub-networks: Trending, Mean-Reversion, and Risk-Off. A gating network dynamically routes data based on VIX correlation.
Temporal Attention
60-day variable lookback windows with exponential positional encoding. The model learns which historical bars are contextually relevant for today.
The Edge of Engineering
KARNA isn't just code; it's a research paradigm in autonomous systems. Interested in the math behind the Oracle?