Configuration
RecDistillery experiments are assembled from YAML configuration files. The config tree separates reusable defaults from complete experiment definitions.
Config Layout
config/
dataset/ dataset definitions
teacher/ teacher model defaults
student/ student model defaults
distillation/ distiller defaults
optimization/ optimizer and scheduler defaults
runtime/ runtime options
evaluation/ metric and top-k defaults
composites/ reusable experiment templates
experiments/ complete runnable experiments
Complete Experiments
Config Integration
RecDistill configuration integration with the new centralized config system.
load_recdistill_config_from_file(config_path: Union[str, Path]) -> RecDistillConfig
Load and validate RecDistill configuration from YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Union[str, Path]
|
Path to configuration YAML file |
required |
Returns:
| Type | Description |
|---|---|
RecDistillConfig
|
Validated RecDistillConfig object |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config file doesn't exist |
ValidationError
|
If config doesn't match schema |
Source code in recdistill/config_integration.py
load_recdistill_experiment(dataset_name: str, teacher_model: str, distiller_strategy: str, student_backbone: Optional[str] = None, teacher_framework: str = 'recbole', student_framework: str = 'recbole', overrides: Optional[Dict[str, Any]] = None) -> RecDistillConfig
Programmatically load RecDistill experiment with centralized configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Dataset name (amazon_cd, bookcrossing, citeulike) |
required |
teacher_model
|
str
|
Teacher model (bprmf, nmf, lgcn) |
required |
distiller_strategy
|
str
|
Distillation strategy (de, htd, ftd, unkd) |
required |
student_backbone
|
Optional[str]
|
Student backbone (default: same as teacher) |
None
|
overrides
|
Optional[Dict[str, Any]]
|
Dict of configuration overrides |
None
|
Returns:
| Type | Description |
|---|---|
RecDistillConfig
|
Validated RecDistillConfig object |
Example
config = load_recdistill_experiment( ... dataset_name='citeulike', ... teacher_model='nmf', ... distiller_strategy='de', ... overrides={ ... 'distill_student.optimization.epochs': 50, ... 'distill_student.runtime.seed': 123 ... } ... )
Source code in recdistill/config_integration.py
normalize_recdistill_config(config: Dict[str, Any]) -> Dict[str, Any]
Normalize RecDistill config dictionaries into RecDistillConfig shape.
Source code in recdistill/config_integration.py
recdistill_config_to_dict(config: Union[RecDistillConfig, Dict[str, Any]]) -> Dict[str, Any]
Return a plain normalized dictionary for runner code.
Source code in recdistill/config_integration.py
get_default_dataset_path(dataset_name: str, file_type: str = 'train') -> str
Get default data path for a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Dataset name |
required |
file_type
|
str
|
'train', 'val', or 'test' |
'train'
|
Returns:
| Type | Description |
|---|---|
str
|
Path to dataset file |
Example
path = get_default_dataset_path('citeulike', 'train') print(path) data/citeulike/train.tsv
Source code in recdistill/config_integration.py
print_config_summary(config: RecDistillConfig) -> None
Print a summary of RecDistill configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RecDistillConfig
|
RecDistillConfig object |
required |
Source code in recdistill/config_integration.py
validate_config(config: RecDistillConfig) -> bool
Validate RecDistill configuration for common issues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
RecDistillConfig
|
RecDistillConfig object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if configuration is valid, False otherwise |
Source code in recdistill/config_integration.py
list_example_experiments() -> None
Print available pre-configured experiments.
Source code in recdistill/config_integration.py
Config Loader
Configuration loader with validation. Centralizes loading and validation of all configuration files.
ConfigLoader
Unified configuration loader for RecDistill.
Source code in config/config_loader.py
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 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 | |
root = Path(config_root)
instance-attribute
__init__(config_root: Optional[Path] = None)
Initialize config loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_root
|
Optional[Path]
|
Root directory for config files. Defaults to ./config |
None
|
Source code in config/config_loader.py
load_module_config(module_path: Union[str, Path], overrides: Optional[Dict[str, Any]] = None) -> Dict[str, Any]
Load a module config and apply optional overrides.
Source code in config/config_loader.py
resolve_config_modules(config: Any) -> Any
Resolve default: path/to/module.yaml sections recursively.
Paths may be absolute or relative to the config root. Sibling keys in the same mapping override the loaded defaults.
Source code in config/config_loader.py
load_recdistill_config(config_path: Union[str, Path]) -> RecDistillConfig
Load and validate RecDistill configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Union[str, Path]
|
Path to RecDistill config YAML file |
required |
Returns:
| Type | Description |
|---|---|
RecDistillConfig
|
Validated RecDistillConfig object |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config file doesn't exist |
ValidationError
|
If config doesn't match schema |
Source code in config/config_loader.py
load_preset(preset_path: Union[str, Path]) -> ConfigPreset
Load a wrapped experiment preset.
Presets preserve provenance metadata under preset and keep the actual
training payload under config.
Source code in config/config_loader.py
load_recdistill_preset(preset_path: Union[str, Path]) -> RecDistillConfig
Load a RecDistill preset and validate its inner config.
Source code in config/config_loader.py
load_dataset_config(dataset_name: str) -> DataConfig
Load dataset configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Name of dataset (amazon_cd, bookcrossing, citeulike) |
required |
Returns:
| Type | Description |
|---|---|
DataConfig
|
Validated DataConfig object |
Source code in config/config_loader.py
load_model_config(model_type: str, model_name: str, framework: str | None = None) -> ModelConfig
Load model configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_type
|
str
|
Type of model ('teacher' or 'student') |
required |
model_name
|
str
|
Name of model (bprmf, nmf, lgcn, etc.) |
required |
Returns:
| Type | Description |
|---|---|
ModelConfig
|
Validated ModelConfig object |
Source code in config/config_loader.py
compose_teacher_training(dataset_name: str, model_name: str, framework: str = 'recbole', model_type: str = 'teacher') -> Dict[str, Any]
Compose a generic teacher training configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Dataset name |
required |
model_name
|
str
|
Model name |
required |
framework
|
str
|
Framework implementation to use |
'recbole'
|
model_type
|
str
|
Model family to load ('teacher' or 'student') |
'teacher'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Complete teacher training configuration dictionary |
Source code in config/config_loader.py
compose_student_training(dataset_name: str, model_name: str, framework: str = 'recbole', model_type: str = 'student') -> Dict[str, Any]
Compose a generic plain-student training configuration.
Source code in config/config_loader.py
save_generated_experiment(*, kind: str, name: str, config: Dict[str, Any], path_parts: list[str], experiment_id: str | None = None) -> Path
Persist an on-the-fly composed config as an experiment file.
Source code in config/config_loader.py
save_generated_preset(*, kind: str, family: str, name: str, config: Dict[str, Any], path_parts: list[str]) -> Path
Backward-compatible alias for saving generated experiment configs.
Source code in config/config_loader.py
compose_recdistill_experiment(dataset_name: str, teacher_model: str, distiller_strategy: str, student_backbone: str = None, teacher_framework: str = 'recbole', student_framework: str = 'recbole') -> Dict[str, Any]
Compose a complete RecDistill experiment configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_name
|
str
|
Dataset name |
required |
teacher_model
|
str
|
Teacher model (bprmf, nmf, lgcn) |
required |
distiller_strategy
|
str
|
Distillation strategy (de, htd, ftd, unkd) |
required |
student_backbone
|
str
|
Student backbone (default: same as teacher) |
None
|
teacher_framework
|
str
|
Framework used to resolve the teacher model config |
'recbole'
|
student_framework
|
str
|
Framework used to resolve the student backbone config |
'recbole'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Complete distillation configuration dictionary |
Source code in config/config_loader.py
clear_cache()
list_datasets() -> list[str]
list_models(model_type: str = None) -> Dict[str, list[str]]
List available models by type.
Source code in config/config_loader.py
list_distillers() -> list[str]
list_presets(kind: Optional[str] = None) -> list[str]
list_experiments(kind: Optional[str] = None) -> list[str]
List experiment files relative to config/experiments.
Source code in config/config_loader.py
get_config_loader(config_root: Optional[Path] = None) -> ConfigLoader
Get or create global config loader instance.
Source code in config/config_loader.py
Schemas
Pydantic schemas for configuration validation. Centralizes all configuration structure definitions for Elliot and RecDistill.
DataConfig
Bases: BaseModel
Dataset configuration.
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
name: str = Field(..., description='Dataset name (amazon_cd, bookcrossing, citeulike)')
class-attribute
instance-attribute
train_path: str = Field(..., description='Path to training data')
class-attribute
instance-attribute
test_path: str = Field(..., description='Path to test data')
class-attribute
instance-attribute
validation_path: Optional[str] = Field(default=None, description='Path to validation data')
class-attribute
instance-attribute
side_information: Optional[Dict[str, Any]] = Field(default=None)
class-attribute
instance-attribute
validate_existing_dataset_path(value: Optional[str]) -> Optional[str]
classmethod
Source code in config/schemas.py
ModelConfig
Bases: BaseModel
Model configuration (common for Teacher/Student).
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
framework: str = Field(default='recbole', description='Framework implementation (recbole, elliot, lenskit)')
class-attribute
instance-attribute
backbone: Optional[str] = Field(default=None, description='Student backbone (BPRMF, NMF, NGCF, LGCN, etc.)')
class-attribute
instance-attribute
model: Optional[str] = Field(default=None, description='Teacher model (BPRMF, NMF, NGCF, LGCN, etc.)')
class-attribute
instance-attribute
embedding_dim: int = Field(..., description='Embedding dimension')
class-attribute
instance-attribute
learning_rate: float = Field(default=0.001)
class-attribute
instance-attribute
l2_reg: float = Field(default=0.0001)
class-attribute
instance-attribute
dropout: float = Field(default=0.0)
class-attribute
instance-attribute
factors: Optional[int] = Field(default=None)
class-attribute
instance-attribute
normalize_model_name() -> ModelConfig
Source code in config/schemas.py
normalize_optional_model_name(value: Optional[str]) -> Optional[str]
classmethod
OptimizationConfig
Bases: BaseModel
Training optimization parameters.
Source code in config/schemas.py
epochs: int = Field(default=100)
class-attribute
instance-attribute
batch_size: int = Field(default=512)
class-attribute
instance-attribute
learning_rate: float = Field(default=0.001)
class-attribute
instance-attribute
l2_reg: float = Field(default=0.0001)
class-attribute
instance-attribute
early_stopping: EarlyStoppingConfig = Field(default_factory=(lambda: EarlyStoppingConfig()))
class-attribute
instance-attribute
bayesian: Dict[str, Any] = Field(default_factory=(lambda: {'enabled': False}))
class-attribute
instance-attribute
EvaluationConfig
Bases: BaseModel
Evaluation configuration.
Source code in config/schemas.py
cutoffs: List[int] = Field(default=[10, 20, 50])
class-attribute
instance-attribute
k: int = Field(default=20)
class-attribute
instance-attribute
every: int = Field(default=5)
class-attribute
instance-attribute
batch_size: int = Field(default=1024)
class-attribute
instance-attribute
simple_metrics: List[str] = Field(default=['nDCGRendle2020', 'Recall', 'Precision', 'HR'])
class-attribute
instance-attribute
val_only: bool = Field(default=True)
class-attribute
instance-attribute
selection_split: str = Field(default='val')
class-attribute
instance-attribute
selection_metric: str = Field(default='ndcg')
class-attribute
instance-attribute
enabled: bool = Field(default=True)
class-attribute
instance-attribute
assert_no_train_leak: bool = Field(default=True)
class-attribute
instance-attribute
relevance_threshold: int = Field(default=0)
class-attribute
instance-attribute
validate_selection_split(value: str) -> str
classmethod
Source code in config/schemas.py
validate_selection_metric(value: str) -> str
classmethod
Source code in config/schemas.py
validate_selection_policy() -> EvaluationConfig
EarlyStoppingConfig
Bases: BaseModel
Early stopping configuration.
Source code in config/schemas.py
enabled: bool = Field(default=True)
class-attribute
instance-attribute
mode: str = Field(default='val_metric')
class-attribute
instance-attribute
metric: str = Field(default='ndcg')
class-attribute
instance-attribute
patience: int = Field(default=10)
class-attribute
instance-attribute
min_delta: float = Field(default=0.0)
class-attribute
instance-attribute
warmup: int = Field(default=0)
class-attribute
instance-attribute
restore_best: bool = Field(default=False)
class-attribute
instance-attribute
RuntimeConfig
Bases: BaseModel
Runtime configuration.
Source code in config/schemas.py
seed: int = Field(default=42)
class-attribute
instance-attribute
device: Optional[str] = Field(default=None)
class-attribute
instance-attribute
num_workers: int = Field(default=4)
class-attribute
instance-attribute
output_path: Optional[str] = Field(default=None)
class-attribute
instance-attribute
output_strategy: str = Field(default='fixed')
class-attribute
instance-attribute
save_every: int = Field(default=0)
class-attribute
instance-attribute
wandb: Dict[str, Any] = Field(default_factory=(lambda: {'enabled': False}))
class-attribute
instance-attribute
extra_args: List[str] = Field(default_factory=list)
class-attribute
instance-attribute
DistillerConfig
Bases: BaseModel
Knowledge distillation configuration.
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
strategy: str = Field(..., description='Distillation strategy (DE, HTD, FTD, UnKD, etc.)')
class-attribute
instance-attribute
temperature: float = Field(default=3.0)
class-attribute
instance-attribute
lambda_kl: float = Field(default=0.5)
class-attribute
instance-attribute
lambda_de: float = Field(default=0.1)
class-attribute
instance-attribute
num_experts: int = Field(default=20)
class-attribute
instance-attribute
unkd: Optional[Dict[str, Any]] = Field(default=None)
class-attribute
instance-attribute
normalize_strategy(value: str) -> str
classmethod
Source code in config/schemas.py
TeacherConfig
Bases: BaseModel
Teacher model configuration.
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
model: str = Field(...)
class-attribute
instance-attribute
embedding_dim: Optional[int] = Field(default=None)
class-attribute
instance-attribute
path: Optional[str] = Field(default=None)
class-attribute
instance-attribute
framework: str = Field(default='auto')
class-attribute
instance-attribute
format: str = Field(default='auto')
class-attribute
instance-attribute
StudentConfig
Bases: BaseModel
Student model configuration.
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
framework: str = Field(default='recbole')
class-attribute
instance-attribute
backbone: str = Field(...)
class-attribute
instance-attribute
embedding_dim: int = Field(...)
class-attribute
instance-attribute
lambda_de: float = Field(default=0.1)
class-attribute
instance-attribute
num_experts: int = Field(default=20)
class-attribute
instance-attribute
temperature: float = Field(default=0.1)
class-attribute
instance-attribute
DistillStudentTrainingConfig
Bases: BaseModel
RecDistill student training configuration.
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
dataset: str = Field(...)
class-attribute
instance-attribute
teacher: TeacherConfig = Field(...)
class-attribute
instance-attribute
student: StudentConfig = Field(...)
class-attribute
instance-attribute
optimization: OptimizationConfig = Field(...)
class-attribute
instance-attribute
distillation: DistillerConfig = Field(...)
class-attribute
instance-attribute
runtime: RuntimeConfig = Field(...)
class-attribute
instance-attribute
evaluation: EvaluationConfig = Field(...)
class-attribute
instance-attribute
validate_cross_config_contracts() -> DistillStudentTrainingConfig
Source code in config/schemas.py
RecDistillConfig
Bases: BaseModel
Root RecDistill configuration.
Source code in config/schemas.py
distill_student: DistillStudentTrainingConfig = Field(...)
class-attribute
instance-attribute
PresetMetadata
Bases: BaseModel
Metadata for experiment presets.
Source code in config/schemas.py
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
schema_version: int = Field(default=1)
class-attribute
instance-attribute
kind: str = Field(..., description='Preset kind, for example recdistill, teacher, student, or raw')
class-attribute
instance-attribute
family: str = Field(..., description='Logical preset family')
class-attribute
instance-attribute
ConfigPreset
Bases: BaseModel
Wrapped preset preserving config plus metadata.