summaryrefslogtreecommitdiff
path: root/scripts/analyze_energy.py
diff options
context:
space:
mode:
authorYurenHao0426 <Blackhao0426@gmail.com>2026-02-16 14:44:42 -0600
committerYurenHao0426 <Blackhao0426@gmail.com>2026-02-16 14:44:42 -0600
commit09d50e47860da0035e178a442dc936028808a0b3 (patch)
tree9d651b0c7d289a9a0405953f2da989a3c431f147 /scripts/analyze_energy.py
parentc90b48e3f8da9dd0f8d2ae82ddf977436bb0cfc3 (diff)
Add memory centering, grid search experiments, and energy visualizationsHEADmaster
- Add centering support to MemoryBank (center_query, apply_centering, mean persistence in save/load) to remove centroid attractor in Hopfield dynamics - Add center flag to MemoryBankConfig, device field to PipelineConfig - Grid search scripts: initial (β≤8), residual, high-β, and centered grids with dedup-based LLM caching (89-91% call savings) - Energy landscape visualization: 2D contour, 1D profile, UMAP, PCA heatmap comparing centered vs uncentered dynamics - Experiment log (note.md) documenting 4 rounds of results and root cause analysis of centroid attractor problem - Key finding: β_critical ≈ 37.6 for centered memory; best configs beat FAISS baseline by +3-4% F1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'scripts/analyze_energy.py')
-rw-r--r--scripts/analyze_energy.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/analyze_energy.py b/scripts/analyze_energy.py
index fd044a4..cd93b15 100644
--- a/scripts/analyze_energy.py
+++ b/scripts/analyze_energy.py
@@ -32,6 +32,7 @@ def main() -> None:
parser.add_argument("--memory-bank", type=str, required=True)
parser.add_argument("--questions", type=str, required=True)
parser.add_argument("--output", type=str, default="energy_analysis.json")
+ parser.add_argument("--device", type=str, default="cpu")
args = parser.parse_args()
with open(args.config) as f:
@@ -43,13 +44,13 @@ def main() -> None:
# Load memory bank
mb = MemoryBank(memory_config)
- mb.load(args.memory_bank)
+ mb.load(args.memory_bank, device=args.device)
# Load questions
with open(args.questions) as f:
questions = [json.loads(line)["question"] for line in f]
- encoder = Encoder(encoder_config)
+ encoder = Encoder(encoder_config, device=args.device)
hopfield = HopfieldRetrieval(hopfield_config)
analyses = []