Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Each attractor conceptually provides “the center of attraction” for candidates: the NNS accepts one or more attractors, to perform the actual near-neighbor search work, by interacting with underlying associative index.

Implementation-wise, attractors are specialized selectors.

Forward attractors

Roughly forward attractors try to find parts from a given a composite.

AttractorQueryAttracts
SetMembersAttractorReleases SET_MARKER from a SetAll members of the Set
SequenceMemberAttractorReleases with SEQUENCE_MARKER + positional markerSequence member at a specific position
TentacleAttractorRelease with keyOctopus value for a given key
memory.set_members(memory.by_item_key("sets", "my_set"))

memory.sequence_member(memory.by_item_key("seqs", "my_seq"), pos=2)

memory.tentacle(memory.by_item_key("records", "person"), key="name")

Reverse Attractors

Roughly reverse attractors try to locate composites given a part.

AttractorQueryAttracts
SetAttractorBinds member with SET_MARKERAll Sets that contain a given member
SequenceAttractorBinds member with SEQUENCE_MARKER + positionAll Sequences containing the given member at a specific position
OctopusAttractorBinds value with keyOctopuses with a given key-value pair
memory.set_attractor(memory.by_item_key("animals", "cat"), domain="sets")

memory.sequence_attractor(memory.by_item_key("animals", "cat"), pos=0, domain="seqs")

# NOTE the value is specified with another selector.
memory.octopus_attractor(key="color", value=memory.by_item_key("colors", "red"))

Analogical Reasoner

Analogical reasoner tries to perform analogical reasoning, like “A is to B as C is to ?”.

Given the analogy “king is to queen as man is to ?”

king   = hv.Sparkle(model, "role", "king")
queen  = hv.Sparkle(model, "role", "queen")
man    = hv.Sparkle(model, "role", "man")

# Analogy: "king is to queen as man is to ?"
#   src     = king   (the known source of the relationship)
#   feature = queen  (the known feature/attribute of src)
#   dst     = man    (the target; we want to find its corresponding feature)
#
# The attractor computes: dst ⊗ feature ⊗ src⁻¹
# This produces a code that should overlap with "woman"
memory.nns(
    memory.analogical_reasoner(memory.with_code(man), src=king, feature=queen)
)
Last change: , commit: 63ad966