Feature Extraction
Transformers
TensorBoard
Safetensors
English
captionbert_v2
sentence-similarity
consensus-distillation
geometric-deep-learning
amoe
custom_code
Instructions to use AbstractPhil/captionbert-8192-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AbstractPhil/captionbert-8192-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="AbstractPhil/captionbert-8192-v2", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AbstractPhil/captionbert-8192-v2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
step 500
Browse files
amoe/sts-combo/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags: [amoe, adapter, sentence-similarity, captionbert, aleph]
|
| 4 |
+
base_model: AbstractPhil/captionbert-8192-v2
|
| 5 |
+
library_name: amoe-lora
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
# captionbert-8192-v2 :: AMOE sentence-similarity anchor
|
| 9 |
+
|
| 10 |
+
An [amoe-lora](https://github.com/AbstractEyes/amoe-lora) aleph anchor trained on
|
| 11 |
+
the **frozen** `captionbert-8192-v2` trunk. The trunk never moves; only the
|
| 12 |
+
adapters train.
|
| 13 |
+
|
| 14 |
+
**This anchor is inert without its trunk.** It rewrites the residual stream of
|
| 15 |
+
specific blocks of this model and means nothing anywhere else, which is why it
|
| 16 |
+
ships here rather than as a standalone adapter repo.
|
| 17 |
+
|
| 18 |
+
## Why it exists
|
| 19 |
+
|
| 20 |
+
The trunk is an unsupervised consensus distillation of five BERT-family teachers.
|
| 21 |
+
Measured at release: the consensus target uses **28.7 of 768** directions, the
|
| 22 |
+
trunk uses **102.9 in domain** but only **~33 on STS-B**, so the extra structure
|
| 23 |
+
it built on CC12M captions does not transfer. This anchor asks whether
|
| 24 |
+
supervision can add transferable directions the unsupervised consensus never had.
|
| 25 |
+
The gauge is the **effective-rank delta with anchors ON vs OFF**, not the
|
| 26 |
+
similarity score alone.
|
| 27 |
+
|
| 28 |
+
## Toggle law
|
| 29 |
+
|
| 30 |
+
All anchors disabled == the base trunk, bit-exact in fp32 (asserted at train
|
| 31 |
+
time, not assumed). One artifact, both models:
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
import amoe, torch
|
| 35 |
+
# trunk: see the parent repo for CaptionEncoder
|
| 36 |
+
h = amoe.attach(trunk, "amoe/sts/captionbert-v2-sts-anchor-combo.anchor.pt", binding=CaptionEncoderBinding(d=512))
|
| 37 |
+
emb_supervised = trunk(input_ids, attention_mask)
|
| 38 |
+
with h.only(): # or set enabled=False on the wrapped blocks
|
| 39 |
+
emb_unsupervised = trunk(input_ids, attention_mask)
|
| 40 |
+
base = h.detach() # bit-exact or raises
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
The `.pt` anchor layout is `{block}.{param}` (the `blocks.{site}.{param}`
|
| 44 |
+
form in the amoe README is the *safetensors* layout — a different serializer).
|
| 45 |
+
|
| 46 |
+
## Results
|
| 47 |
+
|
| 48 |
+
See `metrics.json` in this folder. Report STS-B / SICK-R spearman with anchors
|
| 49 |
+
ON and OFF, plus effective rank for each. SICK-R is never trained on and is the
|
| 50 |
+
honest transfer read.
|
| 51 |
+
|
| 52 |
+
## Training
|
| 53 |
+
|
| 54 |
+
Frozen trunk, adapters only. MultipleNegativesRankingLoss on
|
| 55 |
+
a combo pack (all-nli + simple-wiki + altlex + sentence-compression)
|
| 56 |
+
with in-batch negatives and hard negatives where the source provides them.
|
| 57 |
+
Pure Adam wd=0 (`amoe.laws.make_optimizer`), fp32 / TF32 off
|
| 58 |
+
(`amoe.laws.pin_precision`). Config in `config.json`.
|
amoe/sts-combo/captionbert-v2-sts-anchor-combo.anchor.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7c85b05540bc14e904ccd503ea8f04e6f1b2fae94fc9839ba1310cb6d2ac203
|
| 3 |
+
size 6609809
|
amoe/sts-combo/captionbert-v2-sts-anchor.anchor.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:45bcbf0ccb6d2005c989fac56e6200e53b1ec51bc8c1cee5c874334516afd6ab
|
| 3 |
+
size 6608605
|
amoe/sts-combo/config.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"run_name": "captionbert-v2-sts-anchor-combo",
|
| 3 |
+
"trunk_repo": "AbstractPhil/captionbert-8192-v2",
|
| 4 |
+
"trunk_ckpt": "checkpoints/best_model.pt",
|
| 5 |
+
"tokenizer": "google-bert/bert-base-uncased",
|
| 6 |
+
"d_model": 512,
|
| 7 |
+
"n_heads": 8,
|
| 8 |
+
"n_layers": 12,
|
| 9 |
+
"d_ff": 2048,
|
| 10 |
+
"max_len": 8192,
|
| 11 |
+
"output_dim": 768,
|
| 12 |
+
"pooling": "mean",
|
| 13 |
+
"sites": "all",
|
| 14 |
+
"n_slots": 16,
|
| 15 |
+
"K": 64,
|
| 16 |
+
"D": 4,
|
| 17 |
+
"tau": 0.1,
|
| 18 |
+
"hidden": 178,
|
| 19 |
+
"gate_init": -3.0,
|
| 20 |
+
"sources": [
|
| 21 |
+
[
|
| 22 |
+
"sentence-transformers/all-nli",
|
| 23 |
+
"triplet",
|
| 24 |
+
"anchor",
|
| 25 |
+
"positive",
|
| 26 |
+
"negative",
|
| 27 |
+
200000
|
| 28 |
+
],
|
| 29 |
+
[
|
| 30 |
+
"sentence-transformers/simple-wiki",
|
| 31 |
+
"pair",
|
| 32 |
+
"text",
|
| 33 |
+
"simplified",
|
| 34 |
+
null,
|
| 35 |
+
0
|
| 36 |
+
],
|
| 37 |
+
[
|
| 38 |
+
"sentence-transformers/altlex",
|
| 39 |
+
"pair",
|
| 40 |
+
"text",
|
| 41 |
+
"simplified",
|
| 42 |
+
null,
|
| 43 |
+
0
|
| 44 |
+
],
|
| 45 |
+
[
|
| 46 |
+
"sentence-transformers/sentence-compression",
|
| 47 |
+
"pair",
|
| 48 |
+
"text",
|
| 49 |
+
"simplified",
|
| 50 |
+
null,
|
| 51 |
+
0
|
| 52 |
+
]
|
| 53 |
+
],
|
| 54 |
+
"dedup_jaccard": 0.95,
|
| 55 |
+
"max_tokens": 64,
|
| 56 |
+
"batch_size": 256,
|
| 57 |
+
"temperature": 0.05,
|
| 58 |
+
"use_hard_negatives": true,
|
| 59 |
+
"steps": 4000,
|
| 60 |
+
"lr": 0.001,
|
| 61 |
+
"warmup": 200,
|
| 62 |
+
"grad_clip": 1.0,
|
| 63 |
+
"seed": 0,
|
| 64 |
+
"log_every": 100,
|
| 65 |
+
"eval_every": 500,
|
| 66 |
+
"out_dir": "/content/amoe_sts",
|
| 67 |
+
"hf_repo": "AbstractPhil/captionbert-8192-v2",
|
| 68 |
+
"hf_path": "amoe/sts-combo",
|
| 69 |
+
"hf_private": false,
|
| 70 |
+
"hf_push": true
|
| 71 |
+
}
|
amoe/sts-combo/metrics.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"baseline": {
|
| 3 |
+
"STS-B": {
|
| 4 |
+
"spearman": 0.574721280584061,
|
| 5 |
+
"self_cos": 0.13962045311927795,
|
| 6 |
+
"erank": 36.611595622425114
|
| 7 |
+
},
|
| 8 |
+
"SICK-R": {
|
| 9 |
+
"spearman": 0.652602297708298,
|
| 10 |
+
"self_cos": 0.32337328791618347,
|
| 11 |
+
"erank": 39.12520123844512
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"history": [
|
| 15 |
+
{
|
| 16 |
+
"step": 500,
|
| 17 |
+
"STS-B_OFF": 0.574721280584061,
|
| 18 |
+
"STS-B_ON": 0.7344460298339228,
|
| 19 |
+
"SICK-R_OFF": 0.652602297708298,
|
| 20 |
+
"SICK-R_ON": 0.7453666480223926
|
| 21 |
+
}
|
| 22 |
+
],
|
| 23 |
+
"step": 500,
|
| 24 |
+
"config": {
|
| 25 |
+
"run_name": "captionbert-v2-sts-anchor-combo",
|
| 26 |
+
"trunk_repo": "AbstractPhil/captionbert-8192-v2",
|
| 27 |
+
"trunk_ckpt": "checkpoints/best_model.pt",
|
| 28 |
+
"tokenizer": "google-bert/bert-base-uncased",
|
| 29 |
+
"d_model": 512,
|
| 30 |
+
"n_heads": 8,
|
| 31 |
+
"n_layers": 12,
|
| 32 |
+
"d_ff": 2048,
|
| 33 |
+
"max_len": 8192,
|
| 34 |
+
"output_dim": 768,
|
| 35 |
+
"pooling": "mean",
|
| 36 |
+
"sites": "all",
|
| 37 |
+
"n_slots": 16,
|
| 38 |
+
"K": 64,
|
| 39 |
+
"D": 4,
|
| 40 |
+
"tau": 0.1,
|
| 41 |
+
"hidden": 178,
|
| 42 |
+
"gate_init": -3.0,
|
| 43 |
+
"sources": [
|
| 44 |
+
[
|
| 45 |
+
"sentence-transformers/all-nli",
|
| 46 |
+
"triplet",
|
| 47 |
+
"anchor",
|
| 48 |
+
"positive",
|
| 49 |
+
"negative",
|
| 50 |
+
200000
|
| 51 |
+
],
|
| 52 |
+
[
|
| 53 |
+
"sentence-transformers/simple-wiki",
|
| 54 |
+
"pair",
|
| 55 |
+
"text",
|
| 56 |
+
"simplified",
|
| 57 |
+
null,
|
| 58 |
+
0
|
| 59 |
+
],
|
| 60 |
+
[
|
| 61 |
+
"sentence-transformers/altlex",
|
| 62 |
+
"pair",
|
| 63 |
+
"text",
|
| 64 |
+
"simplified",
|
| 65 |
+
null,
|
| 66 |
+
0
|
| 67 |
+
],
|
| 68 |
+
[
|
| 69 |
+
"sentence-transformers/sentence-compression",
|
| 70 |
+
"pair",
|
| 71 |
+
"text",
|
| 72 |
+
"simplified",
|
| 73 |
+
null,
|
| 74 |
+
0
|
| 75 |
+
]
|
| 76 |
+
],
|
| 77 |
+
"dedup_jaccard": 0.95,
|
| 78 |
+
"max_tokens": 64,
|
| 79 |
+
"batch_size": 256,
|
| 80 |
+
"temperature": 0.05,
|
| 81 |
+
"use_hard_negatives": true,
|
| 82 |
+
"steps": 4000,
|
| 83 |
+
"lr": 0.001,
|
| 84 |
+
"warmup": 200,
|
| 85 |
+
"grad_clip": 1.0,
|
| 86 |
+
"seed": 0,
|
| 87 |
+
"log_every": 100,
|
| 88 |
+
"eval_every": 500,
|
| 89 |
+
"out_dir": "/content/amoe_sts",
|
| 90 |
+
"hf_repo": "AbstractPhil/captionbert-8192-v2",
|
| 91 |
+
"hf_path": "amoe/sts-combo",
|
| 92 |
+
"hf_private": false,
|
| 93 |
+
"hf_push": true
|
| 94 |
+
}
|
| 95 |
+
}
|