|
| 1 | +# AIKA: Artificial Intelligence for Knowledge Acquisition |
| 2 | + |
| 3 | +## Meta Information |
| 4 | +This document provides a comprehensive natural language description of the AIKA project, sufficient for a Large Language Model (LLM) to generate all required source files. These include: |
| 5 | + |
| 6 | +- C++ header and implementation files. |
| 7 | +- Pybind11 binding code for Python integration. |
| 8 | +- Unit tests to verify functionality. |
| 9 | +- CMakeLists.txt for building the project. |
| 10 | +- An example neural network (NN) model in Python, utilizing the library modules. |
| 11 | + |
| 12 | +No user interface (UI) is required. Each generated file should include detailed comments describing the file’s purpose and each method’s functionality. The description is complete when an LLM can build the project, run all unit tests, and execute the example NN model in a Python environment. |
| 13 | + |
| 14 | +## Overview |
| 15 | + |
| 16 | +### Idea and Core Concept |
| 17 | +AIKA is an innovative neural network framework that departs from traditional architectures reliant on rigid matrix and vector operations. It features: |
| 18 | + |
| 19 | +- **Flexible, Sparse, Non-Layered Representation**: Derived from a type hierarchy, enabling arbitrary neural graphs where neurons connect only to relevant inputs, rather than fully connected layers. |
| 20 | +- **Network Separation**: |
| 21 | + - **Neural Network**: Static knowledge represented by neurons and synapses. |
| 22 | + - **Activation Network**: Dynamic inference represented by activations and links, specific to input data (e.g., tokenized text). |
| 23 | +- **Sparse Activation**: During processing, only neurons and synapses exceeding their activation threshold are activated. This sparsity—stemming from selective connections and relevance-based activation—enables efficient handling of large networks (millions of neurons) by focusing on relevant subsections. |
| 24 | + |
| 25 | +### Linker and Binding Signals |
| 26 | +- **Linker**: Transfers the neural network’s structure to the activation network. When a neuron’s activation exceeds its threshold, the Linker instantiates an activation node based on the neuron and creates input links from contributing synapses. |
| 27 | +- **Binding Signals (BS)**: Relational references that propagate along links, determining valid connections in the activation graph. Inspired by: |
| 28 | + - Individual constants in predicate logic. |
| 29 | + - Temporally synchronized spiking in biological neural networks (akin to synchronized firing in the human brain). |
| 30 | +- **BS Rules**: Defined in the Python model specification, these rules dictate which BS-types propagate through specific neuron and synapse types. |
| 31 | + |
| 32 | +### Event-Driven Processing |
| 33 | +AIKA processes network changes asynchronously via time-ordered events in a queue, ensuring correct temporal ordering of activations and binding signal propagations. Event types include: |
| 34 | +- **Neuron Firing**: Occurs when a neuron’s activation exceeds its threshold, triggering the Linker and BS propagation. |
| 35 | +- **Field Value Updates**: Updates in the mathematical fields graph, queued only for recurrent-risk fields (specified in the Python model). |
| 36 | + |
| 37 | +### Type Hierarchy of Network Elements |
| 38 | +Unlike traditional neural networks using vector/matrix operations, AIKA employs a hierarchy of neuron types (e.g., excitatory, inhibitory) with mathematical models organized as graphs of functions. This structure supports flexible, dynamic responses in the activation network. |
| 39 | + |
| 40 | +## Project Structure |
| 41 | + |
| 42 | +### Fields Module |
| 43 | +The mathematical core of AIKA, featuring: |
| 44 | +- **Graph-Based Representation**: Declarative graphs for mathematical models. |
| 45 | +- **Type Hierarchy**: Defines network elements (neurons, synapses, activations, links). |
| 46 | +- **Event-Driven Updates**: Asynchronous state changes via an event queue. |
| 47 | +- **Dual Graphs**: |
| 48 | + - **Field Graph**: Represents mathematical models, with nodes as functions and edges as inputs. Each field node references an object node. |
| 49 | + - **Object Graph**: Used by the Neural Network Module to model neurons, synapses, activations, and links. |
| 50 | +- **Type Definitions**: Field nodes use `FieldDefinition` types; object nodes use `Type`. |
| 51 | + |
| 52 | +### Neural Network Module |
| 53 | +Focuses on the neural and activation networks, with: |
| 54 | +- **Dual Graph Structure**: Separates static knowledge (neurons/synapses) from dynamic inference (activations/links). |
| 55 | +- **Dynamic Activation**: Multiple activations per neuron, tied to specific input data occurrences. |
| 56 | +- **Flexible Topology**: Adapts dynamically to input data, abandoning fixed layers. |
| 57 | +- **Linker Component**: Translates structure and propagates binding signals. |
| 58 | + |
| 59 | +### Example NN Model in Python |
| 60 | +A Python-based example specification demonstrating the use of the Fields and Neural Network modules via pybind11 bindings. |
| 61 | + |
| 62 | +## Technical Implementation |
| 63 | + |
| 64 | +### General Coding Guidelines |
| 65 | +- **Setup**: C++ library using CMake as the build system and pybind11 for Python integration (similar to PyTorch). |
| 66 | +- **Directory Structure**: |
| 67 | + ``` |
| 68 | + - include |
| 69 | + - fields |
| 70 | + - network |
| 71 | + - src |
| 72 | + - fields |
| 73 | + - network |
| 74 | + ``` |
| 75 | + |
| 76 | +### Fields Module Classes |
| 77 | +1. **Type Hierarchy and Object Graph**: |
| 78 | + - `type_registry_python.cpp`: Python-specific type registry bindings. |
| 79 | + - `type_registry.cpp`: Manages type registrations. |
| 80 | + - `type.cpp`: Defines base types for objects. |
| 81 | + - `obj.cpp`: Represents object instances. |
| 82 | + - `relation.cpp`: Handles relationships between objects. |
| 83 | + |
| 84 | +2. **Field Graph and Definitions**: |
| 85 | + - `field_definition.cpp`: Defines field types. |
| 86 | + - `field.cpp`: Implements field instances. |
| 87 | + - `field_link_definition.cpp`: Defines field input edges. |
| 88 | + - `field_update.cpp`: Manages field value updates. |
| 89 | + - `abstract_function_definition.cpp`: Base for mathematical function definitions. |
| 90 | + |
| 91 | +3. **Flattened Types**: |
| 92 | + - `flattened_type.cpp`: Preprocessed flat type structures for runtime efficiency. |
| 93 | + - `flattened_type_relation.cpp`: Relations in flattened types. |
| 94 | + |
| 95 | +4. **Event Processing**: |
| 96 | + - `queue.cpp`: Event queue implementation. |
| 97 | + - `queue_key.cpp`: Event ordering keys. |
| 98 | + - `step.cpp`: Event processing steps. |
| 99 | + - `queue_interceptor.cpp`: Event interception logic. |
| 100 | + |
| 101 | +5. **Mathematical Functions**: |
| 102 | + - `input_field.cpp`: Input field handling. |
| 103 | + - `addition.cpp`, `subtraction.cpp`, `multiplication.cpp`: Basic arithmetic operations. |
| 104 | + - `sum_field.cpp`: Summation function. |
| 105 | + - `identity_field.cpp`: Identity function. |
| 106 | + - `soft_max_fields.cpp`: Softmax function. |
| 107 | + - `scale_function.cpp`: Scaling operations. |
| 108 | + - `threshold_operator.cpp`: Thresholding logic. |
| 109 | + - `invert_function.cpp`: Inversion function. |
| 110 | + |
| 111 | +6. **Utilities**: |
| 112 | + - `direction.cpp`: Direction-related utilities. |
| 113 | + - `utils.cpp`: General helper functions. |
| 114 | + |
| 115 | +#### High-Level Description for each class |
| 116 | + |
| 117 | +##### Type class |
| 118 | +The Type class, housed within the Fields Module of the AIKA framework, serves as a cornerstone of the project's type hierarchy, defining the structural blueprint for network elements such as neurons and synapses. This class is pivotal in enabling AIKA's flexible, non-layered architecture by supporting multiple inheritance, which allows types to inherit properties and behaviors from multiple parent types. This capability fosters a rich and adaptable system for modeling complex relationships within the neural network. |
| 119 | + |
| 120 | +Each Type instance encapsulates field definitions, which are mathematical properties or functions tied to the field graph—a declarative representation of the network's computational models. These definitions bridge the static structure of the network to its mathematical underpinnings. Additionally, the class manages relations, which likely play a role in facilitating binding signals that propagate through the activation network, supporting relational references during dynamic inference. |
| 121 | + |
| 122 | +To enhance runtime efficiency—a key goal of AIKA for managing large-scale, sparse networks—the Type class includes mechanisms to generate flattened type structures. These precomputed representations streamline access to hierarchical information, aligning with the framework's emphasis on selective activation and relevance-based processing. By defining the types of objects instantiated in the object graph, which represents the static knowledge of the neural network (e.g., neurons and synapses), the Type class underpins the Neural Network Module, ensuring a seamless integration of static and dynamic components. |
| 123 | + |
| 124 | +In essence, the Type class embodies AIKA's innovative approach by providing a flexible, hierarchical foundation for network elements, optimizing performance through flattened structures, and linking mathematical models to the network's static and dynamic behaviors. |
| 125 | + |
| 126 | +### Neural Network Module |
| 127 | +*(Note: Specific classes were not provided in the original description. The following is inferred based on context.)* |
| 128 | +Likely includes classes for: |
| 129 | +- Neurons and synapses (static graph). |
| 130 | +- Activations and links (dynamic graph). |
| 131 | +- Linker implementation. |
| 132 | +- Binding signal management. |
| 133 | + |
| 134 | +### Additional Notes |
| 135 | +- **Inter-Module Dependency**: The Neural Network Module builds on the Fields Module. |
| 136 | +- **Unit Tests**: Should cover all classes and functionalities for correctness. |
| 137 | +- **Python Integration**: The example model uses pybind11 to interface with the C++ library, demonstrating practical application. |
| 138 | + |
0 commit comments