diff options
| author | YurenHao0426 <blackhao0426@gmail.com> | 2026-02-15 18:19:50 +0000 |
|---|---|---|
| committer | YurenHao0426 <blackhao0426@gmail.com> | 2026-02-15 18:19:50 +0000 |
| commit | c90b48e3f8da9dd0f8d2ae82ddf977436bb0cfc3 (patch) | |
| tree | 43edac8013fec4e65a0b9cddec5314489b4aafc2 /README.md | |
Core Hopfield retrieval module with energy-based convergence guarantees,
memory bank, FAISS baseline retriever, evaluation metrics, and end-to-end
pipeline. All 45 tests passing on CPU with synthetic data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..7bd7a72 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# HAG: Hopfield-Augmented Generation + +A retrieval-augmented generation system that replaces standard vector similarity search (FAISS top-k) with **iterative Modern Hopfield Network retrieval**. + +## Quick Start + +```bash +pip install -e ".[dev]" +pytest +``` + +## Core Idea + +Standard RAG retrieves passages once via FAISS similarity. HAG iteratively refines the query in embedding space using Modern Continuous Hopfield Network dynamics: + +``` +q_{t+1} = M * softmax(beta * M^T * q_t) +``` + +This enables implicit multi-hop reasoning through energy minimization with convergence guarantees. + +## Project Structure + +- `hag/hopfield.py` — Core Hopfield retrieval module +- `hag/memory_bank.py` — Passage embedding storage +- `hag/retriever_hopfield.py` — Hopfield-based retriever +- `hag/retriever_faiss.py` — FAISS baseline retriever +- `hag/pipeline.py` — End-to-end RAG/HAG pipeline +- `hag/metrics.py` — Evaluation metrics (EM, F1, retrieval recall) +- `hag/energy.py` — Energy analysis utilities +- `scripts/` — Evaluation and analysis scripts +- `tests/` — Comprehensive test suite + +## Running Tests + +```bash +pytest tests/ -v +``` + +All tests run on CPU with synthetic data — no GPU or model downloads required. |
