Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: NOVA architecture for predictive coding #4

Merged
merged 6 commits into from
Dec 13, 2024
Merged

Conversation

leonvanbokhorst
Copy link
Collaborator

@leonvanbokhorst leonvanbokhorst commented Dec 13, 2024

Adds comprehensive module-level documentation explaining:

  • Three-layer NOVA architecture implementation
  • Integration with Friston's Free Energy Principle
  • Theoretical foundations from predictive coding research
  • Key academic references and timescale-based processing
  • Detailed docstrings for core classes and methods

References work by Friston (2010), Clark (2013), and Hohwy (2013)

Summary by Sourcery

Implement a three-layer NOVA architecture for predictive coding in social human-AI interaction, integrating theoretical frameworks from Friston and Clark. Add comprehensive documentation explaining the architecture and its applications in health literacy use cases.

New Features:

  • Implement a three-layer NOVA architecture for predictive coding in social human-AI interaction, integrating Friston's Free Energy Principle and Clark's Prediction Machine perspective.

Documentation:

  • Add comprehensive module-level documentation explaining the NOVA architecture, its integration with predictive coding theories, and key academic references.
  • Introduce a new documentation file detailing the integration of NOVA architecture with health literacy use cases, including technical foundations and practical applications.

Add detailed module-level docstring explaining:
- Historical context from Helmholtz to modern predictive coding
- Core theoretical principles being demonstrated
- Experimental setup using sine wave with noise
- Key references to foundational papers
- Basic usage example

This documentation helps users understand both the theoretical
background and practical implementation of the predictive coding network.
Implements a three-layer predictive coding architecture (NOVA) for social human-AI interaction:
- ReactiveLayer for fast emotional responses (50-300ms)
- ResponsiveLayer for context-aware responses (300-1000ms)
- ReflectiveLayer for pattern learning and adaptation (>1000ms)

Features:
- Predictive coding with dynamic learning rates
- Context window for pattern recognition
- Adaptive response selection based on prediction errors
- Long-term pattern analysis and behavior adaptation
- Interactive demo with simulated social signals
Adds comprehensive module-level documentation explaining:
- Three-layer NOVA architecture implementation
- Integration with Friston's Free Energy Principle
- Theoretical foundations from predictive coding research
- Key academic references and timescale-based processing
- Detailed docstrings for core classes and methods

References work by Friston (2010), Clark (2013), and Hohwy (2013)
Copy link
Contributor

sourcery-ai bot commented Dec 13, 2024

Reviewer's Guide by Sourcery

This PR implements a comprehensive predictive coding architecture for social human-AI interaction based on the NOVA framework. The implementation consists of three main components: a three-layer reactive-responsive-reflective architecture, a predictive coding network, and detailed module documentation. The changes focus on establishing the theoretical foundations and practical implementation of predictive coding principles in human-AI interaction.

Class diagram for NOVA Architecture Implementation

classDiagram
    class SocialSignal {
        - type: str
        - value: float
        - confidence: float
        - timestamp: float
    }
    class ReactiveLayer {
        - emotional_state: float
        - attention_level: float
        - prediction_error: float
        + process_signal(signal: SocialSignal) Dict
    }
    class ResponsiveLayer {
        - context_window: List[SocialSignal]
        - pattern_predictions: Dict
        + process_context(signal: SocialSignal, reactive_output: Dict) Dict
        + _select_response(prediction: float, error: float) str
    }
    class ReflectiveLayer {
        - interaction_patterns: Dict
        - learning_history: List
        + analyze_patterns(signal: SocialSignal, reactive_output: Dict, responsive_output: Dict) Dict
        + _adapt_behavior(error_trend: float, volatility: float, stability: str) str
    }
    class VirtualHuman {
        - reactive: ReactiveLayer
        - responsive: ResponsiveLayer
        - reflective: ReflectiveLayer
        + process_interaction(signal_type: str, value: float) Dict
    }
    SocialSignal --> ReactiveLayer
    ReactiveLayer --> ResponsiveLayer
    ResponsiveLayer --> ReflectiveLayer
    ReflectiveLayer --> VirtualHuman
Loading

Class diagram for Predictive Coding Network

classDiagram
    class PredictiveCodingNode {
        - prediction: float
        - learning_rate: float
        - prediction_history: List
        - error_history: List
        + update(actual_value: float) Tuple
    }
    class PredictiveCodingNetwork {
        - nodes: List[PredictiveCodingNode]
        + process_input(input_value: float) List
        + plot_predictions()
    }
    PredictiveCodingNode --> PredictiveCodingNetwork
Loading

File-Level Changes

Change Details Files
Implemented a three-layer NOVA architecture for predictive coding
  • Created ReactiveLayer class for fast emotional responses (50-300ms)
  • Implemented ResponsiveLayer for context-aware social responses (300-1000ms)
  • Added ReflectiveLayer for long-term adaptation and learning (>1000ms)
  • Integrated layers in VirtualHuman class with hierarchical processing
  • Added demo functionality to showcase the architecture
predictive_coding/02_predcod_nova.py
Created base predictive coding network implementation
  • Implemented PredictiveCodingNode class for prediction generation and error computation
  • Created PredictiveCodingNetwork class for hierarchical processing
  • Added visualization capabilities for predictions and errors
  • Implemented demo with sine wave pattern recognition
predictive_coding/01_predcod.py
Added comprehensive documentation and theoretical foundations
  • Documented three-layer NOVA architecture implementation details
  • Added integration explanations with Friston's Free Energy Principle
  • Included theoretical foundations from predictive coding research
  • Added use cases and implementation examples
  • Included key academic references
docs/01_nova_predcod_use_cases.md
Updated project dependencies and structure
  • Simplified requirements.txt to include only numpy
  • Removed development-specific requirements
  • Cleaned up project structure by removing empty directories
requirements.txt
requirements-dev.txt
src/__init__.py
tests/__init__.py
tests/test_basic.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@leonvanbokhorst leonvanbokhorst self-assigned this Dec 13, 2024
@leonvanbokhorst leonvanbokhorst added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 13, 2024
@leonvanbokhorst leonvanbokhorst added this to the phase 01 milestone Dec 13, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leonvanbokhorst - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please restore the development dependencies (pytest, black, etc.) in requirements.txt while keeping your new implementation. These are needed for testing and code quality.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

predictive_coding/02_predcod_nova.py Show resolved Hide resolved
predictive_coding/01_predcod.py Outdated Show resolved Hide resolved
@leonvanbokhorst leonvanbokhorst changed the title Pred-coding @sourcery-ai Dec 13, 2024
@sourcery-ai sourcery-ai bot changed the title @sourcery-ai Docs: Add module-level documentation for NOVA architecture Dec 13, 2024
@leonvanbokhorst leonvanbokhorst changed the title Docs: Add module-level documentation for NOVA architecture Feat: NOVA architecture for predictive coding Dec 13, 2024
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
leonvanbokhorst and others added 2 commits December 13, 2024 20:12
…figuring Volatility Threshold

Fixes #5

The main changes include:
Added configurable min_samples and volatility_threshold parameters to the constructor
Added validation to ensure min_samples is at least 5
Updated documentation to explain the new parameters and their significance
Modified calculate_statistics() to use the configurable minimum samples
Updated is_stable() to use the configurable volatility threshold
These changes will improve statistical reliability by:
Ensuring a minimum of 5 samples for calculations
Making the volatility threshold configurable for different use cases
Adding proper validation and documentation
The code maintains backward compatibility while adding the new configuration options. Users can still use default values or customize them based on their needs.
@leonvanbokhorst leonvanbokhorst merged commit ddfefae into main Dec 13, 2024
@leonvanbokhorst leonvanbokhorst deleted the pred-coding branch December 13, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance Statistical Reliability by Increasing Minimum Samples and Configuring Volatility Threshold
1 participant