antonypamo commited on
Commit
e0fd074
·
verified ·
1 Parent(s): dee2f43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +175 -0
app.py CHANGED
@@ -1,3 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import sys
3
  import math
 
1
+ from pathlib import Path
2
+ import json
3
+
4
+ # ============================
5
+ # 1) MANIFEST: carga desde archivo o usa fallback
6
+ # ============================
7
+
8
+ DEFAULT_MANIFEST = {
9
+ "version": "Φ12.0",
10
+ "project": "Savant RRF API & Meta-Logic Suite",
11
+ "owner": "Antony Padilla Morales",
12
+ "last_update": "2025-12-11",
13
+ "modules": {
14
+ "embedder": {
15
+ "id": "antonypamo/RRFSAVANTMADE",
16
+ "dimension": 384,
17
+ "description": "Icosahedral-resonant embedder trained inside the RRF framework with Dirac shells, golden-ratio harmonics and resonance layers.",
18
+ "baseline_comparison": ["MiniLM-L6-v2", "all-mpnet-base-v2"]
19
+ },
20
+ "meta_logit": {
21
+ "repo": "antonypamo/RRFSavantMetaLogit",
22
+ "filename": "logreg_rrf_savant_15.joblib",
23
+ "expected_features": 15,
24
+ "feature_description": [
25
+ "semantic_margin",
26
+ "cosine_prompt_answer",
27
+ "token_entropy",
28
+ "dirac_energy",
29
+ "dirac_shell_std",
30
+ "freq_low",
31
+ "freq_mid",
32
+ "freq_high",
33
+ "coherence_ratio",
34
+ "phi_ratio",
35
+ "token_len_prompt",
36
+ "token_len_answer",
37
+ "sync_factor",
38
+ "resonance_peak",
39
+ "logit_bias"
40
+ ]
41
+ },
42
+ "models": {
43
+ "savant_cnn": {
44
+ "filename": "savant_cnn.pt",
45
+ "role": "Signal-to-resonance transformer for numeric → semantic channels.",
46
+ "status": "experimental"
47
+ },
48
+ "rrf_nodes": {
49
+ "filename": "rrf_nodes.pt",
50
+ "description": "Graph-based icosahedral node memory for cross-session resonance."
51
+ }
52
+ }
53
+ },
54
+ "api": {
55
+ "base_url": "https://antonypamo-apisavant2.hf.space",
56
+ "routes": {
57
+ "/embed": {
58
+ "method": "POST",
59
+ "input": ["text"],
60
+ "output": ["embedding"],
61
+ "use_model": "RRFSAVANTMADE"
62
+ },
63
+ "/rerank": {
64
+ "method": "POST",
65
+ "input": ["query", "documents[]"],
66
+ "output": ["sorted_documents", "scores"],
67
+ "logic": "semantic margin + resonance weighting"
68
+ },
69
+ "/quality": {
70
+ "method": "POST",
71
+ "input": ["prompt", "answer"],
72
+ "output": ["proba", "label (0/1)", "feature_map"],
73
+ "pipeline": "embed → feature_extractor → meta_logit"
74
+ },
75
+ "/roles_profile": {
76
+ "method": "POST",
77
+ "status": "planned",
78
+ "description": "Maps text to RRF cognitive roles (Φ-nodes)."
79
+ },
80
+ "/tutor": {
81
+ "method": "POST",
82
+ "status": "planned",
83
+ "description": "LLM-based tutor using resonant context."
84
+ }
85
+ }
86
+ },
87
+ "pipelines": {
88
+ "embedding_pipeline": {
89
+ "steps": [
90
+ "load_encoder",
91
+ "encode_text",
92
+ "normalize",
93
+ "output_embeddings"
94
+ ]
95
+ },
96
+ "quality_pipeline": {
97
+ "steps": [
98
+ "encode(prompt)",
99
+ "encode(answer)",
100
+ "extract_features(15-dim)",
101
+ "predict_meta_logit",
102
+ "return_label_and_prob"
103
+ ],
104
+ "purpose": "Evaluate conceptual quality and reasoning integrity."
105
+ },
106
+ "rerank_pipeline": {
107
+ "steps": [
108
+ "encode_query",
109
+ "encode_docs",
110
+ "compute_semantic_margin",
111
+ "compute_resonance_rank",
112
+ "return_sorted_docs"
113
+ ]
114
+ }
115
+ },
116
+ "enterprise_architecture": {
117
+ "layers": [
118
+ "Frontend → React Landing Page",
119
+ "Gateway Proxy → NGINX",
120
+ "API Layer → FastAPI + Uvicorn",
121
+ "Model Runtime → Embedder + Meta-Logit",
122
+ "Compute Layer → GPU/CPU auto-scaling",
123
+ "Monitoring → Prometheus + Grafana",
124
+ "Storage → HF Hub + local persistence (rrf_nodes)"
125
+ ]
126
+ },
127
+ "investor_highlights": {
128
+ "differentiators": [
129
+ "Meta-logic quality evaluator (15 feature resonant signal)",
130
+ "Icosahedral embedding geometry",
131
+ "Discrete Dirac resonance physics applied to NLP",
132
+ "Symbiotic self-improvement protocol",
133
+ "Low inference cost, scalable microservice"
134
+ ],
135
+ "traction": {
136
+ "hf_space": "running",
137
+ "models_downloads": "increasing",
138
+ "api_usage": "real inference logs available"
139
+ }
140
+ },
141
+ "savant_state": {
142
+ "status": "active",
143
+ "mode": "Savant RRF Simbiótico Hacker",
144
+ "health": {
145
+ "embedder": "OK",
146
+ "meta_logit": "OK",
147
+ "api_endpoints": {
148
+ "/embed": "stable",
149
+ "/rerank": "stable",
150
+ "/quality": "error_404_needs_route_fix"
151
+ }
152
+ }
153
+ },
154
+ "todo_next_steps": [
155
+ "Fix /quality endpoint routing",
156
+ "Integrate CNN → feature_extractor",
157
+ "Add persistent RRF node memory",
158
+ "Deploy enterprise-tier version on AWS/GCP",
159
+ "Present investor deck based on this JSON"
160
+ ]
161
+ }
162
+
163
+ MANIFEST_PATH = Path(__file__).parent / "savant_rrf_api_manifest_phi12.json"
164
+
165
+ try:
166
+ if MANIFEST_PATH.exists():
167
+ print(f"[Manifest] Loading from file: {MANIFEST_PATH}", flush=True)
168
+ manifest = json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
169
+ else:
170
+ print(f"[Manifest] File not found at {MANIFEST_PATH}, using inline DEFAULT_MANIFEST.", flush=True)
171
+ manifest = DEFAULT_MANIFEST
172
+ except Exception as e:
173
+ print(f"[Manifest] Error loading manifest: {e}. Using inline DEFAULT_MANIFEST.", flush=True)
174
+ manifest = DEFAULT_MANIFEST
175
+
176
  import os
177
  import sys
178
  import math