LSTN is an experimental text generation engine that models language not as static probabilities, but as a dynamic and “liquid” neural network. Each trigram (3-character sequence) acts as an individual neuron within a continuous temporal dynamic system.
Instead of calculating a classic probability distribution, the model simulates a network where energy (or “voltage”) flows from neuron to neuron. When a neuron “fires”, it emits its final character and propagates its energy to subsequent neurons based on learned synaptic weights.
This architecture allows for the emergence of pseudo-organic text generation, introducing concepts of refractory period, energy decay, and dynamic resuscitation.
The training text is split into sliding windows of 4 characters to connect contiguous trigrams. For a context window $C = [c_1, c_2, c_3, c_4]$, a synaptic link is created between the source neuron $N_{src} = (c_1, c_2, c_3)$ and the target neuron $N_{tgt} = (c_2, c_3, c_4)$.
The synaptic weight $W_{src \to tgt}$ is incremented by the learning rate $\eta$ (LEARNING_RATE).
After compiling the corpus, each neuron’s weights are normalized locally:
\(W_{src \to tgt} = W_{src \to tgt} \times \frac{2.0}{\max(W_{src})}\)
At each time step of generation, the network evolves:
Organic Selection: Neurons whose voltage exceeds a threshold (0.1) and which are not in a refractory period are considered candidates. The energy of a candidate neuron is cubed to emphasize activation contrasts: \(E_i = V_i^3\) The winner is then randomly drawn proportionally to this energy $E_i$.
FIRE_THRESHOLD ($\ge 1.0$), it fires:
REFRACTORY_TIME = 2), preventing immediate reactivation.Decay: At the end of the cycle, all active neurons have their potential naturally decrease:
\(V_i(t+1) = V_i(t) \times \gamma\)
Where $\gamma$ corresponds to the DECAY_RATE (0.92).
This type of model is highly relevant for experiments in emergence (complexity arising from very simple local rules) or uninterrupted organic text flows.
Windows:
winget install --id Rustlang.Rustup -e
rustup default stable
Linux / macOS:
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
From the root of the project, you can launch or compile the model as follows:
Development Mode:
cargo run --bin lstn
Optimized Build (Release):
cargo build --release --bin lstn
# The executable will be available in target/release/
src/main.rs)The internal physics are driven by several fundamental constants:
DECAY_RATE (0.92): Preservation of temporal inertia. A rate close to 1 preserves a broader activation spectrum.FIRE_THRESHOLD (1.0): Minimum action potential threshold triggering token emission.REFRACTORY_TIME (2): Duration of temporary invalidation of the recently fired neuron (fights local stuttering).LEARNING_RATE (1.0): Absolute increment during synaptic reinforcement.