raglab.recipes#

Recipes: whole workflows composed from raglab’s roles, ready to call.

Functions

label_corpus(corpus, *, facets[, retriever, ...])

Label corpus for each of facets with a graded judge; see the module.

Classes

CorpusLabeling([labels, coverage, levels])

The graded labels of a corpus for one topic, and each facet's coverage.

FacetCoverage(facet, judged, covered, ...)

How well one facet was covered: candidates judged, those at the coverage level, rounds run.

class raglab.recipes.CorpusLabeling(labels=dict(), coverage=dict(), levels=('core', 'strong', 'uses-tools', 'tangential', 'none'))[source]#

Bases: object

The graded labels of a corpus for one topic, and each facet’s coverage.

at_least(level)[source]#

The artifact ids labelled level or better, on the levels they were labelled on.

Return type:

list[str]

class raglab.recipes.FacetCoverage(facet, judged, covered, rounds, sufficient)[source]#

Bases: object

How well one facet was covered: candidates judged, those at the coverage level, rounds run.

raglab.recipes.label_corpus(corpus, *, facets, retriever=None, formulator=<function identity_formulator>, judge=None, reformulate=None, levels=('core', 'strong', 'uses-tools', 'tangential', 'none'), coverage_level='strong', min_covered=1, budget=None, k=50, **evaluator_kwargs)[source]#

Label corpus for each of facets with a graded judge; see the module.

Parameters:
  • corpus (Any) – an ir corpus or corpus name, read through ir.as_retriever(corpus, k=k) unless retriever is given.

  • facets (Mapping[str, str] | Iterable[str]) – the topic’s facets, as {name: goal} or names (a name is its own goal). One sub-task each.

  • retriever (Optional[Callable[..., list[SearchHit]]]) – inject a Retriever instead (a test double, a federated source); corpus is then not read.

  • formulator (Formulator) – the Formulator role (identity, or raglab.make_llm_formulator()).

  • judge (Callable[..., Any] | None) – the graded judge (built lazily on oa when omitted).

  • reformulate (Callable[[str, Mapping[str, GradedLabel]], str | None] | None) – gap-driven reformulation; when a facet has fewer than min_covered labels at coverage_level it gets a new query, which becomes the facet’s next sub-task. None (default): one round each.

  • budget (Budget | None) – the loop bounds (max_rounds caps the reformulations).

  • **evaluator_kwargs (Any) – forwarded to make_graded_rubric_evaluator() (rubric, calibration_offset, disclose_kwargs, rng, …).

Return type:

CorpusLabeling

Modules

corpus_labeling

Label a corpus against a topic, facet by facet, with a graded judge (raglab#8, part B).