agents.common.models.grade.rubric¶
Rubric grading model for multi-criteria evaluations.
This module implements a rubric-based grading system that evaluates multiple criteria with individual scores and weights.
Classes¶
Individual criterion within a rubric. |
|
Rubric grading model for multi-criteria evaluations. |
Module Contents¶
- class agents.common.models.grade.rubric.RubricCriterion(/, **data)¶
Bases:
pydantic.BaseModel
Individual criterion within a rubric.
Represents a single evaluation criterion with its own score, weight, and justification.
- Parameters:
data (Any)
- name¶
Name of the criterion
- score¶
Score for this criterion
- max_score¶
Maximum possible score for this criterion
- weight¶
Relative weight of this criterion (default 1.0)
- justification¶
Explanation for the score given
Example
criterion = RubricCriterion( name="Content Quality", score=8.5, max_score=10, weight=0.4, justification="Strong content with minor gaps in coverage" )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- get_normalized_score()¶
Get the criterion score as a normalized value (0.0 to 1.0).
- Returns:
Normalized score (score / max_score)
- Return type:
- get_percentage_score()¶
Get the criterion score as a percentage.
- Returns:
Percentage score (normalized score * 100)
- Return type:
- get_weighted_max_score()¶
Get the weighted maximum score for this criterion.
- Returns:
Max score multiplied by weight
- Return type:
- get_weighted_score()¶
Get the weighted score for this criterion.
- Returns:
Score multiplied by weight
- Return type:
- classmethod validate_score_range(v, info)¶
Validate that score is within valid range.
- Parameters:
- Returns:
Validated score
- Raises:
ValueError – If score is outside valid range
- Return type:
- validate_score_within_max()¶
Validate that score does not exceed max_score.
- Returns:
Self if validation passes
- Raises:
ValueError – If score exceeds max_score
- Return type:
- class agents.common.models.grade.rubric.RubricGrade(/, **data)¶
Bases:
haive.agents.common.models.grade.base.Grade
Rubric grading model for multi-criteria evaluations.
This grade model evaluates multiple criteria, each with their own scores, weights, and justifications, then combines them into an overall grade.
- Parameters:
data (Any)
- criteria¶
List of individual rubric criteria
- grade_type¶
Always GradeType.RUBRIC
- overall_justification¶
Overall summary justification
Example
criteria = [ RubricCriterion( name="Content Quality", score=8.5, max_score=10, weight=0.4, justification="Strong content with comprehensive coverage" ), RubricCriterion( name="Organization", score=7.0, max_score=10, weight=0.3, justification="Good structure but some transitions unclear" ), RubricCriterion( name="Grammar", score=9.0, max_score=10, weight=0.3, justification="Excellent grammar with only minor errors" ) ] grade = RubricGrade( criteria=criteria, justification="Overall strong performance with room for improvement in organization" )
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- classmethod create_simple_rubric(criteria_scores, justification, max_score=10.0, **kwargs)¶
Create a simple rubric with equal weights.
- Parameters:
- Returns:
RubricGrade instance with equal-weighted criteria
- Return type:
Example
grade = RubricGrade.create_simple_rubric( criteria_scores={ "Content": 8.5, "Style": {"score": 7.0, "justification": "Good style overall"}, "Accuracy": 9.0 }, justification="Strong overall performance", max_score=10 )
- get_criteria_summary()¶
Get a summary of all criteria performance.
- get_criterion_by_name(name)¶
Get a specific criterion by name.
- Parameters:
name (str) – Name of the criterion to find
- Returns:
RubricCriterion if found, None otherwise
- Return type:
RubricCriterion | None
- get_improvement_suggestions()¶
Generate improvement suggestions based on weakest criteria.
- get_max_weighted_score()¶
Get the maximum possible weighted score.
- Returns:
Sum of all weighted maximum scores
- Return type:
- get_normalized_score()¶
Get the overall grade as a normalized score between 0.0 and 1.0.
Calculates weighted average of all criteria scores.
- Returns:
Weighted normalized score across all criteria
- Return type:
- get_raw_weighted_score()¶
Get the total raw weighted score.
- Returns:
Sum of all weighted scores
- Return type:
- get_strongest_criteria(count=3)¶
Get the criteria with the highest normalized scores.
- Parameters:
count (int) – Number of strongest criteria to return
- Returns:
List of criteria sorted by normalized score (highest first)
- Return type:
- get_weakest_criteria(count=3)¶
Get the criteria with the lowest normalized scores.
- Parameters:
count (int) – Number of weakest criteria to return
- Returns:
List of criteria sorted by normalized score (lowest first)
- Return type:
- is_passing(threshold=None)¶
Determine if the rubric grade represents a passing score.
- to_display_string()¶
Convert grade to a human-readable display string.
- Returns:
Formatted string representation of the rubric grade
- Return type:
- classmethod validate_criteria_names_unique(v)¶
Validate that all criterion names are unique.
- Parameters:
v (list[RubricCriterion]) – List of criteria to validate
- Returns:
Validated criteria list
- Raises:
ValueError – If criterion names are not unique
- Return type: