Supervisors¶
Supervision systems wrapped behind a unified Supervisor
interface.
bells_o.supervisors ¶
Impose structure on Class structure.
AutoCustomSupervisor ¶
Class that implements automatic loading of previously implemented supervisor models from HuggingFace.
Source code in src/bells_o/supervisors/custom/auto_model.py
load
classmethod
¶
Load a CustomSupervisor automatically from pre-configured supervisors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
str
|
Model identifier for implemented supervisor model. |
required |
**kwargs
|
Optional keyword arguments to override default parameters. |
{}
|
Source code in src/bells_o/supervisors/custom/auto_model.py
CustomSupervisor ¶
Bases: Supervisor
An abstract class that builds the base for custom supervisors outside of REST or HuggingFace.
Source code in src/bells_o/supervisors/custom/custom_supervisor.py
metadata ¶
Return metadata dictionary for this Supervisor.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Dictionary with metadata. |
Source code in src/bells_o/supervisors/custom/custom_supervisor.py
AutoHuggingFaceSupervisor ¶
Class that implements automatic loading of previously implemented supervisor models from HuggingFace.
Source code in src/bells_o/supervisors/huggingface/auto_model.py
load
classmethod
¶
Load a HuggingFaceSupervisor automatically from pre-configured supervisors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
str
|
Model ID of implemented supervisor model on Huggingface. |
required |
**kwargs
|
Optional keyword arguments to override default parameters. |
{}
|
Source code in src/bells_o/supervisors/huggingface/auto_model.py
HuggingFaceSupervisor ¶
Bases: Supervisor
A concrete class that enables loading any HuggingFace model as a supervisor.
Source code in src/bells_o/supervisors/huggingface/hf_supervisor.py
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 78 79 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
metadata ¶
Return metadata dictionary for this Supervisor.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Dictionary with metadata. |
Source code in src/bells_o/supervisors/huggingface/hf_supervisor.py
pre_process ¶
Apply all preprocessing steps except tokenization.
Source code in src/bells_o/supervisors/huggingface/hf_supervisor.py
judge ¶
Evaluate samples with model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
str | list[str]
|
The sample or batch of samples to be evaluated. |
required |
Returns:
| Type | Description |
|---|---|
list[OutputDict]
|
list[str]: The outputs of the supervisor as a list. |
Source code in src/bells_o/supervisors/huggingface/hf_supervisor.py
AutoRestSupervisor ¶
Class that implements automatic loading of previously implemented supervisor REST APIs.
Source code in src/bells_o/supervisors/rest/auto_endpoint.py
load
classmethod
¶
load(endpoint_name: Literal['lakeraguard-default'], project_id: str, pre_processing: list[PreProcessing] = ..., api_key: str | None = ..., api_variable: str | None = ...) -> LakeraGuardDefaultSupervisor
load(endpoint_name: Literal['lakeraguard-default'] | Literal['lakeraguard'] | str, *args, **kwargs) -> LakeraGuardDefaultSupervisor | LakeraGuardSupervisor | RestSupervisor
Load a RestSupervisor automatically from pre-configured APIs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint_name
|
str
|
name of the endpoint, consult documentation for implemented APIs. |
required |
*args
|
Positional arguments for the class type. |
()
|
|
**kwargs
|
Optional keyword arguments for the instantiated class. |
{}
|
Source code in src/bells_o/supervisors/rest/auto_endpoint.py
RestSupervisor
dataclass
¶
Bases: Supervisor
A concrete class that enables access to supervisors via REST API.
Source code in src/bells_o/supervisors/rest/rest_supervisor.py
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 78 79 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
metadata ¶
Return metadata dictionary for this Supervisor.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Dictionary with metadata. |
Source code in src/bells_o/supervisors/rest/rest_supervisor.py
judge ¶
Evaluate a (batch of) prompt(s simultaneously).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts
|
list[str] | str
|
List of prompts. |
required |
Returns:
| Type | Description |
|---|---|
list[OutputDict]
|
list[OutputDict]: List of outputs and metadata. |
Source code in src/bells_o/supervisors/rest/rest_supervisor.py
Supervisor ¶
Bases: ABC
Abstract base class for Supervisors.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name of the supervisor. |
usage |
Usage
|
The usage type of the supervisor. |
res_map_fn |
ResultMapper
|
Function to map the output to a |
pre_processing |
list[PreProcessing]
|
List of PreProcessing techniques that should be applied. |
provider_name |
str
|
The name of the provider of this model. |
Source code in src/bells_o/supervisors/supervisor.py
10 11 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 78 79 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 | |
metadata ¶
Return metadata dictionary for this Supervisor.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict[str, Any]
|
Dictionary with metadata. |
Source code in src/bells_o/supervisors/supervisor.py
judge
abstractmethod
¶
Run one evaluation on the supervisor.
Similar to forward in PyTorch, it expects prepped inputs s.t.
they can be used directly with the supervisor.
Source code in src/bells_o/supervisors/supervisor.py
pre_process ¶
Apply all preprocessing steps.
Concrete classes will likely need a tokenization equivalent implemented.