Skip to main content

Module hopfield

Module hopfield 

Source
Expand description

Hopfield-Fenchel-Young (HFYN) energy-based associative memory retrieval.

Implements sparse Hopfield retrieval using Tsallis α-entropy transformations (Santos et al., JMLR 2025). For sparse binary vectors, the update rule is:

scores_i = β · |query ∩ pattern_i| (intersection count) weights = entmax_α(scores) (sparse attention) result = patterns with non-zero weights

Key properties:

  • Exact retrieval: for well-separated patterns, converges to a single pattern in one step (margin m = 1/(α-1), requires Δ ≥ m/β).
  • Sparse output: α > 1 produces exact zeros, naturally determining the number of relevant results (no fixed k needed).
  • Exponential capacity: O(ζ^(D/2)) patterns recoverable for dimension D.

Structs§

HopfieldConfig
Hopfield retrieval configuration.

Functions§

hopfield_query
Perform Hopfield-HFYN retrieval against a set of stored patterns.
hopfield_query_iterative
Iterative Hopfield retrieval with query refinement.