QDpy
Loading...
Searching...
No Matches
qdpy.algorithms.qd_rec.QDRec Class Reference

Evolve explanations with Thompson item selection and blind local competition. More...

Public Member Functions

 archive (self)
 stats (self)
 best (self)
 run (self, propose, score, embed, novel, compare, *, budget, initial=())
 Warm-start from supplied recommendations and spend additional proposal calls.

Detailed Description

Evolve explanations with Thompson item selection and blind local competition.

Run the QD-Rec search loop using caller-supplied scoring and generation.

Item embeddings guide the contextual bandit. Separate embeddings of
item-hypothesis pairs determine the archive neighborhood. A novel
recommendation enters the archive directly. Otherwise, a blind
comparison with its nearest neighbor determines replacement.
The bandit observes every scored and fully processed proposal,
including rejected ones.

:param items: Nonempty sequence of distinct hashable item identifiers.
:param item_embeddings: Aligned item embeddings, L2 normalized at construction.
:param neighbors: Number of recommendations passed to the novelty judge.
:param exemplars: Number of archive recommendations passed to the proposer.
:param diversity_weight: Weight of cosine novelty in the item acquisition.
:param prior_precision: Positive isotropic precision of the linear model's prior.
:param noise_variance: Positive observation variance of normalized rewards.
:param selection: "thompson" or "uniform". With zero exemplars, uniform
    selection gives the independent proposal control.
:param seed: Private random seed for item selection, exemplars, and comparisons.

Definition at line 68 of file qd_rec.py.

Member Function Documentation

◆ archive()

qdpy.algorithms.qd_rec.QDRec.archive ( self)
Return an immutable snapshot of the recommendation entries.

Definition at line 116 of file qd_rec.py.

◆ best()

qdpy.algorithms.qd_rec.QDRec.best ( self)
Return the highest pointwise score still in the archive.

Definition at line 126 of file qd_rec.py.

◆ run()

qdpy.algorithms.qd_rec.QDRec.run ( self,
propose,
score,
embed,
novel,
compare,
* ,
budget,
initial = () )

Warm-start from supplied recommendations and spend additional proposal calls.

Return cumulative statistics after a fixed number of proposals.

:param propose: (item, exemplars, rng) -> hypothesis string.
:param score: Recommendation -> quality in [0, 1].
:param embed: Recommendation -> nonzero vector for cosine matching.
:param novel: (candidate, nearest_recommendations) -> Boolean.
:param compare: (first, second) -> index of the preferred recommendation.
    The order is randomized and scores are withheld.
:param budget: Number of proposer calls. Duplicates still consume calls.
:param initial: Optional Recommendation seeds, scored separately
    and admitted without local competition.

Definition at line 204 of file qd_rec.py.

◆ stats()

qdpy.algorithms.qd_rec.QDRec.stats ( self)
Return cumulative callback and archive counters.

Definition at line 121 of file qd_rec.py.


The documentation for this class was generated from the following file: