Skip to content

[Feature] Add support for label-supervised SAEs, and evaluate hypothesis generation results on Congress dataset #2

Description

@rmovva

Feature Request

Recall that in HypotheSAEs, our goal is to hypothesize interpretable concepts present in input texts (e.g. Yelp reviews) that predict a target variable (e.g. ratings).

Description

Currently:

  • In Step 1, we train the SAE solely to reconstruct the input text embeddings: this step doesn't use our labels at all.
  • In Step 2, we use the labels to perform feature selection.

Instead:

  • In Step 1, we could use the labels by training the SAE to use its sparse encoding to perform both reconstruction and target prediction.
  • Step 2 would remain the same. As long as we have the reconstruction loss, many of the neurons will not be relevant to the target variable, so we'll still need to select a subset.
  • The relative weighting of the two losses would be a hyperparameter.

Motivation

The hope is that this would encourage more of the SAE's latent neurons to be relevant to the target (e.g., more neurons about different reasons why the service was bad, and fewer neurons about how many times the review used words starting with 'D').

Proposed Solution

One possible implementation:

  • Add a SupervisedSparseAutoencoder class that extends SparseAutoencoder from [sae.py].
  • This will require re-writing the following functions: forward, compute_loss, and fit.
  • The forward pass should compute the latent SAE encoding, and then use the encoding for two tasks: first, to reconstruct the input embedding, and second, to predict y.
  • User will need to pass in labels y and a weight alpha which specifies weight on the supervised loss (set a reasonable default for this based on experiments, ideally).
  • Add a unit test to make sure the implementation works in [test_workflow.py].

Benchmarking

  • Add a notebook running this implementation on the Congress dataset. (Headlines is pairwise, so it may be difficult to adapt the implementation for it; Yelp is relatively "easy", so not as useful.)
  • Follow the structure of [experiment_reproduction.ipynb].
  • If you don't have access to an OpenAI key and would need one to benchmark your implementation, feel free to reply to the issue with a link to your fork showing your progress so far, and I can give you a key.

Notes

I am happy to advise on this. If you have an implementation in progress on a fork, feel free to reply asking for a review or any questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions