# ZRIA-Ultimate-PFAF: Advanced Cognitive Architecture A sophisticated neural architecture that implements dual-path processing for knowledge-based reasoning and execution-based tasks, with persistent model capabilities for large-scale text processing. ## ๐Ÿง  Architecture Overview The ZRIA (ZRIA-Ultimate with Probabilistic Fractal Attentional Fusion) system implements: - **Dual-Path Processing**: Separate knowledge and execution pathways - **Dynamic Attention**: Content-aware fractal attention mechanisms - **Quantum-Inspired Fusion**: Complex number operations for phase relationships - **Hierarchical Memory**: Multi-scale memory systems - **Persistent Models**: Save and reuse without retraining ## ๐Ÿš€ Key Features ### 1. Large Text File Processing - **Automatic Breakdown**: Process multiple books worth of data - **Hierarchical Categorization**: FACT, CONCEPT, PROCEDURE, RELATIONSHIP, etc. - **Entity Extraction**: Named entities and relationships - **Sentiment Analysis**: Built-in sentiment classification - **Confidence Scoring**: Quality assessment of extracted knowledge ### 2. Persistent Model System - **Save Once, Use Forever**: Train once, use repeatedly - **Interactive Prompting**: Real-time interaction without retraining - **Batch Processing**: Handle multiple inputs efficiently - **Auto-Routing**: Intelligent task type detection ### 3. Advanced Cognitive Components - **Fractal Attentional Resonance**: Dynamic, content-aware attention - **Quantum-Inspired Fusion**: Complex-valued representations - **Hierarchical Memory**: Multi-scale temporal patterns - **Neural ODE**: Continuous-time dynamics ## ๐Ÿ“ File Structure ``` โ”œโ”€โ”€ ae.py # Core ZRIA model architecture โ”œโ”€โ”€ text_processor.py # Large text file processing โ”œโ”€โ”€ persistent_model.py # Persistent model system โ”œโ”€โ”€ example_usage.py # Complete usage demonstration โ”œโ”€โ”€ requirements.txt # Dependencies โ””โ”€โ”€ README.md # This file ``` ## ๐Ÿ› ๏ธ Installation 1. **Install Dependencies**: ```bash pip install -r requirements.txt ``` 2. **Download spaCy Model**: ```bash python -m spacy download en_core_web_sm ``` 3. **Download NLTK Data** (automatic on first run): ```python import nltk nltk.download('punkt') nltk.download('stopwords') nltk.download('wordnet') ``` ## ๐ŸŽฏ Quick Start ### 1. Process Large Text Files ```python from text_processor import HierarchicalTextProcessor # Initialize processor processor = HierarchicalTextProcessor() # Process a large text file knowledge = processor.process_large_text_file("your_large_text_file.txt") # Create training data training_data = processor.create_training_data(knowledge) # Save knowledge base processor.save_knowledge_base(knowledge, "knowledge_base.pkl") ``` ### 2. Train and Save Model ```python from persistent_model import create_and_train_model_from_text_file # Train model from text file model = create_and_train_model_from_text_file("your_large_text_file.txt", "my_model") ``` ### 3. Use Persistent Model ```python from persistent_model import load_and_use_model # Load trained model model = load_and_use_model("my_model") # Interactive prompting result = model.prompt("artificial intelligence is amazing", 'auto') print(f"Task: {result['task_type']}") print(f"Prediction: {result['prediction']}") # Start interactive mode model.interactive_mode() ``` ## ๐Ÿ“Š Knowledge Categories The system automatically categorizes text into: - **FACT**: Factual statements, definitions, data - **CONCEPT**: Abstract concepts, theories, ideas - **PROCEDURE**: How-to instructions, methods, steps - **RELATIONSHIP**: Connections, comparisons, associations - **ATTRIBUTE**: Properties, characteristics, qualities - **EVENT**: Historical events, occurrences, timelines - **LOCATION**: Places, geographical information - **PERSON**: People, characters, entities ## ๐Ÿ”„ Complete Pipeline Example ```python # Run the complete demonstration python example_usage.py ``` This will: 1. Create a sample large text file 2. Process it into structured knowledge 3. Train the ZRIA model 4. Demonstrate interactive usage 5. Show batch processing capabilities ## ๐ŸŽฎ Interactive Usage Once you have a trained model, you can use it interactively: ```bash python persistent_model.py load my_model ``` Then you can: - Type `KNOW ` for sentiment analysis - Type `DO ` for action tasks - Type `AUTO ` for automatic routing - Type `help` for commands - Type `quit` to exit ## ๐Ÿ”ง Advanced Usage ### Custom Model Configuration ```python from persistent_model import PersistentZRIAModel model = PersistentZRIAModel("custom_model") # Custom configuration config = { 'dim': 256, # Model dimension 'max_seq_len': 128, # Maximum sequence length 'action_dim': 1, # Action output dimension 'batch_size': 32, # Training batch size 'epochs': 200, # Training epochs 'learning_rate': 1e-4, # Learning rate 'weight_decay': 0.01 # Weight decay } model.train_and_save(training_data, config) ``` ### Batch Processing ```python # Process multiple texts at once texts = [ "artificial intelligence is revolutionary", "count vowels in this example", "machine learning is difficult" ] results = model.batch_prompt(texts, 'auto') for text, result in zip(texts, results): print(f"{text}: {result['prediction']}") ``` ### Knowledge Base Analysis ```python from text_processor import HierarchicalTextProcessor processor = HierarchicalTextProcessor("knowledge_base.pkl") summary = processor.get_knowledge_summary() print(f"Total items: {summary['total_items']}") print(f"Categories: {summary['categories']}") print(f"Entities: {summary['entities']}") ``` ## ๐Ÿงช Model Architecture Details ### Fractal Attentional Resonance - **Dynamic Bias Generation**: Content-aware attention biases - **Fractal Mathematics**: Multiple mathematical transformations - **Multi-Head Attention**: Enhanced with fractal resonance ### Quantum-Inspired Fusion - **Complex Number Operations**: Real and imaginary components - **Entanglement Gates**: Quantum-inspired transformations - **Phase Relationships**: Captures complex interactions ### Hierarchical Memory System - **Multi-Scale Memory**: 32, 16, 8 token scales - **Attention-Based Retrieval**: Context-aware memory access - **GRU Consolidation**: Temporal pattern integration ## ๐Ÿ“ˆ Performance Considerations ### Memory Usage - **Large Text Files**: Process in chunks (default: 10,000 chars) - **Model Size**: ~128MB for default configuration - **GPU Acceleration**: Automatic CUDA detection ### Processing Speed - **Text Processing**: ~1000 sentences/minute - **Model Inference**: ~1000 predictions/second - **Training**: ~150 epochs for convergence ## ๐Ÿ” Troubleshooting ### Common Issues 1. **spaCy Model Not Found**: ```bash python -m spacy download en_core_web_sm ``` 2. **NLTK Data Missing**: ```python import nltk nltk.download('punkt') nltk.download('stopwords') nltk.download('wordnet') ``` 3. **CUDA Out of Memory**: ```python # Use CPU instead device = 'cpu' ``` 4. **Large File Processing**: ```python # Reduce chunk size knowledge = processor.process_large_text_file("file.txt", chunk_size=5000) ``` ## ๐Ÿค Contributing This system is designed for: - **Large-scale text processing** - **Persistent model deployment** - **Interactive AI systems** - **Research in cognitive architectures** ## ๐Ÿ“„ License This project implements advanced neural architectures for research and educational purposes. ## ๐ŸŽฏ Use Cases ### Research Applications - **Cognitive Architecture Research**: Study dual-path processing - **Large-Scale Text Analysis**: Process entire libraries - **Interactive AI Systems**: Real-time prompting - **Knowledge Extraction**: Structured information extraction ### Practical Applications - **Document Processing**: Large document analysis - **Content Classification**: Automatic categorization - **Sentiment Analysis**: Large-scale sentiment processing - **Action Recognition**: Task identification and execution --- **Note**: This system represents a sophisticated cognitive architecture that can handle both declarative knowledge and procedural execution tasks, with advanced mechanisms for integrating different types of processing.