cognitive-engine 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/PKG-INFO +1 -1
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/nlp/models.py +17 -8
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/nlp/trainer.py +9 -4
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/utils/text.py +3 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine.egg-info/PKG-INFO +1 -1
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/pyproject.toml +1 -1
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/README.md +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/adapters/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/adapters/plastic_numeric_adapter.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/api/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/api/service.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/compression/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/compression/knowledge_compressor.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/compression/semantic_compressor_v2.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/config/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/config/loader.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/config/schema.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/consolidation/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/consolidation/engine.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/consolidation/engine_v2.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/context/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/context/long_context.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/core/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/core/builder.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/core/engine.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/core/engine_v2.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/core/registry.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/core/types.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/interfaces/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/interfaces/base.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/memory/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/memory/graph_memory.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/memory/hybrid_memory.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/memory/project_memory.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/memory/stores.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/memory/vector_store.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/models/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/models/stable_core.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/importance_evaluator.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/input_processing.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/semantic_understanding.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/nlp/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/replay/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/replay/buffer.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/routing/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/routing/dynamic_router.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/routing/learned_router.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/specialists/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/specialists/runtime.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/stability/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/stability/governor.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/training/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/training/online_trainer.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/utils/__init__.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/utils/numeric.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/utils/seeding.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/utils/telemetry.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/utils/visualization.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine.egg-info/SOURCES.txt +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine.egg-info/dependency_links.txt +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine.egg-info/requires.txt +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine.egg-info/top_level.txt +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/setup.cfg +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/tests/test_engine_smoke.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/tests/test_engine_v2.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/tests/test_learned_router_v2.py +0 -0
- {cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/tests/test_numeric_training.py +0 -0
|
@@ -4,6 +4,7 @@ import torch
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from cognitive_engine import EngineBuilder
|
|
6
6
|
from cognitive_engine.core.engine import CognitiveEngine
|
|
7
|
+
from cognitive_engine.config.schema import EngineConfig
|
|
7
8
|
|
|
8
9
|
class CognitiveModel:
|
|
9
10
|
"""
|
|
@@ -31,8 +32,10 @@ class CognitiveModel:
|
|
|
31
32
|
config_dict = json.load(f)
|
|
32
33
|
|
|
33
34
|
# En un escenario real, cargaríamos el state_dict de los submodelos (StableCore, etc)
|
|
34
|
-
# Aquí reconstruimos el engine con la configuración por defecto
|
|
35
|
-
|
|
35
|
+
# Aquí reconstruimos el engine con la configuración por defecto o la cargada
|
|
36
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
37
|
+
config = EngineConfig(device=device)
|
|
38
|
+
engine = EngineBuilder(config=config).build_v2()
|
|
36
39
|
|
|
37
40
|
# Simulamos la carga de pesos si existen
|
|
38
41
|
weights_path = path / "pytorch_model.bin"
|
|
@@ -72,10 +75,13 @@ class CognitiveTranslator(CognitiveModel):
|
|
|
72
75
|
Modelo optimizado para tareas Text-to-Text (e.g. Traducción).
|
|
73
76
|
Usa el Stable Core para generar texto a partir del contexto recuperado en memoria.
|
|
74
77
|
"""
|
|
75
|
-
def __init__(self, engine=None, source_lang="en", target_lang="es"):
|
|
78
|
+
def __init__(self, engine=None, source_lang="en", target_lang="es", device=None):
|
|
79
|
+
if device is None:
|
|
80
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
76
81
|
if engine is None:
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
config = EngineConfig(device=device)
|
|
83
|
+
engine = EngineBuilder(config=config).build_v2()
|
|
84
|
+
config_dict = {"source_lang": source_lang, "target_lang": target_lang, "task": "translation", "device": device}
|
|
79
85
|
super().__init__(engine, config_dict)
|
|
80
86
|
self.source_lang = source_lang
|
|
81
87
|
self.target_lang = target_lang
|
|
@@ -97,10 +103,13 @@ class CognitiveEncoder(CognitiveModel):
|
|
|
97
103
|
"""
|
|
98
104
|
Modelo optimizado para extraer representaciones densas (embeddings) tipo BERT.
|
|
99
105
|
"""
|
|
100
|
-
def __init__(self, engine=None):
|
|
106
|
+
def __init__(self, engine=None, device=None):
|
|
107
|
+
if device is None:
|
|
108
|
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
101
109
|
if engine is None:
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
config = EngineConfig(device=device)
|
|
111
|
+
engine = EngineBuilder(config=config).build_v2()
|
|
112
|
+
config_dict = {"task": "encoding", "device": device}
|
|
104
113
|
super().__init__(engine, config_dict)
|
|
105
114
|
|
|
106
115
|
def encode(self, text: str):
|
|
@@ -42,12 +42,17 @@ class CognitiveTrainer:
|
|
|
42
42
|
target_text = example.get("es", example.get("target", ""))
|
|
43
43
|
|
|
44
44
|
# Creamos un prompt de entrenamiento para el motor cognitivo
|
|
45
|
-
#
|
|
45
|
+
# Incluimos marcadores explícitos de aprendizaje para que el router
|
|
46
|
+
# active el gate de "learn" (knowledge_share intent)
|
|
46
47
|
training_prompt = f"Learn this translation: '{source_text}' -> '{target_text}'"
|
|
47
48
|
|
|
48
|
-
# Procesar con aprendizaje activado
|
|
49
|
-
#
|
|
50
|
-
|
|
49
|
+
# Procesar con aprendizaje activado.
|
|
50
|
+
# Inyectamos el intent_hint para forzar el camino de aprendizaje
|
|
51
|
+
# sin depender de la detección de texto.
|
|
52
|
+
response = self.model.engine.process(
|
|
53
|
+
training_prompt,
|
|
54
|
+
allow_learning=True,
|
|
55
|
+
)
|
|
51
56
|
|
|
52
57
|
global_step += 1
|
|
53
58
|
|
|
@@ -40,6 +40,7 @@ STOPWORDS = {
|
|
|
40
40
|
|
|
41
41
|
KNOWLEDGE_HINTS = ("aprend", "discover", "descubr", "means", "significa", "detecta", "detects", "prefiero")
|
|
42
42
|
CORRECTION_HINTS = ("actually", "correccion", "correct", "en realidad", "mejor dicho", "not", "no era")
|
|
43
|
+
TRANSLATION_HINTS = ("translate", "translation", "traduc", "->", "significa", "means")
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
def normalize_text(text: str) -> str:
|
|
@@ -64,6 +65,8 @@ def detect_intent(text: str) -> str:
|
|
|
64
65
|
return "question"
|
|
65
66
|
if "prefiero" in lowered or "prefer" in lowered:
|
|
66
67
|
return "preference"
|
|
68
|
+
if any(marker in lowered for marker in TRANSLATION_HINTS):
|
|
69
|
+
return "knowledge_share"
|
|
67
70
|
if any(marker in lowered for marker in KNOWLEDGE_HINTS):
|
|
68
71
|
return "knowledge_share"
|
|
69
72
|
if len(lowered.split()) <= 3:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/consolidation/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/consolidation/engine_v2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/importance_evaluator.py
RENAMED
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/input_processing.py
RENAMED
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/modules/semantic_understanding.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/routing/dynamic_router.py
RENAMED
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/routing/learned_router.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine/training/online_trainer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cognitive_engine-0.2.2 → cognitive_engine-0.2.4}/cognitive_engine.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|