Dense Chrono-Spike LM training and prompt retrieval
This document summarizes the current implementation of SpikingEvoTextLM, ChronoSpikeAttention, MetaSTDP, AEG, and the prompt-time retrieval path based on the verified code.
1. Core implementation contract
The dense text path is no longer a single simplified block. It is a system with the following integrated contract:
- token-to-spike conversion via
TASEncoderDecoder - causal temporal attention via
ChronoSpikeAttention - configurable output neuron layers (
EvoLIF,Izhikevich,LIF) - optional
AEGandMetaSTDPadaptation - prompt-time retrieval via
SNNRAGHybridand dense fallback
The safety defaults in the current code are:
EVOSPIKENET_FORCE_HARD_SPIKE_PARITY=trueEVOSPIKENET_TRAIN_CONTINUOUS_RELAXATION=false- any continuous-relaxation mode requires explicit opt-in
2. Neuron structure and types
LIF
LIFNeuronLayeruses integer membrane potential, threshold, and leak states- inference is strictly hard-spike
- training uses
evo_lif_spike_with_ste()to preserve a stable identity gradient
EvoLIF
- the
EvoLIFpath inSpikingEvoTextLMusesLIFNeuronLayerand caps the scale withresolve_evo_lif_scale_factor() EVOSPIKENET_EVO_LIF_SCALE_FACTORis constrained to a maximum of100.0
Izhikevich
IzhikevichNeuronLayerkeeps a float state for \(v\) and \(u\)- it fires when the threshold is crossed and resets after spike
izhikevich_spike_with_ste()preserves hard inference while allowing task gradients to flow
Training-side stability helper
spike_activation_with_residual_gradient()adds a bounded residual to prevent zero-spike collapse in short temporal windows
3. Current ChronoSpikeAttention model
The causal mask is
with tau learnable when learnable_tau=True and optionally per-head when per_head_tau=True.
The layer accepts neuron_type values LIF, EvoLIF, and Izhikevich, and converts its attention output into a spike train via output_lif before the next layer consumes it.
4. Data flow in SpikingEvoTextLM
The current forward path is:
- token encoding to embeddings and spike trains
- optional
AEGimportance gating - transformer block processing
- time aggregation of spike activity
output_potential_sumaccumulation- readout merge of mean activity + deep output + direct embedding shortcut
- final logits from the direct/deep blend
The final readout mixes the two streams as
with \(\alpha = \text{sigmoid}(\text{readout\_direct\_logit\_mix})\).
5. Training convergence and reward design
The convergence profile is resolved in examples/train_spiking_evospikenet_lm.py by _resolve_convergence_profile().
- default:
stable_baseline stable_convergedisablesAEGandMetaSTDPto favor stable trainingaggressive_convergencetunes reward clipping and learning-rate style behavior- explicit environment overrides remain the highest-priority control
The reward path supports raw, clipped_raw, and ema_delta modes, with the EMA form being the default stable option:
This dampens noisy loss spikes and keeps the adaptation signal more stable than a plain negative loss.
6. Corpus flow and chunked training
The training corpus pipeline is:
get_training_corpus(args)_apply_rag_japanese_preprocess()for Japanese normalization/chunking_iter_preprocessed_hf_japanese_wikipedia_chunks()_tokenize_corpus_in_chunks()_build_next_token_dataset()
The design intentionally avoids loading the entire corpus into memory at once. It instead creates bounded text chunks, tokenizes those chunks, and then builds a next-token dataset in a shift-by-one structure.
7. Prompt-time retrieval and fallback logic
The retrieval path in evospikenet/snn_rag.py uses SNNRAGHybrid to encode queries with both spike and dense features.
KnowledgeGraphIntegratorbuilds a lightweight on-device document graphChronoSpikeAttentioncontributes temporal correlation scoring- low-confidence spike retrieval can trigger dense fallback using vector similarity
spike_fallback_thresholdgoverns the fallback gate
This is a hybrid retrieval strategy: spike-based retrieval remains the primary path, while dense retrieval is used as a fallback when the spike signal is too weak or the query is unknown.
8. Summary
The current implementation is best understood as a production-stabilized spiking language model rather than a purely biologically literal architecture. It keeps hard-spike inference as the default path, allows controlled approximations only when explicitly requested, blends direct and deep readout signals for stable learning, and combines prompt-time retrieval with dense fallback for low-confidence queries.