template
Annotation Template System - extensible framework for Label Studio annotation configurations.
Provides base classes and registry for managing annotation templates with custom labeling configurations and post-processing logic for different evaluation tasks.
AnnotationTemplateRegistry
Registry system for managing and discovering annotation templates.
Provides decorator-based registration and factory methods for template instantiation. Enables extensible template ecosystem for different annotation tasks.
Source code in rm_gallery/core/data/annotation/template.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
get_label_config(template_name)
classmethod
Get Label Studio XML configuration from registered template.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template_name
|
str
|
Name of registered template |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
Label Studio XML configuration string if template exists, None otherwise |
Source code in rm_gallery/core/data/annotation/template.py
132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
get_template(name)
classmethod
Retrieve template instance by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Template identifier to look up |
required |
Returns:
Type | Description |
---|---|
Optional[BaseAnnotationTemplate]
|
Template instance if found, None otherwise |
Source code in rm_gallery/core/data/annotation/template.py
119 120 121 122 123 124 125 126 127 128 129 130 |
|
list_templates()
classmethod
List all registered template names.
Returns:
Type | Description |
---|---|
list[str]
|
List of registered template identifiers |
Source code in rm_gallery/core/data/annotation/template.py
146 147 148 149 150 151 152 153 154 |
|
register(name)
classmethod
Decorator for registering annotation templates with unique identifiers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Unique template identifier for registry lookup |
required |
Returns:
Type | Description |
---|---|
Callable[[Type[BaseAnnotationTemplate]], Type[BaseAnnotationTemplate]]
|
Decorator function that registers the template class and returns it unchanged |
Example
@AnnotationTemplateRegistry.register("rewardbench") class RewardBenchTemplate(BaseAnnotationTemplate): ...
Source code in rm_gallery/core/data/annotation/template.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
BaseAnnotationTemplate
Bases: ABC
Abstract base class for annotation templates defining labeling interface and processing logic.
Templates encapsulate Label Studio XML configuration and annotation post-processing for specific evaluation tasks like reward benchmarking or quality assessment.
Attributes:
Name | Type | Description |
---|---|---|
name |
Unique identifier for the template |
Source code in rm_gallery/core/data/annotation/template.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
label_config
abstractmethod
property
Return the Label Studio XML configuration for the annotation interface.
Defines the labeling interface including rating scales, choice options, text areas, and other annotation components specific to the evaluation task.
Returns:
Type | Description |
---|---|
str
|
Label Studio XML configuration string |
__init__(name)
Initialize annotation template with unique identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Unique template name for registry identification |
required |
Source code in rm_gallery/core/data/annotation/template.py
23 24 25 26 27 28 29 30 |
|
process_annotations(annotation_data)
abstractmethod
Process raw annotation data and return structured evaluation results.
Transforms Label Studio annotation output into domain-specific structured data suitable for reward model training or evaluation analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotation_data
|
Dict[str, Any]
|
Raw annotation data from Label Studio containing ratings, choices, text areas, and other annotation components |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Processed annotation data structured for specific evaluation needs |
Dict[str, Any]
|
(e.g., reward scores, preference rankings, quality metrics) |
Source code in rm_gallery/core/data/annotation/template.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
validate_annotation_data(annotation_data)
Validate annotation data structure and completeness (optional override).
Performs sanity checks on annotation data to ensure required fields are present and values are within expected ranges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotation_data
|
Dict[str, Any]
|
Annotation data to validate |
required |
Returns:
Type | Description |
---|---|
bool
|
True if annotation data is valid and complete, False otherwise |
Source code in rm_gallery/core/data/annotation/template.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|