Skip to content

Commit

Permalink
Add target cognition percentage and enhance reporting in cognition pr…
Browse files Browse the repository at this point in the history
…ogress; update tests for new functionality
  • Loading branch information
kasinadhsarma committed Dec 26, 2024
1 parent 3d3bba1 commit d48a25f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
Binary file modified models/__pycache__/consciousness_model.cpython-310.pyc
Binary file not shown.
22 changes: 14 additions & 8 deletions models/consciousness_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def __init__(self, hidden_dim: int, num_heads: int, num_layers: int, num_states:
self.error_handler = ErrorHandler(self.logger)
self.error_correction = ErrorCorrection(hidden_dim)

self.target_cognition_percentage = 90.0 # Target cognition percentage

def add_meta_learning_layer(self):
"""Add meta-learning capabilities"""
self.meta_learner = nn.ModuleDict({
Expand Down Expand Up @@ -249,29 +251,33 @@ def calculate_cognition_progress(self, metrics):

def report_cognition_progress(self):
"""
Report the overall cognition progress and identify areas for improvement.
Report the overall cognition progress, target, and identify areas for improvement.
"""
if not self.cognition_progress_history:
return "No cognition progress data available."

latest = self.cognition_progress_history[-1]
report = [
f"Current Cognition Progress: {latest['total']:.2f}%\n",
f"Current Cognition Progress: {latest['total']:.2f}%",
f"Target Cognition Progress: {self.target_cognition_percentage:.2f}%\n",
"Breakdown:",
f"- Integrated Information (Phi): {latest['breakdown']['phi']*100:.2f}%",
f"- Thought Coherence: {latest['breakdown']['coherence']*100:.2f}%",
f"- Context Stability: {latest['breakdown']['stability']*100:.2f}%",
f"- Adaptability: {latest['breakdown']['adaptability']*100:.2f}%",
f"- Memory Retention: {latest['breakdown']['memory_retention']*100:.2f}%",
f"- Emotional Coherence: {latest['breakdown']['emotional_coherence']*100:.2f}%", # New metric
f"- Decision Making Efficiency: {latest['breakdown']['decision_making_efficiency']*100:.2f}%\n", # New metric
f"- Emotional Coherence: {latest['breakdown']['emotional_coherence']*100:.2f}%",
f"- Decision Making Efficiency: {latest['breakdown']['decision_making_efficiency']*100:.2f}%\n",
"Areas Needing Improvement:"
]

# Identify areas below target threshold (e.g., 70%)
threshold = 70.0
for metric, value in latest['breakdown'].items():
if value < 0.6:
report.append(f"- {metric.replace('_', ' ').title()}")

if value * 100 < threshold:
readable_metric = metric.replace('_', ' ').title()
report.append(f"- {readable_metric}: {value*100:.2f}%")

return "\n".join(report)

def forward(self, inputs, state=None, initial_state=None, deterministic=True, consciousness_threshold=0.5):
Expand Down
Binary file not shown.
39 changes: 38 additions & 1 deletion tests/unit/test_cognition_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,41 @@ def test_stress_condition_large_dataset(self, model):
model.optimize_memory_usage()
assert len(model.cognition_progress_history) == 100
assert len(model.state_history) == 50
assert len(model.context_history) == 50
assert len(model.context_history) == 50

def test_report_cognition_progress_with_target(self, model):
model.target_cognition_percentage = 80.0
metrics = {
'phi': 0.6,
'coherence': 0.75,
'stability': 0.65,
'adaptability': 0.80,
'memory_retention': 0.70,
'emotional_coherence': 0.60, # Below threshold
'decision_making_efficiency': 0.85
}
model.calculate_cognition_progress(metrics)
report = model.report_cognition_progress()
assert "Current Cognition Progress: 68.75%" in report
assert "Target Cognition Progress: 80.00%" in report
assert "Emotional Coherence: 60.00%" in report
assert "Areas Needing Improvement:" in report

def test_report_cognition_progress_no_improvement_needed(self, model):
model.target_cognition_percentage = 70.0
metrics = {
'phi': 0.8,
'coherence': 0.75,
'stability': 0.85,
'adaptability': 0.80,
'memory_retention': 0.90,
'emotional_coherence': 0.75, # Above threshold
'decision_making_efficiency': 0.85
}
model.calculate_cognition_progress(metrics)
report = model.report_cognition_progress()
assert "Current Cognition Progress: 81.00%" in report
assert "Target Cognition Progress: 70.00%" in report
assert "Areas Needing Improvement:" in report
# No areas should be listed as needing improvement
assert not any(metric in report for metric in []), "No metrics should need improvement"

0 comments on commit d48a25f

Please sign in to comment.