Skip to content

solvi.core.primitives

Answer primitives: "not stated" (Unknown), evidence, spans, rankings and estimates.

Answer primitives: "not stated", evidence, spans, rankings and estimates — each a value with a confidence.

A question's answer type says which primitive it is (Answer.span / rank / estimate, Answer.maybe(...), or the types Span[T], Rank[...], Estimate[...], Maybe[T] from solvi.core.types); its rule, a learned part or a model decision proposes the output, and resolve turns the rule's trace record into the answer, its confidence and its details — checking what must hold (a span is literally in its text and parses as its type, a ranking uses only the options, a distribution is over the declared bins). What a failure is:

span not literally in the text / outside it → abstain, guard "grounding" (safeguard "grounding rejected") span text does not parse as its type → abstain, guard "type_rejected" (safeguard "type rejected") ranking / distribution not over the options → abstain, guard "outside_options" (safeguard "outside the options") require_evidence and no supporting quote → abstain, guard "evidence_missing" (safeguard "evidence missing")

Evidence quotes are checked when the part runs (solvi.core.ground): an output whose evidence is not literally in its text is rejected like an ungrounded quote — the fact is missing, the next producer runs, else the answer abstains.

Confidence — the probability that the answer, as returned, is right — per kind:

yes_no / choice / ordinal p(answer) multi the least certain option's max(p, 1 − p) Unknown (not stated) p(not stated) span p(this span) (a rule: 1, or its Claim's confidence) rank Plackett–Luce probability of the returned top k in this order (a rule: 1) estimate probability that the value lies in the interval: the mass of its bins (× p(stated)); a plain number: 1

and for every kind at most the confidence of the facts the answer rests on (quotes, decisions), as for any rule.

plackett_luce

plackett_luce(order, probs)

P(this top-k prefix, in this order) under Plackett–Luce with the options' probabilities as weights.

rank_candidates

rank_candidates(at, probs, limit=2000)

Rankings to consider in joint decoding: every top-k order of the options (when there are at most limit), with its Plackett–Luce log-probability, most probable first; None when there are too many.

estimate_of

estimate_of(at, p)

A distribution over the bins → (value, [lo, hi], mass): the middle of the median bin (an open bin: its edge), the bins from the (1 − c)/2 to the (1 + c)/2 cumulative probability (None for an open end), and their probability mass — the probability that the value lies in the interval. The answer-primitives decider's number_summary, in solvi.

resolve

resolve(at, rec, init, quotes='normalized')

The rule's record → {"answer", "confidence" (the answer's own), "probs", "evidence", "extra"}; raises Rejected. quotes: how a span is matched against its text (the rule's Catalog(quotes=)): "normalized" — a span written otherwise than its text (Unicode form, no-break spaces and hyphens, dashes, "…", whitespace runs, curly quotes) is found in the normalized view, and the span is the text's own substring at offsets into the original; "literal" — as 0.9.

fmt

fmt(answer, kind=None, extra=None)

An answer for people: "not stated", an estimate with its interval, a ranking.