Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
tags:
|
| 4 |
+
- table-retrieval
|
| 5 |
+
- embedding-adapter
|
| 6 |
+
- centroid-adapter
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
# Universal Representation Adapter — splade
|
| 10 |
+
|
| 11 |
+
Lightweight **BottleneckResidualAdapter** trained on top of
|
| 12 |
+
[splade](https://huggingface.co/splade) embeddings to produce
|
| 13 |
+
representation-invariant table embeddings.
|
| 14 |
+
|
| 15 |
+
## Architecture
|
| 16 |
+
|
| 17 |
+
```
|
| 18 |
+
z = e + α · Up( Dropout( GELU( Down( LN(e) ) ) ) )
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
| Hyperparameter | Value |
|
| 22 |
+
|---|---|
|
| 23 |
+
| Embedding dim `d` | 30522 |
|
| 24 |
+
| Bottleneck rank `r` | 512 |
|
| 25 |
+
| Residual scale `α` | 0.01 |
|
| 26 |
+
| Use bias | True |
|
| 27 |
+
|
| 28 |
+
Trained on: WTQ, WIKISQL
|
| 29 |
+
|
| 30 |
+
## Usage
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
import torch
|
| 34 |
+
from huggingface_hub import hf_hub_download
|
| 35 |
+
import json
|
| 36 |
+
|
| 37 |
+
# --- option A: use the from_pretrained helper in this repo ---
|
| 38 |
+
# (copy BottleneckResidualAdapter + from_pretrained from push_to_hub.py)
|
| 39 |
+
adapter = BottleneckResidualAdapter.from_pretrained("KBhandari11/centroid-adapter-subset-splade")
|
| 40 |
+
e = torch.randn(1, 30522) # your backbone embedding
|
| 41 |
+
z = adapter(e) # representation-invariant embedding
|
| 42 |
+
|
| 43 |
+
# --- option B: hf_hub_download one-liner ---
|
| 44 |
+
from safetensors.torch import load_file
|
| 45 |
+
weights_path = hf_hub_download("KBhandari11/centroid-adapter-subset-splade", "model.safetensors")
|
| 46 |
+
cfg_path = hf_hub_download("KBhandari11/centroid-adapter-subset-splade", "config.json")
|
| 47 |
+
with open(cfg_path) as f:
|
| 48 |
+
cfg = json.load(f)
|
| 49 |
+
adapter = BottleneckResidualAdapter(**cfg)
|
| 50 |
+
adapter.load_state_dict(load_file(weights_path))
|
| 51 |
+
adapter.eval()
|
| 52 |
+
```
|