Metrics¶
Agreement and correlation metrics for validating LLM judges against ground truth.
Overview¶
When your dataset includes ground truth labels, compute_metrics() measures how well your LLM judge agrees with human annotations. Metrics include accuracy, precision, recall, F1, Cohen's kappa, correlations, and systematic bias analysis.
Research Background
Casabianca et al. (2025) recommend agreement metrics including ICC, Krippendorff's alpha, and quadratic-weighted kappa (QWK), with iterative refinement until agreement with human-labeled subsets is acceptable. He et al. (2025) emphasize that correlation alone can mask systematic bias.
Quick Example¶
from autorubric import RubricDataset, LLMConfig, evaluate
from autorubric.graders import CriterionGrader
dataset = RubricDataset.from_file("data_with_ground_truth.json")
grader = CriterionGrader(llm_config=LLMConfig(model="openai/gpt-4.1-mini"))
result = await evaluate(dataset, grader, show_progress=True)
# Compute metrics
metrics = result.compute_metrics(dataset)
# Formatted summary
print(metrics.summary())
# Export options
df = metrics.to_dataframe()
metrics.to_file("metrics.json")
Bootstrap Confidence Intervals¶
metrics = result.compute_metrics(
dataset,
bootstrap=True,
n_bootstrap=1000,
confidence_level=0.95,
seed=42,
)
print(metrics.summary())
# Bootstrap CIs (95%):
# Accuracy: [85.2%, 92.1%]
# Kappa: [0.712, 0.845]
Per-Judge Metrics (Ensemble)¶
metrics = result.compute_metrics(
dataset,
per_judge=True,
)
for judge_id, jm in metrics.per_judge.items():
print(f"{judge_id}: Accuracy={jm.criterion_accuracy:.1%}, RMSE={jm.score_rmse:.4f}")
Metric Fields¶
| Field | Description |
|---|---|
criterion_accuracy |
Overall accuracy across all criteria |
criterion_precision |
Precision for MET class |
criterion_recall |
Recall for MET class |
criterion_f1 |
F1 score for MET class |
mean_kappa |
Mean Cohen's kappa across criteria |
score_rmse |
RMSE of cumulative scores |
score_mae |
MAE of cumulative scores |
score_spearman |
Spearman rank correlation |
score_kendall |
Kendall tau correlation |
score_pearson |
Pearson correlation |
compute_metrics¶
Compute agreement metrics between predictions and ground truth.
compute_metrics
¶
compute_metrics(eval_result: 'EvalResult', dataset: 'RubricDataset', *, bootstrap: bool = False, n_bootstrap: int = 1000, per_judge: bool = False, cannot_assess: Literal['exclude', 'as_unmet'] = 'exclude', na_mode: Literal['exclude', 'as_worst'] = 'exclude', confidence_level: float = 0.95, seed: int | None = None) -> MetricsResult
Compute comprehensive evaluation metrics.
This is the main entry point for computing metrics from an evaluation run. It compares predicted verdicts and scores against ground truth from the dataset. Supports binary, ordinal, and nominal (multi-choice) criteria.
| PARAMETER | DESCRIPTION |
|---|---|
eval_result
|
The evaluation result from EvalRunner.
TYPE:
|
dataset
|
The dataset with ground truth labels.
TYPE:
|
bootstrap
|
If True, compute bootstrap confidence intervals (expensive).
TYPE:
|
n_bootstrap
|
Number of bootstrap samples if bootstrap=True.
TYPE:
|
per_judge
|
If True and ensemble, compute per-judge metrics.
TYPE:
|
cannot_assess
|
How to handle CANNOT_ASSESS verdicts (binary criteria): - "exclude": Skip pairs where either is CA (default) - "as_unmet": Treat CA as UNMET
TYPE:
|
na_mode
|
How to handle NA options (multi-choice criteria): - "exclude": Skip pairs where either is NA (default) - "as_worst": Keep NA in metrics (no special treatment)
TYPE:
|
confidence_level
|
Confidence level for bootstrap CIs (default 0.95).
TYPE:
|
seed
|
Random seed for bootstrap reproducibility.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MetricsResult
|
MetricsResult with comprehensive metrics and optional per-judge breakdown. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no common items between eval_result and dataset. |
Example
result = await evaluate(dataset, grader) metrics = result.compute_metrics(dataset) print(metrics.summary()) df = metrics.to_dataframe()
Source code in src/autorubric/metrics/_compute.py
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 | |
MetricsResult¶
Complete metrics result with aggregate and per-criterion breakdowns.
MetricsResult
¶
Bases: BaseModel
Complete metrics result from compute_metrics().
This is the main result type returned by EvalResult.compute_metrics(). It provides a comprehensive view of evaluation quality including: - Criterion-level agreement metrics - Score-level correlation and error metrics - Per-criterion breakdown (supports binary, ordinal, and nominal criteria) - Optional bootstrap confidence intervals - Optional per-judge metrics for ensemble evaluations
| ATTRIBUTE | DESCRIPTION |
|---|---|
criterion_accuracy |
Overall accuracy across all criteria.
TYPE:
|
criterion_precision |
Overall precision for MET class (binary criteria only).
TYPE:
|
criterion_recall |
Overall recall for MET class (binary criteria only).
TYPE:
|
criterion_f1 |
Overall F1 for MET class (binary criteria only).
TYPE:
|
mean_kappa |
Mean kappa across criteria (weighted for ordinal, unweighted for binary/nominal).
TYPE:
|
per_criterion |
Per-criterion metrics breakdown (polymorphic union type).
TYPE:
|
score_rmse |
RMSE of cumulative scores.
TYPE:
|
score_mae |
MAE of cumulative scores.
TYPE:
|
score_spearman |
Spearman correlation result.
TYPE:
|
score_kendall |
Kendall tau correlation result.
TYPE:
|
score_pearson |
Pearson correlation result.
TYPE:
|
bias |
Systematic bias analysis.
TYPE:
|
bootstrap |
Optional bootstrap confidence intervals.
TYPE:
|
per_judge |
Optional per-judge metrics for ensemble.
TYPE:
|
n_items |
Number of items used in computation.
TYPE:
|
n_criteria |
Number of criteria.
TYPE:
|
n_binary_criteria |
Number of binary criteria (default 0 for backwards compat).
TYPE:
|
n_ordinal_criteria |
Number of ordinal multi-choice criteria.
TYPE:
|
n_nominal_criteria |
Number of nominal multi-choice criteria.
TYPE:
|
na_stats |
Statistics for NA handling in multi-choice criteria.
TYPE:
|
warnings |
Any warnings generated during computation.
TYPE:
|
summary
¶
Return formatted text summary of metrics.
Source code in src/autorubric/metrics/_types.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
to_dataframe
¶
Export metrics to pandas DataFrame.
Returns a flat DataFrame with a 'level' column indicating: - 'aggregate': Overall metrics - 'criterion': Per-criterion metrics (binary) - 'criterion_ordinal': Per-criterion metrics (ordinal) - 'criterion_nominal': Per-criterion metrics (nominal) - 'judge': Per-judge metrics (if available)
Source code in src/autorubric/metrics/_types.py
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 | |
to_file
¶
Save metrics to a JSON file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to the output JSON file.
TYPE:
|
Source code in src/autorubric/metrics/_types.py
CriterionMetrics¶
Per-criterion binary metrics.
CriterionMetrics
¶
Bases: BaseModel
Metrics for a single binary criterion.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
Name of the criterion.
TYPE:
|
index |
Index of the criterion in the rubric.
TYPE:
|
criterion_type |
Type of criterion ("binary" for this class).
TYPE:
|
n_samples |
Number of samples used for this criterion.
TYPE:
|
accuracy |
Binary accuracy (proportion of exact matches).
TYPE:
|
precision |
Precision for MET class.
TYPE:
|
recall |
Recall for MET class.
TYPE:
|
f1 |
F1 score for MET class.
TYPE:
|
kappa |
Cohen's kappa coefficient.
TYPE:
|
kappa_interpretation |
Human-readable interpretation of kappa.
TYPE:
|
support_true |
Count of MET in ground truth.
TYPE:
|
support_pred |
Count of MET in predictions.
TYPE:
|
CorrelationResult¶
Correlation statistics between predicted and ground truth scores.
CorrelationResult
¶
Bases: BaseModel
Result from correlation calculation (Spearman, Kendall, Pearson).
| ATTRIBUTE | DESCRIPTION |
|---|---|
coefficient |
The correlation coefficient (-1 to 1).
TYPE:
|
p_value |
P-value for testing the null hypothesis of no correlation.
TYPE:
|
ci |
Optional confidence interval for the coefficient.
TYPE:
|
interpretation |
Human-readable interpretation.
TYPE:
|
n_samples |
Number of samples used in calculation.
TYPE:
|
method |
Correlation method used (e.g., "spearman", "kendall", "pearson").
TYPE:
|
interpret_correlation
staticmethod
¶
Return human-readable interpretation of correlation coefficient.
Source code in src/autorubric/metrics/_types.py
BootstrapResults¶
Bootstrap confidence intervals for key metrics.
BootstrapResults
¶
Bases: BaseModel
Bootstrap confidence interval results.
| ATTRIBUTE | DESCRIPTION |
|---|---|
accuracy_ci |
95% CI for criterion-level accuracy.
TYPE:
|
kappa_ci |
95% CI for mean kappa.
TYPE:
|
rmse_ci |
95% CI for score RMSE.
TYPE:
|
n_bootstrap |
Number of bootstrap samples used.
TYPE:
|
confidence_level |
Confidence level (default 0.95).
TYPE:
|
BootstrapResult¶
Single bootstrap result with confidence interval.
BootstrapResult
¶
Bases: BaseModel
Bootstrap confidence interval result.
| ATTRIBUTE | DESCRIPTION |
|---|---|
estimate |
Point estimate of the statistic.
TYPE:
|
ci |
Confidence interval from bootstrap.
TYPE:
|
standard_error |
Bootstrap standard error.
TYPE:
|
n_bootstrap |
Number of bootstrap samples used.
TYPE:
|
bootstrap_distribution |
Optional array of bootstrap estimates.
TYPE:
|
ConfidenceInterval¶
Confidence interval bounds.
ConfidenceInterval
¶
Bases: BaseModel
Confidence interval for a statistic.
| ATTRIBUTE | DESCRIPTION |
|---|---|
lower |
Lower bound of the interval.
TYPE:
|
upper |
Upper bound of the interval.
TYPE:
|
confidence |
Confidence level (default 0.95 for 95% CI).
TYPE:
|
method |
Method used to compute the interval.
TYPE:
|
JudgeMetrics¶
Per-judge metrics for ensemble evaluations.
JudgeMetrics
¶
Bases: BaseModel
Metrics for a single judge in an ensemble.
| ATTRIBUTE | DESCRIPTION |
|---|---|
judge_id |
Identifier for this judge.
TYPE:
|
criterion_accuracy |
Overall criterion-level accuracy.
TYPE:
|
criterion_precision |
Overall precision for MET class.
TYPE:
|
criterion_recall |
Overall recall for MET class.
TYPE:
|
criterion_f1 |
Overall F1 for MET class.
TYPE:
|
mean_kappa |
Mean Cohen's kappa across criteria.
TYPE:
|
score_rmse |
RMSE of cumulative scores.
TYPE:
|
score_mae |
MAE of cumulative scores.
TYPE:
|
score_spearman |
Spearman correlation result.
TYPE:
|
score_kendall |
Kendall tau correlation result.
TYPE:
|
score_pearson |
Pearson correlation result.
TYPE:
|
bias |
Systematic bias analysis result.
TYPE:
|
References¶
Casabianca, J., McCaffrey, D. F., Johnson, M. S., Alper, N., and Zubenko, V. (2025). Validity Arguments For Constructed Response Scoring Using Generative Artificial Intelligence Applications. arXiv:2501.02334.
He, J., Shi, J., Zhuo, T. Y., Treude, C., Sun, J., Xing, Z., Du, X., and Lo, D. (2025). LLM-as-a-Judge for Software Engineering: Literature Review, Vision, and the Road Ahead. arXiv:2510.24367.