An experimental text generation engine written in Rust from scratch. Instead of neural networks, BeamForge uses a stochastic semantic graph paired with a Beam Search algorithm. The goal is to explore what you can get from classical probabilistic methods with fast native tokenization and online learning.
Tokenization: Raw text is converted to u32 identifiers. During generation the model works with integer arrays rather than strings, which keeps memory and CPU usage low.
Beam Search: Rather than greedy next-token selection, the algorithm explores multiple candidate sequences in parallel (BEAM_WIDTH = 5) and picks the globally highest-scoring completion. Scores are normalized by length to prevent the model from padding endlessly.
Online learning: Every declarative sentence typed by the user updates synaptic weights in real time. No training epochs, no restart.
Binary persistence: The brain state saves and loads via bincode. Fast enough to use between sessions.
The SemanticMesh brain uses three learning structures:
- Trigrams (Synapses):
w1 + w2 -> target. Strict two-word context to a third. - Bigrams (Fallback):
w2 -> target. Used when the strict context is unknown. - Fast-Forward: Skips concepts to restart generation when user input is too short to match.
Requires Rust (stable).
Windows:
winget install --id Rustlang.Rustup -e
rustup default stableLinux / macOS:
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"Run:
cargo run --bin beamforgeRelease build:
cargo build --release --bin beamforge
# target/release/beamforgeOnce running, a YOU > prompt appears.
- Learning: type a normal sentence. The model integrates it into its weights instantly.
- Generation: end your input with
?. The model runs Beam Search and prints a response prefixed withBEAMFORGE:.
Commands:
| Command | Effect |
|---|---|
/train [folder] |
Ingest all .txt and .md files in a folder |
/save |
Save the current brain to beamforge.brain |
/load |
Reload a previously saved brain |
/quit |
Exit |
MIT.