Skip to content

metrics

metrics

Volume and category counts for the composition corpus's collection stage.

Classes

CorpusStats

Bases: BaseModel

Volume sufficiency alone does not establish readiness for training.

Functions:

corpus_stats

corpus_stats(examples)

Count supplied examples; callers deduplicate before measuring volume.

Source code in src/marianne/corpus/metrics.py
def corpus_stats(examples: Iterable[TrainingExample]) -> CorpusStats:
    """Count supplied examples; callers deduplicate before measuring volume."""
    records = list(examples)
    return CorpusStats(
        total_examples=len(records),
        by_source_kind=dict(sorted(Counter(ex.provenance.source_kind for ex in records).items())),
        by_category=dict(
            sorted(
                Counter(
                    ex.provenance.category for ex in records if ex.provenance.category is not None
                ).items()
            )
        ),
        annotated=sum(ex.rationale is not None for ex in records),
        meets_target=len(records) >= CorpusStats.TARGET_VOLUME,
    )