Skip to content

SovranAMR/fitrat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
  β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β•šβ•β•β–ˆβ–ˆβ•”β•β•β•
  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   
  β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   
  β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   
  β•šβ•β•     β•šβ•β•   β•šβ•β•   β•šβ•β•  β•šβ•β•β•šβ•β•  β•šβ•β•   β•šβ•β•   

A brain that fires, learns, dreams, and evolves.

Pure C99. No frameworks. No matrices. No GPU required. Just biology, distilled into 4399 lines of code.


FΔ±trat (Turkish: innate nature) is a biologically-accurate spiking neural network that models the brain at the individual neuron level. Every neuron has DNA. Every synapse has a weight learned through spike-timing. The network sleeps, dreams, and evolves through natural selection. It learns language through pure neural dynamics β€” no backpropagation, no loss functions, no gradient descent.




⚑ What Makes This Different

Most "neural networks" are matrix multipliers wearing a neuroscience costume. FΔ±trat is not.

Feature Traditional NN FΔ±trat
Processing unit Float vector Individual spiking neuron (8 bytes)
Learning rule Backpropagation Spike-Timing Dependent Plasticity (STDP)
Connectivity Dense layers 3D spatial hash β€” neurons connect to neighbors
Position encoding Positional embeddings Morton Z-order curves β€” position IS the ID
Memory Weight matrices Bloom-filtered synapse table (1GB filter β†’ 99% I/O reduction)
Sleep ❌ βœ… REM replay + Tafakkur (contemplation) phases
Evolution ❌ βœ… Neurons reproduce, mutate, and die
Neuromodulation ❌ βœ… Valence Β· Arousal Β· Curiosity signals
Dependencies PyTorch, CUDA, 50GB+ gcc and libc. That's it.



🧬 Architecture


                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚              F I T R A T   B R A I N        β”‚
                    β”‚                                             β”‚
    STIMULUS ──────►│  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  │──────► RESPONSE
    "selam"         β”‚  β”‚  INPUT   β”‚  β”‚  HIDDEN   β”‚  β”‚  OUTPUT    β”‚  β”‚  "aleykum selam"
                    β”‚  β”‚  Z=0     │──│  Z=1-254  │──│  Z=255     β”‚  β”‚
                    β”‚  β”‚  Layer   β”‚  β”‚  Layers   β”‚  β”‚  Layer     β”‚  β”‚
                    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                    β”‚       β”‚            β”‚              β”‚         β”‚
                    β”‚       β–Ό            β–Ό              β–Ό         β”‚
                    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
                    β”‚  β”‚         SPATIAL HASH GRID            β”‚    β”‚
                    β”‚  β”‚    O(1) neighbor lookup via          β”‚    β”‚
                    β”‚  β”‚    Morton Z-order coordinates        β”‚    β”‚
                    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
                    β”‚       β”‚            β”‚              β”‚         β”‚
                    β”‚       β–Ό            β–Ό              β–Ό         β”‚
                    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                    β”‚  β”‚  STDP    β”‚ β”‚  BLOOM   β”‚ β”‚  SYNAPSE   β”‚  β”‚
                    β”‚  β”‚ Learning β”‚ β”‚  FILTER  β”‚ β”‚  TABLE     β”‚  β”‚
                    β”‚  β”‚          β”‚ β”‚  (1 GB)  β”‚ β”‚  (hashmap) β”‚  β”‚
                    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                    β”‚                                             β”‚
                    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                    β”‚  β”‚  SLEEP   β”‚ β”‚ NEURO-   β”‚ β”‚ EVOLUTION  β”‚  β”‚
                    β”‚  β”‚  CYCLE   β”‚ β”‚ MODULAT. β”‚ β”‚ birth/die  β”‚  β”‚
                    β”‚  β”‚ REM+CONT β”‚ β”‚ VΒ·AΒ·C    β”‚ β”‚ reproduce  β”‚  β”‚
                    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Tick Pipeline

Every simulation tick executes 9 stages in strict order:

 β”Œβ”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ FIRE │───►│ PROPAGATE │───►│ STDP │───►│ DECAY │───►│ NEUROMOD β”‚
 β””β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                             β”‚
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”
 β”‚ CHECKPOINT │◄───│  OUTPUT  │◄───│ EVOLUTION│◄───│   SLEEP    β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Each stage is a pure function over the neuron array. No hidden state. No magic.




πŸ”¬ The Neuron

Every neuron is a packed 8-byte struct β€” smaller than a pointer on most systems:

typedef struct {
    uint8_t  flags;        // type (excitatory/inhibitory) + alive + fired + plasticity + layer
    uint8_t  activation;   // current membrane potential [0-255] β†’ [0.0-1.0]
    uint8_t  threshold;    // firing threshold [0-255] β†’ [0.0-2.0]
    uint8_t  ema;          // exponential moving average (homeostasis)
    uint8_t  modulator;    // per-neuron plasticity multiplier
    uint8_t  dna_extra;    // mutation_rate(4) + max_inactivity_class(2) + reserved(2)
    uint16_t last_fire_dt; // ticks since last fire (STDP timing window)
} __attribute__((packed)) Neuron;

_Static_assert(sizeof(Neuron) == 8, "Neuron struct must be exactly 8 bytes");

Every neuron has DNA. The dna_extra field encodes mutation rate and survival traits. When neurons reproduce, offspring inherit traits with mutations. Natural selection operates on the network itself.




🧠 Key Subsystems


πŸŒ€ Morton Code Spatial Encoding

Neuron positions aren't stored β€” they're computed from the ID using Z-order curve encoding. A neuron's ID is its 3D coordinate: X[12 bits] | Y[12 bits] | Z[8 bits]. Decoding costs 3 shifts + 3 masks (~5 ALU cycles). Zero memory overhead.

⚑ Spike-Timing Dependent Plasticity (STDP)

Real Hebbian learning: if neuron A fires before neuron B, strengthen A→B. If A fires after B, weaken it. The timing window is ±40 ticks with exponential decay. Learned weights persist in a hash-map synapse table.

🌸 Bloom-Filtered Synapse Lookup

99% of synapses never change. A 1GB Bloom filter with 4 hash functions screens lookups before hitting the synapse table. False positive rate: ~0.05%. Result: 99% of propagation uses the default weight with zero table I/O.

😴 Sleep & Dreams

The network has a circadian rhythm:

  • REM Phase β€” Random replay of stored spike patterns. Memory consolidation through re-activation.
  • Tafakkur Phase β€” Contemplation. Low-noise introspective processing. The network "thinks" without external input.

🧬 Neuronal Evolution

Every 10,000 ticks, the grim reaper visits:

  • Inactive neurons die (their slot is freed).
  • Active neurons with can_reproduce flag spawn offspring with mutated DNA.
  • The network literally evolves its own topology.

πŸŽ›οΈ Neuromodulation

Global brain-state signals modulate all processing:

  • Valence β€” Positive/negative emotional charge
  • Arousal β€” Alertness level (affects firing thresholds)
  • Curiosity β€” Exploration drive (affects plasticity)

πŸŒ‰ Poisson Bridge

Bidirectional protocol between macrocolumn (float) and spiking (binary) representations. Follows Human Brain Project standards. Enables future multi-scale simulation.

πŸ’Ύ Checkpoint System

Full brain state serialization. Save 50K+ neurons to disk and restore exactly. Training can be interrupted and resumed without loss.




πŸš€ Getting Started

Build

git clone https://github.com/SovranAMR/fitrat.git
cd fitrat
make

Requirements: gcc with C99 support and a POSIX system. No other dependencies.

Train

./fitrat2

Trains through a progressive curriculum β€” from 2-letter echoes to full Turkish conversations. Watch the neural network learn in real-time:

[EPOCH 1] selam β†’ selam  βœ“  (dist=0)
[EPOCH 3] nasilsin β†’ iyiyim  βœ“  (dist=0)
[EPOCH 5] allah var mi β†’ evet  βœ“  (dist=0)

Chat

./fitrat2 --chat

Interactive mode. Type a message, get a neural response. No lookup tables, no pattern matching β€” pure spike dynamics:

YOU: selam
REPLY: aleykum selam

YOU: nasilsin
REPLY: iyiyim

YOU: kimsin
REPLY: ben ali



πŸ“Š By The Numbers

Metric Value
Total source ~4399 lines of C99
Source files 35 (.c + .h)
Neuron memory 8 bytes each
External dependencies 0
Frameworks used 0
GPU required No
Matrices multiplied 0
Backpropagation passes 0
Build time < 2 seconds
Binary size ~100 KB



πŸ—ΊοΈ Project Structure

src/
β”œβ”€β”€ main.c             # Training loop + interactive chat mode
β”œβ”€β”€ neuron.h           # 8-byte packed neuron struct + DNA flags
β”œβ”€β”€ tick.c / tick.h     # 9-stage tick pipeline orchestrator
β”œβ”€β”€ learning.c / .h    # STDP + spike recording + competitive learning
β”œβ”€β”€ synapse_table.c/.h # Hash-map persistent synapse weights
β”œβ”€β”€ io.c / io.h        # Text ↔ spike encoding/decoding + populations
β”œβ”€β”€ grid.c / grid.h    # Spatial hash grid for O(1) neighbor lookup
β”œβ”€β”€ morton.c / .h      # Z-order curve position encoding
β”œβ”€β”€ bloom.h            # 1GB Bloom filter for synapse screening
β”œβ”€β”€ evolution.c / .h   # Neuronal birth, death, and reproduction
β”œβ”€β”€ sleep.c / .h       # REM replay + tafakkur (contemplation)
β”œβ”€β”€ neuromod.c / .h    # Valence Β· Arousal Β· Curiosity modulation
β”œβ”€β”€ poisson.c / .h     # Macrocolumn ↔ spike bridge (HBP standard)
β”œβ”€β”€ homeostasis.c / .h # Activity-dependent threshold regulation
β”œβ”€β”€ checkpoint.c / .h  # Full brain state serialization
β”œβ”€β”€ hash.c / .h        # FNV-1a + Murmur3 hash functions
└── Makefile           # Single `make` builds everything



πŸ’‘ Philosophy

"FΔ±trat" means innate nature in Turkish β€” the original disposition that every being is born with.

This project rejects the dominant paradigm of artificial neural networks. Instead of simulating the math that describes intelligence, it simulates the biology that produces it.

There is no loss function to minimize. There is no gradient to descend. There are only neurons β€” each one unique, each one alive, each one following the same simple rules that real neurons follow:

  1. If your input exceeds your threshold, fire.
  2. If you fire together, wire together.
  3. If you're inactive too long, die.
  4. If you're active enough, reproduce.

From these four rules, intelligence is not programmed β€” it emerges.




πŸ—οΈ Roadmap

  • Vulkan GPU compute for parallel propagation
  • Multi-language curriculum (Turkish β†’ English β†’ Arabic)
  • Persistent long-term memory across sessions
  • Emotional response modulation
  • Telegram bot interface
  • Visual cortex β€” image spike encoding
  • Multi-brain communication protocol



Built with bare metal and biological truth.
No frameworks were harmed in the making of this brain.

Created by SovranAMR

About

🧠 A biologically-accurate spiking neural network. Pure C99. No frameworks. No matrices. Neurons fire, learn, dream, and evolve. β€” Proprietary: Non-commercial use only.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors