Parts and words
A node follows a story as it moves, so after some weeks it holds several facets of it. With Memory(parts=C) each node also keeps up to C parts, each a sum like the node itself, that separate those facets. The outputs on this page come from the Portal stream (Example data).
Parts change no assignment
Section titled “Parts change no assignment”Each item enters its node as a part of its own. When a node holds more than C parts, the two whose merge loses least resultant length, , become one: the heavier keeps its identity. Only the node that takes the largest share of an item can open or merge parts; the slivers of the soft write go to the part of each other node that loses least by them. A node is always the exact sum of its parts.
The read never looks at the parts, so the memory assigns every item as it would without them:
memory = Memory(parts=6).fit_projection(reference)history = memory.read(embeddings, hours)flat = Memory().fit_projection(reference).read(embeddings, hours)print("same nodes as Memory():", np.array_equal(history.node, flat.node))print("merges of parts recorded:", len(history.merges))same nodes as Memory(): True merges of parts recorded: 18588
The history records each item’s part and every merge, so the parts of a node can be recomputed at any past time, like its mass and centre (Timelines).
The parts of a node on a day
Section titled “The parts of a node on a day”The node that followed the invasion of Ukraine, on 3 March 2022, a week in, found through one of its items:
time = hours_at("2022-03-04") # the end of 3 March 2022item = next(i for i, text in enumerate(texts) if "has begun a ground offensive in the Kherson" in text)node = int(history.node[item])parts = history.parts(node, time)for p in parts: print(f"part {p.part:3d} mass {p.mass:5.2f} {len(p.items):3d} items")part 34 mass 14.23 72 items part 27 mass 12.51 53 items part 26 mass 7.55 56 items part 41 mass 6.12 13 items part 45 mass 2.94 3 items part 43 mass 2.34 3 items
History.parts returns them heaviest first, each with its forgotten mass, its centre and its items. Part identities count within the node, so the numbers say only how many parts it has opened and merged.
vmfstream.words.top_words describes groups of texts by class-based TF-IDF (c-TF-IDF; Grootendorst, 2022), as the paper does: each group is one document, and a word weighs its share of the group’s words times , with the mean number of words per group and the word’s frequency over all groups. Words frequent in one group and rare in the others rise. Here each item weighs what the memory still keeps of it, and the parts are compared with each other, so the words say what each part has that its siblings lack. Next to them, the item closest to each part’s centre:
from vmfstream.words import top_words
words = top_words([[texts[i] for i in p.items] for p in parts], count=3, weights=[weights(history, p.items, time) for p in parts])for p, w in zip(parts, words): central = p.items[np.argmax(history.points[p.items] @ p.centre)] print(f"{' · '.join(w):<34} {texts[central][:70]}…")forces · ukrainian · russian Russian Ground Forces say that they have captured the Black Sea port o… ukraine · nato · russia Belarus confirms that it has revoked its status as a non-nuclear state… criminal · anti · war Anti-war protesters gather at Russian embassies in many countries to o… russian · space · exchange The Moscow Stock Exchange will extend its closure until at least March… die · default · equivalent Yandex, the Russian equivalent of Google, announces that it might be h… fire · troops · near The Zaporizhzhia Nuclear Power Plant in Enerhodar catches fire followi…
The fighting, the diplomacy around NATO and Belarus, the protests against the war, the closed Moscow exchange, Russian companies near default, the fire at the Zaporizhzhia plant: one story, which the memory read as one node, in parts that a reader would separate. The smallest parts, with three items each, have words that only make sense next to their items.
The same function compares the nodes in memory on that day, which is how the explorer labels them:
alive = history.active(time)nodes = sorted(alive, key=alive.get, reverse=True)groups = [history.items(k, time) for k in nodes]words = top_words([[texts[i] for i in g] for g in groups], count=3, weights=[weights(history, g, time) for g in groups])for k, w in list(zip(nodes, words))[:6]: print(f"mass {alive[k]:5.1f} {' · '.join(w)}")mass 45.7 russian · ukrainian · forces mass 11.5 union · russia · yacht mass 8.7 air · oblast · missile mass 6.5 talks · round · peace mass 4.7 cases · record · past mass 4.4 people · students · university
The tokens are lowercase runs of two or more letters without stop words (scikit-learn’s English list, without the words that carry news content in it, such as fire, bill or interest, and with the reporting verbs said, says, say and according).
Parts in the state
Section titled “Parts in the state”Memory.node_parts gives the parts the memory holds now, for a node in memory: here the heaviest node at the end of the stream.
largest = int(memory.nodes().ident[memory.nodes().mass.argmax()])for p in memory.node_parts(largest): print(f"part {p.part:4d} mass {p.mass:5.2f} centre {p.centre.shape}")part 63 mass 3.27 centre (256,) part 22 mass 3.21 centre (256,) part 57 mass 3.16 centre (256,) part 46 mass 2.93 centre (256,) part 52 mass 2.37 centre (256,) part 64 mass 1.00 centre (256,)
Parts cost C sums per node: with 256 rows of 256 dimensions and C = 6, about 1.6 MB more in float32. They are saved and loaded with the memory and the history.
In the explorer
Section titled “In the explorer”The explorer reads with parts=6. Scroll into the sphere: the nodes show their words and, closer, their parts, each in a shade of the node’s colour; the inspector lists the parts of a node on the chosen day with their words, mass and central item. There the words and centres are computed on the page from the record, so they can differ slightly from those above, computed with the memory’s own points.