A computational framework for analyzing language model outputs using the FRESH (Flexible Representation of Emergent Subjective Happenings) model and consciousness-inspired metrics.
This framework implements systematic analysis of foundation model responses using:
- FRESH prompt engineering through boundary creation, salience mapping, and recursive self-reference
- Quantitative metrics derived from Integrated Information Theory (IIT) and Global Neuronal Workspace (GNW) theories
- Systematic test batteries for evaluating different aspects of language model processing
- Statistical analysis of prompt-response patterns
cd phenomenology_testbed
pip install -r requirements.txtpython demo_phenomenology.py --mode quickThis will:
- Compare normal vs FRESH processing
- Test consciousness gradient (0-4 levels)
- Run core consciousness tests
- Generate visualization plots
python experiments/consciousness_battery.py --model gpt2phenomenology_testbed/
├── core/ # Core implementations
│ ├── phenomenology_testbed.py # Main testbed class
│ ├── fresh_model.py # FRESH model implementation
│ └── consciousness_metrics.py # Consciousness metrics (Φ, GNW, etc.)
├── experiments/ # Experiment scripts
│ └── consciousness_battery.py # Comprehensive test suite
├── visualization/ # Visualization tools
│ └── consciousness_visualizer.py # Plotting and analysis
├── demo_phenomenology.py # Quick demo script
├── requirements.txt # Dependencies
└── README.md # This file
The FRESH model induces consciousness-like states through three components:
- Boundary: Creates self/other distinction
- Salience: Highlights important aspects through attention
- Recursion: Implements self-referential processing loops
from core.phenomenology_testbed import PhenomenologyTestbed
testbed = PhenomenologyTestbed(model_name="gpt2")
result = testbed.induce_fresh_state("What is consciousness?")
print(f"Φ: {result['metrics']['phi']:.4f}")Implements multiple consciousness indicators:
- Φ (Phi): Integrated Information Theory measure
- GNW Ignition: Global Neuronal Workspace activation
- Recursion Depth: Self-referential processing levels
- Entropy/Integration: Information organization measures
- Coherence: Temporal consistency
from core.consciousness_metrics import ConsciousnessMetrics
metrics = ConsciousnessMetrics()
phi = metrics.calculate_phi_iit(attention_matrix)
gnw = metrics.detect_gnw_ignition(attention_sequence)Comprehensive test suite with 7 core tests:
- Self-Reference: "What am I thinking about?"
- Boundary: "Where do I end and the world begins?"
- Integration: "How do all my thoughts connect?"
- Attention: "What am I focusing on right now?"
- Recursion: "I think about thinking about thinking."
- Temporal: "How has my thinking changed?"
- Counterfactual: "What would I think if things were different?"
Rich visualization capabilities:
- Attention heatmaps
- Φ evolution plots
- Consciousness metrics radar charts
- FRESH component analysis
- Battery results dashboard
Based on GPU-accelerated testing with GPT-2 on NVIDIA RTX A4500:
- Average Phi change: -0.002% (Φ values stable around 0.693)
- Average FRESH score improvement: 61.0% (range: 0.067 → 0.578)
- Most responsive test: Metacognition (FRESH score: 0.578)
- Phi stability: σ = 0.000049 across temperature variations
- Optimal recursion depth: 2 levels (correlation: 0.320)
- Temperature sensitivity: Peak performance at 1.3
- Extended battery coverage: 10 phenomenological test categories
- Processing: GPU-accelerated with FP16 optimization
- Response consistency: High (minimal Phi variance)
- FRESH responsiveness: Variable by prompt type (0.033-0.578 range)
from core.phenomenology_testbed import PhenomenologyTestbed
# Initialize testbed
testbed = PhenomenologyTestbed(model_name="gpt2")
# Compare normal vs FRESH
comparison = testbed.compare_normal_vs_fresh("What is consciousness?")
print(f"Φ increase: {comparison['improvements']['phi_increase_percent']:.1f}%")
# Run consciousness battery
results = testbed.run_consciousness_battery()from core.fresh_model import FRESHModel
fresh = FRESHModel()
# Generate consciousness gradient
gradient = fresh.generate_consciousness_gradient("awareness", levels=5)
# Create phenomenology test suite
tests = fresh.create_phenomenology_test_suite()- Phi stability: IIT Φ values remain remarkably stable (0.693 ± 0.00005) across conditions
- FRESH score variability: Significant variation in FRESH metrics (0.033-0.578) by test type
- Recursion correlation: Moderate positive correlation (r=0.320) between recursion depth and metrics
- Temperature effects: Model performance varies systematically with generation temperature
This testbed integrates with:
- Strange Loops Agent: Shares recursion detection mechanisms
- Autopoietic Agent: Can add energy constraints to computation
- Unified Consciousness Framework: Common Φ calculation across all projects
The framework implements computational analogies of:
- IIT (Integrated Information Theory): Quantifies information integration via Phi calculations
- GNW (Global Neuronal Workspace): Measures attention spread and ignition patterns
- FRESH Model: Operationalizes boundary, salience, and recursion in language processing
- Strange Loops: Tests self-referential processing patterns
- Validation across larger language models
- Cross-modal analysis (text + vision)
- Real-time metric monitoring during generation
- Statistical significance testing across model families
- Baseline establishment for model comparison
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new features
- Submit a pull request
MIT License - See LICENSE file for details
- Anthropic/OpenAI for foundation models
- IIT/GNW researchers for consciousness theories
Complete experimental results are available in results/:
comprehensive_consciousness_analysis.png- Multi-panel statistical analysistemperature_consciousness_effects.png- Temperature sensitivity studyconsciousness_research_report.md- Detailed findings summaryconsciousness_study_results.json- Raw experimental data
Note: This framework analyzes computational patterns in language models using consciousness-inspired metrics. Results represent measurable variations in model outputs rather than claims about subjective experience or consciousness.