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

Producers

ChunkProducers are write builders that create and persist chunks in the substrate. Each producer encapsulates the logic for constructing a specific type of chunk.

Note
Some producers only update existing chunks (e.g., ClusterUpdater) without creating new ones. In those cases, Produce returns the updated chunk rather than a newly created one.

Producer Options

Producer options are additional information supplied to producer constructor to tweak behavior.

# `note` indiciates additional note for the new terminal chunk.
memory.new_terminal("d", "p", note="annotation")

# `enable_semantic_indexing` indicates we need to index the semantic code 
# (on top of the id vector).
memory.from_set_members("d", "p", members, enable_semantic_indexing=True)

Concrete Producers

NewTerminal

Creates a chunk whose code equals its identity (a bare Sparkle). Useful for registering atoms/symbols.

with storage.new_mutable_view() as view:
    memory.new_terminal("fruits", "apple", note="an apple").produce(view)

NewLearner

Creates a fresh Learner chunk for online learning.

with storage.new_mutable_view() as view:
    memory.new_learner("learners", "my_learner", note="a learner").produce(view)

FromSetMembers

Creates a Set from stored members.

with storage.new_mutable_view() as view:
    memory.from_set_members(
        "sets",
        "fruit_set",
        memory.by_item_domain("fruits"),
    ).produce(view)

FromSequenceMembers

Creates a Sequence from stored members with positional encoding.

with storage.new_mutable_view() as view:
    memory.from_sequence_members(
        "seqs",
        "greeting",
        memory.joiner(
            memory.by_item_key("words", "hello"),
            memory.by_item_key("words", "world"),
        ),
        start=0,
    ).produce(view)

FromKeyValues

Creates an Octopus (key-value composite) from keys and value selectors.

with storage.new_mutable_view() as view:
    memory.from_key_values(
        "records",
        "obj1",
        keys=["color", "shape"],
        values=memory.joiner(
            memory.by_item_key("colors", "red"),
            memory.by_item_key("shapes", "circle"),
        ),
    ).produce(view)

NewDart

Creates a Dart 🎯 chunk β€” thrown from a tail chunk to a head chunk. Both selectors must resolve to a single chunk; the produced Dart’s bit-level value is Inv(tail.id) βŠ— head.id.

with storage.new_mutable_view() as view:
    memory.new_dart(
        "edges", "earth_to_moon",
        memory.by_item_key("planets", "earth"),
        memory.by_item_key("planets", "moon"),
    ).produce(view)

ClusterUpdater

Feeds an observed chunk into an existing Learner, updating its accumulated code via bundling. The bundle multiplier defaults to 1; pass an explicit override (multiple=N in Python) to fold the same observation in repeatedly.

with storage.new_mutable_view() as view:
    # With explicit multiplier:
    memory.cluster_updater(
        learner=memory.by_item_key("learners", "my_learner"),
        observed=memory.by_item_key("fruits", "apple"),
        multiple=3,
    ).produce(view)
Last change: , commit: 7d713c7