Downloads · 30 days
0
pauvanbr/sae-encoder-embeddings-research
sae-encoder-embeddings-research is a machine learning model from pauvanbr. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Status: Research & Architecture Design Phase Goal: Build the first encoder-only embedding model where the representation layer IS a Sparse Autoencoder, trained end-to-end with contrastive loss.
Downloads · 30 days
0
Access
Public
Updated May 21, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md8 KB · 84%
From the Hugging Face model README
Status: Research & Architecture Design Phase Goal: Build the first encoder-only embedding model where the representation layer IS a Sparse Autoencoder, trained end-to-end with contrastive loss.
A novel embedding architecture that combines:
This produces embeddings that are simultaneously:
| Approach | Training | Interpretable? | Sparse-native? | End-to-end? |
|---|---|---|---|---|
| Dense bi-encoder (e.g., E5, GTE) | Contrastive | ❌ | ❌ | ✅ |
| SPLADE | Distillation + regularizer | ⚠️ (vocab-tied) | ✅ | ✅ |
| Post-hoc SAE on embeddings | Reconstruction only | ✅ | ✅ | ❌ |
| CSR (Beyond Matryoshka) | Contrastive + recon (frozen backbone) | ✅ | ✅ | ❌ (backbone frozen) |
| SPLARE (Mar 2026) | Distillation (KL from cross-encoder) | ✅ | ✅ | ⚠️ (pretrained SAE, frozen LLM) |
| Ours (this project) | Contrastive + recon + FLOPS reg | ✅ | ✅ | ✅ (backbone + SAE jointly) |
Key differentiator: All prior SAE-for-retrieval work either freezes the backbone or freezes the SAE. We train both jointly, meaning the backbone learns to produce representations that are optimally decomposable into sparse interpretable features.
├── README.md # This file
├── ARCHITECTURE.md # Detailed architecture design
├── PAPERS.md # Papers bibliography + key findings
├── TRAINING_RECIPE.md # Full training recipe with hyperparameters
├── src/ # (future) Implementation code
│ ├── model.py # SAE bottleneck + ModernBERT
│ ├── loss.py # Combined loss functions
│ └── train.py # Training script
└── experiments/ # (future) Training logs and results
Input text
│
▼
┌─────────────────────────────────┐
│ ModernBERT-base (768-dim) │ ← Backbone (trainable)
│ - RoPE positional embeddings │
│ - FlashAttention 2 │
│ - GeGLU activations │
│ - Alternating local/global attn│
│ - 8192 token context │
└──────────────┬──────────────────┘
│ mean-pool → v ∈ ℝ^768
▼
┌─────────────────────────────────┐
│ TopK Sparse Autoencoder │ ← SAE Bottleneck (trainable)
│ │
│ Encoder: z = TopK(W_enc(v-b) + b_enc)
│ z ∈ ℝ^16384, ||z||_0 = k (32-128 active)
│ │
│ Decoder: v̂ = W_dec·z + b │ ← For reconstruction loss only
│ (not used at inference)│
└──────────────┬──────────────────┘
│
▼
z (sparse embedding)
Used for retrieval via sparse dot product
| Paper | ArXiv | Relevance |
|---|---|---|
| ModernBERT | 2412.13663 | Backbone architecture |
| TopK SAE (OpenAI) | 2406.04093 | SAE architecture + dead latent prevention |
| CSR (Beyond Matryoshka) | 2503.01776 | Contrastive sparse coding framework |
| SPLARE | 2603.13277 | SAE for retrieval (closest prior work) |
| SPLADE v2 | 2109.10086 | FLOPS regularizer for sparse retrieval |
| EmbeddingGemma | 2509.20354 | GOR spread-out regularizer |
| Nomic Embed v2 MoE | 2502.07972 | MoE encoder embeddings |
| Ettin | 2507.11412 | Encoder vs Decoder comparison |
| Theoretical Limits | 2508.21038 | Why single-vector has capacity limits |
| Disentangling Embeddings (SAE) | 2408.00657 | SAE interpretability for embeddings |
| Interpretable Embed SAE | 2512.10092 | SAE data analysis toolkit |
| Hypencoder | 2502.05364 | Beyond dot-product retrieval |
| RouterRetriever | 2409.02685 | Router + expert models pattern |
This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "pauvanbr/sae-encoder-embeddings-research"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.