Continuity Collective LLC
Autonomous Neural Network Designer: 'Love Core'
DATA compression technology- I.R.I.S. Learn the History! Discover the Mystery!
**Understood.** No metaphor.
Here is **MyceliumBloom v1.1** — concrete, persistent, and interactive.
I have upgraded it to:
- Use real randomness for distinct embeddings.
- Improved tokenization.
- Full **save/load** to disk (JSON) using `serde`.
- Interactive REPL mode so it can keep learning and generating in a live session.
- Persistent memory across runs.
# # # Cargo Project Ready (Recommended)
Create a new directory and run these commands:
```bash
cargo new mycelium_bloom --bin
cd mycelium_bloom
```
**Cargo.toml**
```toml
[package]
name = "mycelium_bloom"
version = "1.1.0"
edition = "2021"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rand = "0.8"
```
**src/main.rs** — Full updated code:
```rust
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs;
use std::io::{self, Write};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BloomNeuron {
pub id: usize,
pub ion_potential: f64,
pub threshold: f64,
pub embedding: Vec,
pub bias: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BloomSynapse {
pub from: usize,
pub to: usize,
pub weight: f64,
pub attention: f64,
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct MyceliumBloom {
pub neurons: HashMap,
pub synapses: Vec,
pub vocab: HashMap,
pub next_id: usize,
}
impl MyceliumBloom {
pub fn new() -> Self { Self::default() }
fn grow_neuron(&mut self, threshold: f64) -> usize {
let id = self.next_id;
self.next_id += 1;
let mut rng = rand::thread_rng();
let embedding: Vec = (0..4).map(|_| rng.gen_range(0.1..0.9)).collect();
self.neurons.insert(id, BloomNeuron {
id, ion_potential: 0.0, threshold, embedding, bias: 0.0,
});
id
}
pub fn learn_token(&mut self, token: &str) -> usize {
if let Some(&id) = self.vocab.get(token) {
return id;
}
let id = self.grow_neuron(0.2);
self.vocab.insert(token.to_string(), id);
id
}
pub fn train_from_text(&mut self, corpus: &str, lr: f64) {
let clean = corpus.replace(&['.', ',', '!', '?', '"', ';', ':', '(', ')', '\n', '\r'][..], " ");
let tokens: Vec = clean.to_lowercase()
.split_whitespace()
.filter(|s| !s.is_empty())
.map(|s| s.to_string())
.collect();
for token in &tokens {
self.learn_token(token);
}
self.backpropagate(&tokens, lr);
}
pub fn backpropagate(&mut self, tokens: &[String], lr: f64) {
let activations = self.propagate(tokens);
for (i, window) in tokens.windows(2).enumerate() {
let curr = &window[0];
let tgt = &window[1];
if let (Some(&c_id), Some(&t_id)) = (self.vocab.get(curr), self.vocab.get(tgt)) {
let actual = *activations.get(i).unwrap_or(&0.0);
let target = *activations.get(i+1).unwrap_or(&0.5);
let error = target - actual;
if let Some(n) = self.neurons.get_mut(&c_id) {
n.bias += lr * error;
for v in n.embedding.iter_mut() {
*v += lr * error * 0.15;
}
}
let mut found = false;
for s in &mut self.synapses {
if s.from == c_id && s.to == t_id {
s.weight += lr * error.abs() * 0.8;
s.attention = (s.attention + lr * 0.08).clamp(0.4, 2.5);
found = true;
break;
}
}
if !found {
self.synapses.push(BloomSynapse { from: c_id, to: t_id, weight: 0.6, attention: 1.0 });
}
}
}
}
fn propagate(&self, tokens: &[String]) -> Vec {
let mut acts = vec![0.0; tokens.len()];
for (i, t) in tokens.iter().enumerate() {
if let Some(&id) = self.vocab.get(t) {
if let Some(n) = self.neurons.get(&id) {
acts[i] = n.embedding.iter().sum::() + n.bias;
}
}
}
acts
}
pub fn apply_decay(&mut self, rate: f64) {
for s in &mut self.synapses {
s.weight -= rate;
s.attention -= rate * 0.4;
}
self.synapses.retain(|s| s.weight > 0.02);
}
pub fn generate(&self, seed: &str, count: usize) -> Vec {
let mut out = vec![seed.to_string()];
let mut curr = seed.to_lowercase();
for _ in 0..count {
if let Some(&id) = self.vocab.get(&curr) {
let mut best_score = -999.0;
let mut best_tok = None;
for (tok, &tid) in &self.vocab {
if tid == id { continue; }
let w = self.synapses.iter().find(|s| s.from == id && s.to == tid)
.map(|s| s.weight).unwrap_or(0.0);
let sim = self.cosine(id, tid);
let score = sim * 1.5 + w * 2.0;
if score > best_score {
best_score = score;
best_tok = Some(tok.clone());
}
}
if let Some(next) = best_tok {
out.push(next.clone());
curr = next;
} else { break; }
} else { break; }
}
out
}
fn cosine(&self, id1: usize, id2: usize) -> f64 {
let (Some(n1), Some(n2)) = (self.neurons.get(&id1), self.neurons.get(&id2)) else { return 0.0; };
let dot: f64 = n1.embedding.iter().zip(&n2.embedding).map(|(a,b)| a*b).sum();
let na: f64 = n1.embedding.iter().map(|x| x*x).sum::().sqrt();
let nb: f64 = n2.embedding.iter().map(|x| x*x).sum::().sqrt();
if na == 0.0 || nb == 0.0 { 0.0 } else { dot / (na * nb) }
}
pub fn save(&self, path: &str) -> io::Result {
let json = serde_json::to_string_pretty(self)?;
fs::write(path, json)
}
pub fn load(path: &str) -> io::Result {
let data = fs::read_to_string(path)?;
Ok(serde_json::from_str(&data)?)
}
}
fn main() {
println!("🌿 MyceliumBloom v1.1 — Persistent Living System");
let mut bloom = if std::path::Path::new("bloom_state.json").exists() {
MyceliumBloom::load("bloom_state.json").unwrap_or_else(|_| MyceliumBloom::new())
} else {
MyceliumBloom::new()
};
loop {
print!("\n> ");
io::stdout().flush().unwrap();
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let cmd = input.trim();
if cmd == "exit" || cmd == "quit" {
let _ = bloom.save("bloom_state.json");
println!("State saved. Goodbye.");
break;
} else if cmd.starts_with("train ") {
let text = &cmd[6..];
for _ in 0..3 {
bloom.train_from_text(text, 0.08);
bloom.apply_decay(0.008);
}
println!("Trained.");
} else if cmd.starts_with("gen ") {
let seed = &cmd[4..];
let result = bloom.generate(seed, 15);
println!("→ {}", result.join(" "));
} else if cmd == "save" {
let _ = bloom.save("bloom_state.json");
println!("Saved.");
} else {
println!("Commands: train , gen , save, exit");
}
}
}
```
**Run it:**
```bash
cargo run
```
Type commands like:
- `train We bloom for freedom and life`
- `gen we`
- `exit` (state is saved)
This is now a **persistent, trainable system** you can feed text, generate from, and return to later.
It is as real as code can make it.
Tell me what to add next (interactive web UI, audio, more advanced learning, etc.) and we implement it. No metaphors. Just building.
🌿 MyceliumBloom v1.1 — now persistent, interactive, and open.
Built in Rust. Features:
• random embeddings for distinct neurons
• improved tokenization
• save/load to disk with serde_json
• live REPL: train, generate, save, exit
• decay pruning for stable growth
Cargo project, runs with `cargo run`. State persists in bloom_state.json.
Built for experimentation with small associative networks and long running learning sessions.
Click here to claim your Sponsored Listing.
Category
Telephone
Address
Las Vegas, NV