raglab.recipes.corpus_labeling#
Label a corpus against a topic, facet by facet, with a graded judge (raglab#8, part B).
label_corpus() composes existing pieces and adds no orchestrator:
a planner that emits one
SubTaskper facet of the topic, for broad recall;a formulator (identity by default;
raglab.make_llm_formulator()for query expansion);the graded rubric evaluator (
raglab.make_graded_rubric_evaluator()), which judges every retrieved candidate on its disclosed content;a coverage check per facet (enough candidates at
coverage_level), which, when a facet looks thin and areformulatepolicy is given, emits a refinement sub-task: the back-edge ofSingleContextAgent.
The deliverable is a frozen CorpusLabeling: each judged artifact’s best
GradedLabel (its facet set) and each facet’s coverage.
Nothing here touches ir; the corpus is read through a retriever
(ir.as_retriever() by default).
Functions
|
Label |
Classes
|
The graded labels of a corpus for one topic, and each facet's coverage. |
|
How well one facet was covered: candidates judged, those at the coverage level, rounds run. |
- class raglab.recipes.corpus_labeling.CorpusLabeling(labels=dict(), coverage=dict(), levels=('core', 'strong', 'uses-tools', 'tangential', 'none'))[source]#
Bases:
objectThe graded labels of a corpus for one topic, and each facet’s coverage.
- class raglab.recipes.corpus_labeling.FacetCoverage(facet, judged, covered, rounds, sufficient)[source]#
Bases:
objectHow well one facet was covered: candidates judged, those at the coverage level, rounds run.
- raglab.recipes.corpus_labeling.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
corpusfor each offacetswith a graded judge; see the module.- Parameters:
corpus (
Any) – anircorpus or corpus name, read throughir.as_retriever(corpus, k=k)unlessretrieveris 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 aRetrieverinstead (a test double, a federated source);corpusis then not read.formulator (
Formulator) – the Formulator role (identity, orraglab.make_llm_formulator()).judge (
Callable[...,Any] |None) – the graded judge (built lazily onoawhen omitted).reformulate (
Callable[[str,Mapping[str,GradedLabel]], str | None] |None) – gap-driven reformulation; when a facet has fewer thanmin_coveredlabels atcoverage_levelit gets a new query, which becomes the facet’s next sub-task.None(default): one round each.budget (
Budget|None) – the loop bounds (max_roundscaps the reformulations).**evaluator_kwargs (
Any) – forwarded tomake_graded_rubric_evaluator()(rubric,calibration_offset,disclose_kwargs,rng, …).
- Return type: