Runners
High-level runner functions and their settings for common workflows.
PretrainedSAE
pydantic-model
Bases: BaseModelConfig
Fields:
-
device(str) -
dtype(dtype) -
pretrained_name_or_path(str) -
fold_activation_scale(bool) -
strict_loading(bool)
TrainSAESettings
Bases: BaseSettings
Settings for training a Sparse Autoencoder (SAE).
sae
instance-attribute
sae: BaseSAEConfig | PretrainedSAE
Configuration for the SAE model architecture and parameters, or the path to a pretrained SAE.
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
initializer
class-attribute
instance-attribute
initializer: InitializerConfig | None = None
Configuration for model initialization. Should be None for a pretrained SAE.
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
data_parallel_size
class-attribute
instance-attribute
Size of data parallel mesh
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for MongoDB
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. Mixcoder requires a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
train_sae
train_sae(settings: TrainSAESettings) -> None
Train a SAE model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
TrainSAESettings
|
Configuration settings for SAE training |
required |
Source code in src/lm_saes/runners/train.py
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 | |
TrainCLTSettings
Bases: BaseSettings
Settings for training a Cross Layer Transcoder (CLT). CLT works with multiple layers and their corresponding hook points.
sae
instance-attribute
sae: CLTConfig | PretrainedSAE
Configuration for the CLT model architecture and parameters, or the path to a pretrained CLT.
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
initializer
class-attribute
instance-attribute
initializer: InitializerConfig | None = None
Configuration for model initialization
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
data_parallel_size
class-attribute
instance-attribute
Size of data parallel mesh
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for MongoDB
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. CLT requires a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
train_clt
train_clt(settings: TrainCLTSettings) -> None
Train a Cross Layer Transcoder (CLT) model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
TrainCLTSettings
|
Configuration settings for CLT training |
required |
Source code in src/lm_saes/runners/train.py
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | |
TrainCrossCoderSettings
Bases: BaseSettings
Settings for training a CrossCoder. The main difference to TrainSAESettings is that the activation factory is a list of ActivationFactoryConfig, one for each head.
sae
instance-attribute
sae: CrossCoderConfig | PretrainedSAE
Configuration for the CrossCoder model architecture and parameters, or the path to a pretrained CrossCoder.
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
initializer
class-attribute
instance-attribute
initializer: InitializerConfig | None = None
Configuration for model initialization
activation_factories
instance-attribute
activation_factories: list[ActivationFactoryConfig]
Configuration for generating activations
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
data_parallel_size
class-attribute
instance-attribute
Size of data parallel mesh
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for MongoDB
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. Mixcoder requires a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
train_crosscoder
train_crosscoder(settings: TrainCrossCoderSettings) -> None
Train a CrossCoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
TrainCrossCoderSettings
|
Configuration settings for SAE training |
required |
Source code in src/lm_saes/runners/train.py
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 | |
TrainLorsaSettings
Bases: BaseSettings
Settings for training a Lorsa (Low-Rank Sparse Autoencoder) model.
sae
instance-attribute
sae: LorsaConfig | PretrainedSAE
Configuration for the Lorsa model architecture and parameters, or the path to a pretrained Lorsa.
sae_name
instance-attribute
Name of the Lorsa model. Use as identifier for the Lorsa model in the database.
sae_series
instance-attribute
Series of the Lorsa model. Use as identifier for the Lorsa model in the database.
initializer
class-attribute
instance-attribute
initializer: InitializerConfig | None = None
Configuration for model initialization
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
data_parallel_size
class-attribute
instance-attribute
Size of data parallel mesh
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for MongoDB
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. LORSA may require a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
train_lorsa
train_lorsa(settings: TrainLorsaSettings) -> None
Train a LORSA (Low-Rank Sparse Autoencoder) model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
TrainLorsaSettings
|
Configuration settings for LORSA training |
required |
Source code in src/lm_saes/runners/train.py
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 | |
TrainMOLTSettings
Bases: BaseSettings
Settings for training a Mixture of Linear Transforms (MOLT). MOLT is a more efficient alternative to transcoders that sparsely replaces MLP computation in transformers.
sae
instance-attribute
sae: MOLTConfig | PretrainedSAE
Configuration for the MOLT model architecture and parameters
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
initializer
class-attribute
instance-attribute
initializer: InitializerConfig | None = None
Configuration for model initialization. Should be None for a pretrained MOLT.
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
data_parallel_size
class-attribute
instance-attribute
Size of data parallel mesh
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for MongoDB
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. MOLT requires a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
train_molt
train_molt(settings: TrainMOLTSettings) -> None
Train a Mixture of Linear Transforms (MOLT) model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
TrainMOLTSettings
|
Configuration settings for MOLT training |
required |
Source code in src/lm_saes/runners/train.py
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | |
EvaluateSAESettings
Bases: BaseSettings
Settings for evaluating a Sparse Autoencoder.
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
fold_activation_scale
class-attribute
instance-attribute
Whether to fold the activation scale.
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
evaluate_sae
evaluate_sae(settings: EvaluateSAESettings) -> None
Evaluate a SAE model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
EvaluateSAESettings
|
Configuration settings for SAE evaluation |
required |
Source code in src/lm_saes/runners/eval.py
EvaluateCrossCoderSettings
Bases: BaseSettings
Settings for evaluating a CrossCoder model.
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
activation_factories
instance-attribute
activation_factories: list[ActivationFactoryConfig]
Configuration for generating activations
wandb
class-attribute
instance-attribute
wandb: Optional[WandbConfig] = None
Configuration for Weights & Biases logging
evaluate_crosscoder
evaluate_crosscoder(
settings: EvaluateCrossCoderSettings,
) -> None
Evaluate a CrossCoder model. The key difference to evaluate_sae is that the activation factories are a list of ActivationFactoryConfig, one for each head; and the evaluating contains a device mesh transformation from head parallelism to model (feature) parallelism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
EvaluateCrossCoderSettings
|
Configuration settings for CrossCoder evaluation |
required |
Source code in src/lm_saes/runners/eval.py
AnalyzeSAESettings
Bases: BaseSettings
Settings for analyzing a Sparse Autoencoder.
sae
instance-attribute
sae: PretrainedSAE
Configuration for the SAE model architecture and parameters
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. LORSA may require a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
feature_analysis_name
class-attribute
instance-attribute
Name of the feature analysis.
mongo
class-attribute
instance-attribute
mongo: MongoDBConfig | None = None
Configuration for the MongoDB database.
output_dir
class-attribute
instance-attribute
Directory to save analysis results. Only used if MongoDB client is not provided.
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
analyze_sae
analyze_sae(settings: AnalyzeSAESettings) -> None
Analyze a SAE model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
AnalyzeSAESettings
|
Configuration settings for SAE analysis |
required |
Source code in src/lm_saes/runners/analyze.py
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 | |
AnalyzeCrossCoderSettings
Bases: BaseSettings
Settings for analyzing a CrossCoder model.
sae
instance-attribute
sae: PretrainedSAE
Configuration for the CrossCoder model architecture and parameters
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
activation_factories
instance-attribute
activation_factories: list[ActivationFactoryConfig]
Configuration for generating activations
amp_dtype
class-attribute
instance-attribute
The dtype to use for outputting activations. If None, will not override the dtype.
feature_analysis_name
class-attribute
instance-attribute
Name of the feature analysis.
mongo
class-attribute
instance-attribute
mongo: MongoDBConfig | None = None
Configuration for the MongoDB database.
output_dir
class-attribute
instance-attribute
Directory to save analysis results. Only used if MongoDB client is not provided.
analyze_crosscoder
analyze_crosscoder(
settings: AnalyzeCrossCoderSettings,
) -> None
Analyze a CrossCoder model. The key difference to analyze_sae is that the activation factories are a list of ActivationFactoryConfig, one for each head; and the analyzing contains a device mesh transformation from head parallelism to model (feature) parallelism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
AnalyzeCrossCoderSettings
|
Configuration settings for CrossCoder analysis |
required |
Source code in src/lm_saes/runners/analyze.py
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 | |
GenerateActivationsSettings
Bases: BaseSettings
Settings for activation generation.
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for loading the language model. If None, will read from the database.
model_name
instance-attribute
Name of the model to load. Use as identifier for the model in the database.
dataset
class-attribute
instance-attribute
dataset: Optional[DatasetConfig] = None
Configuration for loading the dataset. If None, will read from the database.
dataset_name
instance-attribute
Name of the dataset. Use as identifier for the dataset in the database.
hook_points
instance-attribute
List of model hook points to capture activations from
target
class-attribute
instance-attribute
target: ActivationFactoryTarget = ACTIVATIONS_2D
Target type for activation generation
model_batch_size
class-attribute
instance-attribute
Batch size for model forward
buffer_size
class-attribute
instance-attribute
Size of the buffer for activation generation
buffer_shuffle
class-attribute
instance-attribute
buffer_shuffle: Optional[BufferShuffleConfig] = None
"Manual seed and device of generator for generating randomperm in buffer
total_tokens
class-attribute
instance-attribute
Optional total number of tokens to generate
context_size
class-attribute
instance-attribute
Context window size for tokenization
n_samples_per_chunk
class-attribute
instance-attribute
Number of samples per saved chunk
num_workers
class-attribute
instance-attribute
Number of workers for parallel writing
format
class-attribute
instance-attribute
Format to save activations in ('pt' or 'safetensors')
n_shards
class-attribute
instance-attribute
Number of shards to split the dataset into. If None, the dataset is split to the world size. Must be larger than the world size.
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for the MongoDB database. If None, will not use the database.
ignore_token_ids
class-attribute
instance-attribute
Tokens to ignore in the activations.
device_type
class-attribute
instance-attribute
Device type to use for distributed training ('cuda' or 'cpu')
override_dtype
class-attribute
instance-attribute
Dtype to override the activations to. If None, will not override the dtype.
model_post_init
Validate configuration after initialization.
Source code in src/lm_saes/runners/generate.py
generate_activations
generate_activations(
settings: GenerateActivationsSettings,
) -> None
Generate and save model activations from a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
GenerateActivationsSettings
|
Configuration settings for activation generation |
required |
Source code in src/lm_saes/runners/generate.py
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 | |
AutoInterpSettings
Bases: BaseSettings
Settings for automatic interpretation of SAE features.
sae_name
instance-attribute
Name of the SAE model to interpret. Use as identifier for the SAE model in the database.
sae_series
instance-attribute
Series of the SAE model to interpret. Use as identifier for the SAE model in the database.
model
instance-attribute
model: LanguageModelConfig
Configuration for the language model used to generate activations.
auto_interp
instance-attribute
Configuration for the auto-interpretation process.
features
class-attribute
instance-attribute
List of specific feature indices to interpret. If None, will interpret all features.
analysis_name
class-attribute
instance-attribute
Name of the analysis to use for interpretation.
auto_interp
auto_interp(settings: AutoInterpSettings)
Synchronous wrapper for interpret_feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
AutoInterpSettings
|
Configuration for feature interpretation |
required |
SweepSAESettings
Bases: BaseSettings
Settings for sweeping a Sparse Autoencoder (SAE).
activation_factory
instance-attribute
activation_factory: ActivationFactoryConfig
Configuration for generating activations
data_parallel_size
class-attribute
instance-attribute
Size of data parallel mesh
model_parallel_size
class-attribute
instance-attribute
Size of model parallel (tensor parallel) mesh
mongo
class-attribute
instance-attribute
mongo: Optional[MongoDBConfig] = None
Configuration for MongoDB
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model. Required if using dataset sources.
model_name
class-attribute
instance-attribute
Name of the tokenizer to load. Mixcoder requires a tokenizer to get the modality indices.
datasets
class-attribute
instance-attribute
datasets: Optional[dict[str, Optional[DatasetConfig]]] = (
None
)
Name to dataset config mapping. Required if using dataset sources.
SweepingItem
pydantic-model
Bases: BaseModel
A single item in a sweeping configuration.
Fields:
-
sae(BaseSAEConfig | PretrainedSAE) -
sae_name(str) -
sae_series(str) -
initializer(InitializerConfig | None) -
trainer(TrainerConfig) -
wandb(Optional[WandbConfig])
sae
pydantic-field
sae: BaseSAEConfig | PretrainedSAE
Configuration for the SAE model architecture and parameters, or the path to a pretrained SAE.
sae_name
pydantic-field
Name of the SAE model. Use as identifier for the SAE model in the database.
sae_series
pydantic-field
Series of the SAE model. Use as identifier for the SAE model in the database.
initializer
pydantic-field
initializer: InitializerConfig | None = None
Configuration for model initialization. Should be None for a pretrained SAE.
sweep_sae
sweep_sae(settings: SweepSAESettings) -> None
Sweep experiments for training SAE models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
SweepSAESettings
|
Configuration settings for SAE sweeping |
required |
Source code in src/lm_saes/runners/train.py
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 | |
DirectLogitAttributeSettings
Bases: BaseSettings
Settings for analyzing a CrossCoder model.
sae
instance-attribute
sae: PretrainedSAE
Configuration for the SAE model architecture and parameters
sae_name
instance-attribute
Name of the SAE model. Use as identifier for the SAE model in the database.
layer_idx
class-attribute
instance-attribute
The index of layer to DLA.
sae_series
instance-attribute
Series of the SAE model. Use as identifier for the SAE model in the database.
model
class-attribute
instance-attribute
model: Optional[LanguageModelConfig] = None
Configuration for the language model.
direct_logit_attributor
instance-attribute
direct_logit_attributor: DirectLogitAttributorConfig
Configuration for the direct logit attributor.
mongo
class-attribute
instance-attribute
mongo: MongoDBConfig | None = None
Configuration for the MongoDB database.
analysis_file
class-attribute
instance-attribute
The analysis results file to be updated. Only used if MongoDB client is not provided.
direct_logit_attribute
direct_logit_attribute(
settings: DirectLogitAttributeSettings,
) -> None
Direct logit attribute a SAE model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
DirectLogitAttributeSettings
|
Configuration settings for DirectLogitAttributor |
required |
Source code in src/lm_saes/runners/analyze.py
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 | |
CheckActivationConsistencySettings
Bases: BaseSettings
Settings for checking activation consistency. It will check if the activations are consistent across different hook points by comparing their token ids.
device
class-attribute
instance-attribute
Device to use for checking activation consistency
num_workers
class-attribute
instance-attribute
Number of workers to use for checking activation consistency
check_activation_consistency
check_activation_consistency(
settings: CheckActivationConsistencySettings,
) -> None
Check activation consistency.