mixle.substrate.eig_retrieve moduleΒΆ

Information-gain retrieval over substrate items.

Score substrate items by how much they would actually move a belief, not by how textually similar they are to the query.

retrieve() ranks by cosine/lexical similarity – a sound default, but many similar-looking items can carry the same evidence (redundant), while a single differently-worded item can be decisive. eig_retrieve() instead scores each candidate by the entropy it would actually remove from a given BeliefState if assimilated, and greedily picks the highest-gain item each round, updating the running belief before scoring what remains – so a second item redundant with the first correctly scores near zero the next round. Experiment-design workflows can reuse the same greedy EIG scorer; it is written once, here.

eig_retrieve(substrate, belief, evidence_fn, *, k=8, kind=None, scope=None)[source]

Greedily pick up to k substrate items by expected posterior-entropy reduction against belief.

evidence_fn(item) turns a candidate item into whatever belief.update(...) expects (e.g. a per-hypothesis log-likelihood vector for a CategoricalBelief). Each round, every remaining candidate is scored by current_belief.entropy() - updated_belief.entropy(); the best-scoring item is taken, the running belief moves to its post-update state, and scoring repeats against the shrunk pool – so an item whose evidence is redundant with an already-picked item scores near zero on its next look, the direct fix for similarity retrieval pulling in near-duplicates. Items whose evidence_fn raises (no usable evidence) are skipped, not fatal. Returned as a Retrieval (query is a fixed marker, not a text query) so it composes with the same to_context/by_kind surface as cosine retrieval.

Parameters:
  • substrate (Substrate)

  • belief (BeliefState)

  • evidence_fn (Callable[[SubstrateItem], Any])

  • k (int)

  • kind (str | None)

  • scope (str | None)

Return type:

Retrieval