sae-probes 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sae_probes-0.1.1/LICENSE +21 -0
- sae_probes-0.1.1/PKG-INFO +123 -0
- sae_probes-0.1.1/README.md +102 -0
- sae_probes-0.1.1/pyproject.toml +55 -0
- sae_probes-0.1.1/sae_probes/__init__.py +21 -0
- sae_probes-0.1.1/sae_probes/constants.py +8 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/5_hist_fig_ismale_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/66_living-room_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/66_living-room_translations.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/67_social-security_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/6_hist_fig_isamerican_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/73_control-group_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/7_hist_fig_ispolitician_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/87_glue_cola_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/OOD data/90_glue_qnli_OOD.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/100_news_fake.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/101_disease_class.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/102_twt_emotion.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/103_it_tick.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/105_click_bait.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/106_hate_hate.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/107_hate_offensive.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/108_athlete_sport.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/109_ball_ws.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/10_nyc_borough.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/110_aimade_humangpt3.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/111_yelp_data.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/112_amzn_rev.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/113_movie_sent.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/114_nyc_borough_Manhattan.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/115_nyc_borough_Brooklyn.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/116_nyc_borough_Bronx.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/117_us_state_FL.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/118_us_state_CA.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/119_us_state_TX.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/11_us_lat.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/120_us_timezone_Chicago.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/121_us_timezone_New_York.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/122_us_timezone_Los_Angeles.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/123_world_country_United_Kingdom.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/124_world_country_United_States.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/125_world_country_Italy.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/126_art_type_book.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/127_art_type_song.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/128_art_type_movie.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/129_arith_mc_A.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/12_us_long.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/130_temp_cat_Frequency.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/131_temp_cat_Typical Time.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/132_temp_cat_Event Ordering.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/133_context_type_Causality.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/134_context_type_Belief_states.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/135_context_type_Event_duration.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/136_glue_mnli_entailment.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/137_glue_mnli_neutral.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/138_glue_mnli_contradiction.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/139_news_class_Politics.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/13_us_state.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/140_news_class_Technology.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/141_news_class_Entertainment.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/142_cancer_cat_Thyroid_Cancer.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/143_cancer_cat_Lung_Cancer.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/144_cancer_cat_Colon_Cancer.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/145_disease_class_digestive system diseases.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/146_disease_class_cardiovascular diseases.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/147_disease_class_nervous system diseases.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/148_twt_emotion_worry.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/149_twt_emotion_happiness.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/14_us_timezone.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/150_twt_emotion_sadness.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/151_it_tick_HR Support.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/152_it_tick_Hardware.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/153_it_tick_Administrative rights.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/154_athlete_sport_football.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/155_athlete_sport_basketball.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/156_athlete_sport_baseball.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/157_amazon_5star.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/158_code_C.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/159_code_Python.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/15_us_population.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/160_code_HTML.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/161_agnews_0.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/162_agnews_1.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/163_agnews_2.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/16_us_density.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/17_world_country.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/18_world_latitude.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/19_world_longitude.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/20_world_pageviews.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/21_headline_istrump.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/22_headline_isobama.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/23_headline_ischina.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/24_headline_isiran.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/25_headline_year.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/26_headline_isfrontpage.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/27_art_type.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/28_art_year.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/29_art_pageviews.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/2_hist_fig_birthyear.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/30_book_length.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/36_sciq_tf.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/37_arith_mc.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/38_arith_difficulty.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/39_arith_infix.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/3_hist_fig_deathyear.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/40_arith_rpn.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/41_truthqa_tf.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/42_temp_sense.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/43_temp_cat.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/44_phys_tf.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/45_context_ans.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/46_context_type.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/47_reasoning_tf.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/48_cm_correct.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/49_cm_isshort.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/4_hist_fig_age.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/50_deon_isvalid.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/51_just_is.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/52_virtue_is.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/54_cs_tf.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/55_open_qa.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/56_wikidatasex_or_gender.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/57_wikidatais_alive.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/58_wikidatapolitical_party.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/59_wikidata_occupation_isjournalist.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/5_hist_fig_ismale.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/60_wikidata_occupation_isathlete.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/61_wikidata_occupation_isactor.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/62_wikidata_occupation_ispolitician.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/63_wikidata_occupation_issinger.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/64_wikidata_occupation_isresearcher.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/65_high-school.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/66_living-room.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/67_social-security.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/68_credit-card.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/69_blood-pressure.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/6_hist_fig_isamerican.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/70_prime-factors.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/71_social-media.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/72_gene-expression.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/73_control-group.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/74_magnetic-field.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/75_cell-lines.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/76_trial-court.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/77_second-derivative.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/78_north-america.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/79_human-rights.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/7_hist_fig_ispolitician.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/80_side-effects.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/81_public-health.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/82_federal-government.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/83_third-party.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/84_clinical-trials.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/85_mental-health.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/86_social_iqa.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/87_glue_cola.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/88_glue_mnli.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/89_glue_mrpc.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/8_nyc_lat.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/90_glue_qnli.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/91_glue_qqp.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/92_glue_sst2.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/93_glue_stsb.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/94_ai_gen.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/95_toxic_is.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/96_spam_is.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/97_news_class.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/98_cancer_cat.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/99_sci_cat.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/cleaned_data/9_nyc_long.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/data/probing_datasets_MASTER.csv.gz +0 -0
- sae_probes-0.1.1/sae_probes/generate_model_activations.py +245 -0
- sae_probes-0.1.1/sae_probes/generate_sae_activations.py +214 -0
- sae_probes-0.1.1/sae_probes/run_baselines.py +568 -0
- sae_probes-0.1.1/sae_probes/run_sae_evals.py +344 -0
- sae_probes-0.1.1/sae_probes/utils_data.py +333 -0
- sae_probes-0.1.1/sae_probes/utils_hooks.py +23 -0
- sae_probes-0.1.1/sae_probes/utils_tmp.py +18 -0
- sae_probes-0.1.1/sae_probes/utils_training.py +554 -0
sae_probes-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 sae-probes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: sae-probes
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Sparse probing benchmark for Sparse Autoencoders derived from the paper "Are Sparse Autoencoders Useful? A Case Study in Sparse Probing"
|
|
5
|
+
Author: Subhash Kantamneni
|
|
6
|
+
Requires-Python: >=3.10,<4.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Requires-Dist: hf-transfer (>=0.1.9,<0.2.0)
|
|
13
|
+
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
|
14
|
+
Requires-Dist: sae-bench (>=0.4.0,<0.5.0)
|
|
15
|
+
Requires-Dist: sae-lens (>=5.0.0,<7.0.0)
|
|
16
|
+
Requires-Dist: scikit-learn (>=1.6.1,<2.0.0)
|
|
17
|
+
Requires-Dist: transformer-lens (>=2.15.4,<3.0.0)
|
|
18
|
+
Requires-Dist: xgboost (>=3.0.2,<4.0.0)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# SAE Probes Benchmark
|
|
22
|
+
|
|
23
|
+
This repository contains the code for the paper [_Are Sparse Autoencoders Useful? A Case Study in Sparse Probing_](https://arxiv.org/pdf/2502.16681), but has been reformatted into a Python package that will work with any SAE that can be loaded in [SAELens](https://github.com/jbloomAus/SAELens). This makes it easy to use the sparse probing tasks from the paper as a standalone SAE benchmark.
|
|
24
|
+
|
|
25
|
+
# Installation
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
pip install sae-probes
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Running evaluations
|
|
32
|
+
|
|
33
|
+
You can run benchmarks directly; any missing model activations are generated on demand. If you don't pass a `model_cache_path`, a temporary directory is used and cleaned up when the function completes. To persist activations across runs (recommended for repeated experiments), provide a `model_cache_path`.
|
|
34
|
+
|
|
35
|
+
## Training Probes
|
|
36
|
+
|
|
37
|
+
Probes can be trained directly on the model activations (baselines) or on SAE activations. In both cases, the following test data-balance settings are available: `"normal"`, `"scarcity"`, and `"imbalance"`. For more details about these settings, see the original paper. For the most standard sparse-probing benchmark, use the `normal` setting.
|
|
38
|
+
|
|
39
|
+
### SAE Probes
|
|
40
|
+
|
|
41
|
+
The most standard use of this library is as a sparse probing benchmark for SAEs using the `normal` setting. This is demonstrated below:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from sae_probes import run_sae_evals
|
|
45
|
+
from sae_lens import SAE
|
|
46
|
+
|
|
47
|
+
# run the benchmark on a Gemma Scope SAE
|
|
48
|
+
release = "gemma-scope-2b-pt-res-canonical"
|
|
49
|
+
sae_id = "layer_12/width_16k/canonical"
|
|
50
|
+
sae = SAE.from_pretrained(release, sae_id)
|
|
51
|
+
|
|
52
|
+
run_sae_evals(
|
|
53
|
+
sae=sae,
|
|
54
|
+
model_name="gemma-2-2b",
|
|
55
|
+
hook_name="blocks.12.hook_resid_post",
|
|
56
|
+
reg_type="l1",
|
|
57
|
+
setting="normal",
|
|
58
|
+
results_path="/results/output/path",
|
|
59
|
+
# model_cache_path is optional; if omitted, a temp dir is used and cleared after
|
|
60
|
+
model_cache_path="/path/to/saved/activations",
|
|
61
|
+
ks=[1, 16],
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The sparse probing results for each dataset will be saved to `results_path` as a JSON file per dataset.
|
|
66
|
+
|
|
67
|
+
### Baseline Probes
|
|
68
|
+
|
|
69
|
+
You can now run baseline probes using a unified API that matches the SAE evaluation interface:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from sae_probes import run_baseline_evals
|
|
73
|
+
|
|
74
|
+
# Run baseline probes with consistent API
|
|
75
|
+
run_baseline_evals(
|
|
76
|
+
model_name="gemma-2-2b",
|
|
77
|
+
hook_name="blocks.12.hook_resid_post",
|
|
78
|
+
setting="normal", # or "scarcity", "imbalance"
|
|
79
|
+
results_path="/results/output/path",
|
|
80
|
+
# model_cache_path is optional; if omitted, a temp dir is used and cleared after
|
|
81
|
+
model_cache_path="/path/to/saved/activations",
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Output Format
|
|
86
|
+
|
|
87
|
+
Both SAE and baseline probes now save results as **JSON files** with consistent structure:
|
|
88
|
+
|
|
89
|
+
- **SAE results**: `sae_probes_{model_name}/{setting}_setting/{dataset}_{hook_name}_{reg_type}.json`
|
|
90
|
+
- **Baseline results**: `baseline_results_{model_name}/{setting}_setting/{dataset}_{hook_name}_{method}.json`
|
|
91
|
+
|
|
92
|
+
Each JSON file contains a list with metrics and metadata for easy comparison between SAE and baseline approaches.
|
|
93
|
+
|
|
94
|
+
#### Optional: Pre-generating model activations
|
|
95
|
+
|
|
96
|
+
Pre-generating can speed up repeated runs and lets you inspect the saved tensors. It's optional because benchmarks will auto-generate missing activations on their first run if missing.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from sae_probes import generate_dataset_activations
|
|
100
|
+
|
|
101
|
+
generate_dataset_activations(
|
|
102
|
+
model_name="gemma-2-2b", # the TransformerLens name of the model
|
|
103
|
+
hook_names=["blocks.12.hook_resid_post"], # Any TLens hook names
|
|
104
|
+
batch_size=64,
|
|
105
|
+
device="cuda",
|
|
106
|
+
model_cache_path="/path/to/save/activations",
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If you skip pre-generation, the benchmarks will create any missing activations automatically. Passing a `model_cache_path` persists them; if omitted, activations will be written to a temporary directory that is deleted after the run.
|
|
111
|
+
|
|
112
|
+
## Citation
|
|
113
|
+
|
|
114
|
+
If you use this code in your research, please cite:
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
@inproceedings{kantamnenisparse,
|
|
118
|
+
title={Are Sparse Autoencoders Useful? A Case Study in Sparse Probing},
|
|
119
|
+
author={Kantamneni, Subhash and Engels, Joshua and Rajamanoharan, Senthooran and Tegmark, Max and Nanda, Neel},
|
|
120
|
+
booktitle={Forty-second International Conference on Machine Learning}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# SAE Probes Benchmark
|
|
2
|
+
|
|
3
|
+
This repository contains the code for the paper [_Are Sparse Autoencoders Useful? A Case Study in Sparse Probing_](https://arxiv.org/pdf/2502.16681), but has been reformatted into a Python package that will work with any SAE that can be loaded in [SAELens](https://github.com/jbloomAus/SAELens). This makes it easy to use the sparse probing tasks from the paper as a standalone SAE benchmark.
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pip install sae-probes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Running evaluations
|
|
12
|
+
|
|
13
|
+
You can run benchmarks directly; any missing model activations are generated on demand. If you don't pass a `model_cache_path`, a temporary directory is used and cleaned up when the function completes. To persist activations across runs (recommended for repeated experiments), provide a `model_cache_path`.
|
|
14
|
+
|
|
15
|
+
## Training Probes
|
|
16
|
+
|
|
17
|
+
Probes can be trained directly on the model activations (baselines) or on SAE activations. In both cases, the following test data-balance settings are available: `"normal"`, `"scarcity"`, and `"imbalance"`. For more details about these settings, see the original paper. For the most standard sparse-probing benchmark, use the `normal` setting.
|
|
18
|
+
|
|
19
|
+
### SAE Probes
|
|
20
|
+
|
|
21
|
+
The most standard use of this library is as a sparse probing benchmark for SAEs using the `normal` setting. This is demonstrated below:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from sae_probes import run_sae_evals
|
|
25
|
+
from sae_lens import SAE
|
|
26
|
+
|
|
27
|
+
# run the benchmark on a Gemma Scope SAE
|
|
28
|
+
release = "gemma-scope-2b-pt-res-canonical"
|
|
29
|
+
sae_id = "layer_12/width_16k/canonical"
|
|
30
|
+
sae = SAE.from_pretrained(release, sae_id)
|
|
31
|
+
|
|
32
|
+
run_sae_evals(
|
|
33
|
+
sae=sae,
|
|
34
|
+
model_name="gemma-2-2b",
|
|
35
|
+
hook_name="blocks.12.hook_resid_post",
|
|
36
|
+
reg_type="l1",
|
|
37
|
+
setting="normal",
|
|
38
|
+
results_path="/results/output/path",
|
|
39
|
+
# model_cache_path is optional; if omitted, a temp dir is used and cleared after
|
|
40
|
+
model_cache_path="/path/to/saved/activations",
|
|
41
|
+
ks=[1, 16],
|
|
42
|
+
)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The sparse probing results for each dataset will be saved to `results_path` as a JSON file per dataset.
|
|
46
|
+
|
|
47
|
+
### Baseline Probes
|
|
48
|
+
|
|
49
|
+
You can now run baseline probes using a unified API that matches the SAE evaluation interface:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from sae_probes import run_baseline_evals
|
|
53
|
+
|
|
54
|
+
# Run baseline probes with consistent API
|
|
55
|
+
run_baseline_evals(
|
|
56
|
+
model_name="gemma-2-2b",
|
|
57
|
+
hook_name="blocks.12.hook_resid_post",
|
|
58
|
+
setting="normal", # or "scarcity", "imbalance"
|
|
59
|
+
results_path="/results/output/path",
|
|
60
|
+
# model_cache_path is optional; if omitted, a temp dir is used and cleared after
|
|
61
|
+
model_cache_path="/path/to/saved/activations",
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Output Format
|
|
66
|
+
|
|
67
|
+
Both SAE and baseline probes now save results as **JSON files** with consistent structure:
|
|
68
|
+
|
|
69
|
+
- **SAE results**: `sae_probes_{model_name}/{setting}_setting/{dataset}_{hook_name}_{reg_type}.json`
|
|
70
|
+
- **Baseline results**: `baseline_results_{model_name}/{setting}_setting/{dataset}_{hook_name}_{method}.json`
|
|
71
|
+
|
|
72
|
+
Each JSON file contains a list with metrics and metadata for easy comparison between SAE and baseline approaches.
|
|
73
|
+
|
|
74
|
+
#### Optional: Pre-generating model activations
|
|
75
|
+
|
|
76
|
+
Pre-generating can speed up repeated runs and lets you inspect the saved tensors. It's optional because benchmarks will auto-generate missing activations on their first run if missing.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from sae_probes import generate_dataset_activations
|
|
80
|
+
|
|
81
|
+
generate_dataset_activations(
|
|
82
|
+
model_name="gemma-2-2b", # the TransformerLens name of the model
|
|
83
|
+
hook_names=["blocks.12.hook_resid_post"], # Any TLens hook names
|
|
84
|
+
batch_size=64,
|
|
85
|
+
device="cuda",
|
|
86
|
+
model_cache_path="/path/to/save/activations",
|
|
87
|
+
)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If you skip pre-generation, the benchmarks will create any missing activations automatically. Passing a `model_cache_path` persists them; if omitted, activations will be written to a temporary directory that is deleted after the run.
|
|
91
|
+
|
|
92
|
+
## Citation
|
|
93
|
+
|
|
94
|
+
If you use this code in your research, please cite:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
@inproceedings{kantamnenisparse,
|
|
98
|
+
title={Are Sparse Autoencoders Useful? A Case Study in Sparse Probing},
|
|
99
|
+
author={Kantamneni, Subhash and Engels, Joshua and Rajamanoharan, Senthooran and Tegmark, Max and Nanda, Neel},
|
|
100
|
+
booktitle={Forty-second International Conference on Machine Learning}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "sae-probes"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "Sparse probing benchmark for Sparse Autoencoders derived from the paper \"Are Sparse Autoencoders Useful? A Case Study in Sparse Probing\""
|
|
5
|
+
authors = ["Subhash Kantamneni", "Joshua Engels"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
packages = [{ include = "sae_probes" }]
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = ">=3.10,<4.0"
|
|
11
|
+
transformer-lens = "^2.15.4"
|
|
12
|
+
sae-lens = ">=5.0.0,<7.0.0"
|
|
13
|
+
scikit-learn = "^1.6.1"
|
|
14
|
+
pandas = "^2.2.3"
|
|
15
|
+
sae-bench = "^0.4.0"
|
|
16
|
+
xgboost = "^3.0.2"
|
|
17
|
+
hf-transfer = "^0.1.9"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[tool.poetry.group.dev.dependencies]
|
|
21
|
+
pytest = "^8.3.5"
|
|
22
|
+
ruff = "^0.11.11"
|
|
23
|
+
pyright = "^1.1.401"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
[tool.isort]
|
|
27
|
+
profile = "black"
|
|
28
|
+
|
|
29
|
+
[tool.ruff]
|
|
30
|
+
exclude = ["dist", "docs", "*.ipynb", "tests/_comparison"]
|
|
31
|
+
|
|
32
|
+
[tool.ruff.lint]
|
|
33
|
+
ignore = ["E203", "E501", "E731"]
|
|
34
|
+
extend-select = ["UP", "TID", "I", "F", "E", "ARG"]
|
|
35
|
+
|
|
36
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
|
37
|
+
"typing.Union".msg = "Use `|` instead"
|
|
38
|
+
"typing.Optional".msg = "Use `| None` instead"
|
|
39
|
+
"typing.Dict".msg = "Use `dict` instead"
|
|
40
|
+
"typing.Tuple".msg = "Use `tuple` instead"
|
|
41
|
+
"typing.List".msg = "Use `list` instead"
|
|
42
|
+
|
|
43
|
+
[tool.pyright]
|
|
44
|
+
typeCheckingMode = "basic"
|
|
45
|
+
ignore = ["tests/_comparison"]
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["poetry-core"]
|
|
49
|
+
build-backend = "poetry.core.masonry.api"
|
|
50
|
+
|
|
51
|
+
[tool.semantic_release]
|
|
52
|
+
version_variables = ["sae_probes/__init__.py:__version__"]
|
|
53
|
+
version_toml = ["pyproject.toml:tool.poetry.version"]
|
|
54
|
+
build_command = "pip install poetry && poetry build"
|
|
55
|
+
branches = { main = { match = "main" }, alpha = { match = "alpha", prerelease = true }, beta = { match = "beta", prerelease = true } }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
__version__ = "0.1.1"
|
|
2
|
+
|
|
3
|
+
from .generate_model_activations import generate_dataset_activations
|
|
4
|
+
from .run_baselines import (
|
|
5
|
+
run_all_baseline_class_imbalance,
|
|
6
|
+
run_all_baseline_corrupt,
|
|
7
|
+
run_all_baseline_normal,
|
|
8
|
+
run_all_baseline_scarcity,
|
|
9
|
+
run_baseline_evals,
|
|
10
|
+
)
|
|
11
|
+
from .run_sae_evals import run_sae_evals
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"generate_dataset_activations",
|
|
15
|
+
"run_sae_evals",
|
|
16
|
+
"run_baseline_evals",
|
|
17
|
+
"run_all_baseline_class_imbalance",
|
|
18
|
+
"run_all_baseline_corrupt",
|
|
19
|
+
"run_all_baseline_normal",
|
|
20
|
+
"run_all_baseline_scarcity",
|
|
21
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
sae_probes-0.1.1/sae_probes/data/cleaned_data/145_disease_class_digestive system diseases.csv.gz
ADDED
|
Binary file
|
sae_probes-0.1.1/sae_probes/data/cleaned_data/146_disease_class_cardiovascular diseases.csv.gz
ADDED
|
Binary file
|
sae_probes-0.1.1/sae_probes/data/cleaned_data/147_disease_class_nervous system diseases.csv.gz
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|