eligo — I choose (Latin)
Best-of-N image generation that selects the best candidate by a measurable reward, rather than returning a single one-shot result.
eligo is Latin for "I pick out / I choose" — the root of elect and
elite. Choosing is the tool's one job. Where revelo reveals and
viser sees, eligo chooses: given a prompt, it generates n candidate
images through a [Backend], scores each against the prompt with a
[Scorer] (the reward), and returns the highest-scoring one. An optional
bounded re-roll replaces the single worst candidate once. That generate →
score → select loop is the smallest honest agentic pattern: a numeric reward
drives a decision.
Scope (deliberately bounded)
eligo is a selection library, not a model zoo or an editor. It owns the
loop and the contracts ([Backend], [Scorer]); concrete model inference
(a Stable Diffusion backend, and CLIP scoring via ONNX Runtime) are pluggable
implementations behind those traits. The default build ships a deterministic
mock backend/scorer so the loop is testable without model weights.
use ;
use ;
let backend = default;
let scorer = MockScorer;
let cfg = new.with_candidates;
let selection = best_of_n.unwrap;
assert_eq!;
// The chosen candidate is the highest-scoring one.
let top = selection.all.iter.map.fold;
assert!;