karenina.integrations.adele¶
adele
¶
ADeLe (Annotated Demand Levels) integration for Karenina.
This module provides 18 pre-defined LLMRubricTrait objects based on the ADeLe
evaluation framework. Each trait uses kind="literal" with 6 ordinal classes
(levels 0-5) for evaluating various cognitive and processing dimensions.
ADeLe was introduced in
Zhou, L., Pacchiardi, L., MartÃnez-Plumed, F., Collins, K.M., et al. (2025). "General Scales Unlock AI Evaluation with Explanatory and Predictive Power." arXiv:2503.06378. https://arxiv.org/abs/2503.06378 Project: https://kinds-of-intelligence-cfi.github.io/ADELE/
Available Traits (by snake_case name): - attention_and_scan (AS): Attention and scanning requirements - atypicality (AT): Novelty/uniqueness of the task - comprehension_complexity (CEc): Comprehension difficulty - comprehension_evaluation (CEe): Comprehension evaluation difficulty - conceptualization_and_learning (CL): Learning requirements - knowledge_applied_sciences (KNa): Applied sciences knowledge - knowledge_cultural (KNc): Cultural knowledge - knowledge_formal_sciences (KNf): Formal sciences knowledge - knowledge_natural_sciences (KNn): Natural sciences knowledge - knowledge_social_sciences (KNs): Social sciences knowledge - metacognition_relevance (MCr): Metacognitive relevance recognition - metacognition_task_planning (MCt): Metacognitive task planning - metacognition_uncertainty (MCu): Metacognitive uncertainty handling - mind_modelling (MS): Social cognition/mind modelling - logical_reasoning_logic (QLl): Logical reasoning - logical_reasoning_quantitative (QLq): Quantitative reasoning - spatial_physical_understanding (SNs): Spatial/physical understanding - volume (VO): Time/effort required
Usage
Get a single trait¶
from karenina.integrations.adele import get_adele_trait trait = get_adele_trait("attention_and_scan")
Get all traits¶
from karenina.integrations.adele import get_all_adele_traits traits = get_all_adele_traits()
Create a Rubric with ADeLe traits¶
from karenina.integrations.adele import create_adele_rubric rubric = create_adele_rubric() # All 18 traits rubric = create_adele_rubric(["attention_and_scan", "mind_modelling"]) # Selected
List available trait names¶
from karenina.integrations.adele import ADELE_TRAIT_NAMES print(ADELE_TRAIT_NAMES)
Classify questions using ADeLe dimensions¶
from karenina.integrations.adele import QuestionClassifier classifier = QuestionClassifier() result = classifier.classify_single("What is the capital of France?") print(result.scores) # {"attention_and_scan": 0, "volume": 1, ...}
Classes¶
AdeleLevel
dataclass
¶
A single level in an ADeLe rubric (0-5).
Source code in src/karenina/integrations/adele/parser.py
Functions¶
to_class_description
¶
Format level as a single class description string for LLMRubricTrait.
Format: "Level N: Label. Description
Examples: * example1 * example2"
Source code in src/karenina/integrations/adele/parser.py
AdeleRubric
dataclass
¶
A parsed ADeLe rubric with optional header and 6 levels.
Source code in src/karenina/integrations/adele/parser.py
AdeleTraitInfo
¶
Bases: BaseModel
Information about an ADeLe trait for API responses.
Source code in src/karenina/integrations/adele/schemas.py
QuestionClassificationResult
¶
Bases: BaseModel
Result of classifying a single question against ADeLe dimensions.
Source code in src/karenina/integrations/adele/schemas.py
Functions¶
from_checkpoint_metadata
classmethod
¶
from_checkpoint_metadata(
metadata: dict[str, Any],
question_id: str | None = None,
question_text: str = "",
) -> QuestionClassificationResult | None
Create from checkpoint custom_metadata format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
¶ |
dict[str, Any]
|
The custom_metadata dict from a question |
required |
question_id
¶ |
str | None
|
Optional question ID |
None
|
question_text
¶ |
str
|
Optional question text |
''
|
Returns:
| Type | Description |
|---|---|
QuestionClassificationResult | None
|
QuestionClassificationResult if adele_classification exists, else None |
Source code in src/karenina/integrations/adele/schemas.py
get_summary
¶
Get a summary of classifications as trait -> "label (score)" pairs.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary mapping trait names to "label (score)" strings. |
Source code in src/karenina/integrations/adele/schemas.py
to_checkpoint_metadata
¶
Convert to format suitable for storing in checkpoint custom_metadata.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with adele_classification key containing scores, labels, |
dict[str, Any]
|
timestamp, and model. |
Source code in src/karenina/integrations/adele/schemas.py
QuestionClassifier
¶
Classifies questions using ADeLe rubrics via LLM-as-judge.
This classifier evaluates questions against ADeLe (Assessment Dimensions for Language Evaluation) dimensions to characterize their cognitive complexity. Each dimension produces a score from 0-5 corresponding to levels: none, very_low, low, intermediate, high, very_high.
Example usage
classifier = QuestionClassifier() result = classifier.classify_single("What is 2+2?") print(result.scores) # {"attention_and_scan": 0, "volume": 1, ...} print(result.labels) # {"attention_and_scan": "none", "volume": "very_low", ...}
Source code in src/karenina/integrations/adele/classifier.py
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
Attributes¶
Functions¶
__init__
¶
__init__(
llm: LLMPort | None = None,
model_name: str = "claude-haiku-4-5",
provider: str = "anthropic",
temperature: float = 0.0,
interface: str = "langchain",
endpoint_base_url: str | None = None,
endpoint_api_key: str | None = None,
trait_eval_mode: str = "batch",
async_enabled: bool | None = None,
async_max_workers: int | None = None,
*,
model_config: ModelConfig | None = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
llm
¶ |
LLMPort | None
|
Optional pre-initialized LLMPort instance. If not provided, one will be created using model_config or individual params. |
None
|
model_name
¶ |
str
|
Model name to use if llm not provided. Defaults to claude-haiku-4-5 for efficiency. |
'claude-haiku-4-5'
|
provider
¶ |
str
|
Model provider to use if llm not provided. |
'anthropic'
|
temperature
¶ |
float
|
Temperature for LLM calls. Defaults to 0.0 for deterministic classifications. |
0.0
|
interface
¶ |
str
|
The interface to use for model initialization. Supported values: "langchain", "openrouter", "openai_endpoint". Defaults to "langchain". |
'langchain'
|
endpoint_base_url
¶ |
str | None
|
Custom base URL for openai_endpoint interface. Required when interface="openai_endpoint". |
None
|
endpoint_api_key
¶ |
str | None
|
API key for openai_endpoint interface. Required when interface="openai_endpoint". |
None
|
trait_eval_mode
¶ |
str
|
How to evaluate traits for a single question. "batch" - all traits in one LLM call (faster, cheaper) "sequential" - each trait in separate call (potentially more accurate) Defaults to "batch". |
'batch'
|
async_enabled
¶ |
bool | None
|
Whether to run sequential trait evaluations in parallel. If None, reads from KARENINA_ASYNC_ENABLED env var (default: True). |
None
|
async_max_workers
¶ |
int | None
|
Max concurrent workers for parallel execution. If None, reads from KARENINA_ASYNC_MAX_WORKERS env var (default: 2). |
None
|
model_config
¶ |
ModelConfig | None
|
Optional ModelConfig to use for creating the LLM. Takes precedence over individual model params. |
None
|
Source code in src/karenina/integrations/adele/classifier.py
classify_batch
¶
classify_batch(
questions: list[tuple[str, str]],
trait_names: list[str] | None = None,
on_progress: Callable[[int, int], None] | None = None,
) -> dict[str, QuestionClassificationResult]
Classify multiple questions against ADeLe dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
questions
¶ |
list[tuple[str, str]]
|
List of (question_id, question_text) tuples. |
required |
trait_names
¶ |
list[str] | None
|
Optional list of ADeLe trait names to evaluate. If None, evaluates all 18 ADeLe traits. |
None
|
on_progress
¶ |
Callable[[int, int], None] | None
|
Optional callback function(completed, total) for progress updates. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, QuestionClassificationResult]
|
Dictionary mapping question_id to QuestionClassificationResult. |
Source code in src/karenina/integrations/adele/classifier.py
classify_single
¶
classify_single(
question_text: str,
trait_names: list[str] | None = None,
question_id: str | None = None,
) -> QuestionClassificationResult
Classify a single question against ADeLe dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
question_text
¶ |
str
|
The question text to classify. |
required |
trait_names
¶ |
list[str] | None
|
Optional list of ADeLe trait names to evaluate. If None, evaluates all 18 ADeLe traits. |
None
|
question_id
¶ |
str | None
|
Optional ID for the question. |
None
|
Returns:
| Type | Description |
|---|---|
QuestionClassificationResult
|
QuestionClassificationResult with scores, labels, and metadata. |
Source code in src/karenina/integrations/adele/classifier.py
Functions¶
create_adele_rubric
¶
create_adele_rubric(
trait_names: list[str] | None = None,
) -> Rubric
Create a Rubric with specified ADeLe traits (or all if None).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[str] | None
|
List of snake_case trait names to include. If None, includes all 18 ADeLe traits. |
None
|
Returns:
| Type | Description |
|---|---|
Rubric
|
Rubric containing the specified ADeLe traits as llm_traits |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any trait name is not recognized |
Example
All traits¶
rubric = create_adele_rubric() len(rubric.llm_traits) 18
Selected traits¶
rubric = create_adele_rubric(["attention_and_scan", "mind_modelling"]) len(rubric.llm_traits) 2
Source code in src/karenina/integrations/adele/traits.py
get_adele_trait
¶
get_adele_trait(name: str) -> LLMRubricTrait
Get a single ADeLe trait by snake_case name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Snake_case trait name (e.g., "attention_and_scan", "mind_modelling") |
required |
Returns:
| Type | Description |
|---|---|
LLMRubricTrait
|
LLMRubricTrait with kind="literal" |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the trait name is not recognized |
Example
trait = get_adele_trait("attention_and_scan") trait.name 'attention_and_scan' trait.kind 'literal' len(trait.classes) 6
Source code in src/karenina/integrations/adele/traits.py
get_adele_trait_by_code
¶
get_adele_trait_by_code(code: str) -> LLMRubricTrait
Get a single ADeLe trait by its original code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Original ADeLe code (e.g., "AS", "AT", "CEc") |
required |
Returns:
| Type | Description |
|---|---|
LLMRubricTrait
|
LLMRubricTrait with kind="literal" |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the code is not recognized |
Example
trait = get_adele_trait_by_code("AS") trait.name 'attention_and_scan'
Source code in src/karenina/integrations/adele/traits.py
get_all_adele_traits
¶
get_all_adele_traits() -> list[LLMRubricTrait]
Get all 18 ADeLe traits.
Returns:
| Type | Description |
|---|---|
list[LLMRubricTrait]
|
List of 18 LLMRubricTrait objects with kind="literal" |
Example
traits = get_all_adele_traits() len(traits) 18 all(t.kind == "literal" for t in traits) True
Source code in src/karenina/integrations/adele/traits.py
parse_adele_file
¶
parse_adele_file(content: str, code: str) -> AdeleRubric
Parse ADeLe rubric text content into structured format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Raw text content of the rubric file |
required |
|
str
|
File code/identifier (e.g., "AS", "AT", "CEc") |
required |
Returns:
| Type | Description |
|---|---|
AdeleRubric
|
Parsed AdeleRubric with header (if present) and 6 levels |
Raises:
| Type | Description |
|---|---|
ValueError
|
If parsing fails or rubric structure is invalid |