TheNormsOfIntelligence commited on
Commit
28d4f50
·
verified ·
1 Parent(s): ffdbc95

Restructure into nima_unified package + add model card

Browse files
nima_unified/training/goal_formulator.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Goal Formulator — analyzes capabilities, identifies gaps, defines improvement goals.
3
+ """
4
+
5
+ import logging
6
+ import time
7
+ from collections import deque
8
+ from typing import Any, Dict, List, Optional
9
+
10
+ logger = logging.getLogger("nima_unified.training.goal_formulator")
11
+
12
+
13
+ class GoalFormulator:
14
+ """
15
+ Formulates improvement goals by analyzing capabilities, identifying gaps,
16
+ and defining objectives based on system performance and feedback.
17
+ """
18
+
19
+ def __init__(self):
20
+ self.performance_history: deque = deque(maxlen=100)
21
+ self.capability_map: Dict[str, float] = {}
22
+ self.gap_analysis: List[Dict[str, Any]] = []
23
+ self.goals: List[Dict[str, Any]] = []
24
+ logger.info("GoalFormulator initialized")
25
+
26
+ def analyze_capabilities(self, capabilities: Dict[str, float]) -> Dict[str, Any]:
27
+ """Analyze current capabilities and identify gaps."""
28
+ self.capability_map.update(capabilities)
29
+
30
+ gaps = {}
31
+ priorities = []
32
+
33
+ for cap, score in capabilities.items():
34
+ if score < 0.5:
35
+ gaps[cap] = {"current": score, "priority": "HIGH"}
36
+ priorities.append((cap, score, "HIGH"))
37
+ elif score < 0.8:
38
+ gaps[cap] = {"current": score, "priority": "MEDIUM"}
39
+ priorities.append((cap, score, "MEDIUM"))
40
+ else:
41
+ gaps[cap] = {"current": score, "priority": "LOW"}
42
+
43
+ priorities.sort(key=lambda x: (x[2] != "HIGH", x[2] != "MEDIUM", x[1]))
44
+
45
+ analysis = {
46
+ "timestamp": time.time(),
47
+ "total_capabilities": len(capabilities),
48
+ "average_maturity": sum(capabilities.values()) / len(capabilities) if capabilities else 0.0,
49
+ "gaps": gaps,
50
+ "priority_order": [p[0] for p in priorities],
51
+ }
52
+
53
+ self.gap_analysis.append(analysis)
54
+ logger.debug(f"Capability analysis: {len(priorities)} gaps identified")
55
+ return analysis
56
+
57
+ def formulate_goals(
58
+ self,
59
+ gap_analysis: Dict[str, Any],
60
+ performance_feedback: Optional[Dict[str, Any]] = None,
61
+ ) -> List[Dict[str, Any]]:
62
+ """Formulate improvement goals from gap analysis and feedback."""
63
+ goals = []
64
+ for gap in gap_analysis.get("priority_order", []):
65
+ gap_info = gap_analysis["gaps"][gap]
66
+ current_score = gap_info["current"]
67
+ goal = {
68
+ "capability": gap,
69
+ "current_score": current_score,
70
+ "target_score": min(1.0, current_score + 0.3),
71
+ "priority": gap_info["priority"],
72
+ "formulated_at": time.time(),
73
+ "target_completion": time.time() + (3600 if gap_info["priority"] == "HIGH" else 7200),
74
+ }
75
+ goals.append(goal)
76
+
77
+ self.goals.extend(goals)
78
+ logger.info(f"Formulated {len(goals)} improvement goals")
79
+ return goals