""" Multi-Criteria Rubric Evaluation Layout Rate items on multiple criteria simultaneously in a structured grid. THE missing schema for LLM evaluation — enables MT-Bench-style multi-dimensional scoring. Research: Zheng et al. (2023) "Judging LLM-as-a-judge with MT-Bench"; Ke et al. (2024) "CritiqueLLM". """ import logging from .identifier_utils import ( safe_generate_layout, generate_element_identifier, generate_validation_attribute, escape_html_content, generate_layout_attributes ) logger = logging.getLogger(__name__) DEFAULT_SCALE_POINTS = 5 DEFAULT_SCALE_LABELS = ["Poor", "Below Average", "Average", "Good", "Excellent"] def generate_rubric_eval_layout(annotation_scheme): """ Generate HTML for a Multi-Criteria Rubric Evaluation interface. Args: annotation_scheme (dict): Configuration including: - name: Schema identifier - description: Display description - scale_points: Number of scale points (default 5) - scale_labels: Labels for each scale point - criteria: List of {name, description} dicts - show_overall: Whether to include an "Overall" row Returns: tuple: (html_string, key_bindings) """ return safe_generate_layout(annotation_scheme, _generate_rubric_eval_layout_internal) def _generate_rubric_eval_layout_internal(annotation_scheme): schema_name = annotation_scheme['name'] description = annotation_scheme['description'] scale_points = annotation_scheme.get('scale_points', DEFAULT_SCALE_POINTS) scale_labels = annotation_scheme.get('scale_labels', DEFAULT_SCALE_LABELS[:scale_points]) criteria = annotation_scheme.get('criteria', []) show_overall = annotation_scheme.get('show_overall', False) if not criteria: raise ValueError(f"rubric_eval schema '{schema_name}' requires at least one criterion in 'criteria'") # Pad or trim scale_labels to match scale_points while len(scale_labels) < scale_points: scale_labels.append(f"{len(scale_labels) + 1}") scale_labels = scale_labels[:scale_points] layout_attrs = generate_layout_attributes(annotation_scheme) validation = generate_validation_attribute(annotation_scheme) # Build header row header_cells = '