pulsatrix 1.1.0
Loading...
Searching...
No Matches
crosscoder.hpp File Reference

Crosscoders (FEAT-8): one sparse dictionary read from and written to several sources at once, such as the residual stream at several layers, or the same layer in a base model and its fine-tune (Lindsey et al., "Sparse Crosscoders for Cross-Layer Features and Model Diffing", Transformer Circuits, 2024). Model diffing reads which latents' decoders live in one model only, with Minder et al.'s BatchTopK crosscoder and Latent Scaling ("Overcoming Sparsity Artifacts in Crosscoders to Interpret Chat-Tuning", arXiv 2504.02922), and Kassem et al.'s Delta-Crosscoder for narrow fine-tunes ("Delta- Crosscoder: Robust Crosscoder Model Diffing in Narrow Fine-Tuning Regimes", arXiv 2603.04426). More...

#include <cstdint>
#include <optional>
#include <vector>
#include "pulsatrix/featurizer.hpp"
#include "pulsatrix/linear_module.hpp"
Include dependency graph for crosscoder.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::CrosscoderOptions
 
class  pulsatrix::Crosscoder
 A crosscoder over S sources of the same size d. Its input is the sources side by side, (N, S·d), source s in columns [s·d, (s+1)·d): f = ReLU(Σ_s x^s W_enc^s + b_enc), x̂^s = f W_dec^s + b_dec^s. More...
 
struct  pulsatrix::CrosscoderLatentStats
 One latent across two sources a and b. More...
 
struct  pulsatrix::LatentScaling
 Latent Scaling (Minder et al., Eq. 4): how much of latent j's b-side decoder direction each source actually needs. For a target Y^m over the inputs where it's computed, β^m = ⟨Y^m d, f⟩ / (|f|² |d|²) with d = d_j^b, the best scale of f d against Y^m. More...
 

Namespaces

namespace  pulsatrix
 

Enumerations

enum class  pulsatrix::CrosscoderSparsity { pulsatrix::L1 , pulsatrix::BatchTopK }
 
enum class  pulsatrix::LatentClass { pulsatrix::AOnly , pulsatrix::BOnly , pulsatrix::Shared , pulsatrix::Other }
 

Functions

std::vector< CrosscoderLatentStats > pulsatrix::CrosscoderLatents (Crosscoder &crosscoder, int64_t a=0, int64_t b=1)
 Every latent's stats for sources a and b.
 
LatentClass pulsatrix::ClassifyLatent (const CrosscoderLatentStats &stats)
 Minder et al.'s bins on Δnorm.
 
std::vector< LatentScaling > pulsatrix::MeasureLatentScaling (Crosscoder &crosscoder, const Tensor &x, const std::vector< int64_t > &latents, int64_t a=0, int64_t b=1, int64_t batch=4096)
 Latent Scaling of each of latents on x, (N, S·d), in batches of batch. β is 0 (and ν 0) for a latent that never fires.
 
std::vector< double > pulsatrix::ExplainedVarianceBySource (Crosscoder &crosscoder, const Tensor &x, int64_t batch=4096)
 Each source's explained variance on x: 1 - Σ|x^s - x̂^s|² / Σ|x^s - mean(x^s)|².
 

Detailed Description

Crosscoders (FEAT-8): one sparse dictionary read from and written to several sources at once, such as the residual stream at several layers, or the same layer in a base model and its fine-tune (Lindsey et al., "Sparse Crosscoders for Cross-Layer Features and Model Diffing", Transformer Circuits, 2024). Model diffing reads which latents' decoders live in one model only, with Minder et al.'s BatchTopK crosscoder and Latent Scaling ("Overcoming Sparsity Artifacts in Crosscoders to Interpret Chat-Tuning", arXiv 2504.02922), and Kassem et al.'s Delta-Crosscoder for narrow fine-tunes ("Delta- Crosscoder: Robust Crosscoder Model Diffing in Narrow Fine-Tuning Regimes", arXiv 2603.04426).