Skip to content

Repository files navigation

F.R.I.D.A.Y - AI with Dynamic Neural Network

FRIDAY is a revolutionary AI assistant with a dynamic neural network that learns and grows continuously. Inspired by TRM (Tiny Recursive Model), FRIDAY combines recursive reasoning with transparent, editable neurons.

🌟 Key Features

🧠 TRM-Inspired Architecture

  • Recursive Reasoning - Thinks multiple times, improving answers iteratively
  • Hierarchical Processing - Abstract (z_H) + Detail (z_L) neurons
  • Adaptive Halting - Knows when answer is good enough
  • 7M parameters equivalent - But dynamic and growing!

🎯 Dynamic Neural Network

  • Not statically trained - Add neurons anytime, no retraining needed
  • Transparent - Every neuron has visible content and meaning
  • Editable - Add, remove, or modify knowledge easily
  • Grows continuously - Learns from every interaction

πŸš€ Advanced Learning

  • Autonomous TRM Learning - Learns independently using TRM logic
  • Self-Evaluation - Rates its own responses (0-5.0)
  • Adaptive Learning - Learns more from good responses
  • Teacher Learning - Can learn from other AI models (Ollama, etc.)
  • Hebbian Learning - Strengthens connections between co-activated neurons
  • Meta-Learning - Learns how to learn, optimizes strategies

πŸ“Š 3D Visualization

  • Real-time 3D viewer - See neurons and synapses in action
  • Activation visualization - Watch neurons light up during queries
  • Interactive - Explore the neural network

πŸš€ Quick Start

Installation

# Clone repository
git clone https://github.com/yourusername/F.R.I.D.A.Y.git
cd F.R.I.D.A.Y

# Install dependencies
pip install -r requirements.txt

# Initialize database
python scripts/init_brain.py

First Test

# Test TRM architecture
python scripts/test_trm_architecture.py

Start Web Interface

# Start FRIDAY server
python friday.py

Open http://localhost:5000 to see the 3D neural network!

πŸ“ Project Structure

F.R.I.D.A.Y/
β”œβ”€β”€ friday.py                    # Main entry point
β”œβ”€β”€ requirements.txt             # Dependencies
β”‚
β”œβ”€β”€ src/                         # Core system
β”‚   β”œβ”€β”€ brain.py                 # Neural database
β”‚   β”œβ”€β”€ query_engine.py          # Query processing
β”‚   β”œβ”€β”€ trm_brain.py            # TRM architecture
β”‚   β”œβ”€β”€ autonomous_trm_learner.py # Autonomous learning with TRM
β”‚   β”œβ”€β”€ text_generator.py       # Response generation
β”‚   β”œβ”€β”€ response_evaluator.py   # Self-evaluation
β”‚   β”œβ”€β”€ hebbian_learning.py     # Hebbian learning
β”‚   β”œβ”€β”€ model_teacher.py        # Learn from other models
β”‚   └── server.py               # Web server
β”‚
β”œβ”€β”€ scripts/                     # Utility scripts
β”‚   β”œβ”€β”€ init_brain.py           # Initialize database
β”‚   β”œβ”€β”€ download_lmsys_dataset.py # Download LMSYS dataset
β”‚   β”œβ”€β”€ train_with_lmsys_dataset.py # Train with LMSYS
β”‚   β”œβ”€β”€ assimilate_knowledge.py # Learn from models
β”‚   β”œβ”€β”€ learn_from_teacher.py   # Teacher learning
β”‚   β”œβ”€β”€ autonomous_trm_training.py # Autonomous TRM learning
β”‚   β”œβ”€β”€ demo_autonomous_learning.py # Quick demo
β”‚   β”œβ”€β”€ test_trm_architecture.py # Test TRM
β”‚   β”œβ”€β”€ test_self_learning.py   # Test self-learning
β”‚   └── README.md               # Scripts documentation
β”‚
β”œβ”€β”€ static/                      # Web interface
β”‚   └── viewer.html             # 3D viewer
β”‚
β”œβ”€β”€ data/                        # Data storage
β”‚   └── friday.db               # Neural database
β”‚
β”œβ”€β”€ docs/                        # Documentation
β”‚   β”œβ”€β”€ TRM_ANALYSIS.md         # TRM architecture analysis
β”‚   β”œβ”€β”€ FRIDAY_TRM_HYBRID.md    # Hybrid architecture
β”‚   β”œβ”€β”€ GENERATION_SYSTEM.md    # Text generation
β”‚   β”œβ”€β”€ SELF_LEARNING_ARCHITECTURE.md
β”‚   β”œβ”€β”€ LEARNING_FROM_MODELS.md
β”‚   └── README.md               # Docs index
β”‚
└── model/                       # AI models
    └── TinyRecursiveModels/    # TRM reference

🧠 How It Works

0. Autonomous TRM Learning ⭐ NEW

FRIDAY lernt selbststΓ€ndig mit TRM-Logik zur richtigen KI zu werden:

# FRIDAY testet sich selbst
result = trm_processor.process(question, question_type)
score = result['score']

# Autonomous learning decision
if score < 3.5:
    # Schlecht β†’ Lernen!
    # 1. Analysiere Fehler
    failure = analyze_failure(question, result)
    
    # 2. Hole Wissen vom Teacher
    teacher_answer = teacher.query_model(question)
    
    # 3. Extrahiere Reasoning
    reasoning = extract_reasoning(question, teacher_answer)
    
    # 4. Erstelle Neuronen
    neurons = create_learning_neurons(answer, reasoning)
    
    # 5. Verbinde mit Wissen
    connect_to_existing(neurons, question)
    
elif score >= 4.5:
    # Exzellent β†’ Gemeistert!
    record_mastery(question, result)

# Meta-Learning: Lerne aus Mustern
if improvement_stalled:
    optimize_parameters_from_patterns()

Kernprinzipien:

  • βœ… TRM Recursive Reasoning - Denkt mehrfach nach
  • βœ… Self-Evaluation - Bewertet sich selbst
  • βœ… Autonomous Learning - Lernt automatisch bei Fehlern
  • βœ… Pattern Recognition - Erkennt erfolgreiche Muster
  • βœ… Meta-Learning - Lernt wie man lernt

1. TRM-Inspired Recursive Reasoning

# FRIDAY thinks recursively (like TRM)
for h_cycle in range(3):  # High-level cycles
    for l_cycle in range(4):  # Low-level cycles
        z_L = update_details(z_L, z_H + input)
    z_H = update_abstract(z_H, z_L)
    
    response = generate(z_H, z_L)
    score = self_evaluate(response)
    
    if score >= 4.5:  # Good enough!
        break

2. Dynamic Neurons (Not Static Weights!)

# TRM: Static weights
weights = torch.Tensor([...])  # Fixed, needs retraining

# FRIDAY: Dynamic neurons
neuron = brain.create_neuron(
    content="Python is a programming language",
    tags=['Programming', 'Python']
)
# No retraining needed!

3. Self-Learning

# FRIDAY evaluates its own responses
evaluation = evaluator.evaluate_response(response, query)
# Score: 4.2/5.0

# Learns adaptively
if score >= 4.0:
    learning_strength = 1.5  # Strong learning
elif score < 2.0:
    learning_strength = 0.5  # Weak learning

🎯 Usage

Chat with FRIDAY

from src.brain import Brain
from src.query_engine import QueryEngine
from src.hebbian_learning import HebbianLearner

brain = Brain("data/friday.db")
hebbian = HebbianLearner(brain)
query_engine = QueryEngine(brain, hebbian)

result = query_engine.query("Was ist Python?")
print(result['response'])
# Output: "Python ist ein System, das programming, syntax verwendet."
print(f"Score: {result['evaluation']['total_score']}/5.0")
# Output: Score: 4.8/5.0

Learn from Teacher Model

# Install Ollama first: https://ollama.ai
ollama pull qwen2.5:3b

# Train FRIDAY
python scripts/learn_from_teacher.py

Add Knowledge Manually

# Add a new neuron
neuron_id = brain.create_neuron(
    neuron_type='hidden',
    x=0.0, y=0.0, z=0.0,
    content="Machine Learning is a subset of AI",
    semantic_tags=['AI', 'Machine Learning', 'Concept']
)

# FRIDAY now knows this!

πŸ“Š Testing

Test TRM Architecture

python scripts/test_trm_architecture.py

Output:

🧠 TRM-Style Processing
   H_cycles: 3
   L_cycles: 4
   z_H neurons: 71
   z_L neurons: 26
   
πŸ”„ H-Cycle 1/3
   Score: 4.8/5.0
   βœ… Halted: Score >= 4.5

Test Self-Learning

python scripts/test_self_learning.py

Autonomous TRM Learning

# Quick demo
python scripts/demo_autonomous_learning.py

# Full training
python scripts/autonomous_trm_training.py

LMSYS-Chat-1M Training ⭐ NEW

# Download dataset
python scripts/download_lmsys_dataset.py

# Train with real conversations
python scripts/train_with_lmsys_dataset.py

Test Realistic Queries

python scripts/test_realistic_queries.py

πŸ”§ Configuration

Database Location

Default: data/friday.db

Change in code:

brain = Brain("path/to/your/database.db")

TRM Parameters

Adjust in src/trm_brain.py:

self.H_cycles = 3  # High-level cycles
self.L_cycles = 4  # Low-level cycles
self.halt_threshold = 4.5  # When to stop

πŸ“ˆ Performance

Comparison with TRM

Feature TRM (Original) FRIDAY + TRM
Parameters 7M (static) ~100 neurons (dynamic)
Training 3 days, 4x H100 Continuous, CPU
Knowledge Fixed (puzzles) Growing (any topic)
Editable No (retrain needed) Yes (add/remove neurons)
Transparent No (black box) Yes (see all neurons)
Reasoning Recursive βœ“ Recursive βœ“

Scores

Typical response scores: 4.5-5.0/5.0

Evaluation criteria:

  • Length (optimal 50-300 chars)
  • Relevance (keywords from query)
  • Grammar (proper structure)
  • Neuron usage (knowledge utilization)
  • Type match (fits question type)
  • Completeness (full answer)

πŸ“š Documentation

Getting Started

Architecture

Learning

Complete Index

🎯 Roadmap

Current (v2.1)

  • βœ… TRM-inspired architecture
  • βœ… Dynamic neurons
  • βœ… Self-evaluation
  • βœ… Recursive reasoning
  • βœ… Teacher learning
  • βœ… Autonomous TRM Learning ⭐ NEW
  • βœ… Meta-Learning ⭐ NEW
  • βœ… Pattern Recognition ⭐ NEW
  • βœ… LMSYS-Chat-1M Training ⭐ NEW
  • βœ… Real Conversation Data ⭐ NEW

Next (v2.2)

  • Multi-Teacher Learning (learn from multiple models)
  • Curriculum Learning (structured learning path)
  • Active Learning (self-select questions)
  • Multi-language support
  • Voice interface

Future (v3.0)

  • Distributed neurons (multiple databases)
  • Collaborative learning (multiple FRIDAYs)
  • Advanced reasoning (symbolic + neural)
  • Autonomous goal-setting

🀝 Contributing

Contributions welcome!

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open Pull Request

πŸ“„ License

MIT License - See LICENSE file

πŸ™ Acknowledgments

  • TRM - Inspired by Tiny Recursive Model architecture
  • Ollama - Local LLM support
  • Three.js - 3D visualization
  • SQLite - Neural database

πŸ“§ Contact

Questions? Open an issue on GitHub!


FRIDAY - The AI that thinks recursively and grows continuously! πŸ§ πŸš€


πŸŽ‰ NEW: LMSYS-Chat-1M Training

FRIDAY kann jetzt mit 1M+ echten Konversationen aus der Chatbot Arena trainiert werden!

Quick Start:

# 1. Download dataset
python scripts/download_lmsys_dataset.py

# 2. Train FRIDAY
python scripts/train_with_lmsys_dataset.py

Ergebnis:

  • βœ… 1000+ echte Konversationen
  • βœ… 2800+ Q&A Paare
  • βœ… 300+ Neuronen aus echten Daten
  • βœ… Score 4.6/5.0 nach Training
  • βœ… Autonomous TRM Learning

Mehr Info: LMSYS Quick Start | Full Docs

About

Neuron Based AI and AI Training

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages