Views
No views yet
z = e + α · Up( Dropout( GELU( Down( LN(e) ) ) ) )| Hyperparameter | Value |
|---|---|
Embedding dim d | 30522 |
Bottleneck rank r | 512 |
Residual scale α | 0.01 |
| Use bias | True |
1import torch
2from huggingface_hub import hf_hub_download
3import json
4
5# --- option A: use the from_pretrained helper in this repo ---
6# (copy BottleneckResidualAdapter + from_pretrained from push_to_hub.py)
7adapter = BottleneckResidualAdapter.from_pretrained("KBhandari11/centroid-adapter-splade")
8e = torch.randn(1, 30522) # your backbone embedding
9z = adapter(e) # representation-invariant embedding
10
11# --- option B: hf_hub_download one-liner ---
12from safetensors.torch import load_file
13weights_path = hf_hub_download("KBhandari11/centroid-adapter-splade", "model.safetensors")
14cfg_path = hf_hub_download("KBhandari11/centroid-adapter-splade", "config.json")
15with open(cfg_path) as f:
16 cfg = json.load(f)
17adapter = BottleneckResidualAdapter(**cfg)
18adapter.load_state_dict(load_file(weights_path))
19adapter.eval()